list.add(interCrl);
CollectionCertStoreParameters ccsp = new CollectionCertStoreParameters(list);
CertStore store = CertStore.getInstance("Collection", ccsp, "BC");
// Searching for rootCert by subjectDN
X509CertSelector targetConstraints = new X509CertSelector();
targetConstraints.setSubject(rootCert.getSubjectX500Principal().getName());
Collection certs = store.getCertificates(targetConstraints);
if (certs.size() != 1 || !certs.contains(rootCert))
{
fail("rootCert not found by subjectDN");
}
// Searching for rootCert by subjectDN encoded as byte
targetConstraints = new X509CertSelector();
targetConstraints.setSubject(rootCert.getSubjectX500Principal()
.getEncoded());
certs = store.getCertificates(targetConstraints);
if (certs.size() != 1 || !certs.contains(rootCert))
{
fail("rootCert not found by encoded subjectDN");
}
// Searching for rootCert by public key encoded as byte
targetConstraints = new X509CertSelector();
targetConstraints.setSubjectPublicKey(rootCert.getPublicKey()
.getEncoded());
certs = store.getCertificates(targetConstraints);
if (certs.size() != 1 || !certs.contains(rootCert))
{
fail("rootCert not found by encoded public key");
}
// Searching for interCert by issuerDN
targetConstraints = new X509CertSelector();
targetConstraints.setIssuer(rootCert.getSubjectX500Principal()
.getEncoded());
certs = store.getCertificates(targetConstraints);
if (certs.size() != 2)
{
fail("did not found 2 certs");