Skip to content

Most visited

Recently visited

navigation
Added in API level 1

X509Certificate

public abstract class X509Certificate
extends Certificate

java.lang.Object
   ↳ javax.security.cert.Certificate
     ↳ javax.security.cert.X509Certificate


Abstract base class for X.509 certificates.

This represents a standard way for accessing the attributes of X.509 v1 certificates.

Note: This package is provided only for compatibility reasons. It contains a simplified version of the java.security.cert package that was previously used by JSSE (Java SSL package). All applications that do not have to be compatible with older versions of JSSE (that is before Java SDK 1.5) should only use java.security.cert.

Summary

Public constructors

X509Certificate()

Creates a new X509Certificate.

Public methods

abstract void checkValidity()

Checks whether the certificate is currently valid.

abstract void checkValidity(Date date)

Checks whether the certificate is valid at the specified date.

final static X509Certificate getInstance(InputStream inStream)

Creates a new X509Certificate and initializes it from the specified input stream.

final static X509Certificate getInstance(byte[] certData)

Creates a new X509Certificate and initializes it from the specified byte array.

abstract Principal getIssuerDN()

Returns the issuer (issuer distinguished name) as an implementation specific Principal object.

abstract Date getNotAfter()

Returns the notAfter date of the validity period of the certificate.

abstract Date getNotBefore()

Returns the notBefore date from the validity period of the certificate.

abstract BigInteger getSerialNumber()

Returns the serialNumber of the certificate.

abstract String getSigAlgName()

Returns the name of the algorithm for the certificate signature.

abstract String getSigAlgOID()

Returns the OID of the signature algorithm from the certificate.

abstract byte[] getSigAlgParams()

Returns the parameters of the signature algorithm in DER-encoded format.

abstract Principal getSubjectDN()

Returns the subject (subject distinguished name) as an implementation specific Principal object.

abstract int getVersion()

Returns the certificates version (version number).

Inherited methods

From class javax.security.cert.Certificate
From class java.lang.Object

Public constructors

X509Certificate

Added in API level 1
X509Certificate ()

Creates a new X509Certificate.

Public methods

checkValidity

Added in API level 1
void checkValidity ()

Checks whether the certificate is currently valid.

The validity defined in ASN.1:

 validity             Validity

 Validity ::= SEQUENCE {
      notBefore       CertificateValidityDate,
      notAfter        CertificateValidityDate }

 CertificateValidityDate ::= CHOICE {
      utcTime         UTCTime,
      generalTime     GeneralizedTime }
 

Throws
CertificateExpiredException if the certificate has expired.
CertificateNotYetValidException if the certificate is not yet valid.

checkValidity

Added in API level 1
void checkValidity (Date date)

Checks whether the certificate is valid at the specified date.

Parameters
date Date: the date to check the validity against.
Throws
CertificateExpiredException if the certificate has expired.
CertificateNotYetValidException if the certificate is not yet valid.

See also:

getInstance

Added in API level 1
X509Certificate getInstance (InputStream inStream)

Creates a new X509Certificate and initializes it from the specified input stream.

Parameters
inStream InputStream: input stream containing data to initialize the certificate.
Returns
X509Certificate the certificate initialized from the specified input stream
Throws
CertificateException if the certificate cannot be created or initialized.

getInstance

Added in API level 1
X509Certificate getInstance (byte[] certData)

Creates a new X509Certificate and initializes it from the specified byte array.

Parameters
certData byte: byte array containing data to initialize the certificate.
Returns
X509Certificate the certificate initialized from the specified byte array
Throws
CertificateException if the certificate cannot be created or initialized.

getIssuerDN

Added in API level 1
Principal getIssuerDN ()

Returns the issuer (issuer distinguished name) as an implementation specific Principal object.

The ASN.1 definition of issuer:

  issuer      Name

  Name ::= CHOICE {
      RDNSequence }

    RDNSequence ::= SEQUENCE OF RelativeDistinguishedName

    RelativeDistinguishedName ::= SET OF AttributeTypeAndValue

    AttributeTypeAndValue ::= SEQUENCE {
      type     AttributeType,
      value    AttributeValue }

    AttributeType ::= OBJECT IDENTIFIER

    AttributeValue ::= ANY DEFINED BY AttributeType
 

Returns
Principal the issuer as an implementation specific Principal.

getNotAfter

Added in API level 1
Date getNotAfter ()

Returns the notAfter date of the validity period of the certificate.

Returns
Date the end of the validity period.

getNotBefore

Added in API level 1
Date getNotBefore ()

Returns the notBefore date from the validity period of the certificate.

Returns
Date the start of the validity period.

getSerialNumber

Added in API level 1
BigInteger getSerialNumber ()

Returns the serialNumber of the certificate.

The ASN.1 definition of serialNumber:

 CertificateSerialNumber  ::=  INTEGER
 

Returns
BigInteger the serial number.

getSigAlgName

Added in API level 1
String getSigAlgName ()

Returns the name of the algorithm for the certificate signature.

Returns
String the signature algorithm name.

getSigAlgOID

Added in API level 1
String getSigAlgOID ()

Returns the OID of the signature algorithm from the certificate.

Returns
String the OID of the signature algorithm.

getSigAlgParams

Added in API level 1
byte[] getSigAlgParams ()

Returns the parameters of the signature algorithm in DER-encoded format.

Returns
byte[] the parameters of the signature algorithm, or null if none are used.

getSubjectDN

Added in API level 1
Principal getSubjectDN ()

Returns the subject (subject distinguished name) as an implementation specific Principal object.

The ASN.1 definition of subject:

 subject      Name

  Name ::= CHOICE {
      RDNSequence }

    RDNSequence ::= SEQUENCE OF RelativeDistinguishedName

    RelativeDistinguishedName ::= SET OF AttributeTypeAndValue

    AttributeTypeAndValue ::= SEQUENCE {
      type     AttributeType,
      value    AttributeValue }

    AttributeType ::= OBJECT IDENTIFIER

    AttributeValue ::= ANY DEFINED BY AttributeType
 

Returns
Principal the subject (subject distinguished name).

getVersion

Added in API level 1
int getVersion ()

Returns the certificates version (version number).

The version defined is ASN.1:

 Version ::=  INTEGER  {  v1(0), v2(1), v3(2)  }
 

Returns
int the version number.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.