|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.rsa.certj.cert.X500Name
This class builds and holds X.500 names.
The following are the Cert-J supported attribute types:Name ::= CHOICE { rdnSequence RDNSequence } -- only one possibility for now RDNSequence ::= SEQUENCE OF RelativeDistinguishedName RelativeDistinguishedName ::= SET SIZE (1..MAX) OF AttributeTypeAndValue AttributeTypeAndValue ::= SEQUENCE type ATTRIBUTE.&id ({SupportedAttributes}), value ({ATTRIBUTE.&Type ({SupportedAttributes}{@type})} |
Name ::= SEQUENCE OF { SET OF { -- This is an RDN SEQUENCE { -- This is an AVA OBJECT IDENTIFIER, ANY Encoded } } |
See Also
Constructor Summary |
|
X500Name()
Constructs an empty |
|
X500Name(byte[] nameBER,
int offset,
int special)
Constructs an |
|
X500Name(String nameString)
Constructs an |
Method Summary |
|
void |
addRDN(byte[] rdnBER,
int offset)
Adds an RDN to this object. |
void |
addRDN(RDN rdn)
Adds an RDN to this object. |
void |
addRDN(RDN name,
int index)
Adds the new RDN at the specified index. |
clone()
Overrides the default |
|
boolean |
contains(X500Name name)
Takes the RDNs from name and checks
whether this |
boolean |
equals(Object obj)
Returns |
getAttribute(int attributeType)
Gets the attribute, of the type attributeType, from the name object. |
|
int |
getAttributeCount()
Gets the number of attributes in this X.500 name. |
int |
getDEREncoding(byte[] encoding,
int offset,
int special)
Places the DER encoding of the X.500 name in this object into encoding, beginning at offset. |
int |
getDERLen(int special)
Returns the number of bytes of the DER encoding of this X.500 name. |
static int |
getNextBEROffset(byte[] nameBER,
int offset)
Given nameBER, the BER encoding of an X.500 name beginning at offset, finds the index to the next element in the encoding. |
getRDN(int index)
Gets the RDN at the specified index. |
|
int |
getRDNCount()
Gets the number of RDNs in this X.500 name. |
void |
removeRDN(int index)
Deletes the |
toString()
Returns a |
|
toString(boolean reverse)
Returns a |
Methods inherited from class java.lang.Object |
getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public X500Name(byte[] nameBER, int offset, int special) throws NameException
X500Name
object and initializes it with
the collection of attributes represented by nameBER.
The ASN.1 definition (previously defined in this class) means
the tag will be 0x30. However, an X500Name
object can be
part of a certificate request (or some other construct), and it might
have a different tag, caused by IMPLICIT
or
EXPLICIT
. For example, suppose the definition
is as follows:
name [1] IMPLICIT Name |
0x30
to 0xa1
.
To indicate that the BER encoding of the X500Name
object
should follow any special circumstances, use the special
argument. For example, to indicate the following:
name [1] IMPLICIT Name |
special = (ASN1.CONTEXT_IMPLICIT | 1); |
special = 0 |
APP_IMPLICIT
, APP_EXPLICIT
,
PRIVATE_IMPLICIT
, PRIVATE_EXPLICIT
,
OPTIONAL
, DEFAULT
,
CONTEXT_IMPLICIT
,
or CONTEXT_EXPLICIT
.Parameters
nameBER | A | ||
offset | The offset into nameBER where the encoding begins. | ||
special | The special circumstances of the BER encoding,
if there are any, such as |
Throws
NameException
- If the BER encoding is invalid.public X500Name()
X500Name
object.
After calling this constructor, use the addRDN()
method to set the X500Name
object to the correct
attributes.public X500Name(String nameString) throws NameException
X500Name
object and initializes it with
the collection of attributes represented by the
String
value.Parameters
nameString | A |
Throws
NameException
- If an error occured while
parsing and building the X500Name
object.Method Detail |
public Object clone() throws CloneNotSupportedException
clone
method to get a deeper clone.
Returns
X500Name
object,
a copy of this object.
Throws
CloneNotSupportedException
- If the cloning operation
is not successful.public String toString(boolean reverse)
String
that describes this X.500 name in RFC2253
format. RFC2253 format specifies certain formatting, including the
presence of a backslash before a comma, and a comma without a preceding
backslash to delineate fields.Parameters
reverse | A |
Returns
String
that describes this X.500 name.public String toString()
String
that describes this X.500 name in RFC2253
format. RFC2253 format specifies certain formatting, including the
presence of a backslash before a comma, and a comma without a preceding
backslash to delineate fields.Overrides
toString
in class Object
Returns
String
that describes this X.500 name.public int getRDNCount()
Returns
public int getAttributeCount()
Returns
public RDN getRDN(int index) throws NameException
Parameters
index | The index into the list of RDNs where
the requested |
Returns
Throws
NameException
- If the provided index is invalid.public void removeRDN(int index) throws NameException
RDN
object at the specified index.Parameters
index | The index into the list of RDNs. |
Throws
NameException
- If the provided
index is invalid.public void addRDN(RDN name, int index) throws NameException
Parameters
name | The new RDN object. | ||
index | The index into the list of RDNs. |
Throws
NameException
- If index is invalid.public AttributeValueAssertion getAttribute(int attributeType)
AttributeValueAssertion
class, such as COUNTRY_NAME
or COMMON_NAME
.
If the X.500 name object does not
possess an attribute of attributeType, this method returns
null
.Parameters
attributeType | The flag indicating which attribute type is requested. |
Returns
public static int getNextBEROffset(byte[] nameBER, int offset) throws NameException
nameBER>[120]
is the
first byte in the encoding of the name,
nameBER[1938]
is the
last byte in the encoding of the name,
and the next element begins at index 1939.Parameters
nameBER | The BER encoding of an X.500 name. | ||
offset | The offset into nameBER where the encoding begins. |
Returns
int
that contains the index to the next element
in the BER encoding.
Throws
NameException
- If the method cannot read the BER encoding.public int getDERLen(int special)
Parameters
special | The special circumstances of the DER encoding, if there
are any.
The following ASN.1 constants are
possible values for special:
|
Returns
public int getDEREncoding(byte[] encoding, int offset, int special) throws NameException
getNameDERLen
. If this object is
not yet set with an X.500 name, then this method places nothing
into the array and returns zero.
The ASN.1 definition (previously defined in this class)
means the tag will be 0x30
.
However, an X500Name
object can be
part of a certificate request
(or some other construct) and it
might have a different tag, caused by
IMPLICIT
or
EXPLICIT
.
For example, suppose the definition is as
follows:
name [1] IMPLICIT Name |
0x30
to 0xa1
.
To indicate that the DER encoding of the X500Name
should follow any special circumstances of this particular encoding,
use the special argument.
For example, to indicate the following:
name [1] IMPLICIT Name |
special = (ASN1.CONTEXT_IMPLICIT | 1); |
special = 0 |
APP_IMPLICIT
, APP_EXPLICIT
,
PRIVATE_IMPLICIT
, PRIVATE_EXPLICIT
,
OPTIONAL
, DEFAULT
,
CONTEXT_IMPLICIT
,
or CONTEXT_EXPLICIT
.Parameters
encoding | A | ||
offset | The offset into encoding where the encoding begins. | ||
special | The special circumstances of the DER encoding, if
there are any, such as |
Returns
Throws
NameException
- If unable to encode the X.500 name.public void addRDN(RDN rdn) throws NameException
Parameters
rdn | The |
Throws
NameException
- If the provided RDN is invalid.public void addRDN(byte[] rdnBER, int offset) throws NameException
Parameters
rdnBER | A | ||
offset | The offset into rdnBER where the encoding begins. |
Throws
NameException
- If the provided RDN is invalid.public boolean equals(Object obj)
true
if this object and obj contain the same
X.500 name, returns false
otherwise.Overrides
equals
in class Object
Parameters
obj | An instance of the |
Returns
boolean
indicating whether these objects are equal.public boolean contains(X500Name name)
X500Name
object
contains every RDN from
name and whether the
data is the same. For example, this method could be used
to determine if the name contains everyone from the
engineering department at RSA, by setting name
to the following:
O="RSA", OU="engineering"The O represents "organization name" and the OU represents "organizational unit name."
Parameters
name | The partial |
Returns
true
if this name
contains the RDNs from name, with the
same data.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |