Class C509Name

java.lang.Object
org.bouncycastle.cbor.c509.C509Name

public class C509Name extends Object
A C509 Name (Section 3.1.4 of draft-ietf-cose-cbor-encoded-cert-20):
Name = [ * RDNAttribute ] / SpecialText
RDNAttribute = ( ( attributeType: int, attributeValue: SpecialText ) //
                 ( attributeType: ~oid, attributeValue: bytes ) )
SpecialText = text / bytes / tag
For an int-coded attribute the absolute value of the int is the C509 RDN Attributes Registry value and the sign carries the DER string type (positive for utf8String, negative for printableString; attributes that are always IA5String use a non-negative int). Text values are compacted: a string of even length holding only the symbols '0'-'9' and 'a'-'f' becomes a CBOR byte string, and an EUI-64 of the form "HH-HH-HH-HH-HH-HH-HH-HH" (with "HH-HH-HH-FF-FE-HH-HH-HH" reduced to its EUI-48 form) becomes a CBOR tag 48 item. A Name consisting of a single common name attribute of type utf8String is encoded as just the attribute value.

Instances always hold both the CBOR encoding and the equivalent X500Name, so conversion failures surface at construction rather than at use. A RelativeDistinguishedName with more than one AttributeTypeAndValue has no C509 encoding and is rejected.

  • Method Details

    • getInstance

      public static C509Name getInstance(byte[] cborEncoding) throws IOException
      Parse a C509 Name from its complete CBOR encoding.
      Throws:
      IOException
    • fromX500Name

      public static C509Name fromX500Name(org.bouncycastle.asn1.x500.X500Name name)
      Build the C509 form of an X.500 name.
      Throws:
      IllegalArgumentException - if the name cannot be represented in C509 - only names whose RDNs are all single-valued can be.
    • toX500Name

      public org.bouncycastle.asn1.x500.X500Name toX500Name()
      Return the X.500 view of this name.
    • getEncoded

      public byte[] getEncoded()
      Return the CBOR encoding of this name.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object