Package javax.net.ssl
Class TrustManagerFactory
java.lang.Object
javax.net.ssl.TrustManagerFactory
public class TrustManagerFactory extends Object
The factory for
TrustManagers based on KeyStore or provider
specific implementation.-
Constructor Summary
Constructors Modifier Constructor Description protectedTrustManagerFactory(TrustManagerFactorySpi factorySpi, Provider provider, String algorithm)Creates a newTrustManagerFactoryinstance. -
Method Summary
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 Details
-
TrustManagerFactory
protected TrustManagerFactory(TrustManagerFactorySpi factorySpi, Provider provider, String algorithm)Creates a newTrustManagerFactoryinstance.- Parameters:
factorySpi- the implementation delegate.provider- the provideralgorithm- the algorithm name.
-
-
Method Details
-
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 NoSuchAlgorithmExceptionCreates 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, NoSuchProviderExceptionCreates 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 NoSuchAlgorithmExceptionCreates 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
Returns the name of thisTrustManagerFactoryalgorithm implementation.- Returns:
- the name of this
TrustManagerFactoryalgorithm implementation.
-
getProvider
Returns the provider for thisTrustManagerFactoryinstance.- Returns:
- the provider for this
TrustManagerFactoryinstance.
-
init
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
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
Returns the list ofTrustManagers with one entry for each type of trust material.- Returns:
- the list of
TrustManagers
-