Top Description Constructors Methods
org.bouncycastle.asn1.x509

public abstract Class X509NameEntryConverter

extends Object
Class Inheritance
Known Direct Subclasses
org.bouncycastle.asn1.x509.X509DefaultEntryConverter
Imports
java.io.IOException, org.bouncycastle.asn1.ASN1ObjectIdentifier, .ASN1Primitive, .ASN1PrintableString, org.bouncycastle.util.encoders.Hex

It turns out that the number of standard ways the fields in a DN should be encoded into their ASN.1 counterparts is rapidly approaching the number of machines on the internet. By default the X509Name class will produce UTF8Strings in line with the current recommendations (RFC 3280).

An example of an encoder look like below:

public class X509DirEntryConverter
    extends X509NameEntryConverter
{
    public ASN1Primitive getConvertedValue(
        ASN1ObjectIdentifier  oid,
        String               value)
    {
        if (str.length() != 0 && str.charAt(0) == '#')
        {
            return convertHexEncoded(str, 1);
        }
        if (oid.equals(EmailAddress))
        {
            return new DERIA5String(str);
        }
        else if (canBePrintable(str))
        {
            return new DERPrintableString(str);
        }
        else if (canBeUTF8(str))
        {
            return new DERUTF8String(str);
        }
        else
        {
            return new DERBMPString(str);
        }
    }
}

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected boolean
canBePrintable(String str)

return true if the passed in String can be represented without loss as a PrintableString, false otherwise.

protected ASN1Primitive

Returns:

the decoded object
convertHexEncoded
(String
the hex encoded object
str
,
int
the index at which the encoding starts
off
)

Convert an inline encoded hex string rendition of an ASN.1 object back into its corresponding ASN.1 object.

public abstract ASN1Primitive

Returns:

the ASN.1 equivalent for the value.
getConvertedValue
(ASN1ObjectIdentifier
the oid associated with the value in the DN.
oid
,
String
the value of the particular DN component.
value
)

Convert the passed in String value into the appropriate ASN.1 encoded object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

X509NameEntryConverterback to summary
public X509NameEntryConverter()

Method Detail

canBePrintableback to summary
protected boolean canBePrintable(String str)

return true if the passed in String can be represented without loss as a PrintableString, false otherwise.

convertHexEncodedback to summary
protected ASN1Primitive convertHexEncoded(String str, int off) throws IOException

Convert an inline encoded hex string rendition of an ASN.1 object back into its corresponding ASN.1 object.

Parameters
str:String

the hex encoded object

off:int

the index at which the encoding starts

Returns:ASN1Primitive

the decoded object

getConvertedValueback to summary
public abstract ASN1Primitive getConvertedValue(ASN1ObjectIdentifier oid, String value)

Convert the passed in String value into the appropriate ASN.1 encoded object.

Parameters
oid:ASN1ObjectIdentifier

the oid associated with the value in the DN.

value:String

the value of the particular DN component.

Returns:ASN1Primitive

the ASN.1 equivalent for the value.