com.rsa.certj.cert.extensions

Class GeneralName

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

public class GeneralName
extends Object
implements Cloneable, Serializable

This class is used to define alternative names in a certificate, especially in SubjectAltName and IssuerAltName extensions.

The ASN.1 definition is as follows:

 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 alternative values of the GeneralName type are names of various forms as follows:

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

See Also

Serialized Form

Field Summary

static int

DIRECTORY_NAME_TYPE

Indicates the DIRECTORY_NAME_TYPE type of GeneralName.

static int

DNS_NAME_TYPE

Indicates the DNS_NAME_TYPE type of GeneralName.

static int

EDIPARTY_NAME_TYPE

Indicates the EDIPARTY_NAME_TYPE type of GeneralName.

static int

IPADDRESS_NAME_TYPE

Indicates the IPADDRESS_NAME_TYPE type of GeneralName.

static int

OTHER_NAME_TYPE

Indicates the OTHER_NAME_TYPE type of GeneralName.

static int

REGISTERID_NAME_TYPE

Indicates the REGISTERID_NAME_TYPE type of GeneralName.

static int

RFC822_NAME_TYPE

Indicates the RFC822_NAME_TYPE type of GeneralName.

static int

URL_NAME_TYPE

Indicates the URL_NAME_TYPE type of GeneralName.

static int

X400ADDRESS_NAME_TYPE

Indicates the X400ADDRESS_NAME_TYPE type of GeneralName.

 

Constructor Summary

GeneralName()

Constructs an empty GeneralName object..

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

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

 

Method Summary

 Object

clone()

Overrides the default clone method to get a deeper clone.

 boolean

equals(Object obj)

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

 int

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

Places the DER encoding of the GeneralName 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 GeneralName object.

 Object

getGeneralName()

Gets the GeneralName value.

 int

getGeneralNameType()

Gets the GeneralName type.

static int

getNextBEROffset(byte[] nameBER, int offset)

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

 void

setGeneralName(Object name, int type)

Sets this object with the general name given in name and type.

 String

toString()

Gets a String representation of the GeneralName object.

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

Field Detail

OTHER_NAME_TYPE

public static final int OTHER_NAME_TYPE
Indicates the OTHER_NAME_TYPE type of GeneralName.

RFC822_NAME_TYPE

public static final int RFC822_NAME_TYPE
Indicates the RFC822_NAME_TYPE type of GeneralName.

DNS_NAME_TYPE

public static final int DNS_NAME_TYPE
Indicates the DNS_NAME_TYPE type of GeneralName.

X400ADDRESS_NAME_TYPE

public static final int X400ADDRESS_NAME_TYPE
Indicates the X400ADDRESS_NAME_TYPE type of GeneralName.

DIRECTORY_NAME_TYPE

public static final int DIRECTORY_NAME_TYPE
Indicates the DIRECTORY_NAME_TYPE type of GeneralName.

EDIPARTY_NAME_TYPE

public static final int EDIPARTY_NAME_TYPE
Indicates the EDIPARTY_NAME_TYPE type of GeneralName.

URL_NAME_TYPE

public static final int URL_NAME_TYPE
Indicates the URL_NAME_TYPE type of GeneralName.

IPADDRESS_NAME_TYPE

public static final int IPADDRESS_NAME_TYPE
Indicates the IPADDRESS_NAME_TYPE type of GeneralName.

REGISTERID_NAME_TYPE

public static final int REGISTERID_NAME_TYPE
Indicates the REGISTERID_NAME_TYPE type of GeneralName.
Constructor Detail

GeneralName

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

Parameters

         nameBER  

A byte array that contains the BER encoding of this object.

         offset  

The offset into the nameBER array.

         special  

The special instructions 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 BER encoding is invalid.

GeneralName

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

setGeneralName

public void setGeneralName(Object name,
                           int type)
                    throws NameException
Sets this object with the general name given in name and type.

Parameters

         name  

An object that contains the general name. (For iPAddress and registeredID values, use byte[].)

         type  

The type of this GeneralName. (One of the fields previously defined in this class.)

Throws

NameException - If name is of the wrong type.

getGeneralName

public Object getGeneralName()
Gets the GeneralName value.

Returns

The GeneralName value. (iPAddress and registeredID values will return a byte array.)

getGeneralNameType

public int getGeneralNameType()
Gets the GeneralName type.

Returns

The type of this GeneralName object (one of the static fields previously defined in this class).

toString

public String toString()
Gets a String representation of the GeneralName object.

Overrides

toString in class Object

Returns

A String that describes this GeneralName object.

getNextBEROffset

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

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

Parameters

         nameBER  

The BER encoding of a General Name 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 GeneralName object. If this object is not set with values, this method returns zero.

Parameters

         special  

The special DER circumstances of the 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 length in bytes of the DER encoding of this object.

getDEREncoding

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

For instance, 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  

A byte array into which the result will be placed.

         offset  

The offset into encoding where to begin writing.

         special  

The special DER circumstances of the encoding, if there are any.

Returns

The number of bytes actually 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 GeneralName, returns false otherwise.

Overrides

equals in class Object

Parameters

         obj  

An instance of the GeneralName object.

Returns

A boolean indicating whether these objects are equal.

clone

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

Returns

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