Class DirStrConverter

  • All Implemented Interfaces:
    AVAValueConverter

    public class DirStrConverter
    extends java.lang.Object
    implements AVAValueConverter
    A DirStrConverter converts a string to a DerValue of ASN.1 Directory String, which is a CHOICE of Printable (subset of ASCII), T.61 (Teletex) or Universal String (UCS-4), and vice versa.

    The string to DerValue conversion is done as follows. If the string has only PrintableString characters it is converted to a ASN.1 Printable String using the PrintableString encoder from the global default ASN1CharStrConvMap. If it has only characters covered in the PrintableString or T.61 character set it is converted to a ASN.1 T.61 string using the T.61 encoder from the ASN1CharStrCovnMap. Otherwise it is converted to a ASN.1 UniversalString (UCS-4 character set) which covers all characters.

    See Also:
    AVAValueConverter, ASN1CharStrConvMap
    • Constructor Summary

      Constructors 
      Constructor Description
      DirStrConverter()
      Constructs a DirStrConverter.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getAsString​(DerValue avaValue)
      Converts a DerValue to a string.
      DerValue getValue​(byte[] berByteStream)
      Creates a DerValue from a BER encoded value, obtained from for example a attribute value in octothorpe form of a Ldap DN string.
      DerValue getValue​(java.lang.String ds)
      Converts a string to a DER encoded attribute value.
      DerValue getValue​(java.lang.String valueString, byte[] tags)
      Like getValue(String) with specified DER tags as encoding order.
      static void setDefEncodingOrder​(byte[] defEncodingOrder)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DirStrConverter

        public DirStrConverter()
        Constructs a DirStrConverter.
    • Method Detail

      • setDefEncodingOrder

        public static void setDefEncodingOrder​(byte[] defEncodingOrder)
      • getValue

        public DerValue getValue​(java.lang.String ds)
                          throws java.io.IOException
        Description copied from interface: AVAValueConverter
        Converts a string to a DER encoded attribute value.
        Specified by:
        getValue in interface AVAValueConverter
        Parameters:
        ds - An AVA value string not encoded in any form.
        Returns:
        A DerValue object.
        Throws:
        java.io.IOException - if an error occurs during the conversion.
      • getValue

        public DerValue getValue​(java.lang.String valueString,
                                 byte[] tags)
                          throws java.io.IOException
        Like getValue(String) with specified DER tags as encoding order.
        Specified by:
        getValue in interface AVAValueConverter
        Parameters:
        valueString - An AVA value string not encoded in any form.
        Returns:
        A DerValue object.
        Throws:
        java.io.IOException - if an error occurs during the conversion.
      • getValue

        public DerValue getValue​(byte[] berByteStream)
                          throws java.io.IOException
        Creates a DerValue from a BER encoded value, obtained from for example a attribute value in octothorpe form of a Ldap DN string. Checks if the BER encoded value is legal for a DirectoryString. NOTE: currently only supports DER encoding for the BER encoded value.
        Specified by:
        getValue in interface AVAValueConverter
        Parameters:
        berByteStream - Byte array of a BER encoded value.
        Returns:
        DerValue object.
        Throws:
        java.io.IOException - If the BER value cannot be converted to a valid Directory String DER value.
      • getAsString

        public java.lang.String getAsString​(DerValue avaValue)
                                     throws java.io.IOException
        Converts a DerValue to a string. The string is not in any syntax, such as RFC1779 string syntax.
        Specified by:
        getAsString in interface AVAValueConverter
        Parameters:
        avaValue - a DerValue
        Returns:
        a string if the value can be converted.
        Throws:
        java.io.IOException - if a decoder needed for the conversion is not available.