X500NameStyle (Bouncy Castle Library 1.85 API Specification)
Date: 2026-07-12

org.bouncycastle.asn1.x500

## Interface X500NameStyle

- All Known Implementing Classes:
    AbstractX500NameStyle, BCStrictStyle, BCStyle, RFC4519Style, X500NameTest.DNQStyle

      public interface X500NameStyle

  This interface provides a profile to conform to when DNs are being converted into strings and back. The idea being that we'll be able to deal with the number of standard ways the fields in a DN should be encoded into their ASN.1 counterparts - a number that is rapidly approaching the number of machines on the internet.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `areEqual(X500Name name1, X500Name name2)` Return true if the two names are equal.
    `ASN1ObjectIdentifier` | `attrNameToOID(java.lang.String attrName)` Return the OID associated with the passed in name.
    `int` | `calculateHashCode(X500Name name)` Calculate a hashCode for the passed in name.
    `RDN[]` | `fromString(java.lang.String dirName)` Return an array of RDN generated from the passed in String.
    `java.lang.String[]` | `oidToAttrNames(ASN1ObjectIdentifier oid)` Return the acceptable names in a String DN that map to OID.
    `java.lang.String` | `oidToDisplayName(ASN1ObjectIdentifier oid)` Return the display name for toString() associated with the OID.
    `ASN1Encodable` | `stringToValue(ASN1ObjectIdentifier oid, java.lang.String value)` Convert the passed in String value into the appropriate ASN.1 encoded object.
    `java.lang.String` | `toString(X500Name name)` Convert the passed in X500Name to a String.

- - ### Method Detail

    - #### stringToValue

          ASN1Encodable stringToValue(ASN1ObjectIdentifier 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.

    - #### attrNameToOID

          ASN1ObjectIdentifier attrNameToOID(java.lang.String attrName)

      Return the OID associated with the passed in name.
      Parameters:
        `attrName` - the string to match.
      Returns:
        an OID

    - #### fromString

          RDN[] fromString(java.lang.String dirName)

      Return an array of RDN generated from the passed in String.
      Parameters:
        `dirName` - the String representation.
      Returns:
        an array of corresponding RDNs.

    - #### areEqual

          boolean areEqual(X500Name name1,
                           X500Name name2)

      Return true if the two names are equal.
      Parameters:
        `name1` - first name for comparison.
        `name2` - second name for comparison.
      Returns:
        true if name1 = name 2, false otherwise.

    - #### calculateHashCode

          int calculateHashCode(X500Name name)

      Calculate a hashCode for the passed in name.
      Parameters:
        `name` - the name the hashCode is required for.
      Returns:
        the calculated hashCode.

    - #### toString

          java.lang.String toString(X500Name name)

      Convert the passed in X500Name to a String.
      Parameters:
        `name` - the name to convert.
      Returns:
        a String representation.

    - #### oidToDisplayName

          java.lang.String oidToDisplayName(ASN1ObjectIdentifier oid)

      Return the display name for toString() associated with the OID.
      Parameters:
        `oid` - the OID of interest.
      Returns:
        the name displayed in toString(), null if no mapping provided.

    - #### oidToAttrNames

          java.lang.String[] oidToAttrNames(ASN1ObjectIdentifier oid)

      Return the acceptable names in a String DN that map to OID.
      Parameters:
        `oid` - the OID of interest.
      Returns:
        an array of String aliases for the OID, zero length if there are none.