p2ps.imp.peer
Class DefaultTrustManager

java.lang.Object
  extended byp2ps.imp.peer.DefaultTrustManager
All Implemented Interfaces:
TrustManager

public class DefaultTrustManager
extends java.lang.Object
implements TrustManager

Version:
$Revision: 295 $
Author:
Ian Wang

Constructor Summary
DefaultTrustManager(boolean identity, boolean trust, boolean authorization)
           
 
Method Summary
 void acceptClientCertificate(SecurityContext peercontext, SecurityContext remotecontext, java.security.cert.X509Certificate[] chain, java.lang.String authtype, javax.net.ssl.X509TrustManager deftrustman)
          Check whether a client certificate should be accepted.
 void acceptServerCertificate(SecurityContext peercontext, SecurityContext remotecontext, java.security.cert.X509Certificate[] chain, java.lang.String authtype, javax.net.ssl.X509TrustManager deftrustman)
          Check whether a server certificate should be accepted.
static java.lang.String getCertificateThumbprint(java.security.cert.X509Certificate cert)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultTrustManager

public DefaultTrustManager(boolean identity,
                           boolean trust,
                           boolean authorization)
Parameters:
identity - true if check identity of client/server
trust - true if check trust of client/server
Method Detail

acceptClientCertificate

public void acceptClientCertificate(SecurityContext peercontext,
                                    SecurityContext remotecontext,
                                    java.security.cert.X509Certificate[] chain,
                                    java.lang.String authtype,
                                    javax.net.ssl.X509TrustManager deftrustman)
                             throws java.security.cert.CertificateException
Check whether a client certificate should be accepted.

Specified by:
acceptClientCertificate in interface TrustManager
Parameters:
peercontext - the context for the local peer (server)
remotecontext - the context for the remote entity (client), or null if unknown
chain - the certificate chain received from the client
authtype - the authorization type for the certificate (e.g. RSA)
deftrustman - the default system trust manager
Throws:
java.security.cert.CertificateException - if the certificate is not accepted

acceptServerCertificate

public void acceptServerCertificate(SecurityContext peercontext,
                                    SecurityContext remotecontext,
                                    java.security.cert.X509Certificate[] chain,
                                    java.lang.String authtype,
                                    javax.net.ssl.X509TrustManager deftrustman)
                             throws java.security.cert.CertificateException
Check whether a server certificate should be accepted.

Specified by:
acceptServerCertificate in interface TrustManager
Parameters:
peercontext - the context for the local peer (client)
remotecontext - the context for the remote entity (server), or null if unknown
chain - the certificate chain received from the client
authtype - the authorization type for the certificate (e.g. RSA)
deftrustman - the default system trust manager
Throws:
java.security.cert.CertificateException - if the certificate is not accepted

getCertificateThumbprint

public static java.lang.String getCertificateThumbprint(java.security.cert.X509Certificate cert)
                                                 throws java.security.cert.CertificateEncodingException,
                                                        java.security.NoSuchAlgorithmException
Returns:
the certificate thumbprint for the specified certificate
Throws:
java.security.cert.CertificateEncodingException
java.security.NoSuchAlgorithmException