Package org.bouncycastle.jce.provider
Class CertPathValidatorUtilities
java.lang.Object
org.bouncycastle.jce.provider.CertPathValidatorUtilities
public class CertPathValidatorUtilities extends Object
-
Field Summary
Fields Modifier and Type Field Description protected static StringANY_POLICYprotected static StringAUTHORITY_KEY_IDENTIFIERprotected static StringBASIC_CONSTRAINTSprotected static StringCERTIFICATE_POLICIESprotected static StringCRL_DISTRIBUTION_POINTSprotected static StringCRL_NUMBERprotected static intCRL_SIGNprotected static PKIXCRLUtilCRL_UTILprotected static String[]crlReasonsprotected static StringDELTA_CRL_INDICATORprotected static StringFRESHEST_CRLprotected static StringINHIBIT_ANY_POLICYprotected static StringISSUING_DISTRIBUTION_POINTprotected static intKEY_CERT_SIGNprotected static StringKEY_USAGEprotected static StringNAME_CONSTRAINTSprotected static StringPOLICY_CONSTRAINTSprotected static StringPOLICY_MAPPINGSprotected static StringSUBJECT_ALTERNATIVE_NAME -
Constructor Summary
Constructors Constructor Description CertPathValidatorUtilities() -
Method Summary
Modifier and Type Method Description protected static voidaddAdditionalStoreFromLocation(String location, ExtendedPKIXParameters pkixParams)protected static voidaddAdditionalStoresFromAltNames(X509Certificate cert, ExtendedPKIXParameters pkixParams)protected static voidaddAdditionalStoresFromCRLDistributionPoint(CRLDistPoint crldp, ExtendedPKIXParameters pkixParams)protected static CollectionfindCertificates(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 CollectionfindIssuerCerts(X509Certificate cert, ExtendedPKIXBuilderParameters pkixParams)Find the issuer certificates of a given certificate.protected static TrustAnchorfindTrustAnchor(X509Certificate cert, Set trustAnchors)Search the given Set of TrustAnchor's for one that is the issuer of the given X509 certificate.protected static TrustAnchorfindTrustAnchor(X509Certificate cert, Set trustAnchors, String sigProvider)Search the given Set of TrustAnchor's for one that is the issuer of the given X509 certificate.protected static AlgorithmIdentifiergetAlgorithmIdentifier(PublicKey key)protected static voidgetCertStatus(Date validDate, X509CRL crl, Object cert, org.bouncycastle.jce.provider.CertStatus certStatus)protected static SetgetCompleteCRLs(DistributionPoint dp, Object cert, Date currentDate, ExtendedPKIXParameters paramsPKIX)Fetches complete CRLs according to RFC 3280.protected static voidgetCRLIssuersFromDistributionPoint(DistributionPoint dp, Collection issuerPrincipals, X509CRLSelector selector, ExtendedPKIXParameters pkixParams)Add the CRL issuers from the cRLIssuer field of the distribution point or from the certificate if not given to the issuer criterion of theselector.protected static SetgetDeltaCRLs(Date currentDate, ExtendedPKIXParameters paramsPKIX, X509CRL completeCRL)Fetches delta CRLs according to RFC 3280 section 5.2.4.protected static X500PrincipalgetEncodedIssuerPrincipal(Object cert)Returns the issuer of an attribute certificate or certificate.protected static ASN1PrimitivegetExtensionValue(X509Extension ext, String oid)Extract the value of the given extension, if it exists.protected static X500PrincipalgetIssuerPrincipal(X509CRL crl)protected static PublicKeygetNextWorkingKey(List certs, int index)Return the next working key inheriting DSA parameters if necessary.protected static SetgetQualifierSet(ASN1Sequence qualifiers)protected static X500PrincipalgetSubjectPrincipal(X509Certificate cert)protected static DategetValidCertDateFromValidityModel(ExtendedPKIXParameters paramsPKIX, CertPath certPath, int index)protected static DategetValidDate(PKIXParameters paramsPKIX)protected static booleanisAnyPolicy(Set policySet)protected static booleanisSelfIssued(X509Certificate cert)protected static voidprepareNextCertB1(int i, List[] policyNodes, String id_p, Map m_idp, X509Certificate cert)protected static PKIXPolicyNodeprepareNextCertB2(int i, List[] policyNodes, String id_p, PKIXPolicyNode validPolicyTree)protected static booleanprocessCertD1i(int index, List[] policyNodes, DERObjectIdentifier pOid, Set pq)protected static voidprocessCertD1ii(int index, List[] policyNodes, DERObjectIdentifier _poid, Set _pq)protected static PKIXPolicyNoderemovePolicyNode(PKIXPolicyNode validPolicyTree, List[] policyNodes, PKIXPolicyNode _node)protected static voidverifyX509Certificate(X509Certificate cert, PublicKey publicKey, String sigProvider)
-
Field Details
-
CRL_UTIL
-
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:
- Constant Field Values
-
CRL_NUMBER
-
KEY_CERT_SIGN
protected static final int KEY_CERT_SIGN- See Also:
- Constant Field Values
-
CRL_SIGN
protected static final int CRL_SIGN- See Also:
- Constant Field Values
-
crlReasons
-
-
Constructor Details
-
CertPathValidatorUtilities
public CertPathValidatorUtilities()
-
-
Method Details
-
findTrustAnchor
protected static TrustAnchor findTrustAnchor(X509Certificate cert, Set trustAnchors) throws AnnotatedExceptionSearch the given Set of TrustAnchor's for one that is the issuer of the given X509 certificate. Uses the default provider for signature verification.- Parameters:
cert- the X509 certificatetrustAnchors- a Set of TrustAnchor's- Returns:
- the
TrustAnchorobject if found ornullif not. - Throws:
AnnotatedException- if a TrustAnchor was found but the signature verification on the given certificate has thrown an exception.
-
findTrustAnchor
protected static TrustAnchor findTrustAnchor(X509Certificate cert, Set trustAnchors, String sigProvider) throws AnnotatedExceptionSearch the given Set of TrustAnchor's for one that is the issuer of the given X509 certificate. Uses the specified provider for signature verification, or the default provider if null.- Parameters:
cert- the X509 certificatetrustAnchors- a Set of TrustAnchor'ssigProvider- the provider to use for signature verification- Returns:
- the
TrustAnchorobject if found ornullif not. - Throws:
AnnotatedException- if a TrustAnchor was found but the signature verification on the given certificate has thrown an exception.
-
addAdditionalStoresFromAltNames
protected static void addAdditionalStoresFromAltNames(X509Certificate cert, ExtendedPKIXParameters pkixParams) throws CertificateParsingException- Throws:
CertificateParsingException
-
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 ASN1Primitive getExtensionValue(X509Extension ext, String oid) throws AnnotatedExceptionExtract the value of the given extension, if it exists.- Parameters:
ext- The extension object.oid- The object identifier to obtain.- Throws:
AnnotatedException- if the extension cannot be read.
-
getIssuerPrincipal
-
getAlgorithmIdentifier
protected static AlgorithmIdentifier getAlgorithmIdentifier(PublicKey key) throws CertPathValidatorException- Throws:
CertPathValidatorException
-
getQualifierSet
protected static final Set getQualifierSet(ASN1Sequence qualifiers) throws CertPathValidatorException- Throws:
CertPathValidatorException
-
removePolicyNode
protected static PKIXPolicyNode removePolicyNode(PKIXPolicyNode validPolicyTree, List[] policyNodes, PKIXPolicyNode _node) -
processCertD1i
protected static boolean processCertD1i(int index, List[] policyNodes, DERObjectIdentifier pOid, Set pq) -
processCertD1ii
protected static void processCertD1ii(int index, List[] policyNodes, DERObjectIdentifier _poid, Set _pq) -
prepareNextCertB1
protected static void prepareNextCertB1(int i, List[] policyNodes, String id_p, Map m_idp, X509Certificate cert) throws AnnotatedException, CertPathValidatorException -
prepareNextCertB2
protected static PKIXPolicyNode prepareNextCertB2(int i, List[] policyNodes, String id_p, PKIXPolicyNode validPolicyTree) -
isAnyPolicy
-
addAdditionalStoreFromLocation
protected static void addAdditionalStoreFromLocation(String location, ExtendedPKIXParameters pkixParams) -
findCertificates
protected static Collection findCertificates(X509CertStoreSelector certSelect, List certStores) throws AnnotatedExceptionReturn a Collection of all certificates or attribute certificates found in the X509Store's that are matching the certSelect criteriums.- Parameters:
certSelect- aSelectorobject that will be used to select the certificatescertStores- a List containing onlyX509Storeobjects. These are used to search for certificates.- Returns:
- a Collection of all found
X509CertificateorX509AttributeCertificateobjects. May be empty but nevernull. - Throws:
AnnotatedException
-
addAdditionalStoresFromCRLDistributionPoint
protected static void addAdditionalStoresFromCRLDistributionPoint(CRLDistPoint crldp, ExtendedPKIXParameters pkixParams) throws AnnotatedException- Throws:
AnnotatedException
-
getCRLIssuersFromDistributionPoint
protected static void getCRLIssuersFromDistributionPoint(DistributionPoint dp, Collection issuerPrincipals, X509CRLSelector selector, ExtendedPKIXParameters pkixParams) throws AnnotatedExceptionAdd the CRL issuers from the cRLIssuer field of the distribution point or from the certificate if not given to the issuer criterion of theselector. TheissuerPrincipalsare a collection with a singleX500PrincipalforX509Certificates. ForX509AttributeCertificates the issuer may contain more than oneX500Principal.- Parameters:
dp- The distribution point.issuerPrincipals- The issuers of the certificate or attribute certificate which contains the distribution point.selector- The CRL selector.pkixParams- The PKIX parameters containing the cert stores.- Throws:
AnnotatedException- if an exception occurs while processing.ClassCastException- ifissuerPrincipalsdoes not contain onlyX500Principals.
-
getCertStatus
protected static void getCertStatus(Date validDate, X509CRL crl, Object cert, org.bouncycastle.jce.provider.CertStatus certStatus) throws AnnotatedException- Throws:
AnnotatedException
-
getDeltaCRLs
protected static Set getDeltaCRLs(Date currentDate, ExtendedPKIXParameters paramsPKIX, X509CRL completeCRL) throws AnnotatedExceptionFetches delta CRLs according to RFC 3280 section 5.2.4.- Parameters:
currentDate- The date for which the delta CRLs must be valid.paramsPKIX- The extended PKIX parameters.completeCRL- The complete CRL the delta CRL is for.- Returns:
- A
SetofX509CRLs with delta CRLs. - Throws:
AnnotatedException- if an exception occurs while picking the delta CRLs.
-
getCompleteCRLs
protected static Set getCompleteCRLs(DistributionPoint dp, Object cert, Date currentDate, ExtendedPKIXParameters paramsPKIX) throws AnnotatedExceptionFetches complete CRLs according to RFC 3280.- Parameters:
dp- The distribution point for which the complete CRLcert- TheX509CertificateorX509AttributeCertificatefor which the CRL should be searched.currentDate- The date for which the delta CRLs must be valid.paramsPKIX- The extended PKIX parameters.- Returns:
- A
SetofX509CRLs with complete CRLs. - Throws:
AnnotatedException- if an exception occurs while picking the CRLs or no CRLs are found.
-
getValidCertDateFromValidityModel
protected static Date getValidCertDateFromValidityModel(ExtendedPKIXParameters paramsPKIX, CertPath certPath, int index) throws AnnotatedException- Throws:
AnnotatedException
-
getNextWorkingKey
protected static PublicKey getNextWorkingKey(List certs, int index) throws CertPathValidatorExceptionReturn 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
indexextended with DSA parameters if applicable. - Throws:
AnnotatedException- if DSA parameters cannot be inherited.CertPathValidatorException
-
findIssuerCerts
protected static Collection findIssuerCerts(X509Certificate cert, ExtendedPKIXBuilderParameters pkixParams) throws AnnotatedExceptionFind the issuer certificates of a given certificate.- Parameters:
cert- The certificate for which an issuer should be found.pkixParams-- Returns:
- A
Collectionobject containing the issuerX509Certificates. Nevernull. - Throws:
AnnotatedException- if an error occurs.
-
verifyX509Certificate
protected static void verifyX509Certificate(X509Certificate cert, PublicKey publicKey, String sigProvider) throws GeneralSecurityException- Throws:
GeneralSecurityException
-