use of org.bouncycastle.x509.X509Store in project robovm by robovm.
the class CMSSignedHelper method createAttributeStore.
X509Store createAttributeStore(String type, Provider provider, Store certStore) throws NoSuchStoreException, CMSException {
try {
Collection certHldrs = certStore.getMatches(null);
List certs = new ArrayList(certHldrs.size());
for (Iterator it = certHldrs.iterator(); it.hasNext(); ) {
certs.add(new X509V2AttributeCertificate(((X509AttributeCertificateHolder) it.next()).getEncoded()));
}
return X509Store.getInstance("AttributeCertificate/" + type, new X509CollectionStoreParameters(certs), provider);
} catch (IllegalArgumentException e) {
throw new CMSException("can't setup the X509Store", e);
} catch (IOException e) {
throw new CMSException("can't setup the X509Store", e);
}
}
use of org.bouncycastle.x509.X509Store in project XobotOS by xamarin.
the class PKIXCRLUtil method findCRLs.
/**
* Return a Collection of all CRLs found in the X509Store's that are
* matching the crlSelect criteriums.
*
* @param crlSelect a {@link X509CRLStoreSelector} object that will be used
* to select the CRLs
* @param crlStores a List containing only
* {@link org.bouncycastle.x509.X509Store X509Store} objects.
* These are used to search for CRLs
*
* @return a Collection of all found {@link java.security.cert.X509CRL X509CRL} objects. May be
* empty but never <code>null</code>.
*/
private final Collection findCRLs(X509CRLStoreSelector crlSelect, List crlStores) throws AnnotatedException {
Set crls = new HashSet();
Iterator iter = crlStores.iterator();
AnnotatedException lastException = null;
boolean foundValidStore = false;
while (iter.hasNext()) {
Object obj = iter.next();
if (obj instanceof X509Store) {
X509Store store = (X509Store) obj;
try {
crls.addAll(store.getMatches(crlSelect));
foundValidStore = true;
} catch (StoreException e) {
lastException = new AnnotatedException("Exception searching in X.509 CRL store.", e);
}
} else {
CertStore store = (CertStore) obj;
try {
crls.addAll(store.getCRLs(crlSelect));
foundValidStore = true;
} catch (CertStoreException e) {
lastException = new AnnotatedException("Exception searching in X.509 CRL store.", e);
}
}
}
if (!foundValidStore && lastException != null) {
throw lastException;
}
return crls;
}
use of org.bouncycastle.x509.X509Store in project XobotOS by xamarin.
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;
}
use of org.bouncycastle.x509.X509Store in project robovm by robovm.
the class CMSSignedGenerator method addAttributeCertificates.
// BEGIN android-removed
// /**
// * Add a single instance of otherRevocationData to the CRL set to be included with the generated SignedData message.
// *
// * @param otherRevocationInfoFormat the OID specifying the format of the otherRevocationInfo data.
// * @param otherRevocationInfo the otherRevocationInfo ASN.1 structure.
// */
// public void addOtherRevocationInfo(
// ASN1ObjectIdentifier otherRevocationInfoFormat,
// ASN1Encodable otherRevocationInfo)
// {
// crls.add(new DERTaggedObject(false, 1, new OtherRevocationInfoFormat(otherRevocationInfoFormat, otherRevocationInfo)));
// }
//
// /**
// * Add a Store of otherRevocationData to the CRL set to be included with the generated SignedData message.
// *
// * @param otherRevocationInfoFormat the OID specifying the format of the otherRevocationInfo data.
// * @param otherRevocationInfos a Store of otherRevocationInfo data to add.
// */
// public void addOtherRevocationInfo(
// ASN1ObjectIdentifier otherRevocationInfoFormat,
// Store otherRevocationInfos)
// {
// crls.addAll(CMSUtils.getOthersFromStore(otherRevocationInfoFormat, otherRevocationInfos));
// }
// END android-removed
/**
* Add the attribute certificates contained in the passed in store to the
* generator.
*
* @param store a store of Version 2 attribute certificates
* @throws CMSException if an error occurse processing the store.
* @deprecated use basic Store method
*/
public void addAttributeCertificates(X509Store store) throws CMSException {
try {
for (Iterator it = store.getMatches(null).iterator(); it.hasNext(); ) {
X509AttributeCertificate attrCert = (X509AttributeCertificate) it.next();
certs.add(new DERTaggedObject(false, 2, AttributeCertificate.getInstance(ASN1Primitive.fromByteArray(attrCert.getEncoded()))));
}
} catch (IllegalArgumentException e) {
throw new CMSException("error processing attribute certs", e);
} catch (IOException e) {
throw new CMSException("error processing attribute certs", e);
}
}
use of org.bouncycastle.x509.X509Store in project robovm by robovm.
the class PKIXCRLUtil method findCRLs.
/**
* Return a Collection of all CRLs found in the X509Store's that are
* matching the crlSelect criteriums.
*
* @param crlSelect a {@link X509CRLStoreSelector} object that will be used
* to select the CRLs
* @param crlStores a List containing only
* {@link org.bouncycastle.x509.X509Store X509Store} objects.
* These are used to search for CRLs
*
* @return a Collection of all found {@link java.security.cert.X509CRL X509CRL} objects. May be
* empty but never <code>null</code>.
*/
private final Collection findCRLs(X509CRLStoreSelector crlSelect, List crlStores) throws AnnotatedException {
Set crls = new HashSet();
Iterator iter = crlStores.iterator();
AnnotatedException lastException = null;
boolean foundValidStore = false;
while (iter.hasNext()) {
Object obj = iter.next();
if (obj instanceof X509Store) {
X509Store store = (X509Store) obj;
try {
crls.addAll(store.getMatches(crlSelect));
foundValidStore = true;
} catch (StoreException e) {
lastException = new AnnotatedException("Exception searching in X.509 CRL store.", e);
}
} else {
CertStore store = (CertStore) obj;
try {
crls.addAll(store.getCRLs(crlSelect));
foundValidStore = true;
} catch (CertStoreException e) {
lastException = new AnnotatedException("Exception searching in X.509 CRL store.", e);
}
}
}
if (!foundValidStore && lastException != null) {
throw lastException;
}
return crls;
}
Aggregations