Class X500Principal

    • Constructor Summary

      Constructors 
      Constructor Description
      X500Principal​(byte[] name)
      Creates an X500Principal from a distinguished name in ASN.1 DER encoded form.
      X500Principal​(java.io.InputStream is)
      Creates an X500Principal from an InputStream containing the distinguished name in ASN.1 DER encoded form.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)
      Compares the specified Object with this X500Principal for equality.
      java.lang.String getName()
      Returns a string representation of the X.500 distinguished name.
      int hashCode()
      Return a hash code for this X500Principal.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • X500Principal

        public X500Principal​(byte[] name)
        Creates an X500Principal from a distinguished name in ASN.1 DER encoded form. The ASN.1 notation for this structure is as follows.
         
         Name ::= CHOICE {
           RDNSequence }
        
         RDNSequence ::= SEQUENCE OF RelativeDistinguishedName
        
         RelativeDistinguishedName ::=
           SET SIZE (1 .. MAX) OF AttributeTypeAndValue
        
         AttributeTypeAndValue ::= SEQUENCE {
           type     AttributeType,
           value    AttributeValue }
        
         AttributeType ::= OBJECT IDENTIFIER
        
         AttributeValue ::= ANY DEFINED BY AttributeType
         ....
         DirectoryString ::= CHOICE {
               teletexString           TeletexString (SIZE (1..MAX)),
               printableString         PrintableString (SIZE (1..MAX)),
               universalString         UniversalString (SIZE (1..MAX)),
               utf8String              UTF8String (SIZE (1.. MAX)),
               bmpString               BMPString (SIZE (1..MAX)) }
         
         
        Parameters:
        name - a byte array containing the distinguished name in ASN.1 DER encoded form
        Throws:
        java.lang.IllegalArgumentException - if an encoding error occurs (incorrect form for DN)
      • X500Principal

        public X500Principal​(java.io.InputStream is)
        Creates an X500Principal from an InputStream containing the distinguished name in ASN.1 DER encoded form. The ASN.1 notation for this structure is supplied in the documentation for X500Principal(byte[] name).

        The read position of the input stream is positioned to the next available byte after the encoded distinguished name.

        Parameters:
        is - an InputStream containing the distinguished name in ASN.1 DER encoded form
        Throws:
        java.lang.NullPointerException - if the InputStream is null
        java.lang.IllegalArgumentException - if an encoding error occurs (incorrect form for DN)
    • Method Detail

      • getName

        public java.lang.String getName()
        Returns a string representation of the X.500 distinguished name.

        The chosen format is a '#' character followed by the hexadecimal encoding of de DER representation of the name. (No spaces between digits, letters in lower case).

        Returns:
        the distinguished name of this X500Principal
      • equals

        public boolean equals​(@Nullable
                              java.lang.Object o)
        Compares the specified Object with this X500Principal for equality.

        Specifically, this method returns true if the Object o is an X500Principal and if the respective canonical string representations (obtained via the getName(X500Principal.CANONICAL) method) of this object and o are equal.

        This implementation is compliant with the requirements of RFC 3280.

        Specified by:
        equals in interface Principal
        Overrides:
        equals in class java.lang.Object
        Parameters:
        o - Object to be compared for equality with this X500Principal
        Returns:
        true if the specified Object is equal to this X500Principal, false otherwise
      • hashCode

        public int hashCode()
        Return a hash code for this X500Principal.

        The hash code is calculated via: getName(X500Principal.CANONICAL).hashCode()

        Specified by:
        hashCode in interface Principal
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        a hash code for this X500Principal