Class LdapV3DNStrConverter
- java.lang.Object
-
- org.mozilla.jss.netscape.security.x509.LdapDNStrConverter
-
- org.mozilla.jss.netscape.security.x509.LdapV3DNStrConverter
-
- Direct Known Subclasses:
RFC1779StrConverter
public class LdapV3DNStrConverter extends LdapDNStrConverter
A converter that converts Ldap v3 DN strings as specified in draft-ietf-asid-ldapv3-dn-03.txt to a X500Name, RDN or AVA and vice versa.- See Also:
LdapDNStrConverter,X500Name,RDN,AVA,X500NameAttrMap
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanacceptUnknownOidsprotected X500NameAttrMapattrMapprotected static java.lang.StringhexDigitsprotected static java.lang.StringoctoEndCharsprotected static java.lang.StringquotedEndCharsprotected static java.lang.StringspecialCharsprotected static java.lang.StringvalueEndChars
-
Constructor Summary
Constructors Constructor Description LdapV3DNStrConverter()Constructs a LdapV3DNStrConverter using the global default X500NameAttrMap and accept OIDs not in the default X500NameAttrMap.LdapV3DNStrConverter(X500NameAttrMap attributeMap, boolean doAcceptUnknownOids)Constructs a LdapV3DNStrConverter using the specified X500NameAttrMap and a boolean indicating whether to accept OIDs not listed in the X500NameAttrMap.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringencodeAVA(AVA ava)Converts a AVA to a Ldap v3 DN String (except in unicode).java.lang.StringencodeDN(X500Name x500name)Converts a X500Name object to a Ldap v3 DN string (except in unicode).java.lang.StringencodeOID(ObjectIdentifier oid)Converts an OID to a attribute keyword in a Ldap v3 DN string - either a keyword if known or a string of "1.2.3.4" syntax.java.lang.StringencodeRDN(RDN rdn)Converts a RDN to a Ldap v3 DN string (except in unicode).java.lang.StringencodeString(java.lang.String valueStr)converts a raw value string to a string in Ldap V3 DN string format.java.lang.StringencodeValue(DerValue attrValue, ObjectIdentifier oid)Converts a value as a DerValue to a string in a Ldap V3 DN String.booleangetAcceptUnknownOids()returns true if the converter accepts unregistered attributes i.e.X500NameAttrMapgetAttrMap()gets the X500NameAttrMap used by the converter.protected static char[]getStringFromHexpairs(char[] hexPairs)Parse a sequence of hex pairs, each pair a UTF8 byte to a java string.AVAparseAVA(java.io.PushbackReader in)Parses a Ldap DN string with a AVA component from a string reader to an AVA.AVAparseAVA(java.io.PushbackReader in, byte[] encodingOrder)Like parseAVA(PushbackReader) with a DER encoding order given as argument for Directory Strings.AVAparseAVA(java.lang.String ava)Parse a Ldap v3 DN string with a AVA component to a AVA.AVAparseAVA(java.lang.String ava, byte[] encodingOrder)Like parseDN(String) with a DER encoding order given as argument for Directory Strings.ObjectIdentifierparseAVAKeyword(java.lang.String avaKeyword)Converts a AVA keyword from a Ldap DN string to an ObjectIdentifier from the attribute map or, if this keyword is an OID not in the attribute map, create a new ObjectIdentifier for the keyword if acceptUnknownOids is true.DerValueparseAVAValue(byte[] berValue, ObjectIdentifier oid)Converts a value in BER encoding, for example given in octothorpe form in a Ldap v3 dn string, to a DerValue.DerValueparseAVAValue(java.lang.String avaValueString, ObjectIdentifier oid)Converts a AVA value from a Ldap dn string to a DerValue according the attribute type.DerValueparseAVAValue(java.lang.String avaValueString, ObjectIdentifier oid, byte[] encodingOrder)Like parseAVAValue(String) with a DER encoding order given as argument for Directory Strings.X500NameparseDN(java.io.PushbackReader in)Parses a Ldap DN string in a string reader to a X500Name.X500NameparseDN(java.io.PushbackReader in, byte[] encodingOrder)Like parseDN(PushbackReader in) with a DER encoding order given as argument for Directory Strings.X500NameparseDN(java.lang.String dn)Parse a Ldap v3 DN string to a X500Name.X500NameparseDN(java.lang.String dn, byte[] encodingOrder)Like parseDN(String) with a DER encoding order given as argument for Directory Strings.RDNparseRDN(java.io.PushbackReader in)Parses Ldap DN string with a rdn component from a string reader to a RDN.RDNparseRDN(java.io.PushbackReader in, byte[] encodingOrder)Like parseRDN(PushbackReader) with a DER encoding order given as argument for Directory Strings.RDNparseRDN(java.lang.String rdn)Parse a Ldap v3 DN string with a RDN component to a RDNRDNparseRDN(java.lang.String rdn, byte[] encodingOrder)Like parseRDN(String) with a DER encoding order given as argument for Directory Strings.-
Methods inherited from class org.mozilla.jss.netscape.security.x509.LdapDNStrConverter
getDefault, setDefault
-
-
-
-
Field Detail
-
attrMap
protected X500NameAttrMap attrMap
-
acceptUnknownOids
protected boolean acceptUnknownOids
-
specialChars
protected static final java.lang.String specialChars
- See Also:
- Constant Field Values
-
valueEndChars
protected static final java.lang.String valueEndChars
- See Also:
- Constant Field Values
-
quotedEndChars
protected static final java.lang.String quotedEndChars
- See Also:
- Constant Field Values
-
octoEndChars
protected static final java.lang.String octoEndChars
- See Also:
- Constant Field Values
-
hexDigits
protected static final java.lang.String hexDigits
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
LdapV3DNStrConverter
public LdapV3DNStrConverter()
Constructs a LdapV3DNStrConverter using the global default X500NameAttrMap and accept OIDs not in the default X500NameAttrMap.- See Also:
X500NameAttrMap
-
LdapV3DNStrConverter
public LdapV3DNStrConverter(X500NameAttrMap attributeMap, boolean doAcceptUnknownOids)
Constructs a LdapV3DNStrConverter using the specified X500NameAttrMap and a boolean indicating whether to accept OIDs not listed in the X500NameAttrMap.- Parameters:
attributeMap- a X500NameAttrMapdoAcceptUnknownOids- whether to convert unregistered OIDs (oids not in the X500NameAttrMap)- See Also:
X500NameAttrMap
-
-
Method Detail
-
parseDN
public X500Name parseDN(java.lang.String dn) throws java.io.IOException
Parse a Ldap v3 DN string to a X500Name.- Specified by:
parseDNin classLdapDNStrConverter- Parameters:
dn- a LDAP v3 DN String- Returns:
- a X500Name
- Throws:
java.io.IOException- if an error occurs during the conversion.
-
parseDN
public X500Name parseDN(java.lang.String dn, byte[] encodingOrder) throws java.io.IOException
Like parseDN(String) with a DER encoding order given as argument for Directory Strings.- Specified by:
parseDNin classLdapDNStrConverter- Throws:
java.io.IOException
-
parseRDN
public RDN parseRDN(java.lang.String rdn) throws java.io.IOException
Parse a Ldap v3 DN string with a RDN component to a RDN- Specified by:
parseRDNin classLdapDNStrConverter- Parameters:
rdn- a LDAP v3 DN String- Returns:
- a RDN
- Throws:
java.io.IOException- if an error occurs during the conversion.
-
parseRDN
public RDN parseRDN(java.lang.String rdn, byte[] encodingOrder) throws java.io.IOException
Like parseRDN(String) with a DER encoding order given as argument for Directory Strings.- Specified by:
parseRDNin classLdapDNStrConverter- Throws:
java.io.IOException
-
parseAVA
public AVA parseAVA(java.lang.String ava) throws java.io.IOException
Parse a Ldap v3 DN string with a AVA component to a AVA.- Specified by:
parseAVAin classLdapDNStrConverter- Parameters:
ava- a LDAP v3 DN string- Returns:
- a AVA
- Throws:
java.io.IOException
-
parseAVA
public AVA parseAVA(java.lang.String ava, byte[] encodingOrder) throws java.io.IOException
Like parseDN(String) with a DER encoding order given as argument for Directory Strings.- Specified by:
parseAVAin classLdapDNStrConverter- Throws:
java.io.IOException
-
parseDN
public X500Name parseDN(java.io.PushbackReader in) throws java.io.IOException
Parses a Ldap DN string in a string reader to a X500Name.- Parameters:
in- Pushback string reader for a Ldap DN string. The pushback reader must have a pushback buffer size > 2.- Returns:
- a X500Name
- Throws:
java.io.IOException- if any reading or parsing error occurs.
-
parseDN
public X500Name parseDN(java.io.PushbackReader in, byte[] encodingOrder) throws java.io.IOException
Like parseDN(PushbackReader in) with a DER encoding order given as argument for Directory Strings.- Throws:
java.io.IOException
-
parseRDN
public RDN parseRDN(java.io.PushbackReader in) throws java.io.IOException
Parses Ldap DN string with a rdn component from a string reader to a RDN. The string reader will point to the separator after the rdn component or -1 if at end of string.- Parameters:
in- Pushback string reader containing a Ldap DN string with at least one rdn component. The pushback reader must have a pushback buffer size > 2.- Returns:
- RDN object of the first rdn component in the Ldap DN string.
- Throws:
java.io.IOException- if any read or parse error occurs.
-
parseRDN
public RDN parseRDN(java.io.PushbackReader in, byte[] encodingOrder) throws java.io.IOException
Like parseRDN(PushbackReader) with a DER encoding order given as argument for Directory Strings.- Throws:
java.io.IOException
-
parseAVA
public AVA parseAVA(java.io.PushbackReader in) throws java.io.IOException
Parses a Ldap DN string with a AVA component from a string reader to an AVA. The string reader will point to the AVA separator after the ava string or -1 if end of string.- Parameters:
in- a Pushback reader containg a Ldap string with at least one AVA component. The Pushback reader must have a pushback buffer size > 2.- Returns:
- AVA object of the first AVA component in the Ldap DN string.
- Throws:
java.io.IOException
-
parseAVA
public AVA parseAVA(java.io.PushbackReader in, byte[] encodingOrder) throws java.io.IOException
Like parseAVA(PushbackReader) with a DER encoding order given as argument for Directory Strings.- Throws:
java.io.IOException
-
parseAVAKeyword
public ObjectIdentifier parseAVAKeyword(java.lang.String avaKeyword) throws java.io.IOException
Converts a AVA keyword from a Ldap DN string to an ObjectIdentifier from the attribute map or, if this keyword is an OID not in the attribute map, create a new ObjectIdentifier for the keyword if acceptUnknownOids is true.- Parameters:
avaKeyword- AVA keyword from a Ldap DN string.- Returns:
- a ObjectIdentifier object
- Throws:
java.io.IOException- if the keyword is an OID not in the attribute map and acceptUnknownOids is false, or if an error occurs during conversion.
-
parseAVAValue
public DerValue parseAVAValue(java.lang.String avaValueString, ObjectIdentifier oid) throws java.io.IOException
Converts a AVA value from a Ldap dn string to a DerValue according the attribute type. For example, a value for CN, OU or O is expected to be a Directory String and will be converted to a DerValue of ASN.1 type PrintableString, T61String or UniversalString. A Directory String is a ASN.1 CHOICE of Printable, T.61 or Universal string.- Parameters:
avaValueString- a attribute value from a Ldap DN string.oid- OID of the attribute.- Returns:
- DerValue for the value.
- Throws:
java.io.IOException- if an error occurs during conversion.- See Also:
AVAValueConverter
-
parseAVAValue
public DerValue parseAVAValue(java.lang.String avaValueString, ObjectIdentifier oid, byte[] encodingOrder) throws java.io.IOException
Like parseAVAValue(String) with a DER encoding order given as argument for Directory Strings.- Throws:
java.io.IOException
-
parseAVAValue
public DerValue parseAVAValue(byte[] berValue, ObjectIdentifier oid) throws java.io.IOException
Converts a value in BER encoding, for example given in octothorpe form in a Ldap v3 dn string, to a DerValue. Checks if the BER encoded value is a legal value for the attribute.NOTE: only DER encoded values are supported for the BER encoded value.
- Parameters:
berValue- a value in BER encodingoid- ObjectIdentifier of the attribute.- Returns:
- DerValue for the BER encoded value
- Throws:
java.io.IOException- if an error occurs during conversion.
-
encodeDN
public java.lang.String encodeDN(X500Name x500name) throws java.io.IOException
Converts a X500Name object to a Ldap v3 DN string (except in unicode).- Specified by:
encodeDNin classLdapDNStrConverter- Parameters:
x500name- a X500Name- Returns:
- a Ldap v3 DN String (except in unicode).
- Throws:
java.io.IOException- if an error is encountered during conversion.
-
encodeRDN
public java.lang.String encodeRDN(RDN rdn) throws java.io.IOException
Converts a RDN to a Ldap v3 DN string (except in unicode).- Specified by:
encodeRDNin classLdapDNStrConverter- Parameters:
rdn- a RDN- Returns:
- a LDAP v3 DN string (except in unicode).
- Throws:
java.io.IOException- if an error is encountered during conversion.
-
encodeAVA
public java.lang.String encodeAVA(AVA ava) throws java.io.IOException
Converts a AVA to a Ldap v3 DN String (except in unicode).- Specified by:
encodeAVAin classLdapDNStrConverter- Parameters:
ava- an AVA- Returns:
- a Ldap v3 DN string (except in unicode).
- Throws:
java.io.IOException- If an error is encountered during exception.
-
encodeOID
public java.lang.String encodeOID(ObjectIdentifier oid) throws java.io.IOException
Converts an OID to a attribute keyword in a Ldap v3 DN string - either a keyword if known or a string of "1.2.3.4" syntax.- Parameters:
oid- a ObjectIdentifier- Returns:
- a keyword to use in a Ldap V3 DN string.
- Throws:
java.io.IOException- if an error is encountered during conversion.
-
encodeValue
public java.lang.String encodeValue(DerValue attrValue, ObjectIdentifier oid) throws java.io.IOException
Converts a value as a DerValue to a string in a Ldap V3 DN String. If the value cannot be converted to a string it will be encoded in octothorpe form.- Parameters:
attrValue- a value as a DerValue.oid- OID for the attribute.- Returns:
- a string for the value in a LDAP v3 DN String
- Throws:
java.io.IOException- if an error occurs during conversion.
-
encodeString
public java.lang.String encodeString(java.lang.String valueStr)
converts a raw value string to a string in Ldap V3 DN string format.- Parameters:
valueStr- a 'raw' value string.- Returns:
- a attribute value string in Ldap V3 DN string format.
-
getAttrMap
public X500NameAttrMap getAttrMap()
gets the X500NameAttrMap used by the converter.- Returns:
- X500NameAttrMap used by this converter.
-
getAcceptUnknownOids
public boolean getAcceptUnknownOids()
returns true if the converter accepts unregistered attributes i.e. OIDS not in the X500NameAttrMap.- Returns:
- true if converter converts attributes not in the X500NameAttrMap.
-
getStringFromHexpairs
protected static char[] getStringFromHexpairs(char[] hexPairs) throws java.io.UnsupportedEncodingExceptionParse a sequence of hex pairs, each pair a UTF8 byte to a java string. For example, "4C75C48D" is "Luc", the last c with caron.- Throws:
java.io.UnsupportedEncodingException
-
-