public class X509CertImpl extends java.security.cert.X509Certificate implements com.tencent.kona.sun.security.util.DerEncoder, SMCertificate
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.
X509CertInfo,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
protected com.tencent.kona.sun.security.x509.AlgorithmId |
algId |
protected X509CertInfo |
info |
static java.lang.String |
NAME |
protected byte[] |
signature |
| Constructor and Description |
|---|
X509CertImpl(byte[] certData)
Unmarshals a certificate from its encoded form, parsing the
encoded bytes.
|
X509CertImpl(com.tencent.kona.sun.security.util.DerValue derVal)
Unmarshals 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 info,
com.tencent.kona.sun.security.x509.AlgorithmId algId,
byte[] signature,
byte[] signedCert)
Constructor simply setting all (non-cache) fields.
|
| 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 |
encode(com.tencent.kona.sun.security.util.DerOutputStream out)
DER encode this object onto an output stream.
|
KeyIdentifier |
getAuthKeyId() |
AuthorityInfoAccessExtension |
getAuthorityInfoAccessExtension() |
AuthorityKeyIdentifierExtension |
getAuthorityKeyIdentifierExtension()
Get AuthorityKeyIdentifier extension
|
int |
getBasicConstraints()
Get the certificate constraints path length from
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
|
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 is the overridden implementation of the
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(com.tencent.kona.sun.security.util.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.
|
static java.lang.String |
getFingerprint(java.lang.String algorithm,
java.security.cert.X509Certificate cert,
com.tencent.kona.sun.security.util.Debug debug)
Gets the requested fingerprint of the certificate.
|
byte[] |
getId() |
X509CertInfo |
getInfo()
Return the requested attribute from the certificate.
|
IssuerAlternativeNameExtension |
getIssuerAlternativeNameExtension()
Get IssuerAlternativeName extension
|
java.util.Collection<java.util.List<?>> |
getIssuerAlternativeNames()
This method is the overridden implementation of the
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
getIssuerAlternativeNames 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).
|
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.
|
com.tencent.kona.sun.security.x509.AlgorithmId |
getSigAlg() |
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 is the overridden implementation of the
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
getSubjectAlternativeNames method in X509Certificate.
|
java.security.Principal |
getSubjectDN()
Gets the subject distinguished name from the certificate.
|
KeyIdentifier |
getSubjectKeyId()
Returns the subject's key identifier, or null
|
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(com.tencent.kona.sun.security.util.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.
|
static X509CertImpl |
newSigned(X509CertInfo info,
java.security.PrivateKey key,
java.lang.String algorithm)
Creates a new X.509 certificate, which is signed using the given key
(associating a signature algorithm and an X.500 name).
|
static X509CertImpl |
newSigned(X509CertInfo info,
java.security.PrivateKey key,
java.lang.String algorithm,
java.lang.String provider)
Creates a new X.509 certificate, which is signed using the given key
(associating a signature algorithm and an X.500 name).
|
void |
setId(byte[] id) |
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.security.Provider sigProvider)
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
protected X509CertInfo info
protected com.tencent.kona.sun.security.x509.AlgorithmId algId
protected byte[] signature
public X509CertImpl(X509CertInfo info, com.tencent.kona.sun.security.x509.AlgorithmId algId, byte[] signature, byte[] signedCert)
newSigned(com.tencent.kona.sun.security.x509.X509CertInfo, java.security.PrivateKey, java.lang.String).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(com.tencent.kona.sun.security.util.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 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 byte[] getId()
getId in interface SMCertificatepublic void setId(byte[] id)
setId in interface SMCertificatepublic void encode(com.tencent.kona.sun.security.util.DerOutputStream out)
DerEncoder interface.encode in interface com.tencent.kona.sun.security.util.DerEncoderout - the output stream on which to write the DER encoding.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 verify(java.security.PublicKey key,
java.security.Provider sigProvider)
throws java.security.cert.CertificateException,
java.security.NoSuchAlgorithmException,
java.security.InvalidKeyException,
java.security.SignatureException
verify in class java.security.cert.X509Certificatekey - the public key used for verification.sigProvider - the provider.java.security.NoSuchAlgorithmException - on unsupported signature
algorithms.java.security.InvalidKeyException - on incorrect key.java.security.SignatureException - on signature errors.java.security.cert.CertificateException - on encoding errors.public static X509CertImpl newSigned(X509CertInfo info, 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
info - the X509CertInfo to signkey - 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 static X509CertImpl newSigned(X509CertInfo info, 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
info - the X509CertInfo to signkey - the private key used for signing.algorithm - the name of the signature algorithm used.provider - (optional) 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 X509CertInfo getInfo()
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 com.tencent.kona.sun.security.x509.AlgorithmId getSigAlg()
public 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 KeyIdentifier getAuthKeyId()
public KeyIdentifier getSubjectKeyId()
public 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(com.tencent.kona.sun.security.util.ObjectIdentifier oid)
oid - the Object Identifier value for the extension.public Extension getUnparseableExtension(com.tencent.kona.sun.security.util.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)
public static java.lang.String getFingerprint(java.lang.String algorithm,
java.security.cert.X509Certificate cert,
com.tencent.kona.sun.security.util.Debug debug)
algorithm - the MessageDigest algorithmcert - the X509Certificate