iaik.x509.extensions
Class SubjectDirectoryAttributes

java.lang.Object
  |
  +--iaik.x509.V3Extension
        |
        +--iaik.x509.extensions.SubjectDirectoryAttributes

public class SubjectDirectoryAttributes
extends V3Extension

This class implements the SubjectDirectoryAttributes Extension.

The SubjectDirectoryAttributes extension is a non critical standard X509v3 extension.

Each extension is associated with a specific certificateExtension object identifier, derived from:

 certificateExtension  OBJECT IDENTIFIER ::=
                            {joint-iso-ccitt(2) ds(5) 29}
 id-ce                 OBJECT IDENTIFIER ::=  certificateExtension
 

The object identifier for the SubjectDirectoryAttributes extension is defined as:

id-ce-SubjectDirectoryAttributes OBJECT IDENTIFIER ::= { id-ce 9 }

which corresponds to the OID string "2.5.29.9". The X.509 Certificate and CRL profile presented in RFC 2459 specifies the SubjectDirectoryAttributes extension as not essential extension which may be used in local environments. The PKIX Qualified Certificate Profile suggests the SubjectDirectoryAttributes for including additional attributes describing the subject of a certificate (given in the subject field and the subject alternative name extension).
ASN.1 definition:

 SubjectDirectoryAttributes ::= SEQUENCE SIZE (1..MAX) OF Attribute
 

More information can be found in RFC 2459, section 4.2.1.9 "Subject Directory Attributes".

An SubjectDirectoryAttributes object may be created by either using the empty default constructor, or by directly supplying the attributes to be added as instances of Attribute, e.g.:

 Attribute[] attributes = new Attribute[2];
 // Gender:
 PrintableString gender = new PrintableString("M");
 attributes[0] = new Attribute(ObjectID.gender, new ASN1Object[] {gender});
 // Postal Address:
 SEQUENCE postalAddress = new SEQUENCE();
 postalAddress.addComponent(new UTF8String("A-8010 Graz, Austria"));
 postalAddress.addComponent(new UTF8String("Inffeldgasse 16A"));
 attributes[1] = new Attribute(ObjectID.postalAddress, new ASN1Object[] {postalAddress});
 // create a SubjectDirectoryAttributes extension object:
 SubjectDirectoryAttributes sda = new SubjectDirectoryAttributes(attributes);
 

For adding a SubjectDirectoryAttributes extension object to a X509Certificate, use the addExtension method of the X509Certificate class:

 X505Certificate cert = new X509Certificate();
   ...
 cert.addExtension(sda);
 

Version:
File Revision 8
See Also:
Attribute, ObjectID, V3Extension, X509Extensions, X509Certificate

Field Summary
static ObjectID oid
          The object identifier of this SubjectDirectoryAttributes extension.
 
Fields inherited from class iaik.x509.V3Extension
critical
 
Constructor Summary
SubjectDirectoryAttributes()
          Default constructor.
SubjectDirectoryAttributes(Attribute[] attributes)
          Creates an SubjectDirectoryAttributes object and adds a the the given attributes.
 
Method Summary
 Attribute getAttribute(ObjectID oid)
          Returns the first attribute matching to the given ObjectID, if included in this SubjectDirectoryAttributes object.
 Attribute[] getAttributes()
          Returns the attributes included in this SubjectDirectoryAttributes extension.
 ObjectID getObjectID()
          Returns the object ID of this SubjectDirectoryAttributes extension
 int hashCode()
          Returns a hashcode for this identity.
 void init(ASN1Object obj)
          Inits this SubjectDirectoryAttributes implementation with an ASN1object representing the value of this extension.
 void setAttributes(Attribute[] attributes)
          Sets the attributes of this SubjectDirectoryAttributes extension.
 ASN1Object toASN1Object()
          Returns an ASN1Object representing the value of this SubjectDirectoryAttributes extension object.
 String toString()
          Returns a string that represents the contents of this SubjectDirectoryAttributes extension.
 
Methods inherited from class iaik.x509.V3Extension
getName, isCritical, setCritical
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

oid

public static final ObjectID oid
The object identifier of this SubjectDirectoryAttributes extension. The corresponding OID string is "2.5.29.9".
Constructor Detail

SubjectDirectoryAttributes

public SubjectDirectoryAttributes()
Default constructor. Creates an empty SubjectDirectoryAttributes object.

For supplying the attributes (as instances of class iaik.asn1.structures.Attribute to be included call method setAttributes, e.g.:

 Attribute[] attributes = new Attribute[2];
 // Gender:
 PrintableString gender = new PrintableString("M");
 attributes[0] = new Attribute(ObjectID.gender, new ASN1Object[] {gender});
 // Postal Address:
 SEQUENCE postalAddress = new SEQUENCE();
 postalAddress.addComponent(new UTF8String("A-8010 Graz, Austria"));
 postalAddress.addComponent(new UTF8String("Inffeldgasse 16A"));
 attributes[1] = new Attribute(ObjectID.postalAddress, new ASN1Object[] {postalAddress});
 // create a SubjectDirectoryAttributes extension object:
 SubjectDirectoryAttributes sda = new SubjectDirectoryAttributes();
 // set the attributes:
 sda.setAttributes(attributes);
 // add the extension to a certificate:
 cert.addExtension(sda);
 


SubjectDirectoryAttributes

public SubjectDirectoryAttributes(Attribute[] attributes)
Creates an SubjectDirectoryAttributes object and adds a the the given attributes.

The following example creates a SubjectDirectoryAttributes extension for a Gender and a PostalAddress attribute. The attributes are represented as instances of class iaik.asn1.structures.Attribute, e.g.:

 Attribute[] attributes = new Attribute[2];
 // Gender:
 PrintableString gender = new PrintableString("M");
 attributes[0] = new Attribute(ObjectID.gender, new ASN1Object[] {gender});
 // Postal Address:
 SEQUENCE postalAddress = new SEQUENCE();
 postalAddress.addComponent(new UTF8String("A-8010 Graz, Austria"));
 postalAddress.addComponent(new UTF8String("Inffeldgasse 16A"));
 attributes[1] = new Attribute(ObjectID.postalAddress, new ASN1Object[] {postalAddress});
 // create a SubjectDirectoryAttributes extension object:
 SubjectDirectoryAttributes sda = new SubjectDirectoryAttributes(attributes);
 // add the extension to a certificate:
 cert.addExtension(sda);
 

Parameters:
attributes - a set of attributes to be included into this SubjectDirectoryAttributes extension
Method Detail

getObjectID

public ObjectID getObjectID()
Returns the object ID of this SubjectDirectoryAttributes extension
Overrides:
getObjectID in class V3Extension
Returns:
the object ID

setAttributes

public void setAttributes(Attribute[] attributes)
Sets the attributes of this SubjectDirectoryAttributes extension.

The following example creates a SubjectDirectoryAttributes extension for a Gender and a PostalAddress attribute. The attributes are represented as instances of class iaik.asn1.structures.Attribute, e.g.:

 Attribute[] attributes = new Attribute[2];
 // Gender:
 PrintableString gender = new PrintableString("M");
 attributes[0] = new Attribute(ObjectID.gender, new ASN1Object[] {gender});
 // Postal Address:
 SEQUENCE postalAddress = new SEQUENCE();
 postalAddress.addComponent(new UTF8String("A-8010 Graz, Austria"));
 postalAddress.addComponent(new UTF8String("Inffeldgasse 16A"));
 attributes[1] = new Attribute(ObjectID.postalAddress, new ASN1Object[] {postalAddress});
 // create a SubjectDirectoryAttributes extension object:
 SubjectDirectoryAttributes sda = new SubjectDirectoryAttributes();
 // set the attributes:
 sda.setAttributes(attributes);
 // add the extension to a certificate:
 cert.addExtension(sda);
 

Parameters:
attributes - a set of attributes to be included into this SubjectDirectoryAttributes extension

getAttributes

public Attribute[] getAttributes()
Returns the attributes included in this SubjectDirectoryAttributes extension.
Returns:
the attributes included in this SubjectDirectoryAttributes

getAttribute

public Attribute getAttribute(ObjectID oid)
Returns the first attribute matching to the given ObjectID, if included in this SubjectDirectoryAttributes object.
Returns:
the first attribute belonging to the given ObjectID or null if there is no attribute for the given OID

init

public void init(ASN1Object obj)
          throws X509ExtensionException
Inits this SubjectDirectoryAttributes implementation with an ASN1object representing the value of this extension.

The given ASN1Object consits of a Sequence of attributes included in the SubjectDirectoryAttributes object.

The given ASN1Object is the one created by toASN1Object().

This method is used by the X509Extensions class when parsing the ASN.1 representation of a certificate for properly initializing an included SubjectDirectoryAttributes extension. This method initializes the extension only with its value, but not with its critical specification. For that reason, this method shall not be explicitly called by an application.

Overrides:
init in class V3Extension
Parameters:
obj - the SubjectDirectoryAttributes as ASN1Object
Throws:
X509ExtensionException - if the extension could not be parsed

toASN1Object

public ASN1Object toASN1Object()
                        throws X509ExtensionException
Returns an ASN1Object representing the value of this SubjectDirectoryAttributes extension object.

The ASN1Object is an ASN.1 Sequence including any attribute that has been added to this SubjectDirectoryAttributes object.

 SubjectDirectoryAttributesSyntax  ::=
          SEQUENCE SIZE (1..MAX) OF Attribute
 
Overrides:
toASN1Object in class V3Extension
Returns:
the value of this SubjectDirectoryAttributes as ASN1Object

hashCode

public int hashCode()
Returns a hashcode for this identity.
Overrides:
hashCode in class V3Extension
Returns:
a hash code for this identity

toString

public String toString()
Returns a string that represents the contents of this SubjectDirectoryAttributes extension.
Overrides:
toString in class Object
Returns:
the string representation

This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note).

IAIK-JCE 3.1 with IAIK-JCE CC Core 3.1, (c) 1997-2004 IAIK