Package javax.net.ssl
Class TrustManagerFactory
- java.lang.Object
-
- javax.net.ssl.TrustManagerFactory
-
public class TrustManagerFactory extends Object
The factory forTrustManagers based onKeyStoreor provider specific implementation.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedTrustManagerFactory(TrustManagerFactorySpi factorySpi, Provider provider, String algorithm)Creates a newTrustManagerFactoryinstance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetAlgorithm()Returns the name of thisTrustManagerFactoryalgorithm implementation.static StringgetDefaultAlgorithm()Returns the default algorithm name for theTrustManagerFactory.static TrustManagerFactorygetInstance(String algorithm)Creates a newTrustManagerFactoryinstance for the specified trust management algorithm.static TrustManagerFactorygetInstance(String algorithm, String provider)Creates a newTrustManagerFactoryinstance for the specified trust management algorithm from the specified provider.static TrustManagerFactorygetInstance(String algorithm, Provider provider)Creates a newTrustManagerFactoryinstance for the specified trust management algorithm from the specified provider.ProvidergetProvider()Returns the provider for thisTrustManagerFactoryinstance.TrustManager[]getTrustManagers()Returns the list ofTrustManagers with one entry for each type of trust material.voidinit(KeyStore ks)Initializes this factory instance with the specified keystore as source of certificate authorities and trust material.voidinit(ManagerFactoryParameters spec)Initializes this factory instance with the specified provider-specific parameters for a source of trust material.
-
-
-
Constructor Detail
-
TrustManagerFactory
protected TrustManagerFactory(TrustManagerFactorySpi factorySpi, Provider provider, String algorithm)
Creates a newTrustManagerFactoryinstance.- Parameters:
factorySpi- the implementation delegate.provider- the provideralgorithm- the algorithm name.
-
-
Method Detail
-
getDefaultAlgorithm
public static final String getDefaultAlgorithm()
Returns the default algorithm name for theTrustManagerFactory. The default algorithm name is specified by the security property'ssl.TrustManagerFactory.algorithm'.- Returns:
- the default algorithm name.
-
getInstance
public static final TrustManagerFactory getInstance(String algorithm) throws NoSuchAlgorithmException
Creates a newTrustManagerFactoryinstance for the specified trust management algorithm.- Parameters:
algorithm- the name of the requested trust management algorithm.- Returns:
- a trust 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 TrustManagerFactory getInstance(String algorithm, String provider) throws NoSuchAlgorithmException, NoSuchProviderException
Creates a newTrustManagerFactoryinstance for the specified trust management algorithm from the specified provider.- Parameters:
algorithm- the name of the requested trust management algorithm name.provider- the name of the provider that provides the requested algorithm.- Returns:
- a trust 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 TrustManagerFactory getInstance(String algorithm, Provider provider) throws NoSuchAlgorithmException
Creates a newTrustManagerFactoryinstance for the specified trust 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 thisTrustManagerFactoryalgorithm implementation.- Returns:
- the name of this
TrustManagerFactoryalgorithm implementation.
-
getProvider
public final Provider getProvider()
Returns the provider for thisTrustManagerFactoryinstance.- Returns:
- the provider for this
TrustManagerFactoryinstance.
-
init
public final void init(KeyStore ks) throws KeyStoreException
Initializes this factory instance with the specified keystore as source of certificate authorities and trust material.- Parameters:
ks- the keystore ornull.- Throws:
KeyStoreException- if the initialization fails.
-
init
public final void init(ManagerFactoryParameters spec) throws InvalidAlgorithmParameterException
Initializes this factory instance with the specified provider-specific parameters for a source of trust material.- Parameters:
spec- the provider-specific parameters.- Throws:
InvalidAlgorithmParameterException- if the initialization fails.
-
getTrustManagers
public final TrustManager[] getTrustManagers()
Returns the list ofTrustManagers with one entry for each type of trust material.- Returns:
- the list of
TrustManagers
-
-