Package javax.net.ssl
Class TrustManagerFactory
- java.lang.Object
-
- javax.net.ssl.TrustManagerFactory
-
public class TrustManagerFactory extends Object
This class acts as a factory for trust managers based on a source of trust material. Each trust manager manages a specific type of trust material for use by secure sockets. The trust material is based on a KeyStore and/or provider specific sources.- Since:
- 1.4
- See Also:
TrustManager
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetAlgorithm()Returns the algorithm name of thisTrustManagerFactoryobject.static StringgetDefaultAlgorithm()Obtains the default TrustManagerFactory algorithm name.static TrustManagerFactorygetInstance(String algorithm)Returns aTrustManagerFactoryobject that acts as a factory for trust managers.TrustManager[]getTrustManagers()Returns one trust manager for each type of trust material.voidinit(KeyStore ks)Initializes this factory with a source of certificate authorities and related trust material.
-
-
-
Method Detail
-
getDefaultAlgorithm
public static final String getDefaultAlgorithm()
Obtains the default TrustManagerFactory algorithm name.The default TrustManager can be changed at runtime by setting the value of the
ssl.TrustManagerFactory.algorithmsecurity property to the desired algorithm name.- Returns:
- the default algorithm name as specified by the
ssl.TrustManagerFactory.algorithmsecurity property, or an implementation-specific default if no such property exists.
-
getAlgorithm
public final String getAlgorithm()
Returns the algorithm name of thisTrustManagerFactoryobject.This is the same name that was specified in one of the
getInstancecalls that created thisTrustManagerFactoryobject.- Returns:
- the algorithm name of this
TrustManagerFactoryobject
-
getInstance
public static final TrustManagerFactory getInstance(String algorithm) throws NoSuchAlgorithmException
Returns aTrustManagerFactoryobject that acts as a factory for trust managers.This method traverses the list of registered security Providers, starting with the most preferred Provider. A new TrustManagerFactory object encapsulating the TrustManagerFactorySpi implementation from the first Provider that supports the specified algorithm is returned.
- Parameters:
algorithm- the standard name of the requested trust management algorithm. See the Java Secure Socket Extension Reference Guide for information about standard algorithm names.- Returns:
- the new
TrustManagerFactoryobject. - Throws:
NoSuchAlgorithmException- if no Provider supports a TrustManagerFactorySpi implementation for the specified algorithm.NullPointerException- if algorithm is null.
-
init
public final void init(@Nullable KeyStore ks) throws KeyStoreException
Initializes this factory with a source of certificate authorities and related trust material.The provider typically uses a KeyStore as a basis for making trust decisions.
- Parameters:
ks- the key store, or null- Throws:
KeyStoreException- if this operation fails
-
getTrustManagers
public final TrustManager[] getTrustManagers()
Returns one trust manager for each type of trust material.- Returns:
- the trust managers
- Throws:
IllegalStateException- if the factory is not initialized.
-
-