com.echomine.util
Class SimpleTrustManager

java.lang.Object
  extended by com.echomine.util.SimpleTrustManager
All Implemented Interfaces:
javax.net.ssl.TrustManager, javax.net.ssl.X509TrustManager

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

This sub_class implements the X509TrustManager interface. MyTrustManager trusts known certificate chains, and queries the user to approve unknown chains. It will add trusted chains to the keystore. This class is provided as an example implementation. Depending upon the calling application, it is likely that this would be reimplemented to graphically display and prompt for data. Set the property com.echomine.util.SimpleTrustManager.prompt to "true" (default is "false") if you want the class to prompt for acceptance.


Constructor Summary
SimpleTrustManager(java.security.KeyStore keyStore, java.lang.String keyStorePath, char[] keyStorePassword)
          SimpleTrustManager constructor.
 
Method Summary
 void checkClientTrusted(java.security.cert.X509Certificate[] chain, java.lang.String authType)
          isClientTrusted checks to see if the chain is in the keyStore object.
 void checkServerTrusted(java.security.cert.X509Certificate[] chain, java.lang.String authType)
          checks to see if the chain is in the keyStore object.
 java.security.cert.X509Certificate[] getAcceptedIssuers()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleTrustManager

public SimpleTrustManager(java.security.KeyStore keyStore,
                          java.lang.String keyStorePath,
                          char[] keyStorePassword)
SimpleTrustManager constructor. Save the keyStore object along with the path to the keystore (keyStorePath) and its password (keyStorePassword). If you reimplement this class be warned that SocketConnector assumes there is only one constructor that can be passed the same three arguments as below.

Method Detail

checkClientTrusted

public void checkClientTrusted(java.security.cert.X509Certificate[] chain,
                               java.lang.String authType)
                        throws java.security.cert.CertificateException
isClientTrusted checks to see if the chain is in the keyStore object. This is done with a call to checkChainTrusted.

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 to see if the chain is in the keyStore object. This is done with a call to checkChainTrusted. If not it queries the user to see if the chain should be trusted and stored into the keyStore object. The keyStore is then saved in the file whose path is keyStorePath. Examines the system property com.echomine.util.SimpleTrustManager.prompt to determine whether user should be prompted.

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

getAcceptedIssuers

public java.security.cert.X509Certificate[] getAcceptedIssuers()
Specified by:
getAcceptedIssuers in interface javax.net.ssl.X509TrustManager


Copyright © 2001-2005 Echomine. All Rights Reserved.