CollectionCertStoreParameters ccsp = new CollectionCertStoreParameters(
list);
CertStore store = CertStore.getInstance("Collection", ccsp);
// 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))
{
return new SimpleTestResult(false, this.getName()
+ ": 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))
{
return new SimpleTestResult(false, this.getName()
+ ": 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))
{
return new SimpleTestResult(false, this.getName()
+ ": 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)
{
return new SimpleTestResult(false, this.getName()