@Test public void testGetPrivateKey() throws Exception { File path = OftpTestUtil.getResourceFile(KS_PATH); KeyStore ks = openKeyStore(path, KS_PWD); PrivateKey key = getPrivateKey(ks, KS_PWD); assertNotNull("No private-key were found.", key); }
public static PrivateKey getPrivateKey(KeyStore ks, char[] password) throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException { installBouncyCastleProviderIfNecessary(); PrivateKey key = null; Enumeration<String> aliases = ks.aliases(); while (aliases.hasMoreElements()) { String entry = aliases.nextElement(); if (ks.isKeyEntry(entry)) { key = (PrivateKey) ks.getKey(entry, password); break; } } return key; }
SecurityUtil { public static PrivateKey getPrivateKey(KeyStore ks, char[] password) throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException { installBouncyCastleProviderIfNecessary(); PrivateKey key = null; Enumeration<String> aliases = ks.aliases(); while (aliases.hasMoreElements()) { String entry = aliases.nextElement(); if (ks.isKeyEntry(entry)) { key = (PrivateKey) ks.getKey(entry, password); break; } } return key; } }
SecurityUtil { public static PrivateKey getPrivateKey(KeyStore ks, char[] password) throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException { installBouncyCastleProviderIfNecessary(); PrivateKey key = null; Enumeration<String> aliases = ks.aliases(); while (aliases.hasMoreElements()) { String entry = aliases.nextElement(); if (ks.isKeyEntry(entry)) { key = (PrivateKey) ks.getKey(entry, password); break; } } return key; }  }
SecurityUtil { public static PrivateKey getPrivateKey(KeyStore ks, char[] password) throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException { installBouncyCastleProviderIfNecessary(); PrivateKey key = null; Enumeration<String> aliases = ks.aliases(); while (aliases.hasMoreElements()) { String entry = aliases.nextElement(); if (ks.isKeyEntry(entry)) { key = (PrivateKey) ks.getKey(entry, password); break; } } return key; }  static KeyStore openKeyStore(File path, char[] password); static PrivateKey getPrivateKey(KeyStore ks, char[] password); static X509Certificate openCertificate(File path); static void installBouncyCastleProviderIfNecessary(); static X509Certificate getCertificateEntry(KeyStore ks); static byte[] computeFileHash(File file, String algorithm); }
SecurityUtil { public static PrivateKey getPrivateKey(KeyStore ks, char[] password) throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException { installBouncyCastleProviderIfNecessary(); PrivateKey key = null; Enumeration<String> aliases = ks.aliases(); while (aliases.hasMoreElements()) { String entry = aliases.nextElement(); if (ks.isKeyEntry(entry)) { key = (PrivateKey) ks.getKey(entry, password); break; } } return key; }  static KeyStore openKeyStore(File path, char[] password); static PrivateKey getPrivateKey(KeyStore ks, char[] password); static X509Certificate openCertificate(File path); static void installBouncyCastleProviderIfNecessary(); static X509Certificate getCertificateEntry(KeyStore ks); static byte[] computeFileHash(File file, String algorithm); static final String BC_PROVIDER; static final String DEFAULT_OFTP_HASH_ALGORITHM; }