Class PrintableConverter

java.lang.Object
org.mozilla.jss.netscape.security.x509.PrintableConverter
All Implemented Interfaces:
AVAValueConverter

public class PrintableConverter extends Object implements AVAValueConverter
A AVAValueConverter that converts a Printable String attribute to a DerValue and vice versa. An example an attribute that is a printable string is "C".
See Also:
  • Constructor Details

    • PrintableConverter

      public PrintableConverter()
  • Method Details

    • getValue

      public DerValue getValue(String valueString) throws IOException
      Converts a string with ASN.1 Printable characters to a DerValue.
      Specified by:
      getValue in interface AVAValueConverter
      Parameters:
      valueString - a string with Printable characters.
      Returns:
      a DerValue.
      Throws:
      IOException - if a Printable encoder is not available for the conversion.
    • getValue

      public DerValue getValue(String valueString, byte[] tags) throws IOException
      Description copied from interface: AVAValueConverter
      Converts a string to a DER encoded attribute value. Specify the order of DER tags to use if more than one encoding is possible. Currently Directory Strings can have different order for backwards compatibility. By 2003 all should be UTF8String.
      Specified by:
      getValue in interface AVAValueConverter
      Parameters:
      valueString - An AVA value string not encoded in any form.
      Returns:
      A DerValue object.
      Throws:
      IOException - if an error occurs during the conversion.
    • getValue

      public DerValue getValue(byte[] berStream) throws IOException
      Converts a BER encoded value of PrintableString to a DER encoded value. Checks if the BER encoded value is a PrintableString. NOTE only DER encoded values are currently accepted on input.
      Specified by:
      getValue in interface AVAValueConverter
      Parameters:
      berStream - A byte array of the BER encoded value.
      Returns:
      A DerValue.
      Throws:
      IOException - if the BER value cannot be converted to a PrintableString DER value.
    • getAsString

      public String getAsString(DerValue avaValue) throws IOException
      Converts a DerValue of PrintableString to a java string with PrintableString characters.
      Specified by:
      getAsString in interface AVAValueConverter
      Parameters:
      avaValue - a DerValue.
      Returns:
      a string with PrintableString characters.
      Throws:
      IOException - if the DerValue is not a PrintableString i.e. The DerValue cannot be converted to a string with PrintableString characters.