com.rsa.certj.cert.extensions

Class GeneralNames

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

public class GeneralNames
extends Object
implements Cloneable, Serializable

This class is used in several extensions; for example, AuthorityKeyID and CertificateIssuer.

The ASN.1 definition is as follows:

 GeneralNames ::= SEQUENCE SIZE (1..MAX) OF GeneralName

 GeneralName ::= CHOICE {
      otherName                  [0]     INSTANCE OF OTHER-NAME,
      rfc822Name                 [1]     IA5String,
      dNSName                    [2]     IA5String,
      x400Address                [3]     ORAddress,          
      directoryName              [4]     Name,
      ediPartyName               [5]     EDIPartyName,
      uniformResourceIdentifier  [6]     IA5String,
      iPAddress                  [7]     OCTET STRING,
      registeredID               [8]     OBJECT IDENTIFIER }
The values in the alternatives of the GeneralName type are names of various forms, as follows:

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

See Also

Serialized Form

Constructor Summary

GeneralNames()

Constructs an empty GeneralNames object.

GeneralNames(byte[] nameBER, int offset, int special)

Creates a GeneralNames object and initializes it with the given values.

 

Method Summary

 void

addGeneralName(GeneralName name)

Adds a GeneralName object to this GeneralNames object.

 void

addGeneralName(GeneralName name, int index)

Adds the new GeneralName at the specified index.

 Object

clone()

Overrides the default clone method to get a deeper clone.

 boolean

contains(GeneralName name)

Returns true if this object contains name, returns false otherwise.

 boolean

equals(Object obj)

Returns true if this object and obj contain the same GeneralNames object, returns false otherwise.

 int

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

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

 int

getDERLen(int special)

Returns the number of bytes that will be used by the DER encoding of this GeneralNames object.

 GeneralName

getGeneralName(int index)

Returns the GeneralName object at the specified index.

 Vector

getGeneralNames()

Returns the GeneralName list as a Vector.

 int

getNameCount()

Gets the number of elements in this GeneralNames object.

static int

getNextBEROffset(byte[] nameBER, int offset)

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

 void

removeGeneralName(int index)

Deletes the GeneralName object at the specified index.

 String

toString()

Returns a String that describes this GeneralNames object.

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

Constructor Detail

GeneralNames

public GeneralNames(byte[] nameBER,
                    int offset,
                    int special)
             throws NameException
Creates a GeneralNames object and initializes it with the given values.

Parameters

         nameBER  

A byte array containing the BER encoding of this object.

         offset  

The offset into the nameBER array.

         special  

The special instructions of the BER 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.

Throws

NameException - If the encoding is invalid.

GeneralNames

public GeneralNames()
Constructs an empty GeneralNames object.
Method Detail

addGeneralName

public void addGeneralName(GeneralName name)
Adds a GeneralName object to this GeneralNames object.

Parameters

         name  

The GeneralName to add.


getGeneralNames

public Vector getGeneralNames()
Returns the GeneralName list as a Vector.

Returns

The GeneralName list as a Vector.

getGeneralName

public GeneralName getGeneralName(int index)
                           throws NameException
Returns the GeneralName object at the specified index.

Parameters

         index  

The index to the GeneralName object in the list.

Returns

The GeneralName specified by index.

Throws

NameException - If the specified index is invalid.

removeGeneralName

public void removeGeneralName(int index)
                       throws NameException
Deletes the GeneralName object at the specified index.

Parameters

         index  

The index to the GeneralName in the list.

Throws

NameException - If the specified index is invalid.

addGeneralName

public void addGeneralName(GeneralName name,
                           int index)
                    throws NameException
Adds the new GeneralName at the specified index.

Parameters

         name  

The new GeneralName object.

         index  

The index to the GeneralName object in the list.

Throws

NameException - If the specified index is invalid.

toString

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

Overrides

toString in class Object

Returns

A String that describes this GeneralNames object.

getNameCount

public int getNameCount()
Gets the number of elements in this GeneralNames object.

Returns

The number of elements in this GeneralNames object.

getNextBEROffset

public static int getNextBEROffset(byte[] nameBER,
                                   int offset)
                            throws NameException
Given nameBER, the BER encoding of a GeneralNames 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 GeneralNames object.

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

Parameters

         nameBER  

The BER encoding of this GeneralNames 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 number of bytes that will be used by the DER encoding of this GeneralNames object. If this object is not set with values, then 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 that will be used by the DER encoding of this GeneralNames object.

getDEREncoding

public int getDEREncoding(byte[] encoding,
                          int offset,
                          int special)
                   throws NameException
Places the DER encoding of this GeneralNames object into encoding, beginning at offset. To determine the length of the encoding, call getDERLen. If this object is not yet set with values, then this method places nothing into the 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.CONTEXT_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 offset 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. are any.

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 GeneralNames object, returns false otherwise.

Overrides

equals in class Object

Parameters

         obj  

An instance of the GeneralNames object.

Returns

A boolean that indicates whether these objects are equal.

contains

public boolean contains(GeneralName name)
Returns true if this object contains name, returns false otherwise.

Parameters

         name  

A GeneralName to look for in this object.

Returns

A boolean that returns true if this object contains name, and returns false otherwise.

clone

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

Returns

A new GeneralNames 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