Package org.forgerock.opendj.security
Class TrustManagers
- java.lang.Object
-
- org.forgerock.opendj.security.TrustManagers
-
public final class TrustManagers extends Object
This class contains methods for creating common types of trust manager.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static X509TrustManagercheckUsingKeyStore(KeyStore optionalKeyStore)Creates a newX509TrustManagerwhich will use the key store to determine whether to trust a certificate.static X509TrustManagercheckUsingKeyStoreFile(String file, char[] password, String type)Creates a newX509TrustManagerwhich will use the named trust store file to determine whether to trust a certificate.static X509TrustManagerdistrustAll()Returns anX509TrustManagerwhich does not trust any certificates.static X509ExtendedTrustManagertrustAll()Returns anX509ExtendedTrustManagerwhich trusts all certificates.static X509ExtendedTrustManagertrustAny(List<TrustManager> trustManagers)Returns aX509ExtendedTrustManagerthat wraps the givenTrustManagers and that yields a positive result if ever one of the wrappedTrustManagers yields a positive result.
-
-
-
Method Detail
-
checkUsingKeyStoreFile
public static X509TrustManager checkUsingKeyStoreFile(String file, char[] password, String type) throws GeneralSecurityException, IOException
Creates a newX509TrustManagerwhich will use the named trust store file to determine whether to trust a certificate. It will use the provided trust store type and password.- Parameters:
file- The trust store file name.password- The trust store password, which may benull.type- The trust store type, which may benullto indicate that the default trust store type for the JVM (e.g.KeyManagers.JKS) should be used.- Returns:
- A new
X509TrustManagerwhich will use the named trust store file to determine whether to trust a certificate. - Throws:
GeneralSecurityException- If the trust store could not be loaded, perhaps due to incorrect type, or missing algorithms.IOException- If the trust store file could not be found or could not be read.NullPointerException- If provided file wasnull.
-
checkUsingKeyStore
public static X509TrustManager checkUsingKeyStore(KeyStore optionalKeyStore) throws NoSuchAlgorithmException, KeyStoreException
Creates a newX509TrustManagerwhich will use the key store to determine whether to trust a certificate.- Parameters:
optionalKeyStore- The key store containing the trusted certificates ornullto use the default key store.- Returns:
- A new
X509TrustManagerwhich will use the key store to determine whether to trust a certificate. - Throws:
NoSuchAlgorithmException- If default trust store algorithm cannot be found.KeyStoreException- If the trust manager could not be initialized with the provided key store.
-
distrustAll
public static X509TrustManager distrustAll()
Returns anX509TrustManagerwhich does not trust any certificates.- Returns:
- An
X509TrustManagerwhich does not trust any certificates.
-
trustAll
public static X509ExtendedTrustManager trustAll()
Returns anX509ExtendedTrustManagerwhich trusts all certificates.- Returns:
- An
X509ExtendedTrustManagerwhich trusts all certificates.
-
trustAny
public static X509ExtendedTrustManager trustAny(List<TrustManager> trustManagers)
Returns aX509ExtendedTrustManagerthat wraps the givenTrustManagers and that yields a positive result if ever one of the wrappedTrustManagers yields a positive result.- Parameters:
trustManagers- The trust managers to wrap.- Returns:
- The instance of X509TrustManager that wraps the given trust managers.
-
-