Class DirectoryString

java.lang.Object
org.mozilla.jss.pkix.primitive.DirectoryString
All Implemented Interfaces:
ASN1Value

public class DirectoryString extends 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))  }
 
  • Field Details

  • Constructor Details

    • DirectoryString

      public DirectoryString(String s) throws 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:
      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 Details

    • toString

      public String toString()
      Converts an ASN.1 DirectoryString to a Java string.
      Overrides:
      toString in class 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(OutputStream ostream) throws 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:
      IOException - If an error occurred.
    • encode

      public void encode(Tag implicitTag, OutputStream ostream) throws 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:
      IOException - If an error occurred.
    • getTemplate

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