Package javax.net.ssl

Class KeyManagerFactory

java.lang.Object
javax.net.ssl.KeyManagerFactory

public class KeyManagerFactory
extends Object
The public API for KeyManagerFactory implementations.
  • Constructor Details

    • KeyManagerFactory

      protected KeyManagerFactory​(KeyManagerFactorySpi factorySpi, Provider provider, String algorithm)
      Creates a new KeyManagerFactory.
      Parameters:
      factorySpi - the implementation delegate.
      provider - the provider.
      algorithm - the key management algorithm name.
  • Method Details

    • 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 new KeyManagerFactory instance 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 - if algorithm is null (instead of NoSuchAlgorithmException as in 1.4 release)
    • getInstance

      public static final KeyManagerFactory getInstance​(String algorithm, String provider) throws NoSuchAlgorithmException, NoSuchProviderException
      Creates a new KeyManagerFactory instance 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 - if algorithm is null (instead of NoSuchAlgorithmException as in 1.4 release)
    • getInstance

      public static final KeyManagerFactory getInstance​(String algorithm, Provider provider) throws NoSuchAlgorithmException
      Creates a new KeyManagerFactory instance 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 - if algorithm is null (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 this KeyManagerFactory instance.
      Returns:
      the provider for this KeyManagerFactory instance.
    • 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 or null to use the default key store.
      password - the password for the specified key store or null if 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.