public abstract class Validator
extends java.lang.Object
The model is that a Validator instance is created specifying validation settings, such as trust anchors or PKIX parameters. Then one or more paths are validated using those parameters. In some cases, additional information can be provided per path validation. This is independent of the validation parameters and currently only used for TLS server validation.
Path validation is performed by calling one of the validate() methods. It specifies a suggested path to be used for validation if available, or only the end entity certificate otherwise. Optionally additional certificates can be specified that the caller believes could be helpful. Implementations are free to make use of this information or validate the path using other means. validate() also checks that the end entity certificate is suitable for the intended purpose as described below.
There are two orthogonal parameters to select the Validator implementation: type and variant. Type selects the validation algorithm. Currently supported are TYPE_SIMPLE and TYPE_PKIX. See SimpleValidator and PKIXValidator for details.
Variant controls additional extension checks. Currently supported are five variants:
Examples:
// instantiate validator specifying type, variant, and trust anchors
Validator validator = Validator.getInstance(Validator.TYPE_PKIX,
Validator.VAR_TLS_CLIENT,
trustedCerts);
// validate one or more chains using the validator
validator.validate(chain); // throws CertificateException if failed
SimpleValidator,
PKIXValidator,
EndEntityChecker| Modifier and Type | Field and Description |
|---|---|
static java.security.cert.CertificateFactory |
CERT_FACTORY_DEFAULT
Фабрика сертификатов (default).
|
static java.lang.String |
TYPE_LIBSSPI
Constant for a validator of type LIBSSPI.
|
static java.lang.String |
TYPE_PKIX
Constant for a validator of type PKIX.
|
static java.lang.String |
TYPE_SIMPLE
Constant for a validator of type Simple.
|
static java.lang.String |
VAR_CODE_SIGNING
Constant for a Code Signing variant of a validator.
|
static java.lang.String |
VAR_GENERIC
Constant for a Generic variant of a validator.
|
static java.lang.String |
VAR_JCE_SIGNING
Constant for a JCE Code Signing variant of a validator.
|
static java.lang.String |
VAR_PLUGIN_CODE_SIGNING
Constant for a Code Signing variant of a validator for use by
the J2SE Plugin/WebStart code.
|
static java.lang.String |
VAR_TLS_CLIENT
Constant for a TLS Client variant of a validator.
|
static java.lang.String |
VAR_TLS_SERVER
Constant for a TLS Server variant of a validator.
|
static java.lang.String |
VAR_TSA_SERVER
Constant for a TSA Server variant of a validator.
|
| Modifier and Type | Method and Description |
|---|---|
static Validator |
getInstance(java.lang.String type,
java.lang.String variant,
java.util.Collection<java.security.cert.X509Certificate> trustedCerts)
Get a new Validator instance using the Set of X509Certificates as trust
anchors.
|
static Validator |
getInstance(java.lang.String type,
java.lang.String variant,
java.security.KeyStore ks)
Get a new Validator instance using the trusted certificates from the
specified KeyStore as trust anchors.
|
static Validator |
getInstance(java.lang.String type,
java.lang.String variant,
java.security.cert.PKIXBuilderParameters params)
Get a new Validator instance using the provided PKIXBuilderParameters.
|
abstract java.util.Collection<java.security.cert.X509Certificate> |
getTrustedCertificates()
Returns an immutable Collection of the X509Certificates this instance
uses as trust anchors.
|
static boolean |
isValid(java.security.cert.X509Certificate cert,
java.util.Date date)
Функция проверки действительности данноо сертификата.
|
void |
setValidationDate(java.util.Date validationDate)
Deprecated.
|
java.security.cert.X509Certificate[] |
validate(java.security.cert.X509Certificate[] chain)
Validate the given certificate chain.
|
java.security.cert.X509Certificate[] |
validate(java.security.cert.X509Certificate[] chain,
java.util.Collection<java.security.cert.X509Certificate> otherCerts)
Validate the given certificate chain.
|
java.security.cert.X509Certificate[] |
validate(java.security.cert.X509Certificate[] chain,
java.util.Collection<java.security.cert.X509Certificate> otherCerts,
java.security.AlgorithmConstraints constraints,
java.lang.Object parameter)
Validate the given certificate chain.
|
java.security.cert.X509Certificate[] |
validate(java.security.cert.X509Certificate[] chain,
java.util.Collection<java.security.cert.X509Certificate> otherCerts,
java.lang.Object parameter)
Validate the given certificate chain.
|
public static final java.lang.String TYPE_SIMPLE
public static final java.lang.String TYPE_PKIX
public static final java.lang.String TYPE_LIBSSPI
public static final java.lang.String VAR_GENERIC
public static final java.lang.String VAR_CODE_SIGNING
public static final java.lang.String VAR_JCE_SIGNING
public static final java.lang.String VAR_TLS_CLIENT
public static final java.lang.String VAR_TLS_SERVER
public static final java.lang.String VAR_TSA_SERVER
public static final java.lang.String VAR_PLUGIN_CODE_SIGNING
public static java.security.cert.CertificateFactory CERT_FACTORY_DEFAULT
public static Validator getInstance(java.lang.String type, java.lang.String variant, java.security.KeyStore ks)
public static Validator getInstance(java.lang.String type, java.lang.String variant, java.util.Collection<java.security.cert.X509Certificate> trustedCerts)
public static Validator getInstance(java.lang.String type, java.lang.String variant, java.security.cert.PKIXBuilderParameters params)
public final java.security.cert.X509Certificate[] validate(java.security.cert.X509Certificate[] chain)
throws java.security.cert.CertificateException
java.security.cert.CertificateExceptionpublic final java.security.cert.X509Certificate[] validate(java.security.cert.X509Certificate[] chain,
java.util.Collection<java.security.cert.X509Certificate> otherCerts)
throws java.security.cert.CertificateException
java.security.cert.CertificateExceptionpublic final java.security.cert.X509Certificate[] validate(java.security.cert.X509Certificate[] chain,
java.util.Collection<java.security.cert.X509Certificate> otherCerts,
java.lang.Object parameter)
throws java.security.cert.CertificateException
Parameter is an additional parameter with variant specific meaning. Currently, it is only defined for TLS_SERVER variant validators, where it must be non null and the name of the TLS key exchange algorithm being used (see JSSE X509TrustManager specification). In the future, it could be used to pass in a PKCS#7 object for code signing to check time stamps.
java.security.cert.CertificateExceptionpublic final java.security.cert.X509Certificate[] validate(java.security.cert.X509Certificate[] chain,
java.util.Collection<java.security.cert.X509Certificate> otherCerts,
java.security.AlgorithmConstraints constraints,
java.lang.Object parameter)
throws java.security.cert.CertificateException
chain - the target certificate chainotherCerts - a Collection of additional X509Certificates that
could be helpful for path building (or null)constraints - algorithm constraints for certification path
processingparameter - an additional parameter with variant specific meaning.
Currently, it is only defined for TLS_SERVER variant validators,
where it must be non null and the name of the TLS key exchange
algorithm being used (see JSSE X509TrustManager specification).
In the future, it could be used to pass in a PKCS#7 object for
code signing to check time stamps.java.security.cert.CertificateExceptionpublic abstract java.util.Collection<java.security.cert.X509Certificate> getTrustedCertificates()
@Deprecated public void setValidationDate(java.util.Date validationDate)
public static boolean isValid(java.security.cert.X509Certificate cert,
java.util.Date date)
cert - сертификатdate - дата