use of java.security.cert.X509CertSelector in project jdk8u_jdk by JetBrains.
the class X509CertSelectorTest method testCertificateValid.
/*
* Tests matching on the certificate validity component contained in the
* certificate.
*/
private void testCertificateValid() {
System.out.println("X.509 Certificate Match on certificateValid");
// bad match
X509CertSelector selector = new X509CertSelector();
Calendar cal = Calendar.getInstance();
cal.set(1968, 12, 31);
selector.setCertificateValid(cal.getTime());
checkMatch(selector, cert, false);
// good match
selector.setCertificateValid(cert.getNotBefore());
checkMatch(selector, cert, true);
}
use of java.security.cert.X509CertSelector in project jdk8u_jdk by JetBrains.
the class X509CertSelectorTest method testNameConstraints.
// Tests matching on the name constraints contained in the certificate.
private void testNameConstraints() throws IOException {
System.out.println("X.509 Certificate Match on name constraints");
// bad match
GeneralSubtrees subjectTree = new GeneralSubtrees();
subjectTree.add(getGeneralSubtree((X500Name) cert.getSubjectDN()));
NameConstraintsExtension ext = new NameConstraintsExtension((GeneralSubtrees) null, subjectTree);
X509CertSelector selector = new X509CertSelector();
selector.setNameConstraints(ext.getExtensionValue());
checkMatch(selector, cert, false);
// good match
ext = new NameConstraintsExtension(subjectTree, null);
selector.setNameConstraints(ext.getExtensionValue());
checkMatch(selector, cert, true);
}
use of java.security.cert.X509CertSelector in project jdk8u_jdk by JetBrains.
the class X509CertSelectorTest method testSubjectPublicKeyAlgID.
/*
* Tests matching on the subject public key algorithm ID component contained
* in the certificate.
*/
private void testSubjectPublicKeyAlgID() throws IOException {
System.out.println("X.509 Certificate Match on subjectPublicKeyAlgID");
// bad match
X509CertSelector selector = new X509CertSelector();
selector.setSubjectPublicKeyAlgID("2.5.29.14");
checkMatch(selector, cert, false);
// good match
selector.setSubjectPublicKeyAlgID(getCertPubKeyAlgOID(cert).toString());
checkMatch(selector, cert, true);
}
use of java.security.cert.X509CertSelector in project jdk8u_jdk by JetBrains.
the class X509CertSelectorTest method testAuthorityKeyIdentifier.
/*
* Tests matching on the authority key identifier contained in the
* certificate.
*/
private void testAuthorityKeyIdentifier() throws IOException {
System.out.println("X.509 Certificate Match on authorityKeyIdentifier");
// bad match
X509CertSelector selector = new X509CertSelector();
byte[] b = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
AuthorityKeyIdentifierExtension a = new AuthorityKeyIdentifierExtension(new KeyIdentifier(b), null, null);
selector.setAuthorityKeyIdentifier(a.getExtensionValue());
checkMatch(selector, cert, false);
// good match
DerInputStream in = new DerInputStream(cert.getExtensionValue("2.5.29.35"));
byte[] encoded = in.getOctetString();
selector.setAuthorityKeyIdentifier(encoded);
checkMatch(selector, cert, true);
}
use of java.security.cert.X509CertSelector in project jdk8u_jdk by JetBrains.
the class X509CertSelectorTest method testKeyUsage.
// Tests matching on the key usage extension contained in the certificate.
private void testKeyUsage() {
System.out.println("X.509 Certificate Match on keyUsage");
// bad match
X509CertSelector selector = new X509CertSelector();
boolean[] keyUsage = { true, false, true, false, true, false, true, false };
selector.setKeyUsage(keyUsage);
System.out.println("Selector = " + selector.toString());
checkMatch(selector, cert, false);
// good match
selector.setKeyUsage(cert.getKeyUsage());
System.out.println("Selector = " + selector.toString());
checkMatch(selector, cert, true);
}
Aggregations