public final class TrustManagers extends Object
Modifier and Type | Method and Description |
---|---|
static X509TrustManager |
checkUsingKeyStore(KeyStore optionalKeyStore)
Creates a new
X509TrustManager which will use the key store
to determine whether to trust a certificate. |
static X509TrustManager |
checkUsingKeyStoreFile(String file,
char[] password,
String format)
Creates a new
X509TrustManager which will use the named trust
store file to determine whether to trust a certificate. |
static X509TrustManager |
distrustAll()
Returns an
X509TrustManager which does not trust any
certificates. |
static X509TrustManager |
trustAll()
Returns an
X509TrustManager which trusts all certificates. |
public static X509TrustManager checkUsingKeyStoreFile(String file, char[] password, String format) throws GeneralSecurityException, IOException
X509TrustManager
which will use the named trust
store file to determine whether to trust a certificate. It will use the
provided trust store format and password.file
- The trust store file name.password
- The trust store password, which may be null
.format
- The trust store format, which may be null
to indicate
that the default trust store format for the JVM (e.g.
JKS
) should be used.X509TrustManager
which will use the named trust
store file to determine whether to trust a certificate.GeneralSecurityException
- If the trust store could not be loaded, perhaps due to
incorrect format, or missing algorithms.IOException
- If the trust store file could not be found or could not be
read.NullPointerException
- If file
was null
.public static X509TrustManager checkUsingKeyStore(KeyStore optionalKeyStore) throws NoSuchAlgorithmException, KeyStoreException
X509TrustManager
which will use the key store
to determine whether to trust a certificate.optionalKeyStore
- The key store containing the trusted certificates or
null
to use the default key store.X509TrustManager
which will use the key store
to determine whether to trust a certificate.NoSuchAlgorithmException
- If default trust store algorithm
cannot be found.KeyStoreException
- If the trust manager could not be initialized
with the provided key store.public static X509TrustManager distrustAll()
X509TrustManager
which does not trust any
certificates.X509TrustManager
which does not trust any
certificates.public static X509TrustManager trustAll()
X509TrustManager
which trusts all certificates.X509TrustManager
which trusts all certificates.Copyright © 2010-2018, ForgeRock All Rights Reserved.