Search in sources :

Example 6 with X509Store

use of org.bouncycastle.x509.X509Store in project robovm by robovm.

the class CertPathValidatorUtilities method findCertificates.

/**
     * Return a Collection of all certificates or attribute certificates found
     * in the X509Store's that are matching the certSelect criteriums.
     *
     * @param certSelect a {@link Selector} object that will be used to select
     *                   the certificates
     * @param certStores a List containing only {@link X509Store} objects. These
     *                   are used to search for certificates.
     * @return a Collection of all found {@link X509Certificate} or
     *         {@link org.bouncycastle.x509.X509AttributeCertificate} objects.
     *         May be empty but never <code>null</code>.
     */
protected static Collection findCertificates(X509CertStoreSelector certSelect, List certStores) throws AnnotatedException {
    Set certs = new HashSet();
    Iterator iter = certStores.iterator();
    while (iter.hasNext()) {
        Object obj = iter.next();
        if (obj instanceof X509Store) {
            X509Store certStore = (X509Store) obj;
            try {
                certs.addAll(certStore.getMatches(certSelect));
            } catch (StoreException e) {
                throw new AnnotatedException("Problem while picking certificates from X.509 store.", e);
            }
        } else {
            CertStore certStore = (CertStore) obj;
            try {
                certs.addAll(certStore.getCertificates(certSelect));
            } catch (CertStoreException e) {
                throw new AnnotatedException("Problem while picking certificates from certificate store.", e);
            }
        }
    }
    return certs;
}
Also used : X509Store(org.bouncycastle.x509.X509Store) Set(java.util.Set) HashSet(java.util.HashSet) CertStoreException(java.security.cert.CertStoreException) Iterator(java.util.Iterator) CertStore(java.security.cert.CertStore) HashSet(java.util.HashSet) CertStoreException(java.security.cert.CertStoreException) StoreException(org.bouncycastle.util.StoreException)

Aggregations

Iterator (java.util.Iterator)6 CertStore (java.security.cert.CertStore)4 CertStoreException (java.security.cert.CertStoreException)4 HashSet (java.util.HashSet)4 Set (java.util.Set)4 StoreException (org.bouncycastle.util.StoreException)4 X509Store (org.bouncycastle.x509.X509Store)4 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 List (java.util.List)1 ASN1Object (org.bouncycastle.asn1.ASN1Object)1 DERObject (org.bouncycastle.asn1.DERObject)1 DERTaggedObject (org.bouncycastle.asn1.DERTaggedObject)1 CertificateList (org.bouncycastle.asn1.x509.CertificateList)1 X509AttributeCertificateHolder (org.bouncycastle.cert.X509AttributeCertificateHolder)1 X509AttributeCertificate (org.bouncycastle.x509.X509AttributeCertificate)1 X509CollectionStoreParameters (org.bouncycastle.x509.X509CollectionStoreParameters)1 X509V2AttributeCertificate (org.bouncycastle.x509.X509V2AttributeCertificate)1