Package de.aristaflow.adept2.util.net
Class TrustAllManager
- java.lang.Object
-
- javax.net.ssl.X509ExtendedTrustManager
-
- de.aristaflow.adept2.util.net.TrustAllManager
-
- All Implemented Interfaces:
TrustManager
,X509TrustManager
public class TrustAllManager extends X509ExtendedTrustManager
Trust manager that will trust all.- Author:
- Florian Rapp
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TrustAllManager.TrustAllHostNameVerifier
Host name verifier that verifies all.
-
Constructor Summary
Constructors Constructor Description TrustAllManager()
Creates a new trust manager that will trust all.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkClientTrusted(X509Certificate[] chain, String authType)
void
checkClientTrusted(X509Certificate[] chain, String authType, Socket socket)
void
checkClientTrusted(X509Certificate[] chain, String authType, SSLEngine engine)
void
checkServerTrusted(X509Certificate[] chain, String authType)
void
checkServerTrusted(X509Certificate[] chain, String authType, Socket socket)
void
checkServerTrusted(X509Certificate[] chain, String authType, SSLEngine engine)
static Pair<SSLSocketFactory,HostnameVerifier>
disableSslCheck(HttpsURLConnection conn)
Disables the SSL/TLS check for the designated connection.static Pair<SSLSocketFactory,HostnameVerifier>
disableSslCheckDefault()
Disables the SSL/TLS check for all HTTPS-connections.static void
enableSslCheck(HttpsURLConnection conn, SSLSocketFactory factory, HostnameVerifier verifier)
Re-enables the SSL check for the designated connection using the designatedSSLSocketFactory
andHostnameVerifier
.static void
enableSslCheckDefault(SSLSocketFactory factory, HostnameVerifier verifier)
Re-enables the SSL check for all HTTPS-connections using the designatedSSLSocketFactory
andHostnameVerifier
.X509Certificate[]
getAcceptedIssuers()
static SSLSocketFactory
getTrustfulSslSocketFactory()
Gets an SSL/TLS socket factory that trusts all certificates.
-
-
-
Constructor Detail
-
TrustAllManager
public TrustAllManager()
Creates a new trust manager that will trust all. Note that you usually should not call this constructor explicitly but rather use a method of this class or use theOvertrustfulSSLSocketFactory
.
-
-
Method Detail
-
getAcceptedIssuers
public X509Certificate[] getAcceptedIssuers()
-
checkClientTrusted
public void checkClientTrusted(X509Certificate[] chain, String authType)
-
checkClientTrusted
public void checkClientTrusted(X509Certificate[] chain, String authType, Socket socket)
- Specified by:
checkClientTrusted
in classX509ExtendedTrustManager
-
checkClientTrusted
public void checkClientTrusted(X509Certificate[] chain, String authType, SSLEngine engine)
- Specified by:
checkClientTrusted
in classX509ExtendedTrustManager
-
checkServerTrusted
public void checkServerTrusted(X509Certificate[] chain, String authType)
-
checkServerTrusted
public void checkServerTrusted(X509Certificate[] chain, String authType, Socket socket)
- Specified by:
checkServerTrusted
in classX509ExtendedTrustManager
-
checkServerTrusted
public void checkServerTrusted(X509Certificate[] chain, String authType, SSLEngine engine)
- Specified by:
checkServerTrusted
in classX509ExtendedTrustManager
-
disableSslCheck
public static Pair<SSLSocketFactory,HostnameVerifier> disableSslCheck(HttpsURLConnection conn) throws GeneralSecurityException
Disables the SSL/TLS check for the designated connection.- Parameters:
conn
- The connection for which to disable the SSL/TLS check.- Returns:
- The previous
SSLSocketFactory
andHostnameVerifier
of the connection allowing to re-enable the SSL/TLS check. - Throws:
GeneralSecurityException
- If there are problems creating a newSSLContext
or initialising it, aGeneralSecurityException
will be thrown.
-
disableSslCheckDefault
public static Pair<SSLSocketFactory,HostnameVerifier> disableSslCheckDefault() throws GeneralSecurityException
Disables the SSL/TLS check for all HTTPS-connections.- Returns:
- The previous
SSLSocketFactory
andHostnameVerifier
of HTTPS-connections allowing to re-enable the SSL/TLS check. - Throws:
GeneralSecurityException
- If there are problems creating a newSSLContext
or initialising it, aGeneralSecurityException
will be thrown.
-
enableSslCheck
public static void enableSslCheck(HttpsURLConnection conn, SSLSocketFactory factory, HostnameVerifier verifier)
Re-enables the SSL check for the designated connection using the designatedSSLSocketFactory
andHostnameVerifier
.
-
enableSslCheckDefault
public static void enableSslCheckDefault(SSLSocketFactory factory, HostnameVerifier verifier)
Re-enables the SSL check for all HTTPS-connections using the designatedSSLSocketFactory
andHostnameVerifier
.
-
getTrustfulSslSocketFactory
public static SSLSocketFactory getTrustfulSslSocketFactory() throws GeneralSecurityException
Gets an SSL/TLS socket factory that trusts all certificates.- Returns:
- The previous
SSLSocketFactory
andHostnameVerifier
of HTTPS-connections allowing to re-enable the SSL/TLS check. - Throws:
GeneralSecurityException
- If there are problems creating a newSSLContext
or initialising it, aGeneralSecurityException
will be thrown.
-
-