All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class netscape.security.x509.GenericValueConverter

netscape.security.x509.GenericValueConverter

public class GenericValueConverter
implements AVAValueConverter
A GenericValueConverter converts a string that is not associated with a particular attribute to a DER encoded ASN.1 character string type. Currently supports PrintableString, IA5String, BMPString T.61String and Universal String.

The conversion is done as follows. A CharToByteConverter is obtained for the all the character sets from the global default ASN1CharStrConvMap. The CharToByteConverters are then used to convert the string to the smallest character set first -- printableString. If the string contains characters outside of that character set, it is converted to the next character set -- IA5String character set. If that is not enough it is converted to a BMPString, then Universal String which contains all characters.


Constructor Index

 o GenericValueConverter()

Method Index

 o getAsString(DerValue)
Converts a DerValue of ASN1 Character string type to a java string (the string is not encoded in any form).
 o getValue(byte[])
Creates a DerValue from the byte array of BER encoded value.
 o getValue(String)
Converts a string to a DER encoded ASN.1 primtable string, defined here as a PrintableString, IA5String, T.61String, BMPString or UniversalString.

Constructors

 o GenericValueConverter
 public GenericValueConverter()

Methods

 o getValue
 public DerValue getValue(String s) throws IOException
Converts a string to a DER encoded ASN.1 primtable string, defined here as a PrintableString, IA5String, T.61String, BMPString or UniversalString. The string is not expected to be encoded in any form.

If a CharToByteConverter is not available for a character set that is needed to convert the string, the string cannot be converted and an IOException is thrown. For example, if the string contains characters outside the PrintableString character and only a PrintableString CharToByteConverter is available then an IOException is thrown.

Parameters:
s - A string representing a generic attribute string value.
Returns:
The DER value of the attribute.
Throws: IOException
if the string cannot be converted, such as when a CharToByteConverter needed is unavailable.
 o getValue
 public DerValue getValue(byte berByteStream[]) throws IOException
Creates a DerValue from the byte array of BER encoded value. NOTE: currently only supports DER encoding (a form of BER) on input .

Parameters:
berStream - Byte array of a BER encoded value.
Returns:
DerValue object.
Throws: IOException
If the BER value cannot be converted to a valid Directory String DER value.
 o getAsString
 public String getAsString(DerValue avaValue) throws IOException
Converts a DerValue of ASN1 Character string type to a java string (the string is not encoded in any form).

Parameters:
avaValue - A DerValue
Returns:
A string representing the attribute value.
Throws: IOException
if a ByteToCharConverter needed for the conversion is not available or if BER value is not one of the ASN1 character string types here.

All Packages  Class Hierarchy  This Package  Previous  Next  Index