@Test public void testStore() throws Exception { final KeyStoreHelper helper = new KeyStoreHelper(CertificateUtilTest.TEST_CERT, "test-cert"); helper.store(); assertThat(helper.getKeyStorePath()).isNotEmpty(); assertThat(helper.getPassword()).isNotEmpty(); }
public KeyStoreHelper store() { try { KeyStore keyStore = CertificateUtil.createKeyStore(certificate, alias); tempFile = Files.createTempFile(alias, ".ks", PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rw-------"))); password = generatePassword(); try (OutputStream stream = new FileOutputStream(tempFile.toFile())) { keyStore.store(stream, password.toCharArray()); } } catch (GeneralSecurityException | IOException e) { throw new IllegalArgumentException(String.format("Error creating key store %s: %s", alias, e.getMessage()), e); } return this; }
KeyStoreHelper { public KeyStoreHelper store() { try { KeyStore keyStore = CertificateUtil.createKeyStore(certificate, alias); tempFile = Files.createTempFile(alias, ".ks", PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rw-------"))); password = generatePassword(); try (OutputStream stream = new FileOutputStream(tempFile.toFile())) { keyStore.store(stream, password.toCharArray()); } } catch (GeneralSecurityException | IOException e) { throw new IllegalArgumentException(String.format("Error creating key store %s: %s", alias, e.getMessage()), e); } return this; } }
KeyStoreHelper { public KeyStoreHelper store() { try { KeyStore keyStore = CertificateUtil.createKeyStore(certificate, alias); tempFile = Files.createTempFile(alias, ".ks", PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rw-------"))); password = generatePassword(); try (OutputStream stream = new FileOutputStream(tempFile.toFile())) { keyStore.store(stream, password.toCharArray()); } } catch (GeneralSecurityException | IOException e) { throw new IllegalArgumentException(String.format("Error creating key store %s: %s", alias, e.getMessage()), e); } return this; } KeyStoreHelper(String certificate, String alias); }
KeyStoreHelper { public KeyStoreHelper store() { try { KeyStore keyStore = CertificateUtil.createKeyStore(certificate, alias); tempFile = Files.createTempFile(alias, ".ks", PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rw-------"))); password = generatePassword(); try (OutputStream stream = new FileOutputStream(tempFile.toFile())) { keyStore.store(stream, password.toCharArray()); } } catch (GeneralSecurityException | IOException e) { throw new IllegalArgumentException(String.format("Error creating key store %s: %s", alias, e.getMessage()), e); } return this; } KeyStoreHelper(String certificate, String alias); String getKeyStorePath(); String getPassword(); KeyStoreHelper store(); boolean clean(); static KeyStore defaultKeyStore(); static KeyStore createKeyStoreWithCustomCertificate(String alias, String certContent); }
KeyStoreHelper { public KeyStoreHelper store() { try { KeyStore keyStore = CertificateUtil.createKeyStore(certificate, alias); tempFile = Files.createTempFile(alias, ".ks", PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rw-------"))); password = generatePassword(); try (OutputStream stream = new FileOutputStream(tempFile.toFile())) { keyStore.store(stream, password.toCharArray()); } } catch (GeneralSecurityException | IOException e) { throw new IllegalArgumentException(String.format("Error creating key store %s: %s", alias, e.getMessage()), e); } return this; } KeyStoreHelper(String certificate, String alias); String getKeyStorePath(); String getPassword(); KeyStoreHelper store(); boolean clean(); static KeyStore defaultKeyStore(); static KeyStore createKeyStoreWithCustomCertificate(String alias, String certContent);  }