Package org.bouncycastle.pkix.jcajce
Class PKIXCertPathReviewer
java.lang.Object
org.bouncycastle.pkix.jcajce.PKIXCertPathReviewer
PKIXCertPathReviewer
Validation of X.509 Certificate Paths. Tries to find as much errors in the Path as possible.
Validation of X.509 Certificate Paths. Tries to find as much errors in the Path as possible.
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
protected static final String
protected static final String
protected static final String
protected CertPath
protected List
protected static final String
protected static final String
protected static final int
protected static final String[]
protected Date
protected static final String
protected List[]
protected static final String
protected static final String
protected static final String
protected static final int
protected static final String
protected int
protected static final String
protected List[]
protected PKIXParameters
protected static final String
protected static final String
protected PolicyNode
protected static final String
protected PublicKey
protected TrustAnchor
protected Date
-
Constructor Summary
ConstructorDescriptionCreates an empty PKIXCertPathReviewer.PKIXCertPathReviewer
(CertPath certPath, PKIXParameters params) Creates a PKIXCertPathReviewer and initializes it with the givenCertPath
andPKIXParameters
params -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addError
(ErrorBundle msg) protected void
addError
(ErrorBundle msg, int index) protected void
protected void
addNotification
(ErrorBundle msg, int index) protected void
checkCRLs
(PKIXParameters paramsPKIX, X509Certificate cert, Date validDate, X509Certificate sign, PublicKey workingPublicKey, Vector crlDistPointUrls, int index) protected void
checkRevocation
(PKIXParameters paramsPKIX, X509Certificate cert, Date validDate, X509Certificate sign, PublicKey workingPublicKey, Vector crlDistPointUrls, Vector ocspUrls, int index) protected void
doChecks()
protected static Collection
findCertificates
(org.bouncycastle.jcajce.PKIXCertStoreSelector certSelect, List certStores) protected static Collection
findCertificates
(org.bouncycastle.pkix.jcajce.X509CertStoreSelector certSelect, List certStores) Return a Collection of all certificates or attribute certificates found in the X509Store's that are matching the certSelect criteriums.protected static org.bouncycastle.asn1.x509.AlgorithmIdentifier
int
protected static void
getCertStatus
(Date validDate, X509CRL crl, Object cert, org.bouncycastle.pkix.jcajce.CertStatus certStatus) protected Vector
getCRLDistUrls
(org.bouncycastle.asn1.x509.CRLDistPoint crlDistPoints) protected static X500Principal
Returns the issuer of an attribute certificate or certificate.List[]
Returns an Array of Lists which contains a List of global error messages and a List of error messages for each certificate in the path.getErrors
(int index) Returns an List of error messages for the certificate at the given index in the CertPath.protected static org.bouncycastle.asn1.ASN1Primitive
getExtensionValue
(X509Extension ext, String oid) Extract the value of the given extension, if it exists.protected static X500Principal
protected static PublicKey
getNextWorkingKey
(List certs, int index) Return the next working key inheriting DSA parameters if necessary.List[]
Returns an Array of Lists which contains a List of global notification messages and a List of botification messages for each certificate in the path.getNotifications
(int index) Returns an List of notification messages for the certificate at the given index in the CertPath.protected Vector
getOCSPUrls
(org.bouncycastle.asn1.x509.AuthorityInformationAccess authInfoAccess) protected static final Set
getQualifierSet
(org.bouncycastle.asn1.ASN1Sequence qualifiers) protected static X500Principal
protected Collection
getTrustAnchors
(X509Certificate cert, Set trustanchors) protected static Date
getValidDate
(PKIXParameters paramsPKIX) protected static Date
getValidityDate
(PKIXParameters paramsPKIX, Date currentDate) void
init
(CertPath certPath, PKIXParameters params) Initializes the PKIXCertPathReviewer with the givenCertPath
andPKIXParameters
paramsprotected static boolean
isAnyPolicy
(Set policySet) protected static boolean
isSelfIssued
(X509Certificate cert) boolean
protected static void
prepareNextCertB1
(int i, List[] policyNodes, String id_p, Map m_idp, X509Certificate cert) protected static PKIXPolicyNode
prepareNextCertB2
(int i, List[] policyNodes, String id_p, PKIXPolicyNode validPolicyTree) protected static boolean
processCertD1i
(int index, List[] policyNodes, org.bouncycastle.asn1.ASN1ObjectIdentifier pOid, Set pq) protected static void
processCertD1ii
(int index, List[] policyNodes, org.bouncycastle.asn1.ASN1ObjectIdentifier _poid, Set _pq) protected static PKIXPolicyNode
removePolicyNode
(PKIXPolicyNode validPolicyTree, List[] policyNodes, PKIXPolicyNode _node) protected static void
verifyX509Certificate
(X509Certificate cert, PublicKey publicKey, String sigProvider)
-
Field Details
-
certPath
-
pkixParams
-
currentDate
-
validDate
-
certs
-
n
protected int n -
notifications
-
errors
-
trustAnchor
-
subjectPublicKey
-
policyTree
-
CERTIFICATE_POLICIES
-
BASIC_CONSTRAINTS
-
POLICY_MAPPINGS
-
SUBJECT_ALTERNATIVE_NAME
-
NAME_CONSTRAINTS
-
KEY_USAGE
-
INHIBIT_ANY_POLICY
-
ISSUING_DISTRIBUTION_POINT
-
DELTA_CRL_INDICATOR
-
POLICY_CONSTRAINTS
-
FRESHEST_CRL
-
CRL_DISTRIBUTION_POINTS
-
AUTHORITY_KEY_IDENTIFIER
-
ANY_POLICY
- See Also:
-
CRL_NUMBER
-
KEY_CERT_SIGN
protected static final int KEY_CERT_SIGN- See Also:
-
CRL_SIGN
protected static final int CRL_SIGN- See Also:
-
crlReasons
-
-
Constructor Details
-
PKIXCertPathReviewer
public PKIXCertPathReviewer(CertPath certPath, PKIXParameters params) throws CertPathReviewerException Creates a PKIXCertPathReviewer and initializes it with the givenCertPath
andPKIXParameters
params- Parameters:
certPath
- theCertPath
to validateparams
- thePKIXParameters
to use- Throws:
CertPathReviewerException
- if the certPath is empty
-
PKIXCertPathReviewer
public PKIXCertPathReviewer()Creates an empty PKIXCertPathReviewer. Don't forget to call init() to initialize the object.
-
-
Method Details
-
init
Initializes the PKIXCertPathReviewer with the givenCertPath
andPKIXParameters
params- Parameters:
certPath
- theCertPath
to validateparams
- thePKIXParameters
to use- Throws:
CertPathReviewerException
- if the certPath is emptyIllegalStateException
- if thePKIXCertPathReviewer
is already initialized
-
getCertPath
- Returns:
- the CertPath that was validated
-
getCertPathSize
public int getCertPathSize()- Returns:
- the size of the CertPath
-
getErrors
Returns an Array of Lists which contains a List of global error messages and a List of error messages for each certificate in the path. The global error List is at index 0. The error lists for each certificate at index 1 to n. The error messages are of type.- Returns:
- the Array of Lists which contain the error messages
- Throws:
IllegalStateException
- if thePKIXCertPathReviewer
was not initialized
-
getErrors
Returns an List of error messages for the certificate at the given index in the CertPath. If index == -1 then the list of global errors is returned with errors not specific to a certificate.- Parameters:
index
- the index of the certificate in the CertPath- Returns:
- List of error messages for the certificate
- Throws:
IllegalStateException
- if thePKIXCertPathReviewer
was not initialized
-
getNotifications
Returns an Array of Lists which contains a List of global notification messages and a List of botification messages for each certificate in the path. The global notificatio List is at index 0. The notification lists for each certificate at index 1 to n. The error messages are of type.- Returns:
- the Array of Lists which contain the notification messages
- Throws:
IllegalStateException
- if thePKIXCertPathReviewer
was not initialized
-
getNotifications
Returns an List of notification messages for the certificate at the given index in the CertPath. If index == -1 then the list of global notifications is returned with notifications not specific to a certificate.- Parameters:
index
- the index of the certificate in the CertPath- Returns:
- List of notification messages for the certificate
- Throws:
IllegalStateException
- if thePKIXCertPathReviewer
was not initialized
-
getPolicyTree
- Returns:
- the valid policy tree, null if no valid policy exists.
- Throws:
IllegalStateException
- if thePKIXCertPathReviewer
was not initialized
-
getSubjectPublicKey
- Returns:
- the PublicKey if the last certificate in the CertPath
- Throws:
IllegalStateException
- if thePKIXCertPathReviewer
was not initialized
-
getTrustAnchor
- Returns:
- the TrustAnchor for the CertPath, null if no valid TrustAnchor was found.
- Throws:
IllegalStateException
- if thePKIXCertPathReviewer
was not initialized
-
isValidCertPath
public boolean isValidCertPath()- Returns:
- if the CertPath is valid
- Throws:
IllegalStateException
- if thePKIXCertPathReviewer
was not initialized
-
addNotification
-
addNotification
-
addError
-
addError
-
doChecks
protected void doChecks() -
checkRevocation
protected void checkRevocation(PKIXParameters paramsPKIX, X509Certificate cert, Date validDate, X509Certificate sign, PublicKey workingPublicKey, Vector crlDistPointUrls, Vector ocspUrls, int index) throws CertPathReviewerException - Throws:
CertPathReviewerException
-
checkCRLs
protected void checkCRLs(PKIXParameters paramsPKIX, X509Certificate cert, Date validDate, X509Certificate sign, PublicKey workingPublicKey, Vector crlDistPointUrls, int index) throws CertPathReviewerException - Throws:
CertPathReviewerException
-
getCRLDistUrls
-
getOCSPUrls
-
getTrustAnchors
protected Collection getTrustAnchors(X509Certificate cert, Set trustanchors) throws CertPathReviewerException - Throws:
CertPathReviewerException
-
getEncodedIssuerPrincipal
Returns the issuer of an attribute certificate or certificate.- Parameters:
cert
- The attribute certificate or certificate.- Returns:
- The issuer as
X500Principal
.
-
getValidDate
-
getSubjectPrincipal
-
isSelfIssued
-
getExtensionValue
protected static org.bouncycastle.asn1.ASN1Primitive getExtensionValue(X509Extension ext, String oid) throws org.bouncycastle.pkix.jcajce.AnnotatedException Extract the value of the given extension, if it exists.- Parameters:
ext
- The extension object.oid
- The object identifier to obtain.- Throws:
org.bouncycastle.pkix.jcajce.AnnotatedException
- if the extension cannot be read.
-
getIssuerPrincipal
-
getAlgorithmIdentifier
protected static org.bouncycastle.asn1.x509.AlgorithmIdentifier getAlgorithmIdentifier(PublicKey key) throws CertPathValidatorException - Throws:
CertPathValidatorException
-
getQualifierSet
protected static final Set getQualifierSet(org.bouncycastle.asn1.ASN1Sequence qualifiers) throws CertPathValidatorException - Throws:
CertPathValidatorException
-
removePolicyNode
protected static PKIXPolicyNode removePolicyNode(PKIXPolicyNode validPolicyTree, List[] policyNodes, PKIXPolicyNode _node) -
processCertD1i
-
processCertD1ii
-
prepareNextCertB1
protected static void prepareNextCertB1(int i, List[] policyNodes, String id_p, Map m_idp, X509Certificate cert) throws org.bouncycastle.pkix.jcajce.AnnotatedException, CertPathValidatorException - Throws:
org.bouncycastle.pkix.jcajce.AnnotatedException
CertPathValidatorException
-
prepareNextCertB2
protected static PKIXPolicyNode prepareNextCertB2(int i, List[] policyNodes, String id_p, PKIXPolicyNode validPolicyTree) -
isAnyPolicy
-
findCertificates
protected static Collection findCertificates(org.bouncycastle.pkix.jcajce.X509CertStoreSelector certSelect, List certStores) throws org.bouncycastle.pkix.jcajce.AnnotatedException Return a Collection of all certificates or attribute certificates found in the X509Store's that are matching the certSelect criteriums.- Parameters:
certSelect
- aSelector
object that will be used to select the certificatescertStores
- a List containing onlyStore
objects. These are used to search for certificates.- Returns:
- a Collection of all found
X509Certificate
May be empty but nevernull
. - Throws:
org.bouncycastle.pkix.jcajce.AnnotatedException
-
findCertificates
protected static Collection findCertificates(org.bouncycastle.jcajce.PKIXCertStoreSelector certSelect, List certStores) throws org.bouncycastle.pkix.jcajce.AnnotatedException - Throws:
org.bouncycastle.pkix.jcajce.AnnotatedException
-
getCertStatus
protected static void getCertStatus(Date validDate, X509CRL crl, Object cert, org.bouncycastle.pkix.jcajce.CertStatus certStatus) throws org.bouncycastle.pkix.jcajce.AnnotatedException - Throws:
org.bouncycastle.pkix.jcajce.AnnotatedException
-
getNextWorkingKey
protected static PublicKey getNextWorkingKey(List certs, int index) throws CertPathValidatorException Return the next working key inheriting DSA parameters if necessary.This methods inherits DSA parameters from the indexed certificate or previous certificates in the certificate chain to the returned
PublicKey
. The list is searched upwards, meaning the end certificate is at position 0 and previous certificates are following.If the indexed certificate does not contain a DSA key this method simply returns the public key. If the DSA key already contains DSA parameters the key is also only returned.
- Parameters:
certs
- The certification path.index
- The index of the certificate which contains the public key which should be extended with DSA parameters.- Returns:
- The public key of the certificate in list position
index
extended with DSA parameters if applicable. - Throws:
CertPathValidatorException
- if DSA parameters cannot be inherited.
-
verifyX509Certificate
protected static void verifyX509Certificate(X509Certificate cert, PublicKey publicKey, String sigProvider) throws GeneralSecurityException - Throws:
GeneralSecurityException
-
getValidityDate
-