{
fail("error using wrong selector (certs)");
}
// Searching for attribute certificates
X509V2AttributeCertificate attrCert = new X509V2AttributeCertificate(AttrCertTest.attrCert);
X509AttributeCertificate attrCert2 = new X509V2AttributeCertificate(AttrCertTest.certWithBaseCertificateID);
List attrList = new ArrayList();
attrList.add(attrCert);
attrList.add(attrCert2);
ccsp = new X509CollectionStoreParameters(attrList);
store = X509Store.getInstance("AttributeCertificate/Collection", ccsp, "BC");
X509AttributeCertStoreSelector attrSelector = new X509AttributeCertStoreSelector();
attrSelector.setHolder(attrCert.getHolder());
if (!attrSelector.getHolder().equals(attrCert.getHolder()))
{
fail("holder get not correct");
}
Collection attrs = store.getMatches(attrSelector);
if (attrs.size() != 1 || !attrs.contains(attrCert))
{
fail("attrCert not found on holder");
}
attrSelector.setHolder(attrCert2.getHolder());
if (attrSelector.getHolder().equals(attrCert.getHolder()))
{
fail("holder get not correct");
}
attrs = store.getMatches(attrSelector);
if (attrs.size() != 1 || !attrs.contains(attrCert2))
{
fail("attrCert2 not found on holder");
}
attrSelector = new X509AttributeCertStoreSelector();
attrSelector.setIssuer(attrCert.getIssuer());
if (!attrSelector.getIssuer().equals(attrCert.getIssuer()))
{
fail("issuer get not correct");
}
attrs = store.getMatches(attrSelector);
if (attrs.size() != 1 || !attrs.contains(attrCert))
{
fail("attrCert not found on issuer");
}
attrSelector.setIssuer(attrCert2.getIssuer());
if (attrSelector.getIssuer().equals(attrCert.getIssuer()))
{
fail("issuer get not correct");
}
attrs = store.getMatches(attrSelector);