public class X509CertImpl extends java.security.cert.X509Certificate implements DerEncoder
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.
RFC 1422 is very informative, though it does not describe much of the recent work being done with X.509 certificates. That includes a 1996 version (X.509v3) and a variety of enhancements being made to facilitate an explosion of personal certificates used as "Internet Drivers' Licences", or with SET for credit card transactions.
More recent work includes the IETF PKIX Working Group efforts, especially RFC2459.
X509CertInfo,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ALG_ID |
protected AlgorithmId |
algId |
protected X509CertInfo |
info |
static java.lang.String |
INFO |
static java.lang.String |
ISSUER_DN |
static java.lang.String |
NAME
Public attribute names.
|
static java.lang.String |
PUBLIC_KEY |
static java.lang.String |
SERIAL_ID |
static java.lang.String |
SIG |
static java.lang.String |
SIG_ALG |
protected byte[] |
signature |
static java.lang.String |
SIGNATURE |
static java.lang.String |
SIGNED_CERT |
static java.lang.String |
SUBJECT_DN
The following are defined for ease-of-use.
|
static java.lang.String |
VERSION |
| Constructor and Description |
|---|
X509CertImpl()
Default constructor.
|
X509CertImpl(byte[] certData)
Unmarshals a certificate from its encoded form, parsing the
encoded bytes.
|
X509CertImpl(DerValue derVal)
Unmarshal a certificate from its encoded form, parsing a DER value.
|
X509CertImpl(java.io.InputStream in)
unmarshals an X.509 certificate from an input stream.
|
X509CertImpl(X509CertInfo certInfo)
Construct an initialized X509 Certificate.
|
| Modifier and Type | Method and Description |
|---|---|
void |
checkValidity()
Checks that the certificate is currently valid, i.e.
|
void |
checkValidity(java.util.Date date)
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.
|
void |
delete(java.lang.String name)
Delete the requested attribute from the certificate.
|
void |
derEncode(java.io.OutputStream out)
DER encode this object onto an output stream.
|
void |
encode(java.io.OutputStream out)
Appends the certificate to an output stream.
|
java.lang.Object |
get(java.lang.String name)
Return the requested attribute from the certificate.
|
AuthorityInfoAccessExtension |
getAuthorityInfoAccessExtension() |
AuthorityKeyIdentifierExtension |
getAuthorityKeyIdentifierExtension()
Get AuthorityKeyIdentifier extension
|
int |
getBasicConstraints()
Get the certificate constraints path length from the
the critical BasicConstraints extension, (oid = 2.5.29.19).
|
BasicConstraintsExtension |
getBasicConstraintsExtension()
Get BasicConstraints extension
|
CertificatePoliciesExtension |
getCertificatePoliciesExtension()
Get CertificatePoliciesExtension
|
java.util.Set<java.lang.String> |
getCriticalExtensionOIDs()
Gets a Set of the extension(s) marked CRITICAL in the
certificate.
|
CRLDistributionPointsExtension |
getCRLDistributionPointsExtension()
Get CRLDistributionPoints extension
|
java.util.Enumeration<java.lang.String> |
getElements()
Return an enumeration of names of attributes existing within this
attribute.
|
byte[] |
getEncoded()
Returns the encoded form of this certificate.
|
byte[] |
getEncodedInternal()
Returned the encoding as an uncloned byte array.
|
static byte[] |
getEncodedInternal(java.security.cert.Certificate cert)
Returned the encoding of the given certificate for internal use.
|
java.util.List<java.lang.String> |
getExtendedKeyUsage()
This method are the overridden implementation of
getExtendedKeyUsage method in X509Certificate in the Sun
provider.
|
static java.util.List<java.lang.String> |
getExtendedKeyUsage(java.security.cert.X509Certificate cert)
This static method is the default implementation of the
getExtendedKeyUsage method in X509Certificate.
|
ExtendedKeyUsageExtension |
getExtendedKeyUsageExtension()
Get ExtendedKeyUsage extension
|
Extension |
getExtension(ObjectIdentifier oid)
Gets the extension identified by the given ObjectIdentifier
|
byte[] |
getExtensionValue(java.lang.String oid)
Gets the DER encoded extension identified by the given
oid String.
|
IssuerAlternativeNameExtension |
getIssuerAlternativeNameExtension()
Get IssuerAlternativeName extension
|
java.util.Collection<java.util.List<?>> |
getIssuerAlternativeNames()
This method are the overridden implementation of
getIssuerAlternativeNames method in X509Certificate in the Sun
provider.
|
static java.util.Collection<java.util.List<?>> |
getIssuerAlternativeNames(java.security.cert.X509Certificate cert)
This static method is the default implementation of the
getIssuerAlternaitveNames method in X509Certificate.
|
java.security.Principal |
getIssuerDN()
Gets the issuer distinguished name from the certificate.
|
boolean[] |
getIssuerUniqueID()
Gets the Issuer Unique Identity from the certificate.
|
javax.security.auth.x500.X500Principal |
getIssuerX500Principal()
Get issuer name as X500Principal.
|
static javax.security.auth.x500.X500Principal |
getIssuerX500Principal(java.security.cert.X509Certificate cert)
Extract the issuer X500Principal from an X509Certificate.
|
boolean[] |
getKeyUsage()
Get a boolean array representing the bits of the KeyUsage extension,
(oid = 2.5.29.15).
|
java.lang.String |
getName()
Return the name of this attribute.
|
NameConstraintsExtension |
getNameConstraintsExtension()
Get NameConstraints extension
|
java.util.Set<java.lang.String> |
getNonCriticalExtensionOIDs()
Gets a Set of the extension(s) marked NON-CRITICAL in the
certificate.
|
java.util.Date |
getNotAfter()
Gets the notAfter date from the validity period of the certificate.
|
java.util.Date |
getNotBefore()
Gets the notBefore date from the validity period of the certificate.
|
PolicyConstraintsExtension |
getPolicyConstraintsExtension()
Get PolicyConstraints extension
|
PolicyMappingsExtension |
getPolicyMappingsExtension()
Get PolicyMappingsExtension extension
|
PrivateKeyUsageExtension |
getPrivateKeyUsageExtension()
Get PrivateKeyUsage extension
|
java.security.PublicKey |
getPublicKey()
Gets the publickey from this certificate.
|
java.math.BigInteger |
getSerialNumber()
Gets the serial number from the certificate.
|
SerialNumber |
getSerialNumberObject()
Gets the serial number from the certificate as
a SerialNumber object.
|
java.lang.String |
getSigAlgName()
Gets the signature algorithm name for the certificate
signature algorithm.
|
java.lang.String |
getSigAlgOID()
Gets the signature algorithm OID string from the certificate.
|
byte[] |
getSigAlgParams()
Gets the DER encoded signature algorithm parameters from this
certificate's signature algorithm.
|
byte[] |
getSignature()
Gets the raw Signature bits from the certificate.
|
SubjectAlternativeNameExtension |
getSubjectAlternativeNameExtension()
Get SubjectAlternativeName extension
|
java.util.Collection<java.util.List<?>> |
getSubjectAlternativeNames()
This method are the overridden implementation of
getSubjectAlternativeNames method in X509Certificate in the Sun
provider.
|
static java.util.Collection<java.util.List<?>> |
getSubjectAlternativeNames(java.security.cert.X509Certificate cert)
This static method is the default implementation of the
getSubjectAlternaitveNames method in X509Certificate.
|
java.security.Principal |
getSubjectDN()
Gets the subject distinguished name from the certificate.
|
SubjectKeyIdentifierExtension |
getSubjectKeyIdentifierExtension()
Get SubjectKeyIdentifier extension
|
boolean[] |
getSubjectUniqueID()
Gets the Subject Unique Identity from the certificate.
|
javax.security.auth.x500.X500Principal |
getSubjectX500Principal()
Get subject name as X500Principal.
|
static javax.security.auth.x500.X500Principal |
getSubjectX500Principal(java.security.cert.X509Certificate cert)
Extract the subject X500Principal from an X509Certificate.
|
byte[] |
getTBSCertificate()
Gets the DER encoded certificate informations, the
tbsCertificate from this certificate. |
Extension |
getUnparseableExtension(ObjectIdentifier oid) |
int |
getVersion()
Gets the version number from the certificate.
|
boolean |
hasUnsupportedCriticalExtension()
Return true if a critical extension is found that is
not supported, otherwise return false.
|
static boolean |
isSelfIssued(java.security.cert.X509Certificate cert)
Utility method to test if a certificate is self-issued.
|
static boolean |
isSelfSigned(java.security.cert.X509Certificate cert,
java.lang.String sigProvider)
Utility method to test if a certificate is self-signed.
|
void |
set(java.lang.String name,
java.lang.Object obj)
Set the requested attribute in the certificate.
|
void |
sign(java.security.PrivateKey key,
java.lang.String algorithm)
Creates an X.509 certificate, and signs it using the given key
(associating a signature algorithm and an X.500 name).
|
void |
sign(java.security.PrivateKey key,
java.lang.String algorithm,
java.lang.String provider)
Creates an X.509 certificate, and signs it using the given key
(associating a signature algorithm and an X.500 name).
|
static X509CertImpl |
toImpl(java.security.cert.X509Certificate cert)
Utility method to convert an arbitrary instance of X509Certificate
to a X509CertImpl.
|
java.lang.String |
toString()
Returns a printable representation of the certificate.
|
void |
verify(java.security.PublicKey key)
Throws an exception if the certificate was not signed using the
verification key provided.
|
void |
verify(java.security.PublicKey key,
java.lang.String sigProvider)
Throws an exception if the certificate was not signed using the
verification key provided.
|
public static final java.lang.String NAME
public static final java.lang.String INFO
public static final java.lang.String ALG_ID
public static final java.lang.String SIGNATURE
public static final java.lang.String SIGNED_CERT
public static final java.lang.String SUBJECT_DN
public static final java.lang.String ISSUER_DN
public static final java.lang.String SERIAL_ID
public static final java.lang.String PUBLIC_KEY
public static final java.lang.String VERSION
public static final java.lang.String SIG_ALG
public static final java.lang.String SIG
protected X509CertInfo info
protected AlgorithmId algId
protected byte[] signature
public X509CertImpl()
public X509CertImpl(byte[] certData)
throws java.security.cert.CertificateException
certData - the encoded bytes, with no trailing padding.java.security.cert.CertificateException - on parsing and initialization errors.public X509CertImpl(java.io.InputStream in)
throws java.security.cert.CertificateException
in - an input stream holding at least one certificate that may
be either DER-encoded or RFC1421 hex-encoded version of the
DER-encoded certificate.java.security.cert.CertificateException - on parsing and initialization errors.public X509CertImpl(X509CertInfo certInfo)
public X509CertImpl(DerValue derVal) throws java.security.cert.CertificateException
derVal - the der value containing the encoded cert.java.security.cert.CertificateException - on parsing and initialization errors.public void encode(java.io.OutputStream out)
throws java.security.cert.CertificateEncodingException
out - an input stream to which the certificate is appended.java.security.cert.CertificateEncodingException - on encoding errors.public void derEncode(java.io.OutputStream out)
throws java.io.IOException
DerEncoder interface.derEncode in interface DerEncoderout - the output stream on which to write the DER encoding.java.io.IOException - on encoding error.public byte[] getEncoded()
throws java.security.cert.CertificateEncodingException
getEncoded in class java.security.cert.Certificatejava.security.cert.CertificateEncodingException - if an encoding error occurs.public byte[] getEncodedInternal()
throws java.security.cert.CertificateEncodingException
java.security.cert.CertificateEncodingExceptionpublic void verify(java.security.PublicKey key)
throws java.security.cert.CertificateException,
java.security.NoSuchAlgorithmException,
java.security.InvalidKeyException,
java.security.NoSuchProviderException,
java.security.SignatureException
verify in class java.security.cert.Certificatekey - the public key used for verification.java.security.InvalidKeyException - on incorrect key.java.security.NoSuchAlgorithmException - on unsupported signature
algorithms.java.security.NoSuchProviderException - if there's no default provider.java.security.SignatureException - on signature errors.java.security.cert.CertificateException - on encoding errors.public void verify(java.security.PublicKey key,
java.lang.String sigProvider)
throws java.security.cert.CertificateException,
java.security.NoSuchAlgorithmException,
java.security.InvalidKeyException,
java.security.NoSuchProviderException,
java.security.SignatureException
verify in class java.security.cert.Certificatekey - the public key used for verification.sigProvider - the name of the provider.java.security.NoSuchAlgorithmException - on unsupported signature
algorithms.java.security.InvalidKeyException - on incorrect key.java.security.NoSuchProviderException - on incorrect provider.java.security.SignatureException - on signature errors.java.security.cert.CertificateException - on encoding errors.public void sign(java.security.PrivateKey key,
java.lang.String algorithm)
throws java.security.cert.CertificateException,
java.security.NoSuchAlgorithmException,
java.security.InvalidKeyException,
java.security.NoSuchProviderException,
java.security.SignatureException
key - the private key used for signing.algorithm - the name of the signature algorithm used.java.security.InvalidKeyException - on incorrect key.java.security.NoSuchAlgorithmException - on unsupported signature
algorithms.java.security.NoSuchProviderException - if there's no default provider.java.security.SignatureException - on signature errors.java.security.cert.CertificateException - on encoding errors.public void sign(java.security.PrivateKey key,
java.lang.String algorithm,
java.lang.String provider)
throws java.security.cert.CertificateException,
java.security.NoSuchAlgorithmException,
java.security.InvalidKeyException,
java.security.NoSuchProviderException,
java.security.SignatureException
key - the private key used for signing.algorithm - the name of the signature algorithm used.provider - the name of the provider.java.security.NoSuchAlgorithmException - on unsupported signature
algorithms.java.security.InvalidKeyException - on incorrect key.java.security.NoSuchProviderException - on incorrect provider.java.security.SignatureException - on signature errors.java.security.cert.CertificateException - on encoding errors.public void checkValidity()
throws java.security.cert.CertificateExpiredException,
java.security.cert.CertificateNotYetValidException
checkValidity in class java.security.cert.X509Certificatejava.security.cert.CertificateExpiredException - if the certificate has expired.java.security.cert.CertificateNotYetValidException - if the certificate is not
yet valid.public void checkValidity(java.util.Date date)
throws java.security.cert.CertificateExpiredException,
java.security.cert.CertificateNotYetValidException
checkValidity in class java.security.cert.X509Certificatedate - the Date to check against to see if this certificate
is valid at that date/time.java.security.cert.CertificateExpiredException - if the certificate has expired
with respect to the date supplied.java.security.cert.CertificateNotYetValidException - if the certificate is not
yet valid with respect to the date supplied.public java.lang.Object get(java.lang.String name)
throws java.security.cert.CertificateParsingException
name - the name of the attribute.java.security.cert.CertificateParsingException - on invalid attribute identifier.public void set(java.lang.String name,
java.lang.Object obj)
throws java.security.cert.CertificateException,
java.io.IOException
name - the name of the attribute.obj - the value of the attribute.java.security.cert.CertificateException - on invalid attribute identifier.java.io.IOException - on encoding error of attribute.public void delete(java.lang.String name)
throws java.security.cert.CertificateException,
java.io.IOException
name - the name of the attribute.java.security.cert.CertificateException - on invalid attribute identifier.java.io.IOException - on other errors.public java.util.Enumeration<java.lang.String> getElements()
public java.lang.String getName()
public java.lang.String toString()
toString in class java.security.cert.Certificatepublic java.security.PublicKey getPublicKey()
getPublicKey in class java.security.cert.Certificatepublic int getVersion()
getVersion in class java.security.cert.X509Certificatepublic java.math.BigInteger getSerialNumber()
getSerialNumber in class java.security.cert.X509Certificatepublic SerialNumber getSerialNumberObject()
public java.security.Principal getSubjectDN()
getSubjectDN in class java.security.cert.X509Certificatepublic javax.security.auth.x500.X500Principal getSubjectX500Principal()
getSubjectX500Principal in class java.security.cert.X509Certificatepublic java.security.Principal getIssuerDN()
getIssuerDN in class java.security.cert.X509Certificatepublic javax.security.auth.x500.X500Principal getIssuerX500Principal()
getIssuerX500Principal in class java.security.cert.X509Certificatepublic java.util.Date getNotBefore()
getNotBefore in class java.security.cert.X509Certificatepublic java.util.Date getNotAfter()
getNotAfter in class java.security.cert.X509Certificatepublic byte[] getTBSCertificate()
throws java.security.cert.CertificateEncodingException
tbsCertificate from this certificate.
This can be used to verify the signature independently.getTBSCertificate in class java.security.cert.X509Certificatejava.security.cert.CertificateEncodingException - if an encoding error occurs.public byte[] getSignature()
getSignature in class java.security.cert.X509Certificatepublic java.lang.String getSigAlgName()
getSigAlgName in class java.security.cert.X509Certificatepublic java.lang.String getSigAlgOID()
getSigAlgOID in class java.security.cert.X509Certificatepublic byte[] getSigAlgParams()
getSigAlgParams in class java.security.cert.X509Certificatepublic boolean[] getIssuerUniqueID()
getIssuerUniqueID in class java.security.cert.X509Certificatepublic boolean[] getSubjectUniqueID()
getSubjectUniqueID in class java.security.cert.X509Certificatepublic AuthorityKeyIdentifierExtension getAuthorityKeyIdentifierExtension()
public BasicConstraintsExtension getBasicConstraintsExtension()
public CertificatePoliciesExtension getCertificatePoliciesExtension()
public ExtendedKeyUsageExtension getExtendedKeyUsageExtension()
public IssuerAlternativeNameExtension getIssuerAlternativeNameExtension()
public NameConstraintsExtension getNameConstraintsExtension()
public PolicyConstraintsExtension getPolicyConstraintsExtension()
public PolicyMappingsExtension getPolicyMappingsExtension()
public PrivateKeyUsageExtension getPrivateKeyUsageExtension()
public SubjectAlternativeNameExtension getSubjectAlternativeNameExtension()
public SubjectKeyIdentifierExtension getSubjectKeyIdentifierExtension()
public CRLDistributionPointsExtension getCRLDistributionPointsExtension()
public boolean hasUnsupportedCriticalExtension()
hasUnsupportedCriticalExtension in interface java.security.cert.X509Extensionpublic java.util.Set<java.lang.String> getCriticalExtensionOIDs()
getCriticalExtensionOIDs in interface java.security.cert.X509Extensionpublic java.util.Set<java.lang.String> getNonCriticalExtensionOIDs()
getNonCriticalExtensionOIDs in interface java.security.cert.X509Extensionpublic Extension getExtension(ObjectIdentifier oid)
oid - the Object Identifier value for the extension.public Extension getUnparseableExtension(ObjectIdentifier oid)
public byte[] getExtensionValue(java.lang.String oid)
getExtensionValue in interface java.security.cert.X509Extensionoid - the Object Identifier value for the extension.public boolean[] getKeyUsage()
getKeyUsage in class java.security.cert.X509Certificatepublic java.util.List<java.lang.String> getExtendedKeyUsage()
throws java.security.cert.CertificateParsingException
getExtendedKeyUsage in class java.security.cert.X509Certificatejava.security.cert.CertificateParsingExceptionpublic static java.util.List<java.lang.String> getExtendedKeyUsage(java.security.cert.X509Certificate cert)
throws java.security.cert.CertificateParsingException
java.security.cert.CertificateParsingExceptionpublic int getBasicConstraints()
getBasicConstraints in class java.security.cert.X509Certificatepublic java.util.Collection<java.util.List<?>> getSubjectAlternativeNames()
throws java.security.cert.CertificateParsingException
getSubjectAlternativeNames in class java.security.cert.X509Certificatejava.security.cert.CertificateParsingExceptionpublic static java.util.Collection<java.util.List<?>> getSubjectAlternativeNames(java.security.cert.X509Certificate cert)
throws java.security.cert.CertificateParsingException
java.security.cert.CertificateParsingExceptionpublic java.util.Collection<java.util.List<?>> getIssuerAlternativeNames()
throws java.security.cert.CertificateParsingException
getIssuerAlternativeNames in class java.security.cert.X509Certificatejava.security.cert.CertificateParsingExceptionpublic static java.util.Collection<java.util.List<?>> getIssuerAlternativeNames(java.security.cert.X509Certificate cert)
throws java.security.cert.CertificateParsingException
java.security.cert.CertificateParsingExceptionpublic AuthorityInfoAccessExtension getAuthorityInfoAccessExtension()
public static javax.security.auth.x500.X500Principal getSubjectX500Principal(java.security.cert.X509Certificate cert)
public static javax.security.auth.x500.X500Principal getIssuerX500Principal(java.security.cert.X509Certificate cert)
public static byte[] getEncodedInternal(java.security.cert.Certificate cert)
throws java.security.cert.CertificateEncodingException
java.security.cert.CertificateEncodingExceptionpublic static X509CertImpl toImpl(java.security.cert.X509Certificate cert) throws java.security.cert.CertificateException
java.security.cert.CertificateExceptionpublic static boolean isSelfIssued(java.security.cert.X509Certificate cert)
public static boolean isSelfSigned(java.security.cert.X509Certificate cert,
java.lang.String sigProvider)
Copyright © 2020. All Rights Reserved.