com.rsa.certj.cert.extensions

Class ExtensionAttributes

java.lang.Object
  |
  +--com.rsa.certj.cert.extensions.ExtensionAttributes
All Implemented Interfaces:
Cloneable, Serializable

public class ExtensionAttributes
extends Object
implements Cloneable, Serializable

This class holds and builds an ExtensionAttribute object that is used in the GeneralName class.

The ASN.1 definition is as follows:

 ExtensionAttributes ::= SET SIZE (1..ub-extension-attributes) OF
                       ExtensionAttribute

 ExtensionAttribute ::=  SEQUENCE {
   extension-attribute-type [0] INTEGER (0..ub-extension-attributes),
   extension-attribute-value [1]
                       ANY DEFINED BY extension-attribute-type }
 

Copyright © RSA Security Inc., 1999-2001. All rights reserved.

See Also

Serialized Form

Constructor Summary

ExtensionAttributes()

The default constructor for this class.

ExtensionAttributes(byte[] valueBER, int offset, int special)

Constructs an ExtensionAttributes object and initializes it with the collection of attributes represented by valueBER.

 

Method Summary

 void

addAttribute(ExtensionAttribute attr)

Adds one attribute to the ExtensionAttributes object.

 Object

clone()

Override the default clone method to get a deeper clone.

 boolean

equals(Object obj)

Returns true if this object and obj contain the same ExtensionAttributes; false otherwise.

 ExtensionAttribute

getAttribute(int index)

Gets the attribute specified by index from this ExtensionAttributes object.

 int

getAttributeCount()

Gets the number of attributes.

 int

getDEREncoding(byte[] encoding, int offset, int special)

Places the DER encoding of the ExtensionAttributes object into encoding, beginning at offset.

 int

getDERLen(int special)

Returns the length, in bytes, of the DER encoding of this ExtensionAttributes object.

static int

getNextBEROffset(byte[] nameBER, int offset)

Given nameBER, the BER encoding of an ExtensionAttributes object, beginning at offset, finds the index to the next element in the encoding.

 String

toString()

Returns a String that describes this ExtensionAttributes object.

 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExtensionAttributes

public ExtensionAttributes(byte[] valueBER,
                           int offset,
                           int special)
                    throws NameException
Constructs an ExtensionAttributes object and initializes it with the collection of attributes represented by valueBER.

Parameters

         valueBER  

A byte array that contains the BER encoding of ExtensionAttributes.

         offset  

The offset into valueBER where the encoding begins.

         special  

The special circumstances of the BER encoding. The following ASN.1 constants are possible values for special: APP_IMPLICIT, APP_EXPLICIT, PRIVATE_IMPLICIT, PRIVATE_EXPLICIT, OPTIONAL, DEFAULT, CONTEXT_IMPLICIT, or CONTEXT_EXPLICIT.

Throws

NameException - If the encoding is invalid.

ExtensionAttributes

public ExtensionAttributes()
The default constructor for this class.
Method Detail

addAttribute

public void addAttribute(ExtensionAttribute attr)
Adds one attribute to the ExtensionAttributes object.

Parameters

         attr  

An attribute to be added to this object.


getAttribute

public ExtensionAttribute getAttribute(int index)
                                throws NameException
Gets the attribute specified by index from this ExtensionAttributes object.

Parameters

         index  

An int that specifies the attribute in this object.

Returns

The ExtensionAttribute specified by index.

Throws

NameException - If the specified index is invalid.

getAttributeCount

public int getAttributeCount()
Gets the number of attributes.

Returns

The number of extension attributes in this object.

toString

public String toString()
Returns a String that describes this ExtensionAttributes object.

Overrides

toString in class Object

Returns

A String that describes this ExtensionAttributes object.

getNextBEROffset

public static int getNextBEROffset(byte[] nameBER,
                                   int offset)
                            throws NameException
Given nameBER, the BER encoding of an ExtensionAttributes object, beginning at offset, finds the index to the next element in the encoding. In other words, this method gets the next offset after the ExtensionAttributes object.

For example, if the offset is 120 and the ExtensionAttributes object's BER encoding is 1819 bytes, then this method will return 1939, the index immediately following the ExtensionAttributes object. That is, nameBER[120] is the first byte in the encoding of the ExtensionAttributes object, nameBER[1938] is the last byte in the encoding of the ExtensionAttributes object, and the next element begins at index 1939.

Parameters

         nameBER  

The BER encoding of an ExtensionAttributes object.

         offset  

The offset into nameBER where the encoding begins.

Returns

The index to the next element in the BER encoding.

Throws

NameException - If the method cannot read the BER encoding.

getDERLen

public int getDERLen(int special)
              throws NameException
Returns the length, in bytes, of the DER encoding of this ExtensionAttributes object. If this object is not set with values, this method returns zero.

Parameters

         special  

The special circumstances of the DER encoding, if there are any. The following ASN.1 constants are possible values for special: APP_IMPLICIT, APP_EXPLICIT, PRIVATE_IMPLICIT, PRIVATE_EXPLICIT, OPTIONAL, DEFAULT, CONTEXT_IMPLICIT, or CONTEXT_EXPLICIT.

Returns

The number of bytes the DER encoding for this ExtensionAttributes object.

Throws

NameException - If the method cannot get the BER encoding length.

getDEREncoding

public int getDEREncoding(byte[] encoding,
                          int offset,
                          int special)
                   throws NameException
Places the DER encoding of the ExtensionAttributes object into encoding, beginning at offset. To determine the length of the encoding, call getDERLen. If this object is not set with values, this method places nothing into the encoding array and returns zero. To indicate that the DER encoding should follow any special instructions, use the special argument.

For example, to indicate the following:

      extension   [1] IMPLICIT Extension
 
Pass in the following:
     special = (ASN1.IMPLICIT | 1);
 
If there are no special circumstances, pass in the following:
      special = 0.
 
The following ASN.1 constants are possible values for special: APP_IMPLICIT, APP_EXPLICIT, PRIVATE_IMPLICIT, PRIVATE_EXPLICIT, OPTIONAL, DEFAULT, CONTEXT_IMPLICIT, or CONTEXT_EXPLICIT.

Parameters

         encoding  

The byte array into which the result will be placed.

         offset  

The offest into encoding where writing begins.

         special  

The special circumstances of the DER encoding, if there are any. The following ASN.1 constants are possible values for special: APP_IMPLICIT, APP_EXPLICIT, PRIVATE_IMPLICIT, PRIVATE_EXPLICIT, OPTIONAL, DEFAULT, CONTEXT_IMPLICIT, or CONTEXT_EXPLICIT.

Returns

The number of bytes placed into encoding.

Throws

NameException - If the method cannot create the DER encoding.

equals

public boolean equals(Object obj)
Returns true if this object and obj contain the same ExtensionAttributes; false otherwise.

Overrides

equals in class Object

Parameters

         obj  

An instance of the ExtensionAttributes class.

Returns

A boolean indicating whether these objects are equal.

clone

public Object clone()
             throws CloneNotSupportedException
Override the default clone method to get a deeper clone.

Returns

A new ExtensionAttributes object object, a copy of this object.

Throws

CloneNotSupportedException - If the cloning operation is not successful.


RSA BSAFE ® Cert-J 2.1.1 001-047007-211-001-000