Class DirectoryString

  • All Implemented Interfaces:
    ASN1Value

    public class DirectoryString
    extends java.lang.Object
    implements ASN1Value
    An X.500 DirectoryString. DirectoryString is defined as follows:
     DirectoryString ::= CHOICE {
          teletexString               TeletexString (SIZE (1..MAX)),
          printableString             PrintableString (SIZE (1..MAX)),
          universalString             UniversalString (SIZE (1..MAX)),
          utf8String                  UTF8String (SIZE (1..MAX)),
          bmpString                   BMPString (SIZE (1..MAX))  }
     
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  DirectoryString.Template
      A Template for decoding DirectoryStrings from their BER encoding.
    • Constructor Summary

      Constructors 
      Constructor Description
      DirectoryString​(java.lang.String s)
      Encodes a Java String into a Directory String.
      DirectoryString​(CharacterString s)
      Creates a DirectoryString from an ASN.1 string.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void encode​(java.io.OutputStream ostream)
      Write this value's DER encoding to an output stream using its own base tag.
      void encode​(Tag implicitTag, java.io.OutputStream ostream)
      Write this value's DER encoding to an output stream using an implicit tag.
      Tag getTag()
      Returns the base tag for this type, not counting any tags that may be imposed on it by its context.
      static DirectoryString.Template getTemplate()
      Returns a singleton instance of the decoding template for this class.
      java.lang.String toString()
      Converts an ASN.1 DirectoryString to a Java string.
      • Methods inherited from class java.lang.Object

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

      • DirectoryString

        public DirectoryString​(java.lang.String s)
                        throws java.io.CharConversionException
        Encodes a Java String into a Directory String. The following rules for choosing an encoding are from the IETF PKIX document Internet X.509 Public Key Infrastructure: Certificate and CRL Profile:
        • The preferred encoding is UTF8String, and all certificates issued after December 31, 2003, MUST use UTF8String encoding, with a few exceptions.
        • Until December 31, 2003, strings that fit in the PrintableString character set MAY use PrintableString.
        • Until December 31, 2003, string that fit in the BMPString character set MAY use BMPString.
        • Strings that fit in neither the PrintableString nor the BMPString character set MUST use UTF8String.
        This is all very nice, but for backwards compatibility, what we really do is:
        • Try PrintableString
        • Try TeletexString
        • Try UniversalString
        Throws:
        java.io.CharConversionException
      • DirectoryString

        public DirectoryString​(CharacterString s)
        Creates a DirectoryString from an ASN.1 string.
        Parameters:
        s - Must be a TeletexString, PrintableString, UniversalString, UTF8String, or BMPString.
    • Method Detail

      • toString

        public java.lang.String toString()
        Converts an ASN.1 DirectoryString to a Java string.
        Overrides:
        toString in class java.lang.Object
      • getTag

        public Tag getTag()
        Description copied from interface: ASN1Value
        Returns the base tag for this type, not counting any tags that may be imposed on it by its context.
        Specified by:
        getTag in interface ASN1Value
        Returns:
        Base tag.
      • encode

        public void encode​(java.io.OutputStream ostream)
                    throws java.io.IOException
        Description copied from interface: ASN1Value
        Write this value's DER encoding to an output stream using its own base tag.
        Specified by:
        encode in interface ASN1Value
        Parameters:
        ostream - Output stream.
        Throws:
        java.io.IOException - If an error occurred.
      • encode

        public void encode​(Tag implicitTag,
                           java.io.OutputStream ostream)
                    throws java.io.IOException
        Description copied from interface: ASN1Value
        Write this value's DER encoding to an output stream using an implicit tag.
        Specified by:
        encode in interface ASN1Value
        Parameters:
        implicitTag - Implicit tag.
        ostream - Output stream.
        Throws:
        java.io.IOException - If an error occurred.
      • getTemplate

        public static DirectoryString.Template getTemplate()
        Returns a singleton instance of the decoding template for this class.