/** * Creates a new {@link KeyStore} with the default keystore type and initializes it. * * @return initialized keystore * * @throws GeneralSecurityException if the keystore cannot be initialized */ public static KeyStore newInstance() throws GeneralSecurityException { return newInstance(DEFAULT_TYPE); }
/** * Creates a new {@link KeyStore} with the default keystore type and initializes it. * * @return initialized keystore * * @throws GeneralSecurityException if the keystore cannot be initialized */ public static KeyStore newInstance() throws GeneralSecurityException { return newInstance(DEFAULT_TYPE); }
/** * Creates a new {@link KeyStore} with the default keystore type and initializes it. * * @return initialized keystore * * @throws GeneralSecurityException if the keystore cannot be initialized */ public static KeyStore newInstance() throws GeneralSecurityException { return newInstance(DEFAULT_TYPE); }
/** * Creates a new {@link KeyStore} and initializes it. * * @param type of keystore instance * * @return initialized keystore * * @throws GeneralSecurityException if the keystore cannot be initialized */ public static KeyStore newInstance(final String type) throws GeneralSecurityException { return newInstance(type, null); }
/** * Creates a new {@link KeyStore} with the default keystore type and initializes it. * * @param password to protect the keystore * * @return initialized keystore * * @throws GeneralSecurityException if the keystore cannot be initialized */ public static KeyStore newInstance(final char[] password) throws GeneralSecurityException { return newInstance(DEFAULT_TYPE, password); }
/** * Creates a new {@link KeyStore} with the default keystore type and initializes it. * * @param password to protect the keystore * * @return initialized keystore * * @throws GeneralSecurityException if the keystore cannot be initialized */ public static KeyStore newInstance(final char[] password) throws GeneralSecurityException { return newInstance(DEFAULT_TYPE, password); }
/** * Creates a new {@link KeyStore} with the default keystore type and initializes it. * * @param password to protect the keystore * * @return initialized keystore * * @throws GeneralSecurityException if the keystore cannot be initialized */ public static KeyStore newInstance(final char[] password) throws GeneralSecurityException { return newInstance(DEFAULT_TYPE, password); }
/** * Creates a new {@link KeyStore} and initializes it. * * @param type of keystore instance * * @return initialized keystore * * @throws GeneralSecurityException if the keystore cannot be initialized */ public static KeyStore newInstance(final String type) throws GeneralSecurityException { return newInstance(type, null); }
/** * Creates a new {@link KeyStore} and initializes it. * * @param type of keystore instance * * @return initialized keystore * * @throws GeneralSecurityException if the keystore cannot be initialized */ public static KeyStore newInstance(final String type) throws GeneralSecurityException { return newInstance(type, null); }
@Override protected TrustManager[] createTrustManagers() throws GeneralSecurityException { TrustManager[] tm = null; if (trustCerts != null && trustCerts.length > 0) { final KeyStore ks = KeyStoreUtils.newInstance(); KeyStoreUtils.setCertificateEntry("ldap_trust_", ks, trustCerts); final TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmf.init(ks); tm = tmf.getTrustManagers(); } return tm; }
/** * Creates a new trust manager factory. * * @param certs to add as trusted material * * @return trust manager factory * * @throws GeneralSecurityException if the trust manager factory cannot be initialized */ protected TrustManagerFactory getTrustManagerFactory(final X509Certificate[] certs) throws GeneralSecurityException { final KeyStore ks = KeyStoreUtils.newInstance(); KeyStoreUtils.setCertificateEntry("ldap_trust_", ks, certs); final TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmf.init(ks); return tmf; }
/** * Creates a new trust manager factory. * * @param certs to add as trusted material * * @return trust manager factory * * @throws GeneralSecurityException if the trust manager factory cannot be initialized */ protected TrustManagerFactory getTrustManagerFactory(final X509Certificate[] certs) throws GeneralSecurityException { final KeyStore ks = KeyStoreUtils.newInstance(); KeyStoreUtils.setCertificateEntry("ldap_trust_", ks, certs); final TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmf.init(ks); return tmf; }
@Override public KeyManager[] getKeyManagers() throws GeneralSecurityException { KeyManager[] km = null; if (authenticationCert != null && authenticationKey != null) { final KeyStore ks = KeyStoreUtils.newInstance(); KeyStoreUtils.setKeyEntry( "ldap_client_auth", ks, "changeit".toCharArray(), authenticationKey, authenticationCert); final KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); kmf.init(ks, "changeit".toCharArray()); km = kmf.getKeyManagers(); } return km; }
/** * Creates a new key manager factory. * * @param cert to initialize the key manager factory * @param key to initialize the key manager factory * * @return key manager factory * * @throws GeneralSecurityException if the key manager factory cannot be initialized */ protected KeyManagerFactory getKeyManagerFactory(final X509Certificate cert, final PrivateKey key) throws GeneralSecurityException { final KeyStore ks = KeyStoreUtils.newInstance(); KeyStoreUtils.setKeyEntry("ldap_client_auth", ks, "changeit".toCharArray(), key, cert); final KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); kmf.init(ks, "changeit".toCharArray()); return kmf; }
/** * Creates a new key manager factory. * * @param cert to initialize the key manager factory * @param key to initialize the key manager factory * * @return key manager factory * * @throws GeneralSecurityException if the key manager factory cannot be initialized */ protected KeyManagerFactory getKeyManagerFactory(final X509Certificate cert, final PrivateKey key) throws GeneralSecurityException { final KeyStore ks = KeyStoreUtils.newInstance(); KeyStoreUtils.setKeyEntry("ldap_client_auth", ks, "changeit".toCharArray(), key, cert); final KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); kmf.init(ks, "changeit".toCharArray()); return kmf; }
@Override protected TrustManager[] createTrustManagers() throws GeneralSecurityException { TrustManager[] tm = null; if (trustKeystore != null) { final TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); if (trustAliases != null) { final KeyStore ks = KeyStoreUtils.newInstance(); for (String alias : trustAliases) { final KeyStore.Entry entry = KeyStoreUtils.getEntry(alias, trustKeystore, null); KeyStoreUtils.setEntry(alias, entry, ks, null); } tmf.init(ks); } else { tmf.init(trustKeystore); } tm = tmf.getTrustManagers(); } return tm; }
@Override public KeyManager[] getKeyManagers() throws GeneralSecurityException { KeyManager[] km = null; if (authenticationKeystore != null && authenticationPassword != null) { final KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); if (authenticationAliases != null) { final KeyStore ks = KeyStoreUtils.newInstance(authenticationPassword); for (String alias : authenticationAliases) { final KeyStore.Entry entry = KeyStoreUtils.getEntry(alias, authenticationKeystore, authenticationPassword); KeyStoreUtils.setEntry(alias, entry, ks, authenticationPassword); } kmf.init(ks, authenticationPassword); } else { kmf.init(authenticationKeystore, authenticationPassword); } km = kmf.getKeyManagers(); } return km; }
/** * Creates a new trust manager factory. * * @param keystore to initialize the trust manager factory * @param aliases to include from the supplied keystore or null to include all entries * * @return trust manager factory * * @throws GeneralSecurityException if the trust manager factory cannot be initialized */ protected TrustManagerFactory getTrustManagerFactory(final KeyStore keystore, final String... aliases) throws GeneralSecurityException { final TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); if (aliases != null && aliases.length > 0) { final KeyStore ks = KeyStoreUtils.newInstance(); for (String alias : aliases) { final KeyStore.Entry entry = KeyStoreUtils.getEntry(alias, keystore, null); KeyStoreUtils.setEntry(alias, entry, ks, null); } tmf.init(ks); } else { tmf.init(keystore); } return tmf; }
/** * Creates a new trust manager factory. * * @param keystore to initialize the trust manager factory * @param aliases to include from the supplied keystore or null to include all entries * * @return trust manager factory * * @throws GeneralSecurityException if the trust manager factory cannot be initialized */ protected TrustManagerFactory getTrustManagerFactory(final KeyStore keystore, final String... aliases) throws GeneralSecurityException { final TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); if (aliases != null && aliases.length > 0) { final KeyStore ks = KeyStoreUtils.newInstance(); for (String alias : aliases) { final KeyStore.Entry entry = KeyStoreUtils.getEntry(alias, keystore, null); KeyStoreUtils.setEntry(alias, entry, ks, null); } tmf.init(ks); } else { tmf.init(keystore); } return tmf; }
/** * Creates a new key manager factory. * * @param keystore to initialize the key manager factory * @param password to unlock the supplied keystore * @param aliases to include from the supplied keystore or null to include all entries * * @return key manager factory * * @throws GeneralSecurityException if the key manager factory cannot be initialized */ protected KeyManagerFactory getKeyManagerFactory( final KeyStore keystore, final char[] password, final String... aliases) throws GeneralSecurityException { final KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); if (aliases != null && aliases.length > 0) { final KeyStore ks = KeyStoreUtils.newInstance(password); for (String alias : aliases) { final KeyStore.Entry entry = KeyStoreUtils.getEntry(alias, keystore, password); KeyStoreUtils.setEntry(alias, entry, ks, password); } kmf.init(ks, password); } else { kmf.init(keystore, password); } return kmf; }