Class LdapV3DNStrConverter

    • 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.String encodeAVA​(AVA ava)
      Converts a AVA to a Ldap v3 DN String (except in unicode).
      java.lang.String encodeDN​(X500Name x500name)
      Converts a X500Name object to a Ldap v3 DN string (except in unicode).
      java.lang.String encodeOID​(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.String encodeRDN​(RDN rdn)
      Converts a RDN to a Ldap v3 DN string (except in unicode).
      java.lang.String encodeString​(java.lang.String valueStr)
      converts a raw value string to a string in Ldap V3 DN string format.
      java.lang.String encodeValue​(DerValue attrValue, ObjectIdentifier oid)
      Converts a value as a DerValue to a string in a Ldap V3 DN String.
      boolean getAcceptUnknownOids()
      returns true if the converter accepts unregistered attributes i.e.
      X500NameAttrMap getAttrMap()
      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.
      AVA parseAVA​(java.io.PushbackReader in)
      Parses a Ldap DN string with a AVA component from a string reader to an AVA.
      AVA parseAVA​(java.io.PushbackReader in, byte[] encodingOrder)
      Like parseAVA(PushbackReader) with a DER encoding order given as argument for Directory Strings.
      AVA parseAVA​(java.lang.String ava)
      Parse a Ldap v3 DN string with a AVA component to a AVA.
      AVA parseAVA​(java.lang.String ava, byte[] encodingOrder)
      Like parseDN(String) with a DER encoding order given as argument for Directory Strings.
      ObjectIdentifier parseAVAKeyword​(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.
      DerValue parseAVAValue​(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.
      DerValue parseAVAValue​(java.lang.String avaValueString, ObjectIdentifier oid)
      Converts a AVA value from a Ldap dn string to a DerValue according the attribute type.
      DerValue parseAVAValue​(java.lang.String avaValueString, ObjectIdentifier oid, byte[] encodingOrder)
      Like parseAVAValue(String) with a DER encoding order given as argument for Directory Strings.
      X500Name parseDN​(java.io.PushbackReader in)
      Parses a Ldap DN string in a string reader to a X500Name.
      X500Name parseDN​(java.io.PushbackReader in, byte[] encodingOrder)
      Like parseDN(PushbackReader in) with a DER encoding order given as argument for Directory Strings.
      X500Name parseDN​(java.lang.String dn)
      Parse a Ldap v3 DN string to a X500Name.
      X500Name parseDN​(java.lang.String dn, byte[] encodingOrder)
      Like parseDN(String) with a DER encoding order given as argument for Directory Strings.
      RDN parseRDN​(java.io.PushbackReader in)
      Parses Ldap DN string with a rdn component from a string reader to a RDN.
      RDN parseRDN​(java.io.PushbackReader in, byte[] encodingOrder)
      Like parseRDN(PushbackReader) with a DER encoding order given as argument for Directory Strings.
      RDN parseRDN​(java.lang.String rdn)
      Parse a Ldap v3 DN string with a RDN component to a RDN
      RDN parseRDN​(java.lang.String rdn, byte[] encodingOrder)
      Like parseRDN(String) with a DER encoding order given as argument for Directory Strings.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 X500NameAttrMap
        doAcceptUnknownOids - 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:
        parseDN in class LdapDNStrConverter
        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:
        parseDN in class LdapDNStrConverter
        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:
        parseRDN in class LdapDNStrConverter
        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:
        parseRDN in class LdapDNStrConverter
        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:
        parseAVA in class LdapDNStrConverter
        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:
        parseAVA in class LdapDNStrConverter
        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 encoding
        oid - 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:
        encodeDN in class LdapDNStrConverter
        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:
        encodeRDN in class LdapDNStrConverter
        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:
        encodeAVA in class LdapDNStrConverter
        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.UnsupportedEncodingException
        Parse 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