public class GenericValueConverter extends java.lang.Object implements 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.
Constructor and Description |
---|
GenericValueConverter() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getAsString(DerValue avaValue)
Converts a DerValue of ASN1 Character string type to a java string
(the string is not encoded in any form).
|
DerValue |
getValue(byte[] berByteStream)
Creates a DerValue from the byte array of BER encoded value.
|
DerValue |
getValue(java.lang.String s)
Converts a string to a DER encoded ASN.1 primtable string, defined here
as a PrintableString, IA5String, T.61String, BMPString or
UniversalString.
|
DerValue |
getValue(java.lang.String valueString,
byte[] tags)
Converts a string to a DER encoded attribute value.
|
public DerValue getValue(java.lang.String s) throws java.io.IOException
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.
getValue
in interface AVAValueConverter
s
- A string representing a generic attribute string value.java.io.IOException
- if the string cannot be converted, such as
when an encoder needed is
unavailable.public DerValue getValue(java.lang.String valueString, byte[] tags) throws java.io.IOException
AVAValueConverter
getValue
in interface AVAValueConverter
valueString
- An AVA value string not encoded in any form.java.io.IOException
- if an error occurs during the conversion.public DerValue getValue(byte[] berByteStream) throws java.io.IOException
getValue
in interface AVAValueConverter
berByteStream
- Byte array of a BER encoded value.java.io.IOException
- If the BER value cannot be converted to a
valid Directory String DER value.public java.lang.String getAsString(DerValue avaValue) throws java.io.IOException
getAsString
in interface AVAValueConverter
avaValue
- A DerValuejava.io.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.