java.security.cert
Class PKIXBuilderParameters

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.security.cert.PKIXParameters sample code for java.security.cert.PKIXParameters definition code for java.security.cert.PKIXParameters 
      extended by java.security.cert.PKIXBuilderParameters
All Implemented Interfaces:
Cloneable sample code for java.lang.Cloneable definition code for java.lang.Cloneable , CertPathParameters sample code for java.security.cert.CertPathParameters definition code for java.security.cert.CertPathParameters

public class PKIXBuilderParameters
extends PKIXParameters sample code for java.security.cert.PKIXParameters definition code for java.security.cert.PKIXParameters

Parameters used as input for the PKIX CertPathBuilder algorithm.

A PKIX CertPathBuilder uses these parameters to build sample code for java.security.cert.CertPathBuilder.build(java.security.cert.CertPathParameters) definition code for java.security.cert.CertPathBuilder.build(java.security.cert.CertPathParameters) a CertPath which has been validated according to the PKIX certification path validation algorithm.

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

In addition, an application must specify constraints on the target certificate that the CertPathBuilder will attempt to build a path to. The constraints are specified as a CertSelector object. These constraints should provide the CertPathBuilder with enough search criteria to find the target certificate. Minimal criteria for an X509Certificate usually include the subject name and/or one or more subject alternative names. If enough criteria is not specified, the CertPathBuilder may throw a CertPathBuilderException.

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.

Since:
1.4
See Also:
CertPathBuilder sample code for java.security.cert.CertPathBuilder definition code for java.security.cert.CertPathBuilder

Constructor Summary
PKIXBuilderParameters sample code for java.security.cert.PKIXBuilderParameters.PKIXBuilderParameters(java.security.KeyStore, java.security.cert.CertSelector) definition code for java.security.cert.PKIXBuilderParameters.PKIXBuilderParameters(java.security.KeyStore, java.security.cert.CertSelector) (KeyStore sample code for java.security.KeyStore definition code for java.security.KeyStore  keystore, CertSelector sample code for java.security.cert.CertSelector definition code for java.security.cert.CertSelector  targetConstraints)
          Creates an instance of PKIXBuilderParameters that populates the set of most-trusted CAs from the trusted certificate entries contained in the specified KeyStore.
PKIXBuilderParameters sample code for java.security.cert.PKIXBuilderParameters.PKIXBuilderParameters(java.util.Set, java.security.cert.CertSelector) definition code for java.security.cert.PKIXBuilderParameters.PKIXBuilderParameters(java.util.Set, java.security.cert.CertSelector) (Set sample code for java.util.Set definition code for java.util.Set <TrustAnchor sample code for java.security.cert.TrustAnchor definition code for java.security.cert.TrustAnchor > trustAnchors, CertSelector sample code for java.security.cert.CertSelector definition code for java.security.cert.CertSelector  targetConstraints)
          Creates an instance of PKIXBuilderParameters with the specified Set of most-trusted CAs.
 
Method Summary
 int getMaxPathLength sample code for java.security.cert.PKIXBuilderParameters.getMaxPathLength() definition code for java.security.cert.PKIXBuilderParameters.getMaxPathLength() ()
          Returns the value of the maximum number of intermediate non-self-issued certificates that may exist in a certification path.
 void setMaxPathLength sample code for java.security.cert.PKIXBuilderParameters.setMaxPathLength(int) definition code for java.security.cert.PKIXBuilderParameters.setMaxPathLength(int) (int maxPathLength)
          Sets the value of the maximum number of non-self-issued intermediate certificates that may exist in a certification path.
 String sample code for java.lang.String definition code for java.lang.String toString sample code for java.security.cert.PKIXBuilderParameters.toString() definition code for java.security.cert.PKIXBuilderParameters.toString() ()
          Returns a formatted string describing the parameters.
 
Methods inherited from class java.security.cert.PKIXParameters sample code for java.security.cert.PKIXParameters definition code for java.security.cert.PKIXParameters
addCertPathChecker sample code for java.security.cert.PKIXParameters.addCertPathChecker(java.security.cert.PKIXCertPathChecker) definition code for java.security.cert.PKIXParameters.addCertPathChecker(java.security.cert.PKIXCertPathChecker) , addCertStore sample code for java.security.cert.PKIXParameters.addCertStore(java.security.cert.CertStore) definition code for java.security.cert.PKIXParameters.addCertStore(java.security.cert.CertStore) , clone sample code for java.security.cert.PKIXParameters.clone() definition code for java.security.cert.PKIXParameters.clone() , getCertPathCheckers sample code for java.security.cert.PKIXParameters.getCertPathCheckers() definition code for java.security.cert.PKIXParameters.getCertPathCheckers() , getCertStores sample code for java.security.cert.PKIXParameters.getCertStores() definition code for java.security.cert.PKIXParameters.getCertStores() , getDate sample code for java.security.cert.PKIXParameters.getDate() definition code for java.security.cert.PKIXParameters.getDate() , getInitialPolicies sample code for java.security.cert.PKIXParameters.getInitialPolicies() definition code for java.security.cert.PKIXParameters.getInitialPolicies() , getPolicyQualifiersRejected sample code for java.security.cert.PKIXParameters.getPolicyQualifiersRejected() definition code for java.security.cert.PKIXParameters.getPolicyQualifiersRejected() , getSigProvider sample code for java.security.cert.PKIXParameters.getSigProvider() definition code for java.security.cert.PKIXParameters.getSigProvider() , getTargetCertConstraints sample code for java.security.cert.PKIXParameters.getTargetCertConstraints() definition code for java.security.cert.PKIXParameters.getTargetCertConstraints() , getTrustAnchors sample code for java.security.cert.PKIXParameters.getTrustAnchors() definition code for java.security.cert.PKIXParameters.getTrustAnchors() , isAnyPolicyInhibited sample code for java.security.cert.PKIXParameters.isAnyPolicyInhibited() definition code for java.security.cert.PKIXParameters.isAnyPolicyInhibited() , isExplicitPolicyRequired sample code for java.security.cert.PKIXParameters.isExplicitPolicyRequired() definition code for java.security.cert.PKIXParameters.isExplicitPolicyRequired() , isPolicyMappingInhibited sample code for java.security.cert.PKIXParameters.isPolicyMappingInhibited() definition code for java.security.cert.PKIXParameters.isPolicyMappingInhibited() , isRevocationEnabled sample code for java.security.cert.PKIXParameters.isRevocationEnabled() definition code for java.security.cert.PKIXParameters.isRevocationEnabled() , setAnyPolicyInhibited sample code for java.security.cert.PKIXParameters.setAnyPolicyInhibited(boolean) definition code for java.security.cert.PKIXParameters.setAnyPolicyInhibited(boolean) , setCertPathCheckers sample code for java.security.cert.PKIXParameters.setCertPathCheckers(java.util.List) definition code for java.security.cert.PKIXParameters.setCertPathCheckers(java.util.List) , setCertStores sample code for java.security.cert.PKIXParameters.setCertStores(java.util.List) definition code for java.security.cert.PKIXParameters.setCertStores(java.util.List) , setDate sample code for java.security.cert.PKIXParameters.setDate(java.util.Date) definition code for java.security.cert.PKIXParameters.setDate(java.util.Date) , setExplicitPolicyRequired sample code for java.security.cert.PKIXParameters.setExplicitPolicyRequired(boolean) definition code for java.security.cert.PKIXParameters.setExplicitPolicyRequired(boolean) , setInitialPolicies sample code for java.security.cert.PKIXParameters.setInitialPolicies(java.util.Set) definition code for java.security.cert.PKIXParameters.setInitialPolicies(java.util.Set) , setPolicyMappingInhibited sample code for java.security.cert.PKIXParameters.setPolicyMappingInhibited(boolean) definition code for java.security.cert.PKIXParameters.setPolicyMappingInhibited(boolean) , setPolicyQualifiersRejected sample code for java.security.cert.PKIXParameters.setPolicyQualifiersRejected(boolean) definition code for java.security.cert.PKIXParameters.setPolicyQualifiersRejected(boolean) , setRevocationEnabled sample code for java.security.cert.PKIXParameters.setRevocationEnabled(boolean) definition code for java.security.cert.PKIXParameters.setRevocationEnabled(boolean) , setSigProvider sample code for java.security.cert.PKIXParameters.setSigProvider(java.lang.String) definition code for java.security.cert.PKIXParameters.setSigProvider(java.lang.String) , setTargetCertConstraints sample code for java.security.cert.PKIXParameters.setTargetCertConstraints(java.security.cert.CertSelector) definition code for java.security.cert.PKIXParameters.setTargetCertConstraints(java.security.cert.CertSelector) , setTrustAnchors sample code for java.security.cert.PKIXParameters.setTrustAnchors(java.util.Set) definition code for java.security.cert.PKIXParameters.setTrustAnchors(java.util.Set)
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

PKIXBuilderParameters sample code for java.security.cert.PKIXBuilderParameters(java.util.Set<java.security.cert.TrustAnchor>, java.security.cert.CertSelector) definition code for java.security.cert.PKIXBuilderParameters(java.util.Set<java.security.cert.TrustAnchor>, java.security.cert.CertSelector)

public PKIXBuilderParameters(Set sample code for java.util.Set definition code for java.util.Set <TrustAnchor sample code for java.security.cert.TrustAnchor definition code for java.security.cert.TrustAnchor > trustAnchors,
                             CertSelector sample code for java.security.cert.CertSelector definition code for java.security.cert.CertSelector  targetConstraints)
                      throws InvalidAlgorithmParameterException sample code for java.security.InvalidAlgorithmParameterException definition code for java.security.InvalidAlgorithmParameterException 
Creates an instance of PKIXBuilderParameters with the specified Set of most-trusted CAs. Each element of the set is a TrustAnchor sample code for java.security.cert.TrustAnchor definition code for java.security.cert.TrustAnchor .

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

Parameters:
trustAnchors - a Set of TrustAnchors
targetConstraints - a CertSelector specifying the constraints on the target certificate
Throws:
InvalidAlgorithmParameterException sample code for java.security.InvalidAlgorithmParameterException definition code for java.security.InvalidAlgorithmParameterException - if trustAnchors is empty (trustAnchors.isEmpty() == true)
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if trustAnchors is null
ClassCastException sample code for java.lang.ClassCastException definition code for java.lang.ClassCastException - if any of the elements of trustAnchors are not of type java.security.cert.TrustAnchor

PKIXBuilderParameters sample code for java.security.cert.PKIXBuilderParameters(java.security.KeyStore, java.security.cert.CertSelector) definition code for java.security.cert.PKIXBuilderParameters(java.security.KeyStore, java.security.cert.CertSelector)

public PKIXBuilderParameters(KeyStore sample code for java.security.KeyStore definition code for java.security.KeyStore  keystore,
                             CertSelector sample code for java.security.cert.CertSelector definition code for java.security.cert.CertSelector  targetConstraints)
                      throws KeyStoreException sample code for java.security.KeyStoreException definition code for java.security.KeyStoreException ,
                             InvalidAlgorithmParameterException sample code for java.security.InvalidAlgorithmParameterException definition code for java.security.InvalidAlgorithmParameterException 
Creates an instance of PKIXBuilderParameters 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 - a KeyStore from which the set of most-trusted CAs will be populated
targetConstraints - a CertSelector specifying the constraints on the target certificate
Throws:
KeyStoreException sample code for java.security.KeyStoreException definition code for java.security.KeyStoreException - if keystore has not been initialized
InvalidAlgorithmParameterException sample code for java.security.InvalidAlgorithmParameterException definition code for java.security.InvalidAlgorithmParameterException - if keystore does not contain at least one trusted certificate entry
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if keystore is null
Method Detail

setMaxPathLength sample code for java.security.cert.PKIXBuilderParameters.setMaxPathLength(int) definition code for java.security.cert.PKIXBuilderParameters.setMaxPathLength(int)

public void setMaxPathLength(int maxPathLength)
Sets the value of the maximum number of non-self-issued intermediate certificates that may exist in a certification path. A certificate is self-issued if the DNs that appear in the subject and issuer fields are identical and are not empty. Note that the last certificate in a certification path is not an intermediate certificate, and is not included in this limit. Usually the last certificate is an end entity certificate, but it can be a CA certificate. A PKIX CertPathBuilder instance must not build paths longer than the length specified.

A value of 0 implies that the path can only contain a single certificate. A value of -1 implies that the path length is unconstrained (i.e. there is no maximum). The default maximum path length, if not specified, is 5. Setting a value less than -1 will cause an exception to be thrown.

If any of the CA certificates contain the BasicConstraintsExtension, the value of the pathLenConstraint field of the extension overrides the maximum path length parameter whenever the result is a certification path of smaller length.

Parameters:
maxPathLength - the maximum number of non-self-issued intermediate certificates that may exist in a certification path
Throws:
InvalidParameterException sample code for java.security.InvalidParameterException definition code for java.security.InvalidParameterException - if maxPathLength is set to a value less than -1
See Also:
getMaxPathLength() sample code for java.security.cert.PKIXBuilderParameters.getMaxPathLength() definition code for java.security.cert.PKIXBuilderParameters.getMaxPathLength()

getMaxPathLength sample code for java.security.cert.PKIXBuilderParameters.getMaxPathLength() definition code for java.security.cert.PKIXBuilderParameters.getMaxPathLength()

public int getMaxPathLength()
Returns the value of the maximum number of intermediate non-self-issued certificates that may exist in a certification path. See the setMaxPathLength(int) sample code for java.security.cert.PKIXBuilderParameters.setMaxPathLength(int) definition code for java.security.cert.PKIXBuilderParameters.setMaxPathLength(int) method for more details.

Returns:
the maximum number of non-self-issued intermediate certificates that may exist in a certification path, or -1 if there is no limit
See Also:
setMaxPathLength(int) sample code for java.security.cert.PKIXBuilderParameters.setMaxPathLength(int) definition code for java.security.cert.PKIXBuilderParameters.setMaxPathLength(int)

toString sample code for java.security.cert.PKIXBuilderParameters.toString() definition code for java.security.cert.PKIXBuilderParameters.toString()

public String sample code for java.lang.String definition code for java.lang.String  toString()
Returns a formatted string describing the parameters.

Overrides:
toString sample code for java.security.cert.PKIXParameters.toString() definition code for java.security.cert.PKIXParameters.toString() in class PKIXParameters sample code for java.security.cert.PKIXParameters definition code for java.security.cert.PKIXParameters
Returns:
a formatted string describing the parameters