|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--iaik.utils.RFC2253NameParser
Implements functionality to parse the UTF-8 string representation of a X.501 Name, according to
RFC 2253.
This class may be used for converting a RFC 2253 string representation of a
X.501 Name into a iaik.asn1.structures.Name
object.
For converting a RFC 2253 string first create a new #RFC2253NameParser
object and supply the string to be converted.
Subsequently simply call method parse
to get
the Name object, e.g.:
String rcf2253Name = "CN=Gregor Karlinger,O=IAIK,C=AT"; RFC2253NameParser nameParser = new RFC2253NameParser(rcf2253Name); iaik.asn1.structures.Name = nameParser.parse();Attention! When using this parser, please be aware that a valid transformation from an RFC 2253 string to a Distinguished Name (rspectively its encoding) only can be done when the RFC 2253 string gives a hexadecimal representation of the encoding. See RFC 2253, section 7.2: 7.2. Use of Distinguished Names in Security Applications The transformations of an AttributeValue value from its X.501 form to an LDAP string representation are not always reversible back to the same BER or DER form. An example of a situation which requires the DER form of a distinguished name is the verification of an X.509 certificate. For example, a distinguished name consisting of one RDN with one AVA, in which the type is commonName and the value is of the TeletexString choice with the letters 'Sam' would be represented in LDAP as the string CN=Sam. Another distinguished name in which the value is still 'Sam' but of the PrintableString choice would have the same representation CN=Sam. Applications which require the reconstruction of the DER form of the value SHOULD NOT use the string representation of attribute syntaxes when converting a distinguished name to the LDAP format. Instead, they SHOULD use the hexadecimal form prefixed by the octothorpe ('#') as described in the first paragraph of section 2.4. As specified by RFC 2253 this parser expects a hexadecimal representation when the AttributeType is given in the dotted-decimal form, e.g.:
1.3.6.1.4.1.1466.0=#04024869
Inner Class Summary | |
protected class |
RFC2253NameParser.AVA
Represents the parsing result for a Attribute-Value-Assertion. |
protected class |
RFC2253NameParser.ParsedName
Represents the parsing result for a Name. |
protected class |
RFC2253NameParser.ParsedRDN
Represents the parsing result for a Relative Distinguished Name. |
protected class |
RFC2253NameParser.ShortNameOIDAssociation
Provides functionality to map a Short Name of an well known Object Identifier to the corresponding Object Identifier. |
Field Summary | |
protected static Hashtable |
associations_
Repository for mapping shortNames to OIDs. |
protected RFC2253NameParser.ParsedName |
name_
Collects the parsing results. |
protected StringBuffer |
nameStrBuf_
The name to be parsed as StringBuffer. |
protected int |
position_
The current parsing position within nameStrBuf_ to be parsed. |
Constructor Summary | |
RFC2253NameParser(String name)
Standard constructor. |
Method Summary | |
Name |
parse()
Parses the name string, which has been set in the constructor. |
protected String |
parseAttrType()
Parses the type of an Attribute-Value-Assertion, starting from the position indicated by the current value of the member variable position_ . |
protected RFC2253NameParser.AVA |
parseAttrValue()
Parses the value of an Attribute-Value-Assertion, starting from the position indicated by the current value of the member variable position_ . |
protected RFC2253NameParser.AVA |
parseAVA()
Parses an Attribute-Value-Assertion, starting from the position indicated by the current value of the member variable position_ . |
protected char |
parseHexPair()
Parses a pair of two characters representing the hex value of a character, starting from the position indicated by the current value of the member variable position_ . |
protected char |
parseHexPairEscapeSequence()
|
protected RFC2253NameParser.ParsedRDN |
parseRDN()
Parses a Relative distinguished Name, starting from the position indicated by the current value of the member variable position_ . |
static void |
register(String shortName,
ObjectID oid)
Associates the supplied short name with the given OID. |
protected void |
skipOIDIntro()
Checks if the next for characters, starting at position position_ equal the String
"OID." (case will be ignored). |
protected void |
skipSpace()
Increases the member variable position_ as long as the character at position
position_ does not equal the space character. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static Hashtable associations_
protected RFC2253NameParser.ParsedName name_
protected int position_
nameStrBuf_
to be parsed.protected StringBuffer nameStrBuf_
Constructor Detail |
public RFC2253NameParser(String name)
name
- The ISO 10646 string to be parsed.Method Detail |
public static void register(String shortName, ObjectID oid)
This method allows an application to register additional shortName -- OID associations. The foolowing associations are already registered:
"CN" ....... commonName ("2.5.4.3") "SN" ....... surName ("2.5.4.4") "C" ....... countryName ("2.5.4.6") "L" ....... localityName ("2.5.4.7") "ST" ....... stateOrProvinceName ("2.5.4.8") "STREET" ... streetAddress ("2.5.4.9") "O" ....... organizationName ("2.5.4.10") "OU" ....... organizationUnitName ("2.5.4.11") "T" ....... title ("2.5.4.12") "DC" ....... domainComponent ("0.9.2342.19200300.100.1.25") "UID" ...... userid ("0.9.2342.19200300.100.1.1") "EMail" .... emailAddress ("1.2.840.113549.1.9.1") "E" ........ emailAddress ("1.2.840.113549.1.9.1") "EA" ....... emailAddress ("1.2.840.113549.1.9.1") "MAIL" ..... emailAddress ("1.2.840.113549.1.9.1") "EMAIL" .... emailAddress ("1.2.840.113549.1.9.1") "serialNumber" ....... serialNumber ("2.5.4.5") "postalAddress" ...... postalAddress ("2.5.4.16") "postalCode" ......... postalCode ("2.5.4.17") "telephoneNumber" .... telephoneNumber ("2.5.4.20") "telexNumber" ........ telexNumber ("2.5.4.21");Notice that calling this method for one of the registered shortName will replace the corresponding registration entry.
shortName
- the short name to be associated with an OIDoid
- the object identifier for the short name in mindpublic Name parse() throws RFC2253NameParserException
Name
object representing the structure of the parsed X.501 Name.RFC2253NameParserException
- if the name string could not be parsed successfully.protected RFC2253NameParser.ParsedRDN parseRDN() throws RFC2253NameParserException
position_
.ParsedRDN
object representing the structure of the parsed RDN.RFC2253NameParserException
- if the RDN could not be parsed successfully.protected RFC2253NameParser.AVA parseAVA() throws RFC2253NameParserException
position_
.AVA
object representing the structure of the parsed AVA.RFC2253NameParserException
- if the AVA could not be parsed successfully.protected String parseAttrType() throws RFC2253NameParserException
position_
.String
representing the type of a AVA.RFC2253NameParserException
- if the AVA type could not be parsed successfully.protected RFC2253NameParser.AVA parseAttrValue() throws RFC2253NameParserException
position_
.AVA
object with its value_
and
hasHexValue_
fields set.RFC2253NameParserException
- if the AVA value could not be parsed successfully.protected char parseHexPair() throws RFC2253NameParserException
position_
.RFC2253NameParserException
- if the next two characters cannot be interpreted as hex pair.protected char parseHexPairEscapeSequence() throws RFC2253NameParserException
protected void skipSpace()
position_
as long as the character at position
position_
does not equal the space character.protected void skipOIDIntro()
position_
equal the String
"OID." (case will be ignored). If yes, increases position_
by 4.
|
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). | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |