org.bouncycastle.jcajce.PKIXCertStoreSelector Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcprov-ext-jdk15on Show documentation
Show all versions of bcprov-ext-jdk15on Show documentation
The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms. This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.5 to JDK 1.7. Note: this package includes the IDEA and NTRU encryption algorithms.
package org.bouncycastle.jcajce;
import java.security.cert.CertSelector;
import java.security.cert.CertStore;
import java.security.cert.CertStoreException;
import java.security.cert.Certificate;
import java.util.Collection;
import org.bouncycastle.util.Selector;
/**
* This class is a Selector implementation for certificates.
*
* @see org.bouncycastle.util.Selector
*/
public class PKIXCertStoreSelector
implements Selector
{
/**
* Builder for a PKIXCertStoreSelector.
*/
public static class Builder
{
private final CertSelector baseSelector;
/**
* Constructor initializing a builder with a CertSelector.
*
* @param certSelector the CertSelector to copy the match details from.
*/
public Builder(CertSelector certSelector)
{
this.baseSelector = (CertSelector)certSelector.clone();
}
/**
* Build a selector.
*
* @return a new PKIXCertStoreSelector
*/
public PKIXCertStoreSelector extends Certificate> build()
{
return new PKIXCertStoreSelector(baseSelector);
}
}
private final CertSelector baseSelector;
private PKIXCertStoreSelector(CertSelector baseSelector)
{
this.baseSelector = baseSelector;
}
public boolean match(Certificate cert)
{
return baseSelector.match(cert);
}
public Object clone()
{
return new PKIXCertStoreSelector(baseSelector);
}
public static Collection extends Certificate> getCertificates(final PKIXCertStoreSelector selector, CertStore certStore)
throws CertStoreException
{
return certStore.getCertificates(new CertSelector()
{
public boolean match(Certificate certificate)
{
return (selector == null) ? true : selector.match(certificate);
}
public Object clone()
{
return this;
}
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy