public class SubjectDirectoryAttributes extends V3Extension
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 3280 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 3280, 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);
Attribute,
ObjectID,
V3Extension,
X509Extensions,
X509Certificate| Modifier and Type | Field and Description |
|---|---|
static ObjectID |
oid
The object identifier of this SubjectDirectoryAttributes extension.
|
critical| Constructor and Description |
|---|
SubjectDirectoryAttributes()
Default constructor.
|
SubjectDirectoryAttributes(Attribute[] attributes)
Creates an
SubjectDirectoryAttributes object and adds a the
the given attributes. |
| Modifier and Type | Method and Description |
|---|---|
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. |
java.lang.String |
toString()
Returns a string that represents the contents of
this
SubjectDirectoryAttributes extension. |
getName, isCritical, setCriticalpublic static final ObjectID oid
public SubjectDirectoryAttributes()
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);
public SubjectDirectoryAttributes(Attribute[] attributes)
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);
attributes - a set of attributes to be included into this
SubjectDirectoryAttributes extensionpublic ObjectID getObjectID()
SubjectDirectoryAttributes extensiongetObjectID in class V3Extensionpublic void setAttributes(Attribute[] 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();
// set the attributes:
sda.setAttributes(attributes);
// add the extension to a certificate:
cert.addExtension(sda);
attributes - a set of attributes to be included into this
SubjectDirectoryAttributes extensionpublic Attribute[] getAttributes()
public Attribute getAttribute(ObjectID oid)
null if there is no attribute for the given OIDpublic void init(ASN1Object obj) throws X509ExtensionException
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.
init in class V3Extensionobj - the SubjectDirectoryAttributes as ASN1ObjectX509ExtensionException - if the extension could not be parsedpublic ASN1Object toASN1Object() throws X509ExtensionException
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
toASN1Object in class V3ExtensionSubjectDirectoryAttributes as ASN1ObjectX509ExtensionException - if the extension could not be createdpublic int hashCode()
hashCode in class V3Extensionpublic java.lang.String toString()
SubjectDirectoryAttributes extension.toString in class java.lang.Object