HashSet extKeyUsage = new HashSet(Arrays.asList(new String[] {
"1.3.6.1.5.5.7.3.1", "1.3.6.1.5.5.7.3.2", "1.3.6.1.5.5.7.3.3",
"1.3.6.1.5.5.7.3.4", "1.3.6.1.5.5.7.3.8", "1.3.6.1.5.5.7.3.9",
"1.3.6.1.5.5.7.3.5", "1.3.6.1.5.5.7.3.6", "1.3.6.1.5.5.7.3.7"}
));
GeneralNames subjectAltNames = new GeneralNames(Arrays.asList(
new GeneralName[] {
new GeneralName(1, "rfc@822.Name"),
new GeneralName(2, "dNSName"),
new GeneralName(6, "http://uniform.Resource.Id"),
new GeneralName(7, "1.1.1.1")
}
));
String[] policies = new String[] {
"0.0.0.0.0.0",
"1.1.1.1.1.1",
};
TestCert cert = new TestCert("certificate equality criteria");
cert.setSerialNumber(serial);
cert.setIssuer(issuer);
cert.setSubject(subject);
cert.setKeyIdentifier(subject_auth_KeyID);
cert.setDate(certValid);
cert.setPeriod(privateKeyValid[0], privateKeyValid[2]);
cert.setPublicKey(pkey);
cert.setKeyUsage(keyUsage);
cert.setExtendedKeyUsage(extKeyUsage);
cert.setSubjectAlternativeNames(subjectAltNames);
cert.setPolicies(policies);
X509CertSelector selector = new X509CertSelector();
selector.setCertificate(cert);
selector.setSerialNumber(serial);
selector.setIssuer(issuer);
selector.setSubject(subject);
selector.setSubjectKeyIdentifier(subject_auth_KeyID);
selector.setAuthorityKeyIdentifier(subject_auth_KeyID);
selector.setCertificateValid(certValid);
selector.setPrivateKeyValid(privateKeyValid[1]);
selector.setSubjectPublicKey(pkey);
selector.setSubjectPublicKeyAlgID(pkAlgID);
selector.setKeyUsage(keyUsage);
selector.setExtendedKeyUsage(extKeyUsage);
selector.setSubjectAlternativeNames(subjectAltNames.getPairsList());
selector.setMatchAllSubjectAltNames(true);
selector.setPolicy(new HashSet(Arrays.asList(policies)));
assertTrue("The certificate should match the selector",
((X509CertSelector)selector.clone()).match(cert));