Package org.bouncycastle.jce.provider
Class X509CertificateObject
java.lang.Object
java.security.cert.Certificate
java.security.cert.X509Certificate
org.bouncycastle.jce.provider.X509CertificateObject
- All Implemented Interfaces:
Serializable,X509Extension,PKCS12BagAttributeCarrier
public class X509CertificateObject extends X509Certificate implements PKCS12BagAttributeCarrier
- See Also:
- Serialized Form
-
Nested Class Summary
Nested classes/interfaces inherited from class java.security.cert.Certificate
Certificate.CertificateRep -
Constructor Summary
Constructors Constructor Description X509CertificateObject(Certificate c) -
Method Summary
Modifier and Type Method Description voidcheckValidity()Checks whether the certificate is currently valid.voidcheckValidity(Date date)Checks whether the certificate is valid at the specified date.booleanequals(Object o)Compares the argument to the certificate, and returnstrueif they represent the same object using a class specific comparison.ASN1EncodablegetBagAttribute(ASN1ObjectIdentifier oid)EnumerationgetBagAttributeKeys()intgetBasicConstraints()Returns the path length of the certificate constraints from theBasicContraintsextension.SetgetCriticalExtensionOIDs()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.ListgetExtendedKeyUsage()Returns a read-only list of OID strings representing theExtKeyUsageSyntaxfield of the extended key usage extension.byte[]getExtensionValue(String oid)Returns the extension value as DER-encoded OCTET string for the specified OID.CollectiongetIssuerAlternativeNames()Returns a read-only list of the issuer alternative names from theIssuerAltNameextension.PrincipalgetIssuerDN()Returns theissuer(issuer distinguished name) as an implementation specificPrincipalobject.boolean[]getIssuerUniqueID()Returns theissuerUniqueIDfrom the certificate.X500PrincipalgetIssuerX500Principal()Returns theissuer(issuer distinguished name) as anX500Principal.boolean[]getKeyUsage()Returns theKeyUsageextension as abooleanarray.SetgetNonCriticalExtensionOIDs()Returns the set of OIDs of the extension(s) marked as NON-CRITICAL, that this implementation manages.DategetNotAfter()Returns thenotAfterdate of the validity period of the certificate.DategetNotBefore()Returns thenotBeforedate from the validity period of the certificate.PublicKeygetPublicKey()Returns the public key corresponding to this certificate.BigIntegergetSerialNumber()Returns theserialNumberof the certificate.StringgetSigAlgName()return a more "meaningful" representation for the signature algorithm used in the certficate.StringgetSigAlgOID()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.CollectiongetSubjectAlternativeNames()Returns a read-only list of the subject alternative names from theSubjectAltNameextension.PrincipalgetSubjectDN()Returns thesubject(subject distinguished name) as an implementation specificPrincipalobject.boolean[]getSubjectUniqueID()Returns thesubjectUniqueIDfrom the certificate.X500PrincipalgetSubjectX500Principal()Returns thesubject(subject distinguished name) as anX500Principal.byte[]getTBSCertificate()Returns thetbsCertificateinformation from this certificate in DER-encoded format.intgetVersion()Returns the certificatesversion(version number).inthashCode()Returns an integer hash code for the certificate.booleanhasUnsupportedCriticalExtension()Returns whether this instance has an extension marked as CRITICAL that it cannot support.voidsetBagAttribute(ASN1ObjectIdentifier oid, ASN1Encodable attribute)StringtoString()Returns a string containing a concise, human-readable description of the certificate.voidverify(PublicKey key)Verifies that this certificate was signed with the given public key.voidverify(PublicKey key, String sigProvider)Verifies that this certificate was signed with the given public key.Methods inherited from class java.security.cert.Certificate
getType, writeReplace
-
Constructor Details
-
X509CertificateObject
- Throws:
CertificateParsingException
-
-
Method Details
-
checkValidity
Description copied from class:X509CertificateChecks 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 }- Specified by:
checkValidityin classX509Certificate- Throws:
CertificateExpiredException- if the certificate has expired.CertificateNotYetValidException- if the certificate is not yet valid.
-
checkValidity
public void checkValidity(Date date) throws CertificateExpiredException, CertificateNotYetValidExceptionDescription copied from class:X509CertificateChecks whether the certificate is valid at the specified date.- Specified by:
checkValidityin classX509Certificate- Parameters:
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:
X509Certificate.checkValidity()
-
getVersion
public int getVersion()Description copied from class:X509CertificateReturns the certificatesversion(version number).The version defined is ASN.1:
Version ::= INTEGER { v1(0), v2(1), v3(2) }- Specified by:
getVersionin classX509Certificate- Returns:
- the version number.
-
getSerialNumber
Description copied from class:X509CertificateReturns theserialNumberof the certificate.The ASN.1 definition of
serialNumber:CertificateSerialNumber ::= INTEGER
- Specified by:
getSerialNumberin classX509Certificate- Returns:
- the serial number.
-
getIssuerDN
Description copied from class:X509CertificateReturns theissuer(issuer distinguished name) as an implementation specificPrincipalobject.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 AttributeTypereplaced by:X509Certificate.getIssuerX500Principal().- Specified by:
getIssuerDNin classX509Certificate- Returns:
- the
issueras an implementation specificPrincipal.
-
getIssuerX500Principal
Description copied from class:X509CertificateReturns theissuer(issuer distinguished name) as anX500Principal.- Overrides:
getIssuerX500Principalin classX509Certificate- Returns:
- the
issuer(issuer distinguished name).
-
getSubjectDN
Description copied from class:X509CertificateReturns thesubject(subject distinguished name) as an implementation specificPrincipalobject.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 AttributeTypereplaced by:
X509Certificate.getSubjectX500Principal().- Specified by:
getSubjectDNin classX509Certificate- Returns:
- the
subject(subject distinguished name).
-
getSubjectX500Principal
Description copied from class:X509CertificateReturns thesubject(subject distinguished name) as anX500Principal.- Overrides:
getSubjectX500Principalin classX509Certificate- Returns:
- the
subject(subject distinguished name)
-
getNotBefore
Description copied from class:X509CertificateReturns thenotBeforedate from the validity period of the certificate.- Specified by:
getNotBeforein classX509Certificate- Returns:
- the start of the validity period.
-
getNotAfter
Description copied from class:X509CertificateReturns thenotAfterdate of the validity period of the certificate.- Specified by:
getNotAfterin classX509Certificate- Returns:
- the end of the validity period.
-
getTBSCertificate
Description copied from class:X509CertificateReturns thetbsCertificateinformation from this certificate in DER-encoded format.- Specified by:
getTBSCertificatein classX509Certificate- Returns:
- the DER-encoded certificate information.
- Throws:
CertificateEncodingException- if an error occurs in encoding
-
getSignature
public byte[] getSignature()Description copied from class:X509CertificateReturns the raw signature bits from the certificate.- Specified by:
getSignaturein classX509Certificate- Returns:
- the raw signature bits from the certificate.
-
getSigAlgName
return a more "meaningful" representation for the signature algorithm used in the certficate.- Specified by:
getSigAlgNamein classX509Certificate- Returns:
- the signature algorithm name.
-
getSigAlgOID
return the object identifier for the signature.- Specified by:
getSigAlgOIDin classX509Certificate- Returns:
- the OID of the signature algorithm.
-
getSigAlgParams
public byte[] getSigAlgParams()return the signature parameters, or null if there aren't any.- Specified by:
getSigAlgParamsin classX509Certificate- Returns:
- the parameters of the signature algorithm, or
nullif none are used.
-
getIssuerUniqueID
public boolean[] getIssuerUniqueID()Description copied from class:X509CertificateReturns theissuerUniqueIDfrom the certificate.- Specified by:
getIssuerUniqueIDin classX509Certificate- Returns:
- the
issuerUniqueIDornullif there's none in the certificate.
-
getSubjectUniqueID
public boolean[] getSubjectUniqueID()Description copied from class:X509CertificateReturns thesubjectUniqueIDfrom the certificate.- Specified by:
getSubjectUniqueIDin classX509Certificate- Returns:
- the
subjectUniqueIDor null if there's none in the certificate.
-
getKeyUsage
public boolean[] getKeyUsage()Description copied from class:X509CertificateReturns theKeyUsageextension as abooleanarray.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) }- Specified by:
getKeyUsagein classX509Certificate- Returns:
- the
KeyUsageextension ornullif there's none in the certificate.
-
getExtendedKeyUsage
Description copied from class:X509CertificateReturns a read-only list of OID strings representing theExtKeyUsageSyntaxfield of the extended key usage extension.- Overrides:
getExtendedKeyUsagein classX509Certificate- Returns:
- the extended key usage extension, or
nullif there's none in the certificate. - Throws:
CertificateParsingException- if the extension decoding fails.
-
getBasicConstraints
public int getBasicConstraints()Description copied from class:X509CertificateReturns the path length of the certificate constraints from theBasicContraintsextension. If the certificate has no basic constraints or is not a certificate authority,-1is returned. If the certificate is a certificate authority without a path length,Integer.MAX_VALUEis returned. Otherwise, the certificate authority's path length is returned.- Specified by:
getBasicConstraintsin classX509Certificate
-
getSubjectAlternativeNames
Description copied from class:X509CertificateReturns a read-only list of the subject alternative names from theSubjectAltNameextension.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 }- Overrides:
getSubjectAlternativeNamesin classX509Certificate- Returns:
- the subject alternative names or
nullif there are none in the certificate. - Throws:
CertificateParsingException- if decoding of the extension fails.
-
getIssuerAlternativeNames
Description copied from class:X509CertificateReturns a read-only list of the issuer alternative names from theIssuerAltNameextension.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 }- Overrides:
getIssuerAlternativeNamesin classX509Certificate- Returns:
- the issuer alternative names of
nullif there are none in the certificate. - Throws:
CertificateParsingException- if decoding of the extension fails.
-
getCriticalExtensionOIDs
Description copied from interface:X509ExtensionReturns the set of OIDs of the extension(s) marked as CRITICAL, that this implementation manages.- Specified by:
getCriticalExtensionOIDsin interfaceX509Extension- Returns:
- the set of extension OIDs marked as CRITIAL, an empty set if none
are marked as CRITICAL, or
nullif no extensions are present.
-
getExtensionValue
Description copied from interface:X509ExtensionReturns the extension value as DER-encoded OCTET string for the specified OID.- Specified by:
getExtensionValuein interfaceX509Extension- Parameters:
oid- the object identifier to get the extension value for.- Returns:
- the extension value as DER-encoded OCTET string, or
nullif no extension for the specified OID can be found.
-
getNonCriticalExtensionOIDs
Description copied from interface:X509ExtensionReturns the set of OIDs of the extension(s) marked as NON-CRITICAL, that this implementation manages.- Specified by:
getNonCriticalExtensionOIDsin interfaceX509Extension- Returns:
- the set of extension OIDs marked as NON-CRITIAL, an empty set if
none are marked as NON-.CRITICAL, or
nullif no extensions are present.
-
hasUnsupportedCriticalExtension
public boolean hasUnsupportedCriticalExtension()Description copied from interface:X509ExtensionReturns whether this instance has an extension marked as CRITICAL that it cannot support.- Specified by:
hasUnsupportedCriticalExtensionin interfaceX509Extension- Returns:
trueif an unsupported CRITICAL extension is present,falseotherwise.
-
getPublicKey
Description copied from class:CertificateReturns the public key corresponding to this certificate.- Specified by:
getPublicKeyin classCertificate- Returns:
- the public key corresponding to this certificate.
-
getEncoded
Description copied from class:CertificateReturns the encoded representation for this certificate.- Specified by:
getEncodedin classCertificate- Returns:
- the encoded representation for this certificate.
- Throws:
CertificateEncodingException- if the encoding fails.
-
equals
Description copied from class:CertificateCompares the argument to the certificate, and returnstrueif they represent the same object using a class specific comparison. The implementation in Object returnstrueonly if the argument is the exact same object as the callee (==).- Overrides:
equalsin classCertificate- Parameters:
o- the object to compare with this object.- Returns:
trueif the object is the same as this object,falseif it is different from this object.- See Also:
Certificate.hashCode()
-
hashCode
public int hashCode()Description copied from class:CertificateReturns an integer hash code for the certificate. Any two objects which returntruewhen passed toequalsmust return the same value for this method.- Overrides:
hashCodein classCertificate- Returns:
- the certificate's hash
- See Also:
Certificate.equals(java.lang.Object)
-
setBagAttribute
- Specified by:
setBagAttributein interfacePKCS12BagAttributeCarrier
-
getBagAttribute
- Specified by:
getBagAttributein interfacePKCS12BagAttributeCarrier
-
getBagAttributeKeys
- Specified by:
getBagAttributeKeysin interfacePKCS12BagAttributeCarrier
-
toString
Description copied from class:CertificateReturns a string containing a concise, human-readable description of the certificate.- Specified by:
toStringin classCertificate- Returns:
- a printable representation for the certificate.
-
verify
public final void verify(PublicKey key) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureExceptionDescription copied from class:CertificateVerifies that this certificate was signed with the given public key.- Specified by:
verifyin classCertificate- Parameters:
key- PublicKey public key for which verification should be performed.- Throws:
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.
-
verify
public final void verify(PublicKey key, String sigProvider) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureExceptionDescription copied from class:CertificateVerifies that this certificate was signed with the given public key. It Uses the signature algorithm given by the provider.- Specified by:
verifyin classCertificate- Parameters:
key- PublicKey public key for which verification should be performed.sigProvider- String the name of the signature provider.- Throws:
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.
-