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
Trust manager that will trust all.
- Author:
- Florian Rapp
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classHost name verifier that verifies all. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckClientTrusted(X509Certificate[] chain, String authType) voidcheckClientTrusted(X509Certificate[] chain, String authType, Socket socket) voidcheckClientTrusted(X509Certificate[] chain, String authType, SSLEngine engine) voidcheckServerTrusted(X509Certificate[] chain, String authType) voidcheckServerTrusted(X509Certificate[] chain, String authType, Socket socket) voidcheckServerTrusted(X509Certificate[] chain, String authType, SSLEngine engine) static Pair<SSLSocketFactory,HostnameVerifier> Disables the SSL/TLS check for the designated connection.static Pair<SSLSocketFactory,HostnameVerifier> Disables the SSL/TLS check for all HTTPS-connections.static voidenableSslCheck(HttpsURLConnection conn, SSLSocketFactory factory, HostnameVerifier verifier) Re-enables the SSL check for the designated connection using the designatedSSLSocketFactoryandHostnameVerifier.static voidenableSslCheckDefault(SSLSocketFactory factory, HostnameVerifier verifier) Re-enables the SSL check for all HTTPS-connections using the designatedSSLSocketFactoryandHostnameVerifier.static SSLSocketFactoryGets an SSL/TLS socket factory that trusts all certificates.
-
Constructor Details
-
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 Details
-
getAcceptedIssuers
-
checkClientTrusted
-
checkClientTrusted
- Specified by:
checkClientTrustedin classX509ExtendedTrustManager
-
checkClientTrusted
- Specified by:
checkClientTrustedin classX509ExtendedTrustManager
-
checkServerTrusted
-
checkServerTrusted
- Specified by:
checkServerTrustedin classX509ExtendedTrustManager
-
checkServerTrusted
- Specified by:
checkServerTrustedin 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
SSLSocketFactoryandHostnameVerifierof the connection allowing to re-enable the SSL/TLS check. - Throws:
GeneralSecurityException- If there are problems creating a newSSLContextor initialising it, aGeneralSecurityExceptionwill be thrown.
-
disableSslCheckDefault
public static Pair<SSLSocketFactory,HostnameVerifier> disableSslCheckDefault() throws GeneralSecurityExceptionDisables the SSL/TLS check for all HTTPS-connections.- Returns:
- The previous
SSLSocketFactoryandHostnameVerifierof HTTPS-connections allowing to re-enable the SSL/TLS check. - Throws:
GeneralSecurityException- If there are problems creating a newSSLContextor initialising it, aGeneralSecurityExceptionwill be thrown.
-
enableSslCheck
public static void enableSslCheck(HttpsURLConnection conn, SSLSocketFactory factory, HostnameVerifier verifier) Re-enables the SSL check for the designated connection using the designatedSSLSocketFactoryandHostnameVerifier. -
enableSslCheckDefault
Re-enables the SSL check for all HTTPS-connections using the designatedSSLSocketFactoryandHostnameVerifier. -
getTrustfulSslSocketFactory
Gets an SSL/TLS socket factory that trusts all certificates.- Returns:
- The previous
SSLSocketFactoryandHostnameVerifierof HTTPS-connections allowing to re-enable the SSL/TLS check. - Throws:
GeneralSecurityException- If there are problems creating a newSSLContextor initialising it, aGeneralSecurityExceptionwill be thrown.
-