APIdia Launch Partner
Top Description Fields Constructors Methods
sun.security.x509

public Class X509CertImpl

extends X509Certificate
implements DerEncoder
Class Inheritance
All Implemented Interfaces
sun.security.util.DerEncoder
Annotations
@SuppressWarnings:serial
Imports
java.io.*, java.math.BigInteger, java.security.*, java.security.cert.*, .Certificate, java.util.*, java.util.concurrent.ConcurrentHashMap, javax.security.auth.x500.X500Principal, sun.security.jca.JCAUtil, sun.security.util.*, sun.security.provider.X509Factory

The X509CertImpl class represents an X.509 certificate. These certificates are widely used to support authentication and other functionality in Internet security systems. Common applications include Privacy Enhanced Mail (PEM), Transport Layer Security (SSL), code signing for trusted software distribution, and Secure Electronic Transactions (SET). There is a commercial infrastructure ready to manage large scale deployments of X.509 identity certificates.

These certificates are managed and vouched for by Certificate Authorities (CAs). CAs are services which create certificates by placing data in the X.509 standard format and then digitally signing that data. Such signatures are quite difficult to forge. CAs act as trusted third parties, making introductions between agents who have no direct knowledge of each other. CA certificates are either signed by themselves, or by some other CA such as a "root" CA.

Standards relating to X.509 Public Key Infrastructure for the Internet can be referenced in RFC 5280.

Authors
Dave Brownell, Amit Kapoor, Hemma Prafullchandra
See Also
X509CertInfo

Field Summary

Modifier and TypeField and Description
protected AlgorithmId
private Set<AccessDescription>
private List<String>
private final ConcurrentHashMap<String, String>
protected X509CertInfo
private Collection<List<?>>
public static final String
private static final int
private static final long
protected byte[]
private byte[]
private Collection<List<?>>
private boolean
verificationResult

If verifiedPublicKey is not null, result of the verification using verifiedPublicKey and verifiedProvider.

private String
verifiedProvider

If verifiedPublicKey is not null, name of the provider used to successfully verify the signature of this certificate, or the empty String if no provider was explicitly specified.

private PublicKey
verifiedPublicKey

PublicKey that has previously been used to verify the signature of this certificate.

Constructor Summary

AccessConstructor and Description
public
X509CertImpl(X509CertInfo info, AlgorithmId algId, byte[] signature, byte[] signedCert)

Constructor simply setting all (non-cache) fields.

public
X509CertImpl(byte[]
the encoded bytes, with no trailing padding.
certData
)

Unmarshals a certificate from its encoded form, parsing the encoded bytes.

public
X509CertImpl(DerValue
the der value containing the encoded cert.
derVal
)

Unmarshals a certificate from its encoded form, parsing a DER value.

public
X509CertImpl(InputStream
an input stream holding at least one certificate that may be either DER-encoded or RFC1421 hex-encoded version of the DER-encoded certificate.
in
)

Unmarshals an X.509 certificate from an input stream.

Method Summary

Modifier and TypeMethod and Description
public void
checkValidity()

Implements abstract java.security.cert.X509Certificate.checkValidity.

Checks that the certificate is currently valid, i.e. the current time is within the specified validity period.

public void
checkValidity(Date
the Date to check against to see if this certificate is valid at that date/time.
date
)

Implements abstract java.security.cert.X509Certificate.checkValidity.

Checks that the specified date is within the certificate's validity period, or basically if the certificate would be valid at the specified date/time.

private static Collection<List<?>>
cloneAltNames(Collection<List<?>> altNames)

Checks a Collection of altNames and clones any name entries of type byte [].

public void
encode(DerOutputStream
the output stream on which to write the DER encoding.
out
)

Implements sun.security.util.DerEncoder.encode.

DER encode this object onto an output stream.

public KeyIdentifier
public AuthorityInfoAccessExtension
public AuthorityKeyIdentifierExtension

Returns:

AuthorityKeyIdentifier object or null (if no such object in certificate)
getAuthorityKeyIdentifierExtension
()

Get AuthorityKeyIdentifier extension

public int

Returns:

the length of the constraint.
getBasicConstraints
()

Implements abstract java.security.cert.X509Certificate.getBasicConstraints.

Get the certificate constraints path length from the critical BasicConstraints extension, (oid = 2.5.29.19).

public BasicConstraintsExtension

Returns:

BasicConstraints object or null (if no such object in certificate)
getBasicConstraintsExtension
()

Get BasicConstraints extension

public CertificatePoliciesExtension

Returns:

CertificatePoliciesExtension or null (if no such object in certificate)
getCertificatePoliciesExtension
()

Get CertificatePoliciesExtension

public Set<String>

Returns:

a set of the extension oid strings in the certificate that are marked critical.
getCriticalExtensionOIDs
()

Implements java.security.cert.X509Extension.getCriticalExtensionOIDs.

Gets a Set of the extension(s) marked CRITICAL in the certificate.

public CRLDistributionPointsExtension

Returns:

CRLDistributionPoints object or null (if no such object in certificate)
getCRLDistributionPointsExtension
()

Get CRLDistributionPoints extension

public byte[]
getEncoded()

Implements abstract java.security.cert.Certificate.getEncoded.

Returns the encoded form of this certificate.

public byte[]
getEncodedInternal()

Returned the encoding as an uncloned byte array.

public static byte[]
getEncodedInternal(Certificate cert)

Returned the encoding of the given certificate for internal use.

public synchronized List<String>
getExtendedKeyUsage()

Overrides java.security.cert.X509Certificate.getExtendedKeyUsage.

This method is the overridden implementation of the getExtendedKeyUsage method in X509Certificate in the Sun provider.

public static List<String>
getExtendedKeyUsage(X509Certificate cert)

This static method is the default implementation of the getExtendedKeyUsage method in X509Certificate.

public ExtendedKeyUsageExtension

Returns:

ExtendedKeyUsage extension object or null (if no such object in certificate)
getExtendedKeyUsageExtension
()

Get ExtendedKeyUsage extension

public Extension

Returns:

Extension or null if certificate does not contain this extension
getExtension
(ObjectIdentifier
the Object Identifier value for the extension.
oid
)

Gets the extension identified by the given ObjectIdentifier

private Extension
getExtensionIfParseable(ObjectIdentifier oid)

Returns the extension identified by OID or null if it doesn't exist and is not unparseable.

public byte[]

Returns:

the DER-encoded extension value, or null if the extensions are not present or the value is not found
getExtensionValue
(String
the Object Identifier value for the extension.
oid
)

Implements java.security.cert.X509Extension.getExtensionValue.

Gets the DER encoded extension identified by the given oid String.

private String
getFingerprint(String algorithm, Debug debug)

public static String

Returns:

the fingerprint, or null if it cannot be calculated because of an exception
getFingerprint
(String
the MessageDigest algorithm
algorithm
,
X509Certificate
the X509Certificate
cert
,
Debug debug)

Gets the requested fingerprint of the certificate.

private static String
getFingerprintInternal(String algorithm, byte[] encodedCert, Debug debug)

public X509CertInfo
getInfo()

Return the requested attribute from the certificate.

public IssuerAlternativeNameExtension

Returns:

IssuerAlternativeName object or null (if no such object in certificate)
getIssuerAlternativeNameExtension
()

Get IssuerAlternativeName extension

public synchronized Collection<List<?>>
getIssuerAlternativeNames()

Overrides java.security.cert.X509Certificate.getIssuerAlternativeNames.

This method is the overridden implementation of the getIssuerAlternativeNames method in X509Certificate in the Sun provider.

public static Collection<List<?>>
getIssuerAlternativeNames(X509Certificate cert)

This static method is the default implementation of the getIssuerAlternativeNames method in X509Certificate.

public Principal

Returns:

the issuer name.
getIssuerDN
()

Implements abstract java.security.cert.X509Certificate.getIssuerDN.

Gets the issuer distinguished name from the certificate.

public boolean[]

Returns:

the Issuer Unique Identity.
getIssuerUniqueID
()

Implements abstract java.security.cert.X509Certificate.getIssuerUniqueID.

Gets the Issuer Unique Identity from the certificate.

public X500Principal
public static X500Principal
getIssuerX500Principal(X509Certificate cert)

Extract the issuer X500Principal from an X509Certificate.

public boolean[]

Returns:

the bit values of this extension as an array of booleans.
getKeyUsage
()

Implements abstract java.security.cert.X509Certificate.getKeyUsage.

Get a boolean array representing the bits of the KeyUsage extension, (oid = 2.5.29.15).

public NameConstraintsExtension

Returns:

NameConstraints object or null (if no such object in certificate)
getNameConstraintsExtension
()

Get NameConstraints extension

public Set<String>

Returns:

a set of the extension oid strings in the certificate that are NOT marked critical.
getNonCriticalExtensionOIDs
()

Implements java.security.cert.X509Extension.getNonCriticalExtensionOIDs.

Gets a Set of the extension(s) marked NON-CRITICAL in the certificate.

public Date

Returns:

the end date of the validity period.
getNotAfter
()

Implements abstract java.security.cert.X509Certificate.getNotAfter.

Gets the notAfter date from the validity period of the certificate.

public Date

Returns:

the start date of the validity period.
getNotBefore
()

Implements abstract java.security.cert.X509Certificate.getNotBefore.

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

public PolicyConstraintsExtension

Returns:

PolicyConstraints object or null (if no such object in certificate)
getPolicyConstraintsExtension
()

Get PolicyConstraints extension

public PolicyMappingsExtension

Returns:

PolicyMappingsExtension object or null (if no such object in certificate)
getPolicyMappingsExtension
()

Get PolicyMappingsExtension extension

public PrivateKeyUsageExtension

Returns:

PrivateKeyUsage object or null (if no such object in certificate)
getPrivateKeyUsageExtension
()

Get PrivateKeyUsage extension

public PublicKey

Returns:

the publickey.
getPublicKey
()

Implements abstract java.security.cert.Certificate.getPublicKey.

Gets the publickey from this certificate.

public BigInteger

Returns:

the serial number.
getSerialNumber
()

Implements abstract java.security.cert.X509Certificate.getSerialNumber.

Gets the serial number from the certificate.

public SerialNumber

Returns:

the serial number.
getSerialNumberObject
()

Gets the serial number from the certificate as a SerialNumber object.

public AlgorithmId
public String

Returns:

the signature algorithm name.
getSigAlgName
()

Implements abstract java.security.cert.X509Certificate.getSigAlgName.

Gets the signature algorithm name for the certificate signature algorithm.

public String

Returns:

the signature algorithm oid string.
getSigAlgOID
()

Implements abstract java.security.cert.X509Certificate.getSigAlgOID.

Gets the signature algorithm OID string from the certificate.

public byte[]

Returns:

the DER encoded signature algorithm parameters, or null if no parameters are present.
getSigAlgParams
()

Implements abstract java.security.cert.X509Certificate.getSigAlgParams.

Gets the DER encoded signature algorithm parameters from this certificate's signature algorithm.

public byte[]

Returns:

the signature.
getSignature
()

Implements abstract java.security.cert.X509Certificate.getSignature.

Gets the raw Signature bits from the certificate.

public SubjectAlternativeNameExtension

Returns:

SubjectAlternativeName object or null (if no such object in certificate)
getSubjectAlternativeNameExtension
()

Get SubjectAlternativeName extension

public synchronized Collection<List<?>>
getSubjectAlternativeNames()

Overrides java.security.cert.X509Certificate.getSubjectAlternativeNames.

This method is the overridden implementation of the getSubjectAlternativeNames method in X509Certificate in the Sun provider.

public static Collection<List<?>>
getSubjectAlternativeNames(X509Certificate cert)

This static method is the default implementation of the getSubjectAlternativeNames method in X509Certificate.

public Principal

Returns:

the subject name.
getSubjectDN
()

Implements abstract java.security.cert.X509Certificate.getSubjectDN.

Gets the subject distinguished name from the certificate.

public KeyIdentifier
getSubjectKeyId()

Returns the subject's key identifier, or null

public SubjectKeyIdentifierExtension

Returns:

SubjectKeyIdentifier object or null (if no such object in certificate)
getSubjectKeyIdentifierExtension
()

Get SubjectKeyIdentifier extension

public boolean[]

Returns:

the Subject Unique Identity.
getSubjectUniqueID
()

Implements abstract java.security.cert.X509Certificate.getSubjectUniqueID.

Gets the Subject Unique Identity from the certificate.

public X500Principal
public static X500Principal
getSubjectX500Principal(X509Certificate cert)

Extract the subject X500Principal from an X509Certificate.

public byte[]

Returns:

the DER encoded certificate information.
getTBSCertificate
()

Implements abstract java.security.cert.X509Certificate.getTBSCertificate.

Gets the DER encoded certificate information, the tbsCertificate from this certificate.

public Extension
public int

Returns:

the version number, i.e. 1, 2 or 3.
getVersion
()

Implements abstract java.security.cert.X509Certificate.getVersion.

Gets the version number from the certificate.

private static X500Principal
getX500Principal(X509Certificate cert, boolean getIssuer)

Extract the subject or issuer X500Principal from an X509Certificate.

public boolean
hasUnsupportedCriticalExtension()

Implements java.security.cert.X509Extension.hasUnsupportedCriticalExtension.

Return true if a critical extension is found that is not supported, otherwise return false.

public static boolean
isSelfIssued(X509Certificate cert)

Utility method to test if a certificate is self-issued.

public static boolean
isSelfSigned(X509Certificate cert, String sigProvider)

Utility method to test if a certificate is self-signed.

private static Collection<List<?>>

Returns:

an immutable Collection of alternative names
makeAltNames
(GeneralNames
the GeneralNames to be converted
names
)

Converts a GeneralNames structure into an immutable Collection of alternative names (subject or issuer) in the form required by getSubjectAlternativeNames or getIssuerAlternativeNames.

public static X509CertImpl

Returns:

the newly signed certificate
newSigned
(X509CertInfo
the X509CertInfo to sign
info
,
PrivateKey
the private key used for signing.
key
,
String
the name of the signature algorithm used.
algorithm
)

Creates a new X.509 certificate, which is signed using the given key (associating a signature algorithm and an X.500 name).

public static X509CertImpl

Returns:

the newly signed certificate
newSigned
(X509CertInfo
the X509CertInfo to sign
info
,
PrivateKey
the private key used for signing.
key
,
String
the name of the signature algorithm used.
algorithm
,
String
(optional) the name of the provider.
provider
)

Creates a new X.509 certificate, which is signed using the given key (associating a signature algorithm and an X.500 name).

public static X509CertImpl
newX509CertImpl(byte[] certData)

private void
private void
readObject(ObjectInputStream
the ObjectInputStream from which data is read
stream
)

Restores the state of this object from the stream.

private DerValue

Returns:

DerValue corresponding to decoded HEX-encoded bytes
readRFC1421Cert
(InputStream
InputStream to read
in
)

read input stream as HEX-encoded DER-encoded bytes

public static X509CertImpl
toImpl(X509Certificate cert)

Utility method to convert an arbitrary instance of X509Certificate to a X509CertImpl.

public String
toString()

Implements abstract java.security.cert.Certificate.toString.

Returns a printable representation of the certificate.

public void
verify(PublicKey
the public key used for verification.
key
)

Implements abstract java.security.cert.Certificate.verify.

Throws an exception if the certificate was not signed using the verification key provided.

public synchronized void
verify(PublicKey
the public key used for verification.
key
,
String
the name of the provider.
sigProvider
)

Implements abstract java.security.cert.Certificate.verify.

Throws an exception if the certificate was not signed using the verification key provided.

public synchronized void
verify(PublicKey
the public key used for verification.
key
,
Provider
the provider.
sigProvider
)

Overrides java.security.cert.X509Certificate.verify.

Throws an exception if the certificate was not signed using the verification key provided.