APIdia Launch Partner
Top Description Fields Constructors Methods
sun.security.validator

public final Class PKIXValidator

extends Validator
Class Inheritance
Imports
java.security.*, java.security.cert.*, java.util.*, javax.security.auth.x500.X500Principal, sun.security.provider.certpath.AlgorithmChecker, .PKIXExtendedParameters, sun.security.util.SecurityProperties

Validator implementation built on the PKIX CertPath API. This implementation will be emphasized going forward.

Note that the validate() implementation tries to use a PKIX validator if that appears possible and a PKIX builder otherwise. This increases performance and currently also leads to better exception messages in case of failures.

PKIXValidator objects are immutable once they have been created. Please DO NOT add methods that can change the state of an instance once it has been created.

Author
Andreas Sterbenz

Field Summary

Modifier and TypeField and Description
private static final boolean
ALLOW_NON_CA_ANCHOR

System or security property that if set (or set to "true"), allows trust anchor certificates to be used if they do not have the proper CA extensions.

private int
private static final boolean
checkTLSRevocation

Flag indicating whether to enable revocation check for the PKIX trust manager.

private final CertificateFactory
private final PKIXBuilderParameters
private final Set<X509Certificate>
private final Map<X500Principal, List<PublicKey>>
Inherited from sun.security.validator.Validator:
CHAIN0endEntityCheckerTYPE_PKIXTYPE_SIMPLEvalidationDateVAR_CODE_SIGNINGVAR_GENERICVAR_JCE_SIGNINGVAR_TLS_CLIENTVAR_TLS_SERVERVAR_TSA_SERVERvariant

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv

Method Summary

Modifier and TypeMethod and Description
private static void
addResponses(PKIXBuilderParameters
the pkixParameters object that will be used in path validation.
pkixParams
,
X509Certificate[]
the chain of certificates to verify
chain
,
List<byte[]>
a List of zero or more byte arrays, each one being a DER-encoded OCSP response (per RFC 6960). Entries in the List must match the order of the certificates in the chain parameter.
responseList
)

For OCSP Stapling, add responses that came in during the handshake into a PKIXRevocationChecker so we can evaluate them.

private static boolean
private X509Certificate[]
private X509Certificate[]
pack-priv X509Certificate[]
engineValidate(X509Certificate[] chain, Collection<X509Certificate> otherCerts, List<byte[]> responseList, AlgorithmConstraints constraints, Object parameter)

Implements abstract sun.security.validator.Validator.engineValidate.

public int

Returns:

the length of the last certification path passed to CertPathValidator.validate, or -1 if it has not been invoked yet
getCertPathLength
()

Returns the length of the last certification path that is validated by CertPathValidator.

public PKIXBuilderParameters
getParameters()

Return the PKIX parameters used by this instance.

public Collection<X509Certificate>
getTrustedCertificates()

Implements abstract sun.security.validator.Validator.getTrustedCertificates.

Returns an immutable Collection of the X509Certificates this instance uses as trust anchors.

private void
setDate(PKIXBuilderParameters params)

Set the check date (for debugging).

private void
setDefaultParameters(String variant)

Set J2SE global default PKIX parameters.

private Map<X500Principal, List<PublicKey>>

Returns:

Map containing each subject DN and one or more public keys tied to those DNs.
setTrustedSubjects
()

Populate the trustedSubjects Map using the DN and public keys from the list of trusted certificates

private static X509Certificate[]
private static void
verifyTrustAnchor(X509Certificate trustedCert)

Verify that a trust anchor certificate is a CA certificate.

Inherited from sun.security.validator.Validator:
getInstancegetInstancegetInstancesetValidationDatevalidatevalidatevalidatevalidate

Field Detail

ALLOW_NON_CA_ANCHORback to summary
private static final boolean ALLOW_NON_CA_ANCHOR

System or security property that if set (or set to "true"), allows trust anchor certificates to be used if they do not have the proper CA extensions. Set to false if prop is not set, or set to any other value.

certPathLengthback to summary
private int certPathLength
checkTLSRevocationback to summary
private static final boolean checkTLSRevocation

Flag indicating whether to enable revocation check for the PKIX trust manager. Typically, this will only work if the PKIX implementation supports CRL distribution points as we do not manually set up CertStores.

factoryback to summary
private final CertificateFactory factory
parameterTemplateback to summary
private final PKIXBuilderParameters parameterTemplate
trustedCertsback to summary
private final Set<X509Certificate> trustedCerts
trustedSubjectsback to summary
private final Map<X500Principal, List<PublicKey>> trustedSubjects

Constructor Detail

PKIXValidatorback to summary
pack-priv PKIXValidator(String variant, Collection<X509Certificate> trustedCerts)
PKIXValidatorback to summary
pack-priv PKIXValidator(String variant, PKIXBuilderParameters params)

Method Detail

addResponsesback to summary
private static void addResponses(PKIXBuilderParameters pkixParams, X509Certificate[] chain, List<byte[]> responseList)

For OCSP Stapling, add responses that came in during the handshake into a PKIXRevocationChecker so we can evaluate them.

Parameters
pkixParams:PKIXBuilderParameters

the pkixParameters object that will be used in path validation.

chain:X509Certificate[]

the chain of certificates to verify

responseList:List<byte[]>

a List of zero or more byte arrays, each one being a DER-encoded OCSP response (per RFC 6960). Entries in the List must match the order of the certificates in the chain parameter.

allowNonCaAnchorback to summary
private static boolean allowNonCaAnchor()
doBuildback to summary
private X509Certificate[] doBuild(X509Certificate[] chain, Collection<X509Certificate> otherCerts, PKIXBuilderParameters params) throws CertificateException
doValidateback to summary
private X509Certificate[] doValidate(X509Certificate[] chain, PKIXBuilderParameters params) throws CertificateException
engineValidateback to summary
pack-priv X509Certificate[] engineValidate(X509Certificate[] chain, Collection<X509Certificate> otherCerts, List<byte[]> responseList, AlgorithmConstraints constraints, Object parameter) throws CertificateException

Implements abstract sun.security.validator.Validator.engineValidate.

Annotations
@Override
getCertPathLengthback to summary
public int getCertPathLength()

Returns the length of the last certification path that is validated by CertPathValidator. This is intended primarily as a callback mechanism for PKIXCertPathCheckers to determine the length of the certification path that is being validated. It is necessary since engineValidate() may modify the length of the path.

Returns:int

the length of the last certification path passed to CertPathValidator.validate, or -1 if it has not been invoked yet

getParametersback to summary
public PKIXBuilderParameters getParameters()

Return the PKIX parameters used by this instance. An application may modify the parameters but must make sure not to perform any concurrent validations.

getTrustedCertificatesback to summary
public Collection<X509Certificate> getTrustedCertificates()

Implements abstract sun.security.validator.Validator.getTrustedCertificates.

Doc from sun.security.validator.Validator.getTrustedCertificates.

Returns an immutable Collection of the X509Certificates this instance uses as trust anchors.

Annotations
@Override
setDateback to summary
private void setDate(PKIXBuilderParameters params)

Set the check date (for debugging).

setDefaultParametersback to summary
private void setDefaultParameters(String variant)

Set J2SE global default PKIX parameters. Currently, hardcoded to disable revocation checking. In the future, this should be configurable.

setTrustedSubjectsback to summary
private Map<X500Principal, List<PublicKey>> setTrustedSubjects()

Populate the trustedSubjects Map using the DN and public keys from the list of trusted certificates

Returns:Map<X500Principal, List<PublicKey>>

Map containing each subject DN and one or more public keys tied to those DNs.

toArrayback to summary
private static X509Certificate[] toArray(CertPath path, TrustAnchor anchor) throws CertificateException
verifyTrustAnchorback to summary
private static void verifyTrustAnchor(X509Certificate trustedCert) throws ValidatorException

Verify that a trust anchor certificate is a CA certificate.