/** * Gets the key manager factory configuration. * @return factory bean; if no key manager factory * configuration has been set, a default factory bean is returned */ public KeyManagerFactoryFactoryBean getKeyManagerFactory() { if (keyManagerFactory == null) { return new KeyManagerFactoryFactoryBean(); } return keyManagerFactory; }
/** * Creates a {@link KeyManagerFactory} using the receiver's configuration. * @return factory object * @throws NoSuchProviderException if the provider specified by * {@link #setProvider(String)} is not known to the platform * @throws NoSuchAlgorithmException if the algorithm specified by * {@link #setAlgorithm(String)} is not known to the specified provider * (or to the default platform provider if no provider is specified) */ public KeyManagerFactory createKeyManagerFactory() throws NoSuchProviderException, NoSuchAlgorithmException { return getProvider() != null ? KeyManagerFactory.getInstance(getAlgorithm(), getProvider()) : KeyManagerFactory.getInstance(getAlgorithm()); }
+ "': " + getKeyStore().getLocation()); KeyManagerFactory kmf = getKeyManagerFactory().createKeyManagerFactory(); context.addInfo("key manager algorithm '" + kmf.getAlgorithm() + "' provider '" + kmf.getProvider() + "'");
@Test public void testExplicitAlgorithm() throws Exception { factoryBean.setAlgorithm(KeyManagerFactory.getDefaultAlgorithm()); assertNotNull(factoryBean.createKeyManagerFactory()); }
@Test public void testExplicitProvider() throws Exception { KeyManagerFactory factory = KeyManagerFactory.getInstance( KeyManagerFactory.getDefaultAlgorithm()); factoryBean.setProvider(factory.getProvider().getName()); assertNotNull(factoryBean.createKeyManagerFactory()); } }
@Override public KeyManagerFactory createKeyManagerFactory() throws NoSuchProviderException, NoSuchAlgorithmException { factoryCreated = true; return super.createKeyManagerFactory(); }
/** * Creates a {@link KeyManagerFactory} using the receiver's configuration. * @return factory object * @throws NoSuchProviderException if the provider specified by * {@link #setProvider(String)} is not known to the platform * @throws NoSuchAlgorithmException if the algorithm specified by * {@link #setAlgorithm(String)} is not known to the specified provider * (or to the default platform provider if no provider is specified) */ public KeyManagerFactory createKeyManagerFactory() throws NoSuchProviderException, NoSuchAlgorithmException { return getProvider() != null ? KeyManagerFactory.getInstance(getAlgorithm(), getProvider()) : KeyManagerFactory.getInstance(getAlgorithm()); }
@Test public void testDefaults() throws Exception { assertNotNull(factoryBean.createKeyManagerFactory()); }
/** * Gets the key manager factory configuration. * @return factory bean; if no key manager factory * configuration has been set, a default factory bean is returned */ public KeyManagerFactoryFactoryBean getKeyManagerFactory() { if (keyManagerFactory == null) { return new KeyManagerFactoryFactoryBean(); } return keyManagerFactory; }
/** * Creates a {@link KeyManagerFactory} using the receiver's configuration. * @return factory object * @throws NoSuchProviderException if the provider specified by * {@link #setProvider(String)} is not known to the platform * @throws NoSuchAlgorithmException if the algorithm specified by * {@link #setAlgorithm(String)} is not known to the specified provider * (or to the default platform provider if no provider is specified) */ public KeyManagerFactory createKeyManagerFactory() throws NoSuchProviderException, NoSuchAlgorithmException { return getProvider() != null ? KeyManagerFactory.getInstance(getAlgorithm(), getProvider()) : KeyManagerFactory.getInstance(getAlgorithm()); }
/** * Creates key managers using the receiver's key store configuration. * @param context context for status messages * @return an array of key managers or {@code null} if no key store * configuration was provided * @throws NoSuchProviderException if a provider specified for one * of the key manager components is not known to the platform * @throws NoSuchAlgorithmException if an algorithm specified for * one of the key manager components is not known to the relevant * provider * @throws KeyStoreException if an error occurs in reading a key store */ private KeyManager[] createKeyManagers(ContextAware context) throws NoSuchProviderException, NoSuchAlgorithmException, UnrecoverableKeyException, KeyStoreException { if (getKeyStore() == null) return null; KeyStore keyStore = getKeyStore().createKeyStore(); context.addInfo("key store of type '" + keyStore.getType() + "' provider '" + keyStore.getProvider() + "': " + getKeyStore().getLocation()); KeyManagerFactory kmf = getKeyManagerFactory().createKeyManagerFactory(); context.addInfo("key manager algorithm '" + kmf.getAlgorithm() + "' provider '" + kmf.getProvider() + "'"); char[] passphrase = getKeyStore().getPassword().toCharArray(); kmf.init(keyStore, passphrase); return kmf.getKeyManagers(); }
/** * Gets the key manager factory configuration. * @return factory bean; if no key manager factory * configuration has been set, a default factory bean is returned */ public KeyManagerFactoryFactoryBean getKeyManagerFactory() { if (keyManagerFactory == null) { return new KeyManagerFactoryFactoryBean(); } return keyManagerFactory; }
/** * Creates a {@link KeyManagerFactory} using the receiver's configuration. * @return factory object * @throws NoSuchProviderException if the provider specified by * {@link #setProvider(String)} is not known to the platform * @throws NoSuchAlgorithmException if the algorithm specified by * {@link #setAlgorithm(String)} is not known to the specified provider * (or to the default platform provider if no provider is specified) */ public KeyManagerFactory createKeyManagerFactory() throws NoSuchProviderException, NoSuchAlgorithmException { return getProvider() != null ? KeyManagerFactory.getInstance(getAlgorithm(), getProvider()) : KeyManagerFactory.getInstance(getAlgorithm()); }
/** * Creates key managers using the receiver's key store configuration. * @param context context for status messages * @return an array of key managers or {@code null} if no key store * configuration was provided * @throws NoSuchProviderException if a provider specified for one * of the key manager components is not known to the platform * @throws NoSuchAlgorithmException if an algorithm specified for * one of the key manager components is not known to the relevant * provider * @throws KeyStoreException if an error occurs in reading a key store */ private KeyManager[] createKeyManagers(ContextAware context) throws NoSuchProviderException, NoSuchAlgorithmException, UnrecoverableKeyException, KeyStoreException { if (getKeyStore() == null) return null; KeyStore keyStore = getKeyStore().createKeyStore(); context.addInfo("key store of type '" + keyStore.getType() + "' provider '" + keyStore.getProvider() + "': " + getKeyStore().getLocation()); KeyManagerFactory kmf = getKeyManagerFactory().createKeyManagerFactory(); context.addInfo("key manager algorithm '" + kmf.getAlgorithm() + "' provider '" + kmf.getProvider() + "'"); char[] passphrase = getKeyStore().getPassword().toCharArray(); kmf.init(keyStore, passphrase); return kmf.getKeyManagers(); }
/** * Gets the key manager factory configuration. * @return factory bean; if no key manager factory * configuration has been set, a default factory bean is returned */ public KeyManagerFactoryFactoryBean getKeyManagerFactory() { if (keyManagerFactory == null) { return new KeyManagerFactoryFactoryBean(); } return keyManagerFactory; }
/** * Creates a {@link KeyManagerFactory} using the receiver's configuration. * @return factory object * @throws NoSuchProviderException if the provider specified by * {@link #setProvider(String)} is not known to the platform * @throws NoSuchAlgorithmException if the algorithm specified by * {@link #setAlgorithm(String)} is not known to the specified provider * (or to the default platform provider if no provider is specified) */ public KeyManagerFactory createKeyManagerFactory() throws NoSuchProviderException, NoSuchAlgorithmException { return getProvider() != null ? KeyManagerFactory.getInstance(getAlgorithm(), getProvider()) : KeyManagerFactory.getInstance(getAlgorithm()); }
/** * Creates key managers using the receiver's key store configuration. * @param context context for status messages * @return an array of key managers or {@code null} if no key store * configuration was provided * @throws NoSuchProviderException if a provider specified for one * of the key manager components is not known to the platform * @throws NoSuchAlgorithmException if an algorithm specified for * one of the key manager components is not known to the relevant * provider * @throws KeyStoreException if an error occurs in reading a key store */ private KeyManager[] createKeyManagers(ContextAware context) throws NoSuchProviderException, NoSuchAlgorithmException, UnrecoverableKeyException, KeyStoreException { if (getKeyStore() == null) return null; KeyStore keyStore = getKeyStore().createKeyStore(); context.addInfo("key store of type '" + keyStore.getType() + "' provider '" + keyStore.getProvider() + "': " + getKeyStore().getLocation()); KeyManagerFactory kmf = getKeyManagerFactory().createKeyManagerFactory(); context.addInfo("key manager algorithm '" + kmf.getAlgorithm() + "' provider '" + kmf.getProvider() + "'"); char[] passphrase = getKeyStore().getPassword().toCharArray(); kmf.init(keyStore, passphrase); return kmf.getKeyManagers(); }
/** * Gets the key manager factory configuration. * @return factory bean; if no key manager factory * configuration has been set, a default factory bean is returned */ public KeyManagerFactoryFactoryBean getKeyManagerFactory() { if (keyManagerFactory == null) { return new KeyManagerFactoryFactoryBean(); } return keyManagerFactory; }
/** * Creates a {@link KeyManagerFactory} using the receiver's configuration. * @return factory object * @throws NoSuchProviderException if the provider specified by * {@link #setProvider(String)} is not known to the platform * @throws NoSuchAlgorithmException if the algorithm specified by * {@link #setAlgorithm(String)} is not known to the specified provider * (or to the default platform provider if no provider is specified) */ public KeyManagerFactory createKeyManagerFactory() throws NoSuchProviderException, NoSuchAlgorithmException { return getProvider() != null ? KeyManagerFactory.getInstance(getAlgorithm(), getProvider()) : KeyManagerFactory.getInstance(getAlgorithm()); }
/** * Creates key managers using the receiver's key store configuration. * @param context context for status messages * @return an array of key managers or {@code null} if no key store * configuration was provided * @throws NoSuchProviderException if a provider specified for one * of the key manager components is not known to the platform * @throws NoSuchAlgorithmException if an algorithm specified for * one of the key manager components is not known to the relevant * provider * @throws KeyStoreException if an error occurs in reading a key store */ private KeyManager[] createKeyManagers(ContextAware context) throws NoSuchProviderException, NoSuchAlgorithmException, UnrecoverableKeyException, KeyStoreException { if (getKeyStore() == null) return null; KeyStore keyStore = getKeyStore().createKeyStore(); context.addInfo( "key store of type '" + keyStore.getType() + "' provider '" + keyStore.getProvider() + "': " + getKeyStore().getLocation()); KeyManagerFactory kmf = getKeyManagerFactory().createKeyManagerFactory(); context.addInfo("key manager algorithm '" + kmf.getAlgorithm() + "' provider '" + kmf.getProvider() + "'"); char[] passphrase = getKeyStore().getPassword().toCharArray(); kmf.init(keyStore, passphrase); return kmf.getKeyManagers(); }