public class X509CertificateObject extends X509Certificate implements PKCS12BagAttributeCarrier
Certificate.CertificateRep| Constructor and Description |
|---|
X509CertificateObject(Certificate c) |
| Modifier and Type | Method and Description |
|---|---|
void |
checkValidity()
Checks whether the certificate is currently valid.
|
void |
checkValidity(Date date)
Checks whether the certificate is valid at the specified date.
|
boolean |
equals(Object o)
Compares the argument to the certificate, and returns
true if they
represent the same object using a class specific comparison. |
ASN1Encodable |
getBagAttribute(ASN1ObjectIdentifier oid) |
Enumeration |
getBagAttributeKeys() |
int |
getBasicConstraints()
Returns the path length of the certificate constraints from the
BasicContraints extension. |
Set |
getCriticalExtensionOIDs()
Returns the set of OIDs of the extension(s) marked as CRITICAL, that this
implementation manages.
|
byte[] |
getEncoded()
Returns the encoded representation for this certificate.
|
List |
getExtendedKeyUsage()
Returns a read-only list of OID strings representing the
ExtKeyUsageSyntax field of the extended key usage extension. |
byte[] |
getExtensionValue(String oid)
Returns the extension value as DER-encoded OCTET string for the specified
OID.
|
Collection |
getIssuerAlternativeNames()
Returns a read-only list of the issuer alternative names from the
IssuerAltName extension. |
Principal |
getIssuerDN()
Returns the
issuer (issuer distinguished name) as an
implementation specific Principal object. |
boolean[] |
getIssuerUniqueID()
Returns the
issuerUniqueID from the certificate. |
X500Principal |
getIssuerX500Principal()
Returns the
issuer (issuer distinguished name) as an X500Principal. |
boolean[] |
getKeyUsage()
Returns the
KeyUsage extension as a boolean array. |
Set |
getNonCriticalExtensionOIDs()
Returns the set of OIDs of the extension(s) marked as NON-CRITICAL, that
this implementation manages.
|
Date |
getNotAfter()
Returns the
notAfter date of the validity period of the
certificate. |
Date |
getNotBefore()
Returns the
notBefore date from the validity period of the
certificate. |
PublicKey |
getPublicKey()
Returns the public key corresponding to this certificate.
|
BigInteger |
getSerialNumber()
Returns the
serialNumber of the certificate. |
String |
getSigAlgName()
return a more "meaningful" representation for the signature algorithm used in
the certficate.
|
String |
getSigAlgOID()
return the object identifier for the signature.
|
byte[] |
getSigAlgParams()
return the signature parameters, or null if there aren't any.
|
byte[] |
getSignature()
Returns the raw signature bits from the certificate.
|
Collection |
getSubjectAlternativeNames()
Returns a read-only list of the subject alternative names from the
SubjectAltName extension. |
Principal |
getSubjectDN()
Returns the
subject (subject distinguished name) as an
implementation specific Principal object. |
boolean[] |
getSubjectUniqueID()
Returns the
subjectUniqueID from the certificate. |
X500Principal |
getSubjectX500Principal()
Returns the
subject (subject distinguished name) as an X500Principal. |
byte[] |
getTBSCertificate()
Returns the
tbsCertificate information from this certificate in
DER-encoded format. |
int |
getVersion()
Returns the certificates
version (version number). |
int |
hashCode()
Returns an integer hash code for the certificate.
|
boolean |
hasUnsupportedCriticalExtension()
Returns whether this instance has an extension marked as CRITICAL that it
cannot support.
|
void |
setBagAttribute(ASN1ObjectIdentifier oid,
ASN1Encodable attribute) |
String |
toString()
Returns a string containing a concise, human-readable description of the
certificate.
|
void |
verify(PublicKey key)
Verifies that this certificate was signed with the given public key.
|
void |
verify(PublicKey key,
String sigProvider)
Verifies that this certificate was signed with the given public key.
|
getType, writeReplacepublic X509CertificateObject(Certificate c) throws CertificateParsingException
CertificateParsingExceptionpublic void checkValidity()
throws CertificateExpiredException,
CertificateNotYetValidException
X509CertificateThe validity defined in ASN.1:
validity Validity
Validity ::= SEQUENCE {
notBefore CertificateValidityDate,
notAfter CertificateValidityDate }
CertificateValidityDate ::= CHOICE {
utcTime UTCTime,
generalTime GeneralizedTime }
checkValidity in class X509CertificateCertificateExpiredException - if the certificate has expired.CertificateNotYetValidException - if the certificate is not yet valid.public void checkValidity(Date date) throws CertificateExpiredException, CertificateNotYetValidException
X509CertificatecheckValidity in class X509Certificatedate - the date to check the validity against.CertificateExpiredException - if the certificate has expired.CertificateNotYetValidException - if the certificate is not yet valid.X509Certificate.checkValidity()public int getVersion()
X509Certificateversion (version number).
The version defined is ASN.1:
Version ::= INTEGER { v1(0), v2(1), v3(2) }
getVersion in class X509Certificatepublic BigInteger getSerialNumber()
X509CertificateserialNumber of the certificate.
The ASN.1 definition of serialNumber:
CertificateSerialNumber ::= INTEGER
getSerialNumber in class X509Certificatepublic Principal getIssuerDN()
X509Certificateissuer (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
replaced by: X509Certificate.getIssuerX500Principal().getIssuerDN in class X509Certificateissuer as an implementation specific Principal.public X500Principal getIssuerX500Principal()
X509Certificateissuer (issuer distinguished name) as an X500Principal.getIssuerX500Principal in class X509Certificateissuer (issuer distinguished name).public Principal getSubjectDN()
X509Certificatesubject (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
replaced by: X509Certificate.getSubjectX500Principal().
getSubjectDN in class X509Certificatesubject (subject distinguished name).public X500Principal getSubjectX500Principal()
X509Certificatesubject (subject distinguished name) as an X500Principal.getSubjectX500Principal in class X509Certificatesubject (subject distinguished name)public Date getNotBefore()
X509CertificatenotBefore date from the validity period of the
certificate.getNotBefore in class X509Certificatepublic Date getNotAfter()
X509CertificatenotAfter date of the validity period of the
certificate.getNotAfter in class X509Certificatepublic byte[] getTBSCertificate()
throws CertificateEncodingException
X509CertificatetbsCertificate information from this certificate in
DER-encoded format.getTBSCertificate in class X509CertificateCertificateEncodingException - if an error occurs in encodingpublic byte[] getSignature()
X509CertificategetSignature in class X509Certificatepublic String getSigAlgName()
getSigAlgName in class X509Certificatepublic String getSigAlgOID()
getSigAlgOID in class X509Certificatepublic byte[] getSigAlgParams()
getSigAlgParams in class X509Certificatenull if
none are used.public boolean[] getIssuerUniqueID()
X509CertificateissuerUniqueID from the certificate.getIssuerUniqueID in class X509CertificateissuerUniqueID or null if there's none in the
certificate.public boolean[] getSubjectUniqueID()
X509CertificatesubjectUniqueID from the certificate.getSubjectUniqueID in class X509CertificatesubjectUniqueID or null if there's none in the
certificate.public boolean[] getKeyUsage()
X509CertificateKeyUsage extension as a boolean array.
The ASN.1 definition of KeyUsage:
KeyUsage ::= BIT STRING {
digitalSignature (0),
nonRepudiation (1),
keyEncipherment (2),
dataEncipherment (3),
keyAgreement (4),
keyCertSign (5),
cRLSign (6),
encipherOnly (7),
decipherOnly (8) }
getKeyUsage in class X509CertificateKeyUsage extension or null if there's none in
the certificate.public List getExtendedKeyUsage() throws CertificateParsingException
X509CertificateExtKeyUsageSyntax field of the extended key usage extension.getExtendedKeyUsage in class X509Certificatenull if there's none
in the certificate.CertificateParsingException - if the extension decoding fails.public int getBasicConstraints()
X509CertificateBasicContraints extension.
If the certificate has no basic constraints or is not a
certificate authority, -1 is returned. If the
certificate is a certificate authority without a path length,
Integer.MAX_VALUE is returned. Otherwise, the
certificate authority's path length is returned.getBasicConstraints in class X509Certificatepublic Collection getSubjectAlternativeNames() throws CertificateParsingException
X509CertificateSubjectAltName extension.
The ASN.1 definition of SubjectAltName:
SubjectAltName ::= GeneralNames
GeneralNames ::= SEQUENCE SIZE (1..MAX) OF GeneralName
GeneralName ::= CHOICE {
otherName [0] AnotherName,
rfc822Name [1] IA5String,
dNSName [2] IA5String,
x400Address [3] ORAddress,
directoryName [4] Name,
ediPartyName [5] EDIPartyName,
uniformResourceIdentifier [6] IA5String,
iPAddress [7] OCTET STRING,
registeredID [8] OBJECT IDENTIFIER }
getSubjectAlternativeNames in class X509Certificatenull if there are none
in the certificate.CertificateParsingException - if decoding of the extension fails.public Collection getIssuerAlternativeNames() throws CertificateParsingException
X509CertificateIssuerAltName extension.
The ASN.1 definition of IssuerAltName:
IssuerAltName ::= GeneralNames
GeneralNames ::= SEQUENCE SIZE (1..MAX) OF GeneralName
GeneralName ::= CHOICE {
otherName [0] AnotherName,
rfc822Name [1] IA5String,
dNSName [2] IA5String,
x400Address [3] ORAddress,
directoryName [4] Name,
ediPartyName [5] EDIPartyName,
uniformResourceIdentifier [6] IA5String,
iPAddress [7] OCTET STRING,
registeredID [8] OBJECT IDENTIFIER }
getIssuerAlternativeNames in class X509Certificatenull if there are none in
the certificate.CertificateParsingException - if decoding of the extension fails.public Set getCriticalExtensionOIDs()
X509ExtensiongetCriticalExtensionOIDs in interface X509Extensionnull if no extensions are
present.public byte[] getExtensionValue(String oid)
X509ExtensiongetExtensionValue in interface X509Extensionoid - the object identifier to get the extension value for.null
if no extension for the specified OID can be found.public Set getNonCriticalExtensionOIDs()
X509ExtensiongetNonCriticalExtensionOIDs in interface X509Extensionnull if no
extensions are present.public boolean hasUnsupportedCriticalExtension()
X509ExtensionhasUnsupportedCriticalExtension in interface X509Extensiontrue if an unsupported CRITICAL extension is present,
false otherwise.public PublicKey getPublicKey()
CertificategetPublicKey in class Certificatepublic byte[] getEncoded()
throws CertificateEncodingException
CertificategetEncoded in class CertificateCertificateEncodingException - if the encoding fails.public boolean equals(Object o)
Certificatetrue if they
represent the same object using a class specific comparison. The
implementation in Object returns true only if the argument is the
exact same object as the callee (==).equals in class Certificateo - the object to compare with this object.true if the object is the same as this object, false if it is different from this object.Certificate.hashCode()public int hashCode()
Certificatetrue when passed to equals must return the same
value for this method.hashCode in class CertificateCertificate.equals(java.lang.Object)public void setBagAttribute(ASN1ObjectIdentifier oid, ASN1Encodable attribute)
setBagAttribute in interface PKCS12BagAttributeCarrierpublic ASN1Encodable getBagAttribute(ASN1ObjectIdentifier oid)
getBagAttribute in interface PKCS12BagAttributeCarrierpublic Enumeration getBagAttributeKeys()
getBagAttributeKeys in interface PKCS12BagAttributeCarrierpublic String toString()
CertificatetoString in class Certificatepublic final void verify(PublicKey key) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException
Certificateverify in class Certificatekey - PublicKey public key for which verification should be
performed.CertificateException - if encoding errors are detected.NoSuchAlgorithmException - if an unsupported algorithm is detected.InvalidKeyException - if an invalid key is detected.NoSuchProviderException - if there is no default provider.SignatureException - if signature errors are detected.public final void verify(PublicKey key, String sigProvider) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException
Certificateverify in class Certificatekey - PublicKey public key for which verification should be
performed.sigProvider - String the name of the signature provider.CertificateException - if encoding errors are detected.NoSuchAlgorithmException - if an unsupported algorithm is detected.InvalidKeyException - if an invalid key is detected.NoSuchProviderException - if the specified provider does not exists.SignatureException - if signature errors are detected.