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 classTrustAllManager.TrustAllHostNameVerifierHost 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 voidcheckClientTrusted(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>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 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.X509Certificate[]getAcceptedIssuers()static SSLSocketFactorygetTrustfulSslSocketFactory()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:
checkClientTrustedin classX509ExtendedTrustManager
-
checkClientTrusted
public void checkClientTrusted(X509Certificate[] chain, String authType, SSLEngine engine)
- Specified by:
checkClientTrustedin classX509ExtendedTrustManager
-
checkServerTrusted
public void checkServerTrusted(X509Certificate[] chain, String authType)
-
checkServerTrusted
public void checkServerTrusted(X509Certificate[] chain, String authType, Socket socket)
- Specified by:
checkServerTrustedin classX509ExtendedTrustManager
-
checkServerTrusted
public void checkServerTrusted(X509Certificate[] chain, String authType, SSLEngine engine)
- 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 GeneralSecurityException
Disables 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
public static void enableSslCheckDefault(SSLSocketFactory factory, HostnameVerifier verifier)
Re-enables the SSL check for all HTTPS-connections using the designatedSSLSocketFactoryandHostnameVerifier.
-
getTrustfulSslSocketFactory
public static SSLSocketFactory getTrustfulSslSocketFactory() throws GeneralSecurityException
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.
-
-