@Test public void testIssueCert() throws IOException, CertificateException, NoSuchAlgorithmException, OperatorCreationException, NoSuchProviderException, InvalidKeyException, SignatureException { X509Certificate issuer = loadCertificate(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("rootCert.crt"))); KeyPair issuerKeyPair = loadKeyPair(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("rootCert.key"))); String dn = "CN=testIssued, O=testOrg"; KeyPair keyPair = TlsHelper.generateKeyPair(keyPairAlgorithm, keySize); X509Certificate x509Certificate = CertificateUtils.generateIssuedCertificate(dn, keyPair.getPublic(), issuer, issuerKeyPair, signingAlgorithm, days); assertEquals(dn, x509Certificate.getSubjectX500Principal().toString()); assertEquals(issuer.getSubjectX500Principal().toString(), x509Certificate.getIssuerX500Principal().toString()); assertEquals(keyPair.getPublic(), x509Certificate.getPublicKey()); Date notAfter = x509Certificate.getNotAfter(); assertTrue(notAfter.after(inFuture(days - 1))); assertTrue(notAfter.before(inFuture(days + 1))); Date notBefore = x509Certificate.getNotBefore(); assertTrue(notBefore.after(inFuture(-1))); assertTrue(notBefore.before(inFuture(1))); assertEquals(signingAlgorithm, x509Certificate.getSigAlgName()); assertEquals(keyPairAlgorithm, x509Certificate.getPublicKey().getAlgorithm()); x509Certificate.verify(issuerKeyPair.getPublic()); }
public static KeyPair generateKeyPair(String algorithm, int keySize) throws NoSuchAlgorithmException { return createKeyPairGenerator(algorithm, keySize).generateKeyPair(); }
TlsHelper { public static KeyPair generateKeyPair(String algorithm, int keySize) throws NoSuchAlgorithmException { return createKeyPairGenerator(algorithm, keySize).generateKeyPair(); } }
TlsHelper { public static KeyPair generateKeyPair(String algorithm, int keySize) throws NoSuchAlgorithmException { return createKeyPairGenerator(algorithm, keySize).generateKeyPair(); } private  TlsHelper(); }
TlsHelper { public static KeyPair generateKeyPair(String algorithm, int keySize) throws NoSuchAlgorithmException { return createKeyPairGenerator(algorithm, keySize).generateKeyPair(); } private  TlsHelper(); static boolean isUnlimitedStrengthCryptographyEnabled(); static String writeKeyStore(KeyStore keyStore, OutputStreamFactory outputStreamFactory, File file, String password, boolean generatedPassword); static byte[] calculateHMac(String token, PublicKey publicKey); static byte[] getKeyIdentifier(PublicKey publicKey); static String pemEncodeJcaObject(Object object); static JcaPKCS10CertificationRequest parseCsr(String pemEncodedCsr); static X509Certificate parseCertificate(Reader pemEncodedCertificate); static KeyPair parseKeyPair(Reader pemEncodedKeyPair); static T parsePem(Class<T> clazz, Reader pemReader); static KeyPair generateKeyPair(String algorithm, int keySize); static JcaPKCS10CertificationRequest generateCertificationRequest(String requestedDn, String domainAlternativeNames,
            KeyPair keyPair, String signingAlgorithm); static Extensions createDomainAlternativeNamesExtensions(String domainAlternativeNames); }
TlsHelper { public static KeyPair generateKeyPair(String algorithm, int keySize) throws NoSuchAlgorithmException { return createKeyPairGenerator(algorithm, keySize).generateKeyPair(); } private  TlsHelper(); static boolean isUnlimitedStrengthCryptographyEnabled(); static String writeKeyStore(KeyStore keyStore, OutputStreamFactory outputStreamFactory, File file, String password, boolean generatedPassword); static byte[] calculateHMac(String token, PublicKey publicKey); static byte[] getKeyIdentifier(PublicKey publicKey); static String pemEncodeJcaObject(Object object); static JcaPKCS10CertificationRequest parseCsr(String pemEncodedCsr); static X509Certificate parseCertificate(Reader pemEncodedCertificate); static KeyPair parseKeyPair(Reader pemEncodedKeyPair); static T parsePem(Class<T> clazz, Reader pemReader); static KeyPair generateKeyPair(String algorithm, int keySize); static JcaPKCS10CertificationRequest generateCertificationRequest(String requestedDn, String domainAlternativeNames,
            KeyPair keyPair, String signingAlgorithm); static Extensions createDomainAlternativeNamesExtensions(String domainAlternativeNames); static final String JCE_URL; static final String ILLEGAL_KEY_SIZE; }