@Test public void testSelfSignedCertificateWithStringExtensionValues() throws Exception { SelfSignedX509CertificateAndSigningKey selfSignedX509CertificateAndSigningKey = populateBasicBuilder() .addExtension(true, "BasicConstraints", "CA:true,pathlen:2") .addExtension(true, "KeyUsage", "digitalSignature,keyCertSign,cRLSign") .addExtension(false, "ExtendedKeyUsage", "clientAuth,timeStamping") .addExtension(false, "SubjectAlternativeName", "email:bobsmith@example.com,DNS:bobsmith.example.com") .addExtension(false, "IssuerAlternativeName", "IP:10.20.30.40,uri:http: .addExtension(false, "AuthorityInfoAccess", "ocsp:uri:http: .addExtension(false, "SubjectInfoAccess", "timeStamping:IP:11.22.33.44,caRepository:uri:http: .build(); X509Certificate certificate = selfSignedX509CertificateAndSigningKey.getSelfSignedCertificate(); assertEquals(2, certificate.getCriticalExtensionOIDs().size()); assertEquals(6, certificate.getNonCriticalExtensionOIDs().size()); assertEquals(2, certificate.getBasicConstraints()); boolean[] keyUsage = certificate.getKeyUsage(); assertNotNull(keyUsage); assertTrue(KeyUsage.digitalSignature.in(keyUsage)); assertTrue(KeyUsage.keyCertSign.in(keyUsage)); assertTrue(KeyUsage.cRLSign.in(keyUsage)); assertEquals(Arrays.asList(X500.OID_KP_CLIENT_AUTH, X500.OID_KP_TIME_STAMPING), certificate.getExtendedKeyUsage()); Collection<List<?>> names = certificate.getSubjectAlternativeNames(); assertEquals(2, names.size()); Iterator<List<?>> iterator = names.iterator(); List<?> item = iterator.next(); assertEquals(2, item.size()); assertEquals(Integer.valueOf(GeneralName.RFC_822_NAME), item.get(0)); assertEquals("bobsmith@example.com", item.get(1)); item = iterator.next(); assertEquals(2, item.size()); assertEquals(Integer.valueOf(GeneralName.DNS_NAME), item.get(0)); assertEquals("bobsmith.example.com", item.get(1)); names = certificate.getIssuerAlternativeNames(); assertEquals(2, names.size()); iterator = names.iterator(); item = iterator.next(); assertEquals(2, item.size()); assertEquals(Integer.valueOf(GeneralName.IP_ADDRESS), item.get(0)); assertEquals("10.20.30.40", item.get(1)); item = iterator.next(); assertEquals(2, item.size()); assertEquals(Integer.valueOf(GeneralName.URI_NAME), item.get(0)); assertEquals("http: byte[] authorityInfoAccessExtension = certificate.getExtensionValue(X500.OID_PE_AUTHORITY_INFO_ACCESS); assertNotNull(authorityInfoAccessExtension); byte[] subjectInfoAccessExtension = certificate.getExtensionValue(X500.OID_PE_SUBJECT_INFO_ACCESS); assertNotNull(subjectInfoAccessExtension); assertNotNull(certificate.getExtensionValue(X500.OID_CE_SUBJECT_KEY_IDENTIFIER)); }
public X509Certificate getSelfSignedCertificate() { return selfSignedcertificate; }
SelfSignedX509CertificateAndSigningKey { public X509Certificate getSelfSignedCertificate() { return selfSignedcertificate; } }
SelfSignedX509CertificateAndSigningKey { public X509Certificate getSelfSignedCertificate() { return selfSignedcertificate; } private  SelfSignedX509CertificateAndSigningKey(Builder builder); }
SelfSignedX509CertificateAndSigningKey { public X509Certificate getSelfSignedCertificate() { return selfSignedcertificate; } private  SelfSignedX509CertificateAndSigningKey(Builder builder); X509Certificate getSelfSignedCertificate(); PrivateKey getSigningKey(); PKCS10CertificateSigningRequest generatePKCS10CertificateSigningRequest(); static Builder builder(); }
SelfSignedX509CertificateAndSigningKey { public X509Certificate getSelfSignedCertificate() { return selfSignedcertificate; } private  SelfSignedX509CertificateAndSigningKey(Builder builder); X509Certificate getSelfSignedCertificate(); PrivateKey getSigningKey(); PKCS10CertificateSigningRequest generatePKCS10CertificateSigningRequest(); static Builder builder();  }