Top Description Fields Constructors Methods
org.bouncycastle.jce.provider

public Class X509LDAPCertStoreSpi

extends CertStoreSpi
Class Inheritance
Imports
java.io.ByteArrayInputStream, .IOException, java.security.InvalidAlgorithmParameterException, java.security.cert.CRL, .CRLSelector, .CertSelector, .CertStoreException, .CertStoreParameters, .CertStoreSpi, .Certificate, .CertificateFactory, .X509CRLSelector, .X509CertSelector, java.util.ArrayList, .Collection, .HashSet, .Iterator, .List, .Properties, .Set, javax.naming.Context, .NamingEnumeration, .NamingException, javax.naming.directory.Attribute, .DirContext, .InitialDirContext, .SearchControls, .SearchResult, javax.security.auth.x500.X500Principal, org.bouncycastle.asn1.ASN1InputStream, org.bouncycastle.asn1.x509.CertificatePair, org.bouncycastle.jce.X509LDAPCertStoreParameters

This is a general purpose implementation to get X.509 certificates and CRLs from a LDAP location.

At first a search is performed in the ldap*AttributeNames of the org.bouncycastle.jce.X509LDAPCertStoreParameters with the given information of the subject (for all kind of certificates) or issuer (for CRLs), respectively, if a X509CertSelector is given with that details. For CRLs, CA certificates and cross certificates a coarse search is made only for entries with that content to get more possibly matching results.

Field Summary

Modifier and TypeField and Description
private static String[]
private static String
LDAP_PROVIDER

Initial Context Factory.

private X509LDAPCertStoreParameters
private static String
REFERRALS_IGNORE

Processing referrals..

private static final String
SEARCH_SECURITY_LEVEL

Security level to be used for LDAP connections.

private static final String
URL_CONTEXT_PREFIX

Package Prefix for loading URL context factories.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private Set<E>
certSubjectSerialSearch(X509CertSelector xselector, String[] attrs, String attrName, String subjectAttributeName)

private DirContext
public Collection<E>
engineGetCertificates(CertSelector
A CertSelector used to select which Certificates should be returned. Specify null to return all Certificates (if supported).
selector
)

Implements abstract java.security.cert.CertStoreSpi.engineGetCertificates.

Returns a Collection of Certificates that match the specified selector.
public Collection<E>
engineGetCRLs(CRLSelector
A CRLSelector used to select which CRLs should be returned. Specify null to return all CRLs (if supported).
selector
)

Implements abstract java.security.cert.CertStoreSpi.engineGetCRLs.

Returns a Collection of CRLs that match the specified selector.
private String

Returns:

a properly escaped representation of the supplied value.
filterEncode
(String
the value to escape.
value
)

Escape a value for use in a filter.

private Set<E>
private Set<E>
private Set<E>
private String
parseDN(String subject, String subjectAttributeName)

private Set<E>

Returns:

Set of byte arrays with the certificate encodings.
search
(String
The attribute name to look for in the LDAP.
attributeName
,
String
The value the attribute name must have.
attributeValue
,
String[]
The attributes in the LDAP which hold the certificate, certificate pair or CRL in a found entry.
attrs
)

Returns a Set of byte arrays with the certificate or CRL encodings.

Field Detail

FILTER_ESCAPE_TABLEback to summary
private static String[] FILTER_ESCAPE_TABLE
LDAP_PROVIDERback to summary
private static String LDAP_PROVIDER

Initial Context Factory.

paramsback to summary
private X509LDAPCertStoreParameters params
REFERRALS_IGNOREback to summary
private static String REFERRALS_IGNORE

Processing referrals..

SEARCH_SECURITY_LEVELback to summary
private static final String SEARCH_SECURITY_LEVEL

Security level to be used for LDAP connections.

URL_CONTEXT_PREFIXback to summary
private static final String URL_CONTEXT_PREFIX

Package Prefix for loading URL context factories.

Constructor Detail

X509LDAPCertStoreSpiback to summary
public X509LDAPCertStoreSpi(CertStoreParameters params) throws InvalidAlgorithmParameterException

Method Detail

certSubjectSerialSearchback to summary
private Set<E> certSubjectSerialSearch(X509CertSelector xselector, String[] attrs, String attrName, String subjectAttributeName) throws CertStoreException
connectLDAPback to summary
private DirContext connectLDAP() throws NamingException
engineGetCertificatesback to summary
public Collection<E> engineGetCertificates(CertSelector selector) throws CertStoreException

Implements abstract java.security.cert.CertStoreSpi.engineGetCertificates.

Doc from java.security.cert.CertStoreSpi.engineGetCertificates.

Returns a Collection of Certificates that match the specified selector. If no Certificates match the selector, an empty Collection will be returned.

For some CertStore types, the resulting Collection may not contain all of the Certificates that match the selector. For instance, an LDAP CertStore may not search all entries in the directory. Instead, it may just search entries that are likely to contain the Certificates it is looking for.

Some CertStore implementations (especially LDAP CertStores) may throw a CertStoreException unless a non-null CertSelector is provided that includes specific criteria that can be used to find the certificates. Issuer and/or subject names are especially useful criteria.

Parameters
selector:CertSelector

A CertSelector used to select which Certificates should be returned. Specify null to return all Certificates (if supported).

Returns:Collection<E>

A Collection of Certificates that match the specified selector (never null)

Exceptions
CertStoreException:
if an exception occurs
engineGetCRLsback to summary
public Collection<E> engineGetCRLs(CRLSelector selector) throws CertStoreException

Implements abstract java.security.cert.CertStoreSpi.engineGetCRLs.

Doc from java.security.cert.CertStoreSpi.engineGetCRLs.

Returns a Collection of CRLs that match the specified selector. If no CRLs match the selector, an empty Collection will be returned.

For some CertStore types, the resulting Collection may not contain all of the CRLs that match the selector. For instance, an LDAP CertStore may not search all entries in the directory. Instead, it may just search entries that are likely to contain the CRLs it is looking for.

Some CertStore implementations (especially LDAP CertStores) may throw a CertStoreException unless a non-null CRLSelector is provided that includes specific criteria that can be used to find the CRLs. Issuer names and/or the certificate to be checked are especially useful.

Parameters
selector:CRLSelector

A CRLSelector used to select which CRLs should be returned. Specify null to return all CRLs (if supported).

Returns:Collection<E>

A Collection of CRLs that match the specified selector (never null)

Exceptions
CertStoreException:
if an exception occurs
filterEncodeback to summary
private String filterEncode(String value)

Escape a value for use in a filter.

Parameters
value:String

the value to escape.

Returns:String

a properly escaped representation of the supplied value.

getCACertificatesback to summary
private Set<E> getCACertificates(X509CertSelector xselector) throws CertStoreException
getCrossCertificatesback to summary
private Set<E> getCrossCertificates(X509CertSelector xselector) throws CertStoreException
getEndCertificatesback to summary
private Set<E> getEndCertificates(X509CertSelector xselector) throws CertStoreException
parseDNback to summary
private String parseDN(String subject, String subjectAttributeName)
searchback to summary
private Set<E> search(String attributeName, String attributeValue, String[] attrs) throws CertStoreException

Returns a Set of byte arrays with the certificate or CRL encodings.

Parameters
attributeName:String

The attribute name to look for in the LDAP.

attributeValue:String

The value the attribute name must have.

attrs:String[]

The attributes in the LDAP which hold the certificate, certificate pair or CRL in a found entry.

Returns:Set<E>

Set of byte arrays with the certificate encodings.