@Test void checkKeyStoreIsPKCS12() { KeystoreHelper keystoreHelper = new KeystoreHelper(); KeyStore keyStore = keystoreHelper.createKeyStoreInstance(emptyList()); assertNotNull(keyStore); assertEquals("PKCS12", keyStore.getType()); }
@VisibleForTesting KeyStore createKeyStoreInstance(Collection<PrivateKey> privateKeys) { Security.insertProviderAt(new BouncyCastleProvider(), 1); KeyStore ks; try { ks = loadKeyStore(null, keystorePassword); } catch (CertificateException | NoSuchAlgorithmException | IOException | KeyStoreException e) { throw new KeyStoreCreationException("Error creating default key store", e); } privateKeys.forEach(pk -> storeKey(ks, pk)); return ks; }
KeystoreHelper { @VisibleForTesting KeyStore createKeyStoreInstance(Collection<PrivateKey> privateKeys) { Security.insertProviderAt(new BouncyCastleProvider(), 1); KeyStore ks; try { ks = loadKeyStore(null, keystorePassword); } catch (CertificateException | NoSuchAlgorithmException | IOException | KeyStoreException e) { throw new KeyStoreCreationException("Error creating default key store", e); } privateKeys.forEach(pk -> storeKey(ks, pk)); return ks; } }
KeystoreHelper { @VisibleForTesting KeyStore createKeyStoreInstance(Collection<PrivateKey> privateKeys) { Security.insertProviderAt(new BouncyCastleProvider(), 1); KeyStore ks; try { ks = loadKeyStore(null, keystorePassword); } catch (CertificateException | NoSuchAlgorithmException | IOException | KeyStoreException e) { throw new KeyStoreCreationException("Error creating default key store", e); } privateKeys.forEach(pk -> storeKey(ks, pk)); return ks; } @VisibleForTesting  KeystoreHelper(); }
KeystoreHelper { @VisibleForTesting KeyStore createKeyStoreInstance(Collection<PrivateKey> privateKeys) { Security.insertProviderAt(new BouncyCastleProvider(), 1); KeyStore ks; try { ks = loadKeyStore(null, keystorePassword); } catch (CertificateException | NoSuchAlgorithmException | IOException | KeyStoreException e) { throw new KeyStoreCreationException("Error creating default key store", e); } privateKeys.forEach(pk -> storeKey(ks, pk)); return ks; } @VisibleForTesting  KeystoreHelper(); @VisibleForTesting byte[] createKeyStore(Collection<PrivateKey> privateKeys); Certificate[] loadCertificatesForPrivateKey(PrivateKey pk, KeyStore privateKeyStore); KeyStore loadKeyStore(PrivateKey pk); @NotNull char[] getKeystorePassword(); @NotNull String getKeyStoreType(); }
KeystoreHelper { @VisibleForTesting KeyStore createKeyStoreInstance(Collection<PrivateKey> privateKeys) { Security.insertProviderAt(new BouncyCastleProvider(), 1); KeyStore ks; try { ks = loadKeyStore(null, keystorePassword); } catch (CertificateException | NoSuchAlgorithmException | IOException | KeyStoreException e) { throw new KeyStoreCreationException("Error creating default key store", e); } privateKeys.forEach(pk -> storeKey(ks, pk)); return ks; } @VisibleForTesting  KeystoreHelper(); @VisibleForTesting byte[] createKeyStore(Collection<PrivateKey> privateKeys); Certificate[] loadCertificatesForPrivateKey(PrivateKey pk, KeyStore privateKeyStore); KeyStore loadKeyStore(PrivateKey pk); @NotNull char[] getKeystorePassword(); @NotNull String getKeyStoreType();  }