APIdia Launch Partner
Top Description Fields Constructors Methods
java.security.cert

public Class PKIXParameters

extends Object
implements CertPathParameters
Class Inheritance
All Implemented Interfaces
java.security.cert.CertPathParameters, java.lang.Cloneable
Known Direct Subclasses
java.security.cert.PKIXBuilderParameters
Imports
java.security.InvalidAlgorithmParameterException, .KeyStore, .KeyStoreException, java.util.ArrayList, .Collections, .Date, .Enumeration, .HashSet, .Iterator, .List, .Set

Parameters used as input for the PKIX CertPathValidator algorithm.

A PKIX CertPathValidator uses these parameters to validate a CertPath according to the PKIX certification path validation algorithm.

To instantiate a PKIXParameters object, an application must specify one or more most-trusted CAs as defined by the PKIX certification path validation algorithm. The most-trusted CAs can be specified using one of two constructors. An application can call PKIXParameters(Set), specifying a Set of TrustAnchor objects, each of which identify a most-trusted CA. Alternatively, an application can call PKIXParameters(KeyStore), specifying a KeyStore instance containing trusted certificate entries, each of which will be considered as a most-trusted CA.

Once a PKIXParameters object has been created, other parameters can be specified (by calling setInitialPolicies or setDate, for instance) and then the PKIXParameters is passed along with the CertPath to be validated to CertPathValidator.validate.

Any parameter that is not set (or is set to null) will be set to the default value for that parameter. The default value for the date parameter is null, which indicates the current time when the path is validated. The default for the remaining parameters is the least constrained.

Concurrent Access

Unless otherwise specified, the methods defined in this class are not thread-safe. Multiple threads that need to access a single object concurrently should synchronize amongst themselves and provide the necessary locking. Multiple threads each manipulating separate objects need not synchronize.

Authors
Sean Mullan, Yassir Elley
Since
1.4
See Also
CertPathValidator

Field Summary

Modifier and TypeField and Description
private boolean
private List<PKIXCertPathChecker>
private CertSelector
private List<CertStore>
private Date
private boolean
private boolean
private boolean
private boolean
private String
private Set<String>
private Set<TrustAnchor>

Constructor Summary

AccessConstructor and Description
public
PKIXParameters(Set<TrustAnchor>
a Set of TrustAnchors
trustAnchors
)

Creates an instance of PKIXParameters with the specified Set of most-trusted CAs.

public
PKIXParameters(KeyStore
a KeyStore from which the set of most-trusted CAs will be populated
keystore
)

Creates an instance of PKIXParameters that populates the set of most-trusted CAs from the trusted certificate entries contained in the specified KeyStore.

Method Summary

Modifier and TypeMethod and Description
public void
addCertPathChecker(PKIXCertPathChecker
a PKIXCertPathChecker to add to the list of checks. If null, the checker is ignored (not added to list).
checker
)

Adds a PKIXCertPathChecker to the list of certification path checkers.

public void
addCertStore(CertStore
the CertStore to add. If null, the store is ignored (not added to list).
store
)

Adds a CertStore to the end of the list of CertStores used in finding certificates and CRLs.

public Object

Returns:

a copy of this PKIXParameters object
clone
()

Overrides java.lang.Object.clone.

Implements java.security.cert.CertPathParameters.clone.

Makes a copy of this PKIXParameters object.

public List<PKIXCertPathChecker>

Returns:

an immutable List of PKIXCertPathCheckers (may be empty, but not null)
getCertPathCheckers
()

Returns the List of certification path checkers.

public List<CertStore>

Returns:

an immutable List of CertStores (may be empty, but never null)
getCertStores
()

Returns an immutable List of CertStores that are used to find certificates and CRLs.

public Date

Returns:

the Date, or null if not set
getDate
()

Returns the time for which the validity of the certification path should be determined.

public Set<String>

Returns:

an immutable Set of initial policy OIDs in String format, or an empty Set (implying any policy is acceptable). Never returns null.
getInitialPolicies
()

Returns an immutable Set of initial policy identifiers (OID strings), indicating that any one of these policies would be acceptable to the certificate user for the purposes of certification path processing.

public boolean

Returns:

the current value of the PolicyQualifiersRejected flag
getPolicyQualifiersRejected
()

Gets the PolicyQualifiersRejected flag.

public String

Returns:

the signature provider's name (or null)
getSigProvider
()

Returns the signature provider's name, or null if not set.

public CertSelector

Returns:

a CertSelector specifying the constraints on the target certificate (or null)
getTargetCertConstraints
()

Returns the required constraints on the target certificate.

public Set<TrustAnchor>

Returns:

an immutable Set of TrustAnchors (never null)
getTrustAnchors
()

Returns an immutable Set of the most-trusted CAs.

public boolean

Returns:

true if the any policy OID is inhibited, false otherwise
isAnyPolicyInhibited
()

Checks whether the any policy OID should be processed if it is included in a certificate.

public boolean

Returns:

true if explicit policy is required, false otherwise
isExplicitPolicyRequired
()

Checks if explicit policy is required.

public boolean

Returns:

true if policy mapping is inhibited, false otherwise
isPolicyMappingInhibited
()

Checks if policy mapping is inhibited.

public boolean

Returns:

the current value of the RevocationEnabled flag
isRevocationEnabled
()

Checks the RevocationEnabled flag.

public void
setAnyPolicyInhibited(boolean
true if the any policy OID is to be inhibited, false otherwise
val
)

Sets state to determine if the any policy OID should be processed if it is included in a certificate.

public void
setCertPathCheckers(List<PKIXCertPathChecker>
a List of PKIXCertPathCheckers. May be null, in which case no additional checkers will be used.
checkers
)

Sets a List of additional certification path checkers.

public void
setCertStores(List<CertStore>
a List of CertStores (or null)
stores
)

Sets the list of CertStores to be used in finding certificates and CRLs.

public void
setDate(Date
the Date, or null for the current time
date
)

Sets the time for which the validity of the certification path should be determined.

public void
setExplicitPolicyRequired(boolean
true if explicit policy is to be required, false otherwise
val
)

Sets the ExplicitPolicyRequired flag.

public void
setInitialPolicies(Set<String>
a Set of initial policy OIDs in String format (or null)
initialPolicies
)

Sets the Set of initial policy identifiers (OID strings), indicating that any one of these policies would be acceptable to the certificate user for the purposes of certification path processing.

public void
setPolicyMappingInhibited(boolean
true if policy mapping is to be inhibited, false otherwise
val
)

Sets the PolicyMappingInhibited flag.

public void
setPolicyQualifiersRejected(boolean
the new value of the PolicyQualifiersRejected flag
qualifiersRejected
)

Sets the PolicyQualifiersRejected flag.

public void
setRevocationEnabled(boolean
the new value of the RevocationEnabled flag
val
)

Sets the RevocationEnabled flag.

public void
setSigProvider(String
the signature provider's name (or null)
sigProvider
)

Sets the signature provider's name.

public void
setTargetCertConstraints(CertSelector
a CertSelector specifying the constraints on the target certificate (or null)
selector
)

Sets the required constraints on the target certificate.

public void
setTrustAnchors(Set<TrustAnchor>
a Set of TrustAnchors
trustAnchors
)

Sets the Set of most-trusted CAs.

public String

Returns:

a formatted string describing the parameters.
toString
()

Overrides java.lang.Object.toString.

Returns a formatted string describing the parameters.

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

anyPolicyInhibitedback to summary
private boolean anyPolicyInhibited
certPathCheckersback to summary
private List<PKIXCertPathChecker> certPathCheckers
certSelectorback to summary
private CertSelector certSelector
certStoresback to summary
private List<CertStore> certStores
dateback to summary
private Date date
explicitPolicyRequiredback to summary
private boolean explicitPolicyRequired
policyMappingInhibitedback to summary
private boolean policyMappingInhibited
policyQualifiersRejectedback to summary
private boolean policyQualifiersRejected
revocationEnabledback to summary
private boolean revocationEnabled
sigProviderback to summary
private String sigProvider
unmodInitialPoliciesback to summary
private Set<String> unmodInitialPolicies
unmodTrustAnchorsback to summary
private Set<TrustAnchor> unmodTrustAnchors

Constructor Detail

PKIXParametersback to summary
public PKIXParameters(Set<TrustAnchor> trustAnchors) throws InvalidAlgorithmParameterException

Creates an instance of PKIXParameters with the specified Set of most-trusted CAs. Each element of the set is a TrustAnchor.

Note that the Set is copied to protect against subsequent modifications.

Parameters
trustAnchors:Set<TrustAnchor>

a Set of TrustAnchors

Annotations
@SuppressWarnings:this-escape
Exceptions
InvalidAlgorithmParameterException:
if the specified Set is empty (trustAnchors.isEmpty() == true)
NullPointerException:
if the specified Set is null
ClassCastException:
if any of the elements in the Set are not of type java.security.cert.TrustAnchor
PKIXParametersback to summary
public PKIXParameters(KeyStore keystore) throws KeyStoreException, InvalidAlgorithmParameterException

Creates an instance of PKIXParameters that populates the set of most-trusted CAs from the trusted certificate entries contained in the specified KeyStore. Only keystore entries that contain trusted X509Certificates are considered; all other certificate types are ignored.

Parameters
keystore:KeyStore

a KeyStore from which the set of most-trusted CAs will be populated

Annotations
@SuppressWarnings:this-escape
Exceptions
KeyStoreException:
if the keystore has not been initialized
InvalidAlgorithmParameterException:
if the keystore does not contain at least one trusted certificate entry
NullPointerException:
if the keystore is null

Method Detail

addCertPathCheckerback to summary
public void addCertPathChecker(PKIXCertPathChecker checker)

Adds a PKIXCertPathChecker to the list of certification path checkers. See the setCertPathCheckers method for more details.

Note that the PKIXCertPathChecker is cloned to protect against subsequent modifications.

Parameters
checker:PKIXCertPathChecker

a PKIXCertPathChecker to add to the list of checks. If null, the checker is ignored (not added to list).

addCertStoreback to summary
public void addCertStore(CertStore store)

Adds a CertStore to the end of the list of CertStores used in finding certificates and CRLs.

Parameters
store:CertStore

the CertStore to add. If null, the store is ignored (not added to list).

cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Implements java.security.cert.CertPathParameters.clone.

Makes a copy of this PKIXParameters object. Changes to the copy will not affect the original and vice versa.

Returns:Object

a copy of this PKIXParameters object

getCertPathCheckersback to summary
public List<PKIXCertPathChecker> getCertPathCheckers()

Returns the List of certification path checkers. The returned List is immutable, and each PKIXCertPathChecker in the List is cloned to protect against subsequent modifications.

Returns:List<PKIXCertPathChecker>

an immutable List of PKIXCertPathCheckers (may be empty, but not null)

See Also
setCertPathCheckers
getCertStoresback to summary
public List<CertStore> getCertStores()

Returns an immutable List of CertStores that are used to find certificates and CRLs.

Returns:List<CertStore>

an immutable List of CertStores (may be empty, but never null)

See Also
setCertStores
getDateback to summary
public Date getDate()

Returns the time for which the validity of the certification path should be determined. If null, the current time is used.

Note that the Date returned is copied to protect against subsequent modifications.

Returns:Date

the Date, or null if not set

See Also
setDate
getInitialPoliciesback to summary
public Set<String> getInitialPolicies()

Returns an immutable Set of initial policy identifiers (OID strings), indicating that any one of these policies would be acceptable to the certificate user for the purposes of certification path processing. The default return value is an empty Set, which is interpreted as meaning that any policy would be acceptable.

Returns:Set<String>

an immutable Set of initial policy OIDs in String format, or an empty Set (implying any policy is acceptable). Never returns null.

See Also
setInitialPolicies
getPolicyQualifiersRejectedback to summary
public boolean getPolicyQualifiersRejected()

Gets the PolicyQualifiersRejected flag. If this flag is true, certificates that include policy qualifiers in a certificate policies extension that is marked critical are rejected. If the flag is false, certificates are not rejected on this basis.

When a PKIXParameters object is created, this flag is set to true. This setting reflects the most common (and simplest) strategy for processing policy qualifiers. Applications that want to use a more sophisticated policy must set this flag to false.

Returns:boolean

the current value of the PolicyQualifiersRejected flag

See Also
setPolicyQualifiersRejected
getSigProviderback to summary
public String getSigProvider()

Returns the signature provider's name, or null if not set.

Returns:String

the signature provider's name (or null)

See Also
setSigProvider
getTargetCertConstraintsback to summary
public CertSelector getTargetCertConstraints()

Returns the required constraints on the target certificate. The constraints are returned as an instance of CertSelector. If null, no constraints are defined.

Note that the CertSelector returned is cloned to protect against subsequent modifications.

Returns:CertSelector

a CertSelector specifying the constraints on the target certificate (or null)

See Also
setTargetCertConstraints
getTrustAnchorsback to summary
public Set<TrustAnchor> getTrustAnchors()

Returns an immutable Set of the most-trusted CAs.

Returns:Set<TrustAnchor>

an immutable Set of TrustAnchors (never null)

See Also
setTrustAnchors
isAnyPolicyInhibitedback to summary
public boolean isAnyPolicyInhibited()

Checks whether the any policy OID should be processed if it is included in a certificate.

Returns:boolean

true if the any policy OID is inhibited, false otherwise

isExplicitPolicyRequiredback to summary
public boolean isExplicitPolicyRequired()

Checks if explicit policy is required. If this flag is true, an acceptable policy needs to be explicitly identified in every certificate. By default, the ExplicitPolicyRequired flag is false.

Returns:boolean

true if explicit policy is required, false otherwise

isPolicyMappingInhibitedback to summary
public boolean isPolicyMappingInhibited()

Checks if policy mapping is inhibited. If this flag is true, policy mapping is inhibited. By default, policy mapping is not inhibited (the flag is false).

Returns:boolean

true if policy mapping is inhibited, false otherwise

isRevocationEnabledback to summary
public boolean isRevocationEnabled()

Checks the RevocationEnabled flag. If this flag is true, the default revocation checking mechanism of the underlying PKIX service provider will be used, unless a PKIXRevocationChecker is passed in as a CertPathChecker. If this flag is false, the default revocation checking mechanism will be disabled (not used). See the setRevocationEnabled method for more details on setting the value of this flag.

Returns:boolean

the current value of the RevocationEnabled flag

setAnyPolicyInhibitedback to summary
public void setAnyPolicyInhibited(boolean val)

Sets state to determine if the any policy OID should be processed if it is included in a certificate. By default, the any policy OID is not inhibited (isAnyPolicyInhibited() returns false).

Parameters
val:boolean

true if the any policy OID is to be inhibited, false otherwise

setCertPathCheckersback to summary
public void setCertPathCheckers(List<PKIXCertPathChecker> checkers)

Sets a List of additional certification path checkers. If the specified List contains an object that is not a PKIXCertPathChecker, it is ignored.

Each PKIXCertPathChecker specified implements additional checks on a certificate. Typically, these are checks to process and verify private extensions contained in certificates. Each PKIXCertPathChecker should be instantiated with any initialization parameters needed to execute the check.

This method allows sophisticated applications to extend a PKIX CertPathValidator or CertPathBuilder. Each of the specified PKIXCertPathCheckers will be called, in turn, by a PKIX CertPathValidator or CertPathBuilder for each certificate processed or validated.

Regardless of whether these additional PKIXCertPathCheckers are set, a PKIX CertPathValidator or CertPathBuilder must perform all of the required PKIX checks on each certificate. The one exception to this rule is if the RevocationEnabled flag is set to false (see the setRevocationEnabled method).

Note that the List supplied here is copied and each PKIXCertPathChecker in the list is cloned to protect against subsequent modifications.

Parameters
checkers:List<PKIXCertPathChecker>

a List of PKIXCertPathCheckers. May be null, in which case no additional checkers will be used.

Exceptions
ClassCastException:
if any of the elements in the list are not of type java.security.cert.PKIXCertPathChecker
See Also
getCertPathCheckers
setCertStoresback to summary
public void setCertStores(List<CertStore> stores)

Sets the list of CertStores to be used in finding certificates and CRLs. May be null, in which case no CertStores will be used. The first CertStores in the list may be preferred to those that appear later.

Note that the List is copied to protect against subsequent modifications.

Parameters
stores:List<CertStore>

a List of CertStores (or null)

Exceptions
ClassCastException:
if any of the elements in the list are not of type java.security.cert.CertStore
See Also
getCertStores
setDateback to summary
public void setDate(Date date)

Sets the time for which the validity of the certification path should be determined. If null, the current time is used.

Note that the Date supplied here is copied to protect against subsequent modifications.

Parameters
date:Date

the Date, or null for the current time

See Also
getDate
setExplicitPolicyRequiredback to summary
public void setExplicitPolicyRequired(boolean val)

Sets the ExplicitPolicyRequired flag. If this flag is true, an acceptable policy needs to be explicitly identified in every certificate. By default, the ExplicitPolicyRequired flag is false.

Parameters
val:boolean

true if explicit policy is to be required, false otherwise

setInitialPoliciesback to summary
public void setInitialPolicies(Set<String> initialPolicies)

Sets the Set of initial policy identifiers (OID strings), indicating that any one of these policies would be acceptable to the certificate user for the purposes of certification path processing. By default, any policy is acceptable (i.e. all policies), so a user that wants to allow any policy as acceptable does not need to call this method, or can call it with an empty Set (or null).

Note that the Set is copied to protect against subsequent modifications.

Parameters
initialPolicies:Set<String>

a Set of initial policy OIDs in String format (or null)

Exceptions
ClassCastException:
if any of the elements in the set are not of type String
See Also
getInitialPolicies
setPolicyMappingInhibitedback to summary
public void setPolicyMappingInhibited(boolean val)

Sets the PolicyMappingInhibited flag. If this flag is true, policy mapping is inhibited. By default, policy mapping is not inhibited (the flag is false).

Parameters
val:boolean

true if policy mapping is to be inhibited, false otherwise

setPolicyQualifiersRejectedback to summary
public void setPolicyQualifiersRejected(boolean qualifiersRejected)

Sets the PolicyQualifiersRejected flag. If this flag is true, certificates that include policy qualifiers in a certificate policies extension that is marked critical are rejected. If the flag is false, certificates are not rejected on this basis.

When a PKIXParameters object is created, this flag is set to true. This setting reflects the most common (and simplest) strategy for processing policy qualifiers. Applications that want to use a more sophisticated policy must set this flag to false.

Note that the PKIX certification path validation algorithm specifies that any policy qualifier in a certificate policies extension that is marked critical must be processed and validated. Otherwise the certification path must be rejected. If the policyQualifiersRejected flag is set to false, it is up to the application to validate all policy qualifiers in this manner in order to be PKIX compliant.

Parameters
qualifiersRejected:boolean

the new value of the PolicyQualifiersRejected flag

See Also
getPolicyQualifiersRejected, PolicyQualifierInfo
setRevocationEnabledback to summary
public void setRevocationEnabled(boolean val)

Sets the RevocationEnabled flag. If this flag is true, the default revocation checking mechanism of the underlying PKIX service provider will be used, unless a PKIXRevocationChecker is passed in as a CertPathChecker (see below for further explanation). If this flag is false, the default revocation checking mechanism will be disabled (not used).

When a PKIXParameters object is created, this flag is set to true. This setting reflects the most common strategy for checking revocation, since each service provider must support revocation checking to be PKIX compliant. Sophisticated applications should set this flag to false when it is not practical to use a PKIX service provider's default revocation checking mechanism or when an alternative revocation checking mechanism is to be substituted (by also calling the addCertPathChecker or setCertPathCheckers methods).

Note that when a PKIXRevocationChecker is passed in as a parameter via the addCertPathChecker or setCertPathCheckers methods, it will be used to check revocation irrespective of the setting of the RevocationEnabled flag.

Parameters
val:boolean

the new value of the RevocationEnabled flag

setSigProviderback to summary
public void setSigProvider(String sigProvider)

Sets the signature provider's name. The specified provider will be preferred when creating Signature objects. If null or not set, the first provider found supporting the algorithm will be used.

Parameters
sigProvider:String

the signature provider's name (or null)

See Also
getSigProvider
setTargetCertConstraintsback to summary
public void setTargetCertConstraints(CertSelector selector)

Sets the required constraints on the target certificate. The constraints are specified as an instance of CertSelector. If null, no constraints are defined.

Note that the CertSelector specified is cloned to protect against subsequent modifications.

Parameters
selector:CertSelector

a CertSelector specifying the constraints on the target certificate (or null)

See Also
getTargetCertConstraints
setTrustAnchorsback to summary
public void setTrustAnchors(Set<TrustAnchor> trustAnchors) throws InvalidAlgorithmParameterException

Sets the Set of most-trusted CAs.

Note that the Set is copied to protect against subsequent modifications.

Parameters
trustAnchors:Set<TrustAnchor>

a Set of TrustAnchors

Exceptions
InvalidAlgorithmParameterException:
if the specified Set is empty (trustAnchors.isEmpty() == true)
NullPointerException:
if the specified Set is null
ClassCastException:
if any of the elements in the set are not of type java.security.cert.TrustAnchor
See Also
getTrustAnchors
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a formatted string describing the parameters.

Returns:String

a formatted string describing the parameters.