SIP Communicator: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.gui.main.login
Class CertificateVerificationServiceImpl

java.lang.Object
  extended by net.java.sip.communicator.impl.gui.main.login.CertificateVerificationServiceImpl
All Implemented Interfaces:
CertificateVerificationService

public class CertificateVerificationServiceImpl
extends Object
implements CertificateVerificationService

Asks the user for permission for the certificates which are for some reason not valid and not globally trusted.

Author:
Damian Minkov

Field Summary
 
Fields inherited from interface net.java.sip.communicator.service.gui.CertificateVerificationService
ALWAYS_TRUST_MODE_ENABLED_PROP_NAME, DO_NOT_TRUST, TRUST_ALWAYS, TRUST_THIS_SESSION_ONLY
 
Constructor Summary
CertificateVerificationServiceImpl()
           
 
Method Summary
 SSLContext getSSLContext(String toHost, int toPort)
          Returns SSLContext instance initialized with the custom trust manager, which will try verify the certificate and if verification fails will query the user for acceptance.
 X509TrustManager getTrustManager(String toHost, int toPort)
          Obtain custom trust manager, which will try verify the certificate and if verification fails will query the user for acceptance.
 int verify(X509Certificate[] chain, String toHost, int toPort)
          Checks does the user trust the supplied chain of certificates, when connecting to the server and port.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CertificateVerificationServiceImpl

public CertificateVerificationServiceImpl()
Method Detail

verify

public int verify(X509Certificate[] chain,
                  String toHost,
                  int toPort)
Checks does the user trust the supplied chain of certificates, when connecting to the server and port.

Specified by:
verify in interface CertificateVerificationService
Parameters:
chain - the chain of the certificates to check with user.
toHost - the host we are connecting.
toPort - the port used when connecting.
Returns:
the result of user interaction on of DO_NOT_TRUST, TRUST_ALWAYS, TRUST_THIS_SESSION_ONLY.

getTrustManager

public X509TrustManager getTrustManager(String toHost,
                                        int toPort)
                                 throws GeneralSecurityException
Obtain custom trust manager, which will try verify the certificate and if verification fails will query the user for acceptance.

Specified by:
getTrustManager in interface CertificateVerificationService
Parameters:
toHost - the host we are connecting.
toPort - the port used when connecting.
Returns:
the custom trust manager.
Throws:
GeneralSecurityException - when there is problem creating the trust manager

getSSLContext

public SSLContext getSSLContext(String toHost,
                                int toPort)
                         throws IOException
Returns SSLContext instance initialized with the custom trust manager, which will try verify the certificate and if verification fails will query the user for acceptance.

Specified by:
getSSLContext in interface CertificateVerificationService
Parameters:
toHost - the host we are connecting.
toPort - the port used when connecting.
Returns:
SSL context object
Throws:
IOException - throws exception when unable to initialize the ssl context.

SIP Communicator: the OpenSource Java VoIP and Instant Messaging client.

SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.