@Test public void testLoadPrivateKeyFromKeyStore() throws IOException, GeneralSecurityException { Optional<String> optPassword = x509TestContext.getKeyStorePassword().length() > 0 ? Optional.of(x509TestContext.getKeyStorePassword()) : Optional.empty(); PrivateKey privateKey = PemReader.loadPrivateKey( x509TestContext.getKeyStoreFile(KeyStoreFileType.PEM), optPassword); Assert.assertEquals(x509TestContext.getKeyStoreKeyPair().getPrivate(), privateKey); }
public static PrivateKey loadPrivateKey(File privateKeyFile, Optional<String> keyPassword) throws IOException, GeneralSecurityException { String privateKey = new String(Files.readAllBytes(privateKeyFile.toPath()), US_ASCII); return loadPrivateKey(privateKey, keyPassword); }
PemReader { public static PrivateKey loadPrivateKey(File privateKeyFile, Optional<String> keyPassword) throws IOException, GeneralSecurityException { String privateKey = new String(Files.readAllBytes(privateKeyFile.toPath()), US_ASCII); return loadPrivateKey(privateKey, keyPassword); } }
PemReader { public static PrivateKey loadPrivateKey(File privateKeyFile, Optional<String> keyPassword) throws IOException, GeneralSecurityException { String privateKey = new String(Files.readAllBytes(privateKeyFile.toPath()), US_ASCII); return loadPrivateKey(privateKey, keyPassword); } private  PemReader(); }
PemReader { public static PrivateKey loadPrivateKey(File privateKeyFile, Optional<String> keyPassword) throws IOException, GeneralSecurityException { String privateKey = new String(Files.readAllBytes(privateKeyFile.toPath()), US_ASCII); return loadPrivateKey(privateKey, keyPassword); } private  PemReader(); static KeyStore loadTrustStore(File certificateChainFile); static KeyStore loadKeyStore(File certificateChainFile, File privateKeyFile, Optional<String> keyPassword); static List<X509Certificate> readCertificateChain(File certificateChainFile); static List<X509Certificate> readCertificateChain(String certificateChain); static PrivateKey loadPrivateKey(File privateKeyFile, Optional<String> keyPassword); static PrivateKey loadPrivateKey(String privateKey, Optional<String> keyPassword); static PublicKey loadPublicKey(File publicKeyFile); static PublicKey loadPublicKey(String publicKey); }
PemReader { public static PrivateKey loadPrivateKey(File privateKeyFile, Optional<String> keyPassword) throws IOException, GeneralSecurityException { String privateKey = new String(Files.readAllBytes(privateKeyFile.toPath()), US_ASCII); return loadPrivateKey(privateKey, keyPassword); } private  PemReader(); static KeyStore loadTrustStore(File certificateChainFile); static KeyStore loadKeyStore(File certificateChainFile, File privateKeyFile, Optional<String> keyPassword); static List<X509Certificate> readCertificateChain(File certificateChainFile); static List<X509Certificate> readCertificateChain(String certificateChain); static PrivateKey loadPrivateKey(File privateKeyFile, Optional<String> keyPassword); static PrivateKey loadPrivateKey(String privateKey, Optional<String> keyPassword); static PublicKey loadPublicKey(File publicKeyFile); static PublicKey loadPublicKey(String publicKey);  }