org.spongycastle.jce.provider.X509StoreLDAPCRLs Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scprov-jdk15 Show documentation
Show all versions of scprov-jdk15 Show documentation
Spongy Castle is a package-rename (org.bouncycastle.* to org.spongycastle.*) of Bouncy Castle intended for Android.
Android ships with a stripped-down version of Bouncy Castle - this causes classloader collisions if you try to add
an alternative (updated/complete) Bouncy Castle jar.
This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.5.
package org.spongycastle.jce.provider;
import org.spongycastle.jce.X509LDAPCertStoreParameters;
import org.spongycastle.util.Selector;
import org.spongycastle.util.StoreException;
import org.spongycastle.x509.X509CRLStoreSelector;
import org.spongycastle.x509.X509StoreParameters;
import org.spongycastle.x509.X509StoreSpi;
import org.spongycastle.x509.util.LDAPStoreHelper;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
/**
* A SPI implementation of Bouncy Castle X509Store
for getting
* certificate revocation lists from an LDAP directory.
*
* @see org.spongycastle.x509.X509Store
*/
public class X509StoreLDAPCRLs extends X509StoreSpi
{
private LDAPStoreHelper helper;
public X509StoreLDAPCRLs()
{
}
/**
* Initializes this LDAP CRL store implementation.
*
* @param params X509LDAPCertStoreParameters
.
* @throws IllegalArgumentException if params
is not an instance of
* X509LDAPCertStoreParameters
.
*/
public void engineInit(X509StoreParameters params)
{
if (!(params instanceof X509LDAPCertStoreParameters))
{
throw new IllegalArgumentException(
"Initialization parameters must be an instance of "
+ X509LDAPCertStoreParameters.class.getName() + ".");
}
helper = new LDAPStoreHelper((X509LDAPCertStoreParameters)params);
}
/**
* Returns a collection of matching CRLs from the LDAP location.
*
* The selector must be a of type X509CRLStoreSelector
. If
* it is not an empty collection is returned.
*
* The issuer should be a reasonable criteria for a selector.
*
* @param selector The selector to use for finding.
* @return A collection with the matches.
* @throws StoreException if an exception occurs while searching.
*/
public Collection engineGetMatches(Selector selector) throws StoreException
{
if (!(selector instanceof X509CRLStoreSelector))
{
return Collections.EMPTY_SET;
}
X509CRLStoreSelector xselector = (X509CRLStoreSelector)selector;
Set set = new HashSet();
// test only delta CRLs should be selected
if (xselector.isDeltaCRLIndicatorEnabled())
{
set.addAll(helper.getDeltaCertificateRevocationLists(xselector));
}
// nothing specified
else
{
set.addAll(helper.getDeltaCertificateRevocationLists(xselector));
set.addAll(helper.getAttributeAuthorityRevocationLists(xselector));
set
.addAll(helper
.getAttributeCertificateRevocationLists(xselector));
set.addAll(helper.getAuthorityRevocationLists(xselector));
set.addAll(helper.getCertificateRevocationLists(xselector));
}
return set;
}
}