@Test public void testSelfSignedCertificateWithExtensions() throws Exception { final List<String> usage = Arrays.asList(X500.OID_KP_CLIENT_AUTH); SelfSignedX509CertificateAndSigningKey selfSignedX509CertificateAndSigningKey = populateBasicBuilder() .addExtension(new ExtendedKeyUsageExtension(false, usage)) .addExtension(new KeyUsageExtension(KeyUsage.digitalSignature)) .addExtension(new SubjectAlternativeNamesExtension( true, Arrays.asList(new GeneralName.RFC822Name("bobsmith@example.com"), new GeneralName.DNSName("bobsmith.example.com")))) .build(); X509Certificate certificate = selfSignedX509CertificateAndSigningKey.getSelfSignedCertificate(); assertEquals(2, certificate.getCriticalExtensionOIDs().size()); assertEquals(2, certificate.getNonCriticalExtensionOIDs().size()); assertEquals(usage, certificate.getExtendedKeyUsage()); boolean[] keyUsage = certificate.getKeyUsage(); assertNotNull(keyUsage); assertTrue(KeyUsage.digitalSignature.in(keyUsage)); final Collection<List<?>> names = certificate.getSubjectAlternativeNames(); assertEquals(2, names.size()); final 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)); 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();  }