Class X509CertInfo

  • All Implemented Interfaces:
    java.io.Serializable, CertAttrSet
    Direct Known Subclasses:
    CertInfo

    public class X509CertInfo
    extends java.lang.Object
    implements CertAttrSet, java.io.Serializable
    The X509CertInfo class represents X.509 certificate information.

    X.509 certificates have several base data elements, including:

    • The Subject Name, an X.500 Distinguished Name for the entity (subject) for which the certificate was issued.
    • The Subject Public Key, the public key of the subject. This is one of the most important parts of the certificate.
    • The Validity Period, a time period (e.g. six months) within which the certificate is valid (unless revoked).
    • The Issuer Name, an X.500 Distinguished Name for the Certificate Authority (CA) which issued the certificate.
    • A Serial Number assigned by the CA, for use in certificate revocation and other applications.
    Version:
    1.16
    Author:
    Amit Kapoor, Hemma Prafullchandra
    See Also:
    CertAttrSet, Serializable, X509CertImpl, Serialized Form
    • Constructor Detail

      • X509CertInfo

        public X509CertInfo()
        Construct an uninitialized X509CertInfo on which decode must later be called (or which may be deserialized).
      • X509CertInfo

        public X509CertInfo​(byte[] cert)
                     throws java.security.cert.CertificateParsingException
        Unmarshals a certificate from its encoded form, parsing the encoded bytes. This form of constructor is used by agents which need to examine and use certificate contents. That is, this is one of the more commonly used constructors. Note that the buffer must include only a certificate, and no "garbage" may be left at the end. If you need to ignore data at the end of a certificate, use another constructor.
        Parameters:
        cert - the encoded bytes, with no trailing data.
        Throws:
        java.security.cert.CertificateParsingException - on parsing errors.
      • X509CertInfo

        public X509CertInfo​(DerValue derVal)
                     throws java.security.cert.CertificateParsingException
        Unmarshal a certificate from its encoded form, parsing a DER value. This form of constructor is used by agents which need to examine and use certificate contents.
        Parameters:
        derVal - the der value containing the encoded cert.
        Throws:
        java.security.cert.CertificateParsingException - on parsing errors.
    • Method Detail

      • decode

        public void decode​(java.io.InputStream in)
                    throws java.security.cert.CertificateParsingException,
                           java.io.IOException
        Decode an X.509 certificate from an input stream.
        Specified by:
        decode in interface CertAttrSet
        Parameters:
        in - an input stream holding at least one certificate
        Throws:
        java.security.cert.CertificateParsingException - on decoding errors.
        java.io.IOException - on other errors.
      • encode

        public void encode​(java.io.OutputStream out)
                    throws java.security.cert.CertificateException,
                           java.io.IOException
        Appends the certificate to an output stream.
        Specified by:
        encode in interface CertAttrSet
        Parameters:
        out - an output stream to which the certificate is appended.
        Throws:
        java.security.cert.CertificateException - on encoding errors.
        java.io.IOException - on other errors.
      • encode

        public void encode​(java.io.OutputStream out,
                           boolean ignoreCache)
                    throws java.io.IOException,
                           java.security.cert.CertificateException
        Appends the certificate to an output stream.
        Parameters:
        out - An output stream to which the certificate is appended.
        ignoreCache - Whether to ignore the internal cache when encoding. (the cache can easily become out of date).
        Throws:
        java.io.IOException
        java.security.cert.CertificateException
      • getAttributeNames

        public java.util.Enumeration<java.lang.String> getAttributeNames()
        Return an enumeration of names of attributes existing within this attribute.
        Specified by:
        getAttributeNames in interface CertAttrSet
        Returns:
        an enumeration of the attribute names.
      • getName

        public java.lang.String getName()
        Return the name of this attribute.
        Specified by:
        getName in interface CertAttrSet
        Returns:
        the name of this CertAttrSet.
      • getEncodedInfo

        public byte[] getEncodedInfo()
                              throws java.security.cert.CertificateEncodingException
        Returns the encoded certificate info.
        Throws:
        java.security.cert.CertificateEncodingException - on encoding information errors.
      • getEncodedInfo

        public byte[] getEncodedInfo​(boolean ignoreCache)
                              throws java.security.cert.CertificateEncodingException
        Throws:
        java.security.cert.CertificateEncodingException
      • equals

        public boolean equals​(java.lang.Object other)
        Compares two X509CertInfo objects. This is false if the certificates are not both X.509 certs, otherwise it compares them as binary data.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        other - the object being compared with this one
        Returns:
        true iff the certificates are equivalent
      • equals

        public boolean equals​(X509CertInfo other)
        Compares two certificates, returning false if any data differs between the two.
        Parameters:
        other - the object being compared with this one
        Returns:
        true iff the certificates are equivalent
      • hashCode

        public int hashCode()
        Calculates a hash code value for the object. Objects which are equal will also have the same hashcode.
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Returns a printable representation of the certificate.
        Specified by:
        toString in interface CertAttrSet
        Overrides:
        toString in class java.lang.Object
        Returns:
        value of this certificate attribute in printable form.
      • set

        public void set​(java.lang.String name,
                        java.lang.Object val)
                 throws java.security.cert.CertificateException,
                        java.io.IOException
        Set the certificate attribute.
        Specified by:
        set in interface CertAttrSet
        Parameters:
        name - the name of the Certificate attribute.
        val - the value of the Certificate attribute.
        Throws:
        java.security.cert.CertificateException - on invalid attributes.
        java.io.IOException - on other errors.
      • delete

        public void delete​(java.lang.String name)
                    throws java.security.cert.CertificateException,
                           java.io.IOException
        Delete the certificate attribute.
        Specified by:
        delete in interface CertAttrSet
        Parameters:
        name - the name of the Certificate attribute.
        Throws:
        java.security.cert.CertificateException - on invalid attributes.
        java.io.IOException - on other errors.
      • get

        public java.lang.Object get​(java.lang.String name)
                             throws java.security.cert.CertificateException,
                                    java.io.IOException
        Get the certificate attribute.
        Specified by:
        get in interface CertAttrSet
        Parameters:
        name - the name of the Certificate attribute.
        Throws:
        java.security.cert.CertificateException - on invalid attributes.
        java.io.IOException - on other errors.