com.rsa.certj.cert.attributes

Class X501Attribute

java.lang.Object
  |
  +--com.rsa.certj.cert.attributes.X501Attribute
All Implemented Interfaces:
Cloneable, Serializable
Direct Known Subclasses:
ChallengePassword, ContentType, CountryOfCitizenship, CountryOfResidence, DateOfBirth, FriendlyName, Gender, LocalKeyID, MessageDigest, NonStandardAttribute, PlaceOfBirth, PostalAddress, Pseudonym, SigningTime, V3ExtensionAttribute, VeriSignCRSDualEnrollmentStatus, VeriSignCRSFailureInfo, VeriSignCRSMessageType, VeriSignCRSPKIStatus, VeriSignCRSRecipientNonce, VeriSignCRSSenderNonce, VeriSignCRSTransactionID, VeriSignCRSVersion, VeriSignSmartCSP

public abstract class X501Attribute
extends Object
implements Cloneable, Serializable

This class is the superclass of all X.501 attribute objects.

 Attribute  ::=  SEQUENCE {
       type    AttributeType,
       values  SET OF AttributeValue }

 AttributeType  ::=   OBJECT IDENTIFIER

 AttributeValue ::=   ANY

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

See Also

Serialized Form

Field Summary

static int

CHALLENGE_PASSWORD

Indicates a challenge password attribute.

static int

CONTENT_TYPE

Indicates a content type attribute, defined in PKCS #9.

static int

COUNTRY_OF_CITIZENSHIP

Indicates a Country Of Citizenship attribute, defined in PKCS #9.

static int

COUNTRY_OF_RESIDENCE

Indicates a Country Of Residence attribute, defined in PKCS #9.

static int

CRS_DUAL_STATUS

Indicates a VeriSign-defined CRS dual enrollment status attribute.

static int

CRS_FAILURE_INFO

Indicates a VeriSign-defined CRS failure info attribute.

static int

CRS_MESSAGE_TYPE

Indicates a VeriSign-defined CRS message type attribute.

static int

CRS_PKI_STATUS

Indicates a VeriSign-defined CRS PKI status attribute.

static int

CRS_RECIPIENT_NONCE

Indicates a VeriSign-defined CRS recipient nonce attribute.

static int

CRS_SENDER_NONCE

Indicates a VeriSign-defined CRS sender nonce attribute.

static int

CRS_TRANSACTION_ID

Indicates a VeriSign-defined CRS transaction ID attribute.

static int

CRS_VERSION

Indicates a VeriSign-defined CRS version attribute.

static int

DATE_OF_BIRTH

Indicates a Date Of Birth attribute, defined in PKCS #9.

static int

FRIENDLY_NAME

Indicates a friendly name attribute.

static int

GENDER

Indicates a Gender attribute, defined in PKCS #9.

static int

LOCAL_KEY_ID

Indicates a local key ID attribute.

static int

MESSAGE_DIGEST

Indicates a message digest attribute, defined in PKCS #9.

static int

NON_STANDARD

Indicates a non-standard attribute.

static int

PLACE_OF_BIRTH

Indicates a Place Of Birth attribute, defined in PKCS #9.

static int

POSTAL_ADDRESS

Indicates a Postal Address attribute defined in X.520.

static int

PSEUDONYM

Indicates a Pseudonym attribute, defined in PKCS #9.

static int

SIGNING_TIME

Indicates a signing time attribute.

static int

SMART_CSP

Indicates a VeriSign-defined smart CSP attribute.

static int

X509_V3_EXTENSION

Indicates an X.509 v3 extension.

 

Constructor Summary

X501Attribute()

 

 

Method Summary

 void

clearSensitiveData()

Clears any sensitive data.

abstract  Object

clone()

Overrides the default clone method to get a deeper clone.

 boolean

compareOID(byte[] oid)

Compares the OID of this attribute to oid.

 int

derEncodeAttributeLen(int special, int valueLen)

Returns the number of bytes of the DER encoding of this attribute.

 int

getAttributeType()

Gets the attribute type.

 String

getAttributeTypeString()

Gets the name of the attribute type.

 int

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

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

 int

getDERLen(int special)

Returns the number of bytes of the DER encoding of this attribute.

static X501Attribute

getInstance(byte[] attributeBER, int offset, int special)

Creates an attribute based on attributeBER, the BER encoding of an attribute.

static int

getNextBEROffset(byte[] attributeBER, int offset)

Finds the index to the next element in the encoding, beginning at offset, given attributeBER, the BER encoding of an X.501 attribute.

 byte[]

getOID()

Gets the OID of this attribute.

 boolean

isAttributeType(int type)

Checks whether this object is of the type represented by the given type, which should be one of the fields listed in this class.

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

Field Detail

SIGNING_TIME

public static final int SIGNING_TIME
Indicates a signing time attribute.

CHALLENGE_PASSWORD

public static final int CHALLENGE_PASSWORD
Indicates a challenge password attribute.

X509_V3_EXTENSION

public static final int X509_V3_EXTENSION
Indicates an X.509 v3 extension.

FRIENDLY_NAME

public static final int FRIENDLY_NAME
Indicates a friendly name attribute.

LOCAL_KEY_ID

public static final int LOCAL_KEY_ID
Indicates a local key ID attribute.

SMART_CSP

public static final int SMART_CSP
Indicates a VeriSign-defined smart CSP attribute.

CRS_MESSAGE_TYPE

public static final int CRS_MESSAGE_TYPE
Indicates a VeriSign-defined CRS message type attribute.

CRS_PKI_STATUS

public static final int CRS_PKI_STATUS
Indicates a VeriSign-defined CRS PKI status attribute.

CRS_FAILURE_INFO

public static final int CRS_FAILURE_INFO
Indicates a VeriSign-defined CRS failure info attribute.

CRS_SENDER_NONCE

public static final int CRS_SENDER_NONCE
Indicates a VeriSign-defined CRS sender nonce attribute.

CRS_RECIPIENT_NONCE

public static final int CRS_RECIPIENT_NONCE
Indicates a VeriSign-defined CRS recipient nonce attribute.

CRS_TRANSACTION_ID

public static final int CRS_TRANSACTION_ID
Indicates a VeriSign-defined CRS transaction ID attribute.

CRS_VERSION

public static final int CRS_VERSION
Indicates a VeriSign-defined CRS version attribute.

CRS_DUAL_STATUS

public static final int CRS_DUAL_STATUS
Indicates a VeriSign-defined CRS dual enrollment status attribute.

CONTENT_TYPE

public static final int CONTENT_TYPE
Indicates a content type attribute, defined in PKCS #9.

MESSAGE_DIGEST

public static final int MESSAGE_DIGEST
Indicates a message digest attribute, defined in PKCS #9.

POSTAL_ADDRESS

public static final int POSTAL_ADDRESS
Indicates a Postal Address attribute defined in X.520.

PSEUDONYM

public static final int PSEUDONYM
Indicates a Pseudonym attribute, defined in PKCS #9.

DATE_OF_BIRTH

public static final int DATE_OF_BIRTH
Indicates a Date Of Birth attribute, defined in PKCS #9.

PLACE_OF_BIRTH

public static final int PLACE_OF_BIRTH
Indicates a Place Of Birth attribute, defined in PKCS #9.

GENDER

public static final int GENDER
Indicates a Gender attribute, defined in PKCS #9.

COUNTRY_OF_CITIZENSHIP

public static final int COUNTRY_OF_CITIZENSHIP
Indicates a Country Of Citizenship attribute, defined in PKCS #9.

COUNTRY_OF_RESIDENCE

public static final int COUNTRY_OF_RESIDENCE
Indicates a Country Of Residence attribute, defined in PKCS #9.

NON_STANDARD

public static final int NON_STANDARD
Indicates a non-standard attribute.
Constructor Detail

X501Attribute

public X501Attribute()
Method Detail

getInstance

public static X501Attribute getInstance(byte[] attributeBER,
                                        int offset,
                                        int special)
                                 throws AttributeException
Creates an attribute based on attributeBER, the BER encoding of an attribute. Use this method to determine which kind of attribute is represented, and to instantiate the appropriate subclass.

The ASN.1 definition means the tag will be 0x30. However, an attribute can be part of some other construct, and it might have a different tag, caused by IMPLICIT or EXPLICIT. For example, suppose the definition is as follows:

      attribute   [1] EXPLICIT Attribute
To indicate that the BER encoding of Attribute should follow special circumstances, use the special argument. Set special to any special instructions of the BER-encoding. For example, to indicate the following:

      attribute   [1] EXPLICIT Attribute
pass in the following:

      special = (ASN1.CONTEXT_EXPLICIT | 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

         attributeBER  

The BER-encoding of an attribute.

         offset  

The offset into attributeBER where the encoding begins.

         special  

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

Returns

An X501Attribute object. The return is actually a subclass of X501Attribute, an object of the class associated with the attribute type.

Throws

AttributeException - If the BER encoding is invalid.

getAttributeTypeString

public String getAttributeTypeString()
Gets the name of the attribute type.

Returns

A String describing the attribute type.

getOID

public byte[] getOID()
Gets the OID of this attribute.

Returns

A new byte array that contains the OID.

compareOID

public boolean compareOID(byte[] oid)
Compares the OID of this attribute to oid.

Parameters

         oid  

A byte array containing the OID to compare.

Returns

Returns true if oid is equal to the OID of this attribute; false otherwise.

getAttributeType

public int getAttributeType()
Gets the attribute type. The return value will be one of the fields previously listed in this class.

Returns

An int specifying which attribute type is represented in this object.

getDERLen

public int getDERLen(int special)
Returns the number of bytes of the DER encoding of this attribute. If this object is not set with an attribute, then this method returns zero.

An attribute object can be part of a certificate (or some other construct), and it can have a different tag caused by IMPLICIT or EXPLICIT. This can affect the length. For instance, suppose the definition is as follows:
 
   attribute   [1] EXPLICIT Attribute
To request the length of Attribute, indicating the special nature of this particular encoding, use the special argument. Set that argument to any special instructions of the DER encoding. For instance, to indicate
 
   attribute   [1] EXPLICIT Attribute
pass in the following:

      special = (ASN1.CONTEXT_EXPLICIT | 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

         special  

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

Returns

The number of bytes in the DER encoding of this attribute.

getNextBEROffset

public static int getNextBEROffset(byte[] attributeBER,
                                   int offset)
                            throws AttributeException
Finds the index to the next element in the encoding, beginning at offset, given attributeBER, the BER encoding of an X.501 attribute. That is, this method gets the next offset following the attribute.

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

Parameters

         attributeBER  

The BER encoding of the X.501 attribute.

         offset  

The offset into attributeBER where the encoding begins.

Returns

An int that contains the index to the next element in the BER encoding.

Throws

AttributeException - If the method cannot read the BER encoding.

getDEREncoding

public int getDEREncoding(byte[] encoding,
                          int offset,
                          int special)
                   throws AttributeException
Places the DER encoding of the attribute in this object into encoding, beginning at offset. To determine the length of the encoding, call getDERLen. If this object is not yet set with an attribute, then this method throws an exception. The ASN.1 definition means the tag will be 0x30. However, an attribute can be part of some other construct, and it might have a different tag, caused by IMPLICIT or EXPLICIT. For example, suppose the definition is:
 
      attribute   [1] EXPLICIT Attribute
To indicate that the BER encoding of Attribute should follow special circumstances, use the special argument. Set special to any special instructions of the BER-encoding. For example, to indicate the following:

      attribute   [1] EXPLICIT Attribute
pass in the following:

      special = (ASN1.CONTEXT_EXPLICIT | 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 that will hold the BER encoding of the X.501 attribute.

         offset  

The offset into encoding where the encoding actually begins.

         special  

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

Returns

The number of bytes placed into encoding.

Throws

AttributeException - If the method cannot create the BER encoding.

isAttributeType

public boolean isAttributeType(int type)
Checks whether this object is of the type represented by the given type, which should be one of the fields listed in this class.

Parameters

         type  

The attribute type to check.

Returns

A boolean indicating whether this object's type matches type.

derEncodeAttributeLen

public int derEncodeAttributeLen(int special,
                                 int valueLen)
Returns the number of bytes of the DER encoding of this attribute. If this object is not set with an attribute, then this method returns zero.

An attribute object can be part of a certificate (or some other construct), and it might have a different tag caused by IMPLICIT or EXPLICIT. This can affect the length. For example, suppose the definition is as follows:
  
      attribute   [1] EXPLICIT Attribute
To request the length of Attribute, indicating the special nature of this particular encoding, use the special argument. Set special to any special instructions of the DER encoding. For example, to indicate the following:
 
      attribute   [1] EXPLICIT Attribute
pass in the following:
 
      special = (ASN1.CONTEXT_EXPLICIT | 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

         special  

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

         valueLen  

Specifies the length of this attribute's value.

Returns

The number of bytes in the DER encoding of this attribute.

clone

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

Returns

A new X501Attribute object, a copy of this object.

Throws

CloneNotSupportedException - If the cloning operation is not successful.

clearSensitiveData

public void clearSensitiveData()
Clears any sensitive data. The finalizer will clear the data, but the user cannot be sure when the garbage collector will call the finalizer. This method allows the user to clear data as soon as possible.


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