org.jsslutils.sslcontext.trustmanagers
Class TrustAllServersWrappingTrustManager

java.lang.Object
  extended by org.jsslutils.sslcontext.trustmanagers.TrustAllServersWrappingTrustManager
All Implemented Interfaces:
javax.net.ssl.TrustManager, javax.net.ssl.X509TrustManager

public class TrustAllServersWrappingTrustManager
extends java.lang.Object
implements javax.net.ssl.X509TrustManager

TrustManager that accepts all server certificates as trusted; BE VERY CAREFUL, THIS WILL MAKE YOUR CONNECTION INSECURE.

Author:
Bruno Harbulot.

Nested Class Summary
static class TrustAllServersWrappingTrustManager.Wrapper
          Wrapper factory class that wraps existing X509TrustManagers into X509TrustManagers that trust any clients.
 
Constructor Summary
TrustAllServersWrappingTrustManager(javax.net.ssl.X509TrustManager trustManager)
          Creates a new instance from an existing X509TrustManager.
 
Method Summary
 void checkClientTrusted(java.security.cert.X509Certificate[] chain, java.lang.String authType)
          Checks that the client is trusted; in this case, it delegates this check to the trust manager it wraps
 void checkServerTrusted(java.security.cert.X509Certificate[] chain, java.lang.String authType)
          Checks that the server is trusted; in this case, it accepts anything.
 java.security.cert.X509Certificate[] getAcceptedIssuers()
          Returns the accepted issuers; in this case, it's an empty array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TrustAllServersWrappingTrustManager

public TrustAllServersWrappingTrustManager(javax.net.ssl.X509TrustManager trustManager)
Creates a new instance from an existing X509TrustManager.

Parameters:
trustManager - X509TrustManager to wrap.
Method Detail

checkClientTrusted

public void checkClientTrusted(java.security.cert.X509Certificate[] chain,
                               java.lang.String authType)
                        throws java.security.cert.CertificateException
Checks that the client is trusted; in this case, it delegates this check to the trust manager it wraps

Specified by:
checkClientTrusted in interface javax.net.ssl.X509TrustManager
Throws:
java.security.cert.CertificateException

checkServerTrusted

public void checkServerTrusted(java.security.cert.X509Certificate[] chain,
                               java.lang.String authType)
                        throws java.security.cert.CertificateException
Checks that the server is trusted; in this case, it accepts anything.

Specified by:
checkServerTrusted in interface javax.net.ssl.X509TrustManager
Throws:
java.security.cert.CertificateException

getAcceptedIssuers

public java.security.cert.X509Certificate[] getAcceptedIssuers()
Returns the accepted issuers; in this case, it's an empty array.

Specified by:
getAcceptedIssuers in interface javax.net.ssl.X509TrustManager


Copyright © 2011. All Rights Reserved.