Class 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 java.util.Hashtable<org.bouncycastle.asn1.ASN1ObjectIdentifier,​java.lang.String> asn2StringAll
      All mappings which are supported by the JDK impl (see sun.security.x509.AVA class).
      static JavaAndBCStyle INSTANCE  
      static org.bouncycastle.asn1.ASN1ObjectIdentifier IP  
      • 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
      JavaAndBCStyle()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.bouncycastle.asn1.ASN1ObjectIdentifier attrNameToOID​(java.lang.String attrName)  
      org.bouncycastle.asn1.x500.RDN[] fromString​(java.lang.String dirName)  
      java.lang.String getLabelForOid​(org.bouncycastle.asn1.ASN1ObjectIdentifier oid)  
      java.lang.String getLabelForOidFull​(org.bouncycastle.asn1.ASN1ObjectIdentifier oid)  
      java.lang.String toString​(org.bouncycastle.asn1.x500.X500Name name)  
      java.lang.String toString​(org.bouncycastle.asn1.x500.X500Name name, java.util.Hashtable<org.bouncycastle.asn1.ASN1ObjectIdentifier,​java.lang.String> mappings)  
      java.lang.String 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 Detail

      • asn2StringAll

        public static final java.util.Hashtable<org.bouncycastle.asn1.ASN1ObjectIdentifier,​java.lang.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
    • Constructor Detail

      • JavaAndBCStyle

        public JavaAndBCStyle()
    • Method Detail

      • attrNameToOID

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

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

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

        public java.lang.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 java.lang.String toStringFull​(org.bouncycastle.asn1.x500.X500Name name)
        Parameters:
        name - name
        Returns:
        String representation with human readable labels for all known attributes.
      • getLabelForOid

        public java.lang.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 java.lang.String getLabelForOidFull​(org.bouncycastle.asn1.ASN1ObjectIdentifier oid)
        Parameters:
        oid - oid
        Returns:
        String label for the oid if it is among all known attributes