Class GenericValueConverter
- All Implemented Interfaces:
AVAValueConverter
The conversion is done as follows. An encoder is obtained for the all the character sets from the global default ASN1CharStrConvMap. The encoders 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.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetAsString
(DerValue avaValue) Converts a DerValue of ASN1 Character string type to a java string (the string is not encoded in any form).getValue
(byte[] berByteStream) Creates a DerValue from the byte array of BER encoded value.Converts a string to a DER encoded ASN.1 primtable string, defined here as a PrintableString, IA5String, T.61String, BMPString or UniversalString.Converts a string to a DER encoded attribute value.
-
Field Details
-
DefEncodingTags
private static byte[] DefEncodingTags
-
-
Constructor Details
-
GenericValueConverter
public GenericValueConverter()
-
-
Method Details
-
getValue
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 an encoder 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 encoder is available then an IOException is thrown.
- Specified by:
getValue
in interfaceAVAValueConverter
- 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 an encoder needed is unavailable.
-
getValue
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 interfaceAVAValueConverter
- 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
Creates a DerValue from the byte array of BER encoded value. NOTE: currently only supports DER encoding (a form of BER) on input .- Specified by:
getValue
in interfaceAVAValueConverter
- Parameters:
berByteStream
- 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.
-
getAsString
Converts a DerValue of ASN1 Character string type to a java string (the string is not encoded in any form).- Specified by:
getAsString
in interfaceAVAValueConverter
- Parameters:
avaValue
- A DerValue- Returns:
- A string representing the attribute value.
- Throws:
IOException
- if a decoder needed for the conversion is not available or if BER value is not one of the ASN1 character string types here.
-