Overview | Package | Class | Tree | Deprecated | Index | Help
| Bouncy Castle Cryptography 1.25
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.bouncycastle.asn1.x509
Class X509NameEntryConverter

    java.lang.Object
      org.bouncycastle.asn1.x509.X509NameEntryConverter

Direct Known Subclasses:
  X509DefaultEntryConverter

public abstract class X509NameEntryConverter
extends java.lang.Object

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 PrintableStrings if the field value will decode to that, next UTF8Strings if the field value will decode to that, and finally BMPStrings if 16 bit characters are required.

The way this is done is with a default encoder which is implemented as follows:

###

###

###

###

###

     public class X509DefaultEntryConverter
         extends X509NameEntryConverter
     {
         public DERObject getConvertedValue(
             DERObjectIdentifier  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

    X509NameEntryConverter()

    Method Summary

    protected  boolean
    canBePrintable(java.lang.String str)

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

    protected  boolean
    canBeUTF8(java.lang.String str)

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

    protected  DERObject
    convertHexEncoded(java.lang.String str,
                      int off)

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

    abstract  DERObject
    getConvertedValue(DERObjectIdentifier oid,
                      java.lang.String value)

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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Constructor Detail

    X509NameEntryConverter

    public X509NameEntryConverter()

    Method Detail

    convertHexEncoded

    protected DERObject convertHexEncoded(java.lang.String str,
                                          int off)
                                   throws java.io.IOException

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

    Parameters:str - the hex encoded objectoff - the index at which the encoding starts
    Returns:the decoded object
    Throws:
    java.io.IOException

    canBePrintable

    protected boolean canBePrintable(java.lang.String str)

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

    canBeUTF8

    protected boolean canBeUTF8(java.lang.String str)

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

    getConvertedValue

    public abstract DERObject getConvertedValue(DERObjectIdentifier oid,
                                                java.lang.String value)

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

    Parameters:oid - the oid associated with the value in the DN.value - the value of the particular DN component.
    Returns:the ASN.1 equivalent for the value.

          Overview
          Package
        Class
          Tree
          Deprecated
          Index
          Help

    Bouncy Castle Cryptography 1.25

     PREV CLASS
     NEXT CLASS

      FRAMES
     NO FRAMES

      SUMMARY: NESTED | FIELD | CONSTR | METHOD

    DETAIL: FIELD | CONSTR | METHOD