Class JavaAndBCStyle

java.lang.Object
org.bouncycastle.asn1.x500.style.AbstractX500NameStyle
org.bouncycastle.asn1.x500.style.BCStyle
eu.emi.security.authn.x509.helpers.JavaAndBCStyle
All Implemented Interfaces:
org.bouncycastle.asn1.x500.X500NameStyle

public class JavaAndBCStyle extends org.bouncycastle.asn1.x500.style.BCStyle
Extends BCStyle with additional recognized attribute names, to make it fully compatible with what the internal OpenJDK implementation supports when parsing string RFC 2253 DNs.

The serialization part of this class (toString(X500Name)) behaves in a different way: it only outputs labels for the attribute names which are recognized by JDK. All other are output as OIDs.

Therefore this class allows to consume even unsupported by the JDK DNs, all supported and convert them to BC RDNs form. On the other hand it allows to convert RDNs to RFC 2253 form ensuring that this form is acceptable by the JDK X500Principal class.

Author:
K. Benedyczak
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Hashtable<org.bouncycastle.asn1.ASN1ObjectIdentifier,String>
    All mappings which are supported by the JDK impl (see sun.security.x509.AVA class).
    static final JavaAndBCStyle
     
    static final org.bouncycastle.asn1.ASN1ObjectIdentifier
     

    Fields inherited from class org.bouncycastle.asn1.x500.style.BCStyle

    BUSINESS_CATEGORY, C, CN, COUNTRY_OF_CITIZENSHIP, COUNTRY_OF_RESIDENCE, DATE_OF_BIRTH, DC, defaultLookUp, defaultSymbols, DESCRIPTION, DMD_NAME, DN_QUALIFIER, E, EmailAddress, GENDER, GENERATION, GIVENNAME, INITIALS, L, NAME, NAME_AT_BIRTH, O, ORGANIZATION_IDENTIFIER, OU, PLACE_OF_BIRTH, POSTAL_ADDRESS, POSTAL_CODE, PSEUDONYM, ROLE, SERIALNUMBER, SN, ST, STREET, SURNAME, T, TELEPHONE_NUMBER, UID, UNIQUE_IDENTIFIER, UnstructuredAddress, UnstructuredName
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.bouncycastle.asn1.ASN1ObjectIdentifier
     
    org.bouncycastle.asn1.x500.RDN[]
    fromString(String dirName)
     
    getLabelForOid(org.bouncycastle.asn1.ASN1ObjectIdentifier oid)
     
    getLabelForOidFull(org.bouncycastle.asn1.ASN1ObjectIdentifier oid)
     
    toString(org.bouncycastle.asn1.x500.X500Name name)
     
    toString(org.bouncycastle.asn1.x500.X500Name name, Hashtable<org.bouncycastle.asn1.ASN1ObjectIdentifier,String> mappings)
     
    toStringFull(org.bouncycastle.asn1.x500.X500Name name)
     

    Methods inherited from class org.bouncycastle.asn1.x500.style.BCStyle

    encodeStringValue, oidToAttrNames, oidToDisplayName

    Methods inherited from class org.bouncycastle.asn1.x500.style.AbstractX500NameStyle

    areEqual, calculateHashCode, copyHashTable, rdnAreEqual, stringToValue

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • asn2StringAll

      public static final Hashtable<org.bouncycastle.asn1.ASN1ObjectIdentifier,String> asn2StringAll
      All mappings which are supported by the JDK impl (see sun.security.x509.AVA class). and the BCStyle.
    • IP

      public static final org.bouncycastle.asn1.ASN1ObjectIdentifier IP
    • INSTANCE

      public static final JavaAndBCStyle INSTANCE
  • Constructor Details

    • JavaAndBCStyle

      public JavaAndBCStyle()
  • Method Details

    • attrNameToOID

      public org.bouncycastle.asn1.ASN1ObjectIdentifier attrNameToOID(String attrName)
      Specified by:
      attrNameToOID in interface org.bouncycastle.asn1.x500.X500NameStyle
      Overrides:
      attrNameToOID in class org.bouncycastle.asn1.x500.style.BCStyle
    • toString

      public String toString(org.bouncycastle.asn1.x500.X500Name name, Hashtable<org.bouncycastle.asn1.ASN1ObjectIdentifier,String> mappings)
    • fromString

      public org.bouncycastle.asn1.x500.RDN[] fromString(String dirName)
      Specified by:
      fromString in interface org.bouncycastle.asn1.x500.X500NameStyle
      Overrides:
      fromString in class org.bouncycastle.asn1.x500.style.BCStyle
    • toString

      public String toString(org.bouncycastle.asn1.x500.X500Name name)
      Specified by:
      toString in interface org.bouncycastle.asn1.x500.X500NameStyle
      Overrides:
      toString in class org.bouncycastle.asn1.x500.style.BCStyle
      Parameters:
      name - name
      Returns:
      String representation with human readable labels for all attributes known by the JDK.
    • toStringFull

      public String toStringFull(org.bouncycastle.asn1.x500.X500Name name)
      Parameters:
      name - name
      Returns:
      String representation with human readable labels for all known attributes.
    • getLabelForOid

      public String getLabelForOid(org.bouncycastle.asn1.ASN1ObjectIdentifier oid)
      Parameters:
      oid - oid
      Returns:
      String label for the oid if it is known by the JDK
    • getLabelForOidFull

      public String getLabelForOidFull(org.bouncycastle.asn1.ASN1ObjectIdentifier oid)
      Parameters:
      oid - oid
      Returns:
      String label for the oid if it is among all known attributes