CertSelector
that selects X509Certificates
that
match all specified criteria. This class is particularly useful when
selecting certificates from a CertStore
to build a
PKIX-compliant certification path.
When first constructed, an X509CertSelector
has no criteria
enabled and each of the get
methods return a default value
(null
, or -1
for the getBasicConstraints
method). Therefore, the match
method would return true
for any X509Certificate
.
Typically, several criteria are enabled (by calling
setIssuer(X500Principal)
or
setKeyUsage
, for instance) and then the
X509CertSelector
is passed to
CertStore.
or some similar
method.
Several criteria can be enabled (by calling
setIssuer(X500Principal)
and setSerialNumber
,
for example) such that the match
method
usually uniquely matches a single X509Certificate
. We say
usually, since it is possible for two issuing CAs to have the same
distinguished name and each issue a certificate with the same serial
number. Other unique combinations include the issuer, subject,
subjectKeyIdentifier and/or the subjectPublicKey criteria.
Please refer to RFC 5280: Internet X.509 Public Key Infrastructure Certificate and CRL Profile for definitions of the X.509 certificate extensions mentioned below.
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.
CertSelector
, X509Certificate
Modifier and Type | Field and Description |
---|---|
private static final ObjectIdentifier | |
private byte[] | |
private int | |
private Date | |
private static final Debug | |
private static final Boolean | |
private X500Principal | |
private Set | |
private Set | |
private boolean[] | |
private boolean | |
pack-priv static final int | |
pack-priv static final int | |
pack-priv static final int | |
pack-priv static final int | |
pack-priv static final int | |
pack-priv static final int | |
pack-priv static final int | |
pack-priv static final int | |
pack-priv static final int | |
private NameConstraintsExtension | |
private byte[] | |
private Set | |
private Set | |
private CertificatePolicySet | |
private Set | |
private Date | |
private BigInteger | |
private X500Principal | |
private Set | |
private Set | |
private byte[] | |
private PublicKey | |
private ObjectIdentifier | |
private byte[] | |
private X509Certificate |
Access | Constructor and Description |
---|---|
public |
Modifier and Type | Method and Description |
---|---|
public void | addPathToName(int
the name type (0-8, as specified in
RFC 5280, section 4.2.1.6) type, String the name in string form name)Adds a name to the pathToNames criterion. |
public void | addPathToName(int
the name type (0-8, as specified in
RFC 5280, section 4.2.1.6) type, byte[] a byte array containing the name in ASN.1 DER encoded form name)Adds a name to the pathToNames criterion. |
private void | addPathToNameInternal(int
the name type (0-8, as specified in
RFC 5280, section 4.2.1.6) type, Object the name in string or byte array form name)A private method that adds a name (String or byte array) to the pathToNames criterion. |
public void | addSubjectAlternativeName(int
the name type (0-8, as specified in
RFC 5280, section 4.2.1.6) type, String the name in string form (not name)null )Adds a name to the subjectAlternativeNames criterion. |
public void | addSubjectAlternativeName(int
the name type (0-8, as listed above) type, byte[] a byte array containing the name in ASN.1 DER encoded form name)Adds a name to the subjectAlternativeNames criterion. |
private void | addSubjectAlternativeNameInternal(int
the name type (0-8, as specified in
RFC 5280, section 4.2.1.6) type, Object the name in string or byte array form name)A private method that adds a name (String or byte array) to the subjectAlternativeNames criterion. |
public Object | Returns: the copyOverrides java. Implements java. Returns a copy of this object. |
private static Set | Returns: a deep copy of the specifiedCollection a names)Collection with one entry per name.
Each entry is a List whose first entry
is an Integer (the name type, 0-8) and whose second
entry is a String or a byte array (the name, in
string or ASN.1 DER encoded form, respectively).
There can be multiple names of the same type.
null is not an acceptable value.Clone and check an argument of the form passed to setSubjectAlternativeNames and setPathToNames. |
private static Set | Returns: a deep copy of the specifiedCollection a names)Collection with one entry per name.
Each entry is a List whose first entry
is an Integer (the name type, 0-8) and whose second
entry is a String or a byte array (the name, in
string or ASN.1 DER encoded form, respectively).
There can be multiple names of the same type. Null
is not an acceptable value.Clone an object of the form passed to setSubjectAlternativeNames and setPathToNames. |
private static <T> Set | |
pack-priv static boolean | Returns: true if the objects are equal, false otherwisea Collection containing the first object to compare object1, Collection<?> a Collection containing the second object to compare object2)Compare for equality two objects of the form passed to setSubjectAlternativeNames (or X509CRLSelector.setIssuerNames). |
public byte[] | Returns: the key identifier (ornull )Returns the authorityKeyIdentifier criterion. |
public int | Returns: the value for the basic constraints constraintReturns the basic constraints constraint. |
public X509Certificate | Returns: theX509Certificate to match (or null )Returns the certificateEquals criterion. |
public Date | |
public Set | Returns: an immutableSet of key purpose OIDs in string
format (or null )Returns the extendedKeyUsage criterion. |
private static Extension | Returns: anExtension object whose real type is as specified
by the extension oid.a cert, KnownOIDs X509Certificate an extId)integer which specifies the extension index.
Currently, the supported extensions are as follows:
index 0 - PrivateKeyUsageExtension
index 1 - SubjectAlternativeNameExtension
index 2 - NameConstraintsExtension
index 3 - CertificatePoliciesExtension
index 4 - ExtendedKeyUsageExtensionReturns an Extension object given any X509Certificate and extension oid. |
public X500Principal | Returns: the required issuer distinguished name as X500Principal (ornull )Returns the issuer criterion as an |
public byte[] | Returns: a byte array containing the required issuer distinguished name in ASN.1 DER format (ornull )Returns the issuer criterion as a byte array. |
public String | Returns: the required issuer distinguished name in RFC 2253 format (ornull )
Deprecated
since 16. Use
getIssuer() or getIssuerAsBytes()
instead.
Returns the issuer criterion as a |
public boolean[] | Returns: a boolean array in the same format as the boolean array returned byX509Certificate. .
Or null .Returns the keyUsage criterion. |
public boolean | Returns: true if the flag is enabled;
false if the flag is disabled. The flag is
true by default.Indicates if the |
public byte[] | Returns: a byte array containing the ASN.1 DER encoding of a NameConstraints extension used for checking name constraints.null if no name constraints check will be performed.Returns the name constraints criterion. |
public Collection | Returns: aCollection of names (or null )Returns a copy of the pathToNames criterion. |
public Set | Returns: an immutableSet of certificate policy OIDs in
string format (or null )Returns the policy criterion. |
public Date | |
public BigInteger | Returns: the certificate serial number to match (ornull )Returns the serialNumber criterion. |
public X500Principal | Returns: the required subject distinguished name as X500Principal (ornull )Returns the subject criterion as an |
public Collection | Returns: aCollection of names (or null )Returns a copy of the subjectAlternativeNames criterion. |
public byte[] | Returns: a byte array containing the required subject distinguished name in ASN.1 DER format (ornull )Returns the subject criterion as a byte array. |
public String | Returns: the required subject distinguished name in RFC 2253 format (ornull )
Deprecated
since 16. Use
getSubject() or getSubjectAsBytes()
instead.
Returns the subject criterion as a |
public byte[] | Returns: the key identifier (ornull )Returns the subjectKeyIdentifier criterion. |
public PublicKey | Returns: the subject public key to check for (ornull )Returns the subjectPublicKey criterion. |
public String | Returns: the object identifier (OID) of the signature algorithm to check for (ornull ). An OID is represented by a set of
nonnegative integers separated by periods.Returns the subjectPublicKeyAlgID criterion. |
private static String | |
pack-priv static GeneralNameInterface | Returns: a GeneralNameInterface namename type (0-8) type, Object name as ASN.1 Der-encoded byte array or String name)Make a |
public boolean | Returns: true if the Certificate should be
selected, false otherwisethe cert)Certificate to be checkedImplements java. Decides whether a |
private boolean | |
private boolean | |
private boolean | |
private boolean | |
private boolean | |
private boolean | |
private boolean | |
private boolean | |
private boolean | |
private boolean | |
private boolean | |
private boolean | |
private boolean | |
private static Set | Returns: a Set ofGeneralNameInterface sa Collection with one entry per name.
Each entry is a names)List whose first entry
is an Integer (the name type, 0-8) and whose second
entry is a String or a byte array (the name, in
string or ASN.1 DER encoded form, respectively).
There can be multiple names of the same type. Null is
not an acceptable value.Parse an argument of the form passed to setSubjectAlternativeNames,
returning a |
public void | setAuthorityKeyIdentifier(byte[]
the authority key identifier
(or authorityKeyID)null )Sets the authorityKeyIdentifier criterion. |
public void | setBasicConstraints(int
the value for the basic constraints constraint minMaxPathLen)Sets the basic constraints constraint. |
public void | setCertificate(X509Certificate
the cert)X509Certificate to match (or
null )Sets the certificateEquals criterion. |
public void | |
public void | setExtendedKeyUsage(Set<String>
a keyPurposeSet)Set of key purpose OIDs in string
format (or null ). Each OID is represented by a set of
nonnegative integers separated by periods.Sets the extendedKeyUsage criterion. |
public void | setIssuer(X500Principal
a distinguished name as X500Principal
(or issuer)null )Sets the issuer criterion. |
public void | setIssuer(String
a distinguished name in RFC 2253 format
(or issuerDN)null )
Deprecated
since 16. Use
setIssuer(X500Principal) or
setIssuer(byte[]) instead.
Sets the issuer criterion. |
public void | setIssuer(byte[]
a byte array containing the distinguished name
in ASN.1 DER encoded form (or issuerDN)null )Sets the issuer criterion. |
public void | setKeyUsage(boolean[]
a boolean array in the same format as the boolean
array returned by
keyUsage)X509Certificate. .
Or null .Sets the keyUsage criterion. |
public void | setMatchAllSubjectAltNames(boolean
if matchAllNames)true , the flag is enabled;
if false , the flag is disabled.Enables/disables matching all of the subjectAlternativeNames
specified in the |
public void | setNameConstraints(byte[]
a byte array containing the ASN.1 DER encoding of
a NameConstraints extension to be used for checking
name constraints. Only the value of the extension is
included, not the OID or criticality flag. Can be
bytes)null ,
in which case no name constraints check will be performed.Sets the name constraints criterion. |
public void | setPathToNames(Collection<List<?>>
a names)Collection with one entry per name
(or null )Sets the pathToNames criterion. |
public void | |
public void | setPrivateKeyValid(Date
the privateKeyValid)Date to check (or
null )Sets the privateKeyValid criterion. |
public void | setSerialNumber(BigInteger
the certificate serial number to match
(or serial)null )Sets the serialNumber criterion. |
public void | setSubject(X500Principal
a distinguished name as X500Principal
(or subject)null )Sets the subject criterion. |
public void | setSubject(String
a distinguished name in RFC 2253 format
(or subjectDN)null )
Deprecated
since 16. Use
setSubject(X500Principal) or
setSubject(byte[]) instead.
Sets the subject criterion. |
public void | setSubject(byte[]
a byte array containing the distinguished name in
ASN.1 DER format (or subjectDN)null )Sets the subject criterion. |
public void | setSubjectAlternativeNames(Collection<List<?>>
a names)Collection of names (or null )Sets the subjectAlternativeNames criterion. |
public void | setSubjectKeyIdentifier(byte[]
the subject key identifier (or subjectKeyID)null )Sets the subjectKeyIdentifier criterion. |
public void | setSubjectPublicKey(PublicKey
the subject public key to check for (or key)null )Sets the subjectPublicKey criterion. |
public void | setSubjectPublicKey(byte[]
a byte array containing the subject public key in ASN.1 DER
form (or key)null )Sets the subjectPublicKey criterion. |
public void | setSubjectPublicKeyAlgID(String
The object identifier (OID) of the algorithm to check
for (or oid)null ). An OID is represented by a
set of nonnegative integers separated by periods.Sets the subjectPublicKeyAlgID criterion. |
public String | Returns: aString describing the contents of the
CertSelector Overrides java. Return a printable representation of the |