Package javax.net.ssl
Class KeyManagerFactory
- java.lang.Object
-
- javax.net.ssl.KeyManagerFactory
-
public class KeyManagerFactory extends Object
The public API forKeyManagerFactoryimplementations.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedKeyManagerFactory(KeyManagerFactorySpi factorySpi, Provider provider, String algorithm)Creates a newKeyManagerFactory.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetAlgorithm()Returns the name of the key management algorithm.static StringgetDefaultAlgorithm()Returns the default key manager factory algorithm name.static KeyManagerFactorygetInstance(String algorithm)Creates a newKeyManagerFactoryinstance for the specified key management algorithm.static KeyManagerFactorygetInstance(String algorithm, String provider)Creates a newKeyManagerFactoryinstance for the specified key management algorithm from the specified provider.static KeyManagerFactorygetInstance(String algorithm, Provider provider)Creates a newKeyManagerFactoryinstance for the specified key management algorithm from the specified provider.KeyManager[]getKeyManagers()Returns a list of key managers, one instance for each type of key in the key store.ProvidergetProvider()Returns the provider for thisKeyManagerFactoryinstance.voidinit(KeyStore ks, char[] password)Initializes this instance with the specified key store and password.voidinit(ManagerFactoryParameters spec)Initializes this instance with the specified factory parameters.
-
-
-
Constructor Detail
-
KeyManagerFactory
protected KeyManagerFactory(KeyManagerFactorySpi factorySpi, Provider provider, String algorithm)
Creates a newKeyManagerFactory.- Parameters:
factorySpi- the implementation delegate.provider- the provider.algorithm- the key management algorithm name.
-
-
Method Detail
-
getDefaultAlgorithm
public static final String getDefaultAlgorithm()
Returns the default key manager factory algorithm name.The default algorithm name is specified by the security property:
'ssl.KeyManagerFactory.algorithm'.- Returns:
- the default algorithm name.
-
getInstance
public static final KeyManagerFactory getInstance(String algorithm) throws NoSuchAlgorithmException
Creates a newKeyManagerFactoryinstance for the specified key management algorithm.- Parameters:
algorithm- the name of the requested key management algorithm.- Returns:
- a key manager factory for the requested algorithm.
- Throws:
NoSuchAlgorithmException- if no installed provider can provide the requested algorithm.NullPointerException- ifalgorithmisnull(instead of NoSuchAlgorithmException as in 1.4 release)
-
getInstance
public static final KeyManagerFactory getInstance(String algorithm, String provider) throws NoSuchAlgorithmException, NoSuchProviderException
Creates a newKeyManagerFactoryinstance for the specified key management algorithm from the specified provider.- Parameters:
algorithm- the name of the requested key management algorithm name.provider- the name of the provider that provides the requested algorithm.- Returns:
- a key manager factory for the requested algorithm.
- Throws:
NoSuchAlgorithmException- if the specified provider cannot provide the requested algorithm.NoSuchProviderException- if the specified provider does not exist.NullPointerException- ifalgorithmisnull(instead of NoSuchAlgorithmException as in 1.4 release)
-
getInstance
public static final KeyManagerFactory getInstance(String algorithm, Provider provider) throws NoSuchAlgorithmException
Creates a newKeyManagerFactoryinstance for the specified key management algorithm from the specified provider.- Parameters:
algorithm- the name of the requested key management algorithm name.provider- the provider that provides the requested algorithm.- Returns:
- a key manager factory for the requested algorithm.
- Throws:
NoSuchAlgorithmException- if the specified provider cannot provide the requested algorithm.NullPointerException- ifalgorithmisnull(instead of NoSuchAlgorithmException as in 1.4 release)
-
getAlgorithm
public final String getAlgorithm()
Returns the name of the key management algorithm.- Returns:
- the name of the key management algorithm.
-
getProvider
public final Provider getProvider()
Returns the provider for thisKeyManagerFactoryinstance.- Returns:
- the provider for this
KeyManagerFactoryinstance.
-
init
public final void init(KeyStore ks, char[] password) throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException
Initializes this instance with the specified key store and password.- Parameters:
ks- the key store ornullto use the default key store.password- the password for the specified key store ornullif no key store is provided.- Throws:
KeyStoreException- if initializing this key manager factory fails.NoSuchAlgorithmException- if a required algorithm is not available.UnrecoverableKeyException- if a key cannot be recovered.
-
init
public final void init(ManagerFactoryParameters spec) throws InvalidAlgorithmParameterException
Initializes this instance with the specified factory parameters.- Parameters:
spec- the factory parameters.- Throws:
InvalidAlgorithmParameterException- if an error occurs.
-
getKeyManagers
public final KeyManager[] getKeyManagers()
Returns a list of key managers, one instance for each type of key in the key store.- Returns:
- a list of key managers.
-
-