org.w3c.mwi.mobileok.basic
Class MobileOKSSLProtocolSocketFactory

java.lang.Object
  extended by org.w3c.mwi.mobileok.basic.MobileOKSSLProtocolSocketFactory
All Implemented Interfaces:
org.apache.commons.httpclient.protocol.ProtocolSocketFactory, org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory

public final class MobileOKSSLProtocolSocketFactory
extends java.lang.Object
implements org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory

SSL factory to use to create and check secure sockets to a remote host against the mobileOK trust rules defined in the HTTPS section of the W3C mobileOK Basic Tests 1.0 standard.

The resulting warnings and failures are stored in the instance of the class and available through the getHttperror() and getTrustManager() methods. Because of this storage at the instance level, using the class as a real factory is not recommended.

This code is based on EasySSLProtocolSocketFactory and StrictSSLProtocolSocketFactory from Jakarta's HttpClient 3.1's "contrib" code.

Version:
$Revision: 1.1 $
Author:
The W3C mobileOK Checker Task Force
See Also:
MobileOKTrustManager

Field Summary
private  HTTPErrorsType httperror
           
private  javax.net.ssl.SSLContext sslContext
           
private  MobileOKTrustManager trustManager
           
 
Constructor Summary
MobileOKSSLProtocolSocketFactory()
           
 
Method Summary
 java.net.Socket createSocket(java.net.Socket socket, java.lang.String host, int port, boolean autoClose)
           
 java.net.Socket createSocket(java.lang.String host, int port)
           
 java.net.Socket createSocket(java.lang.String host, int port, java.net.InetAddress clientHost, int clientPort)
           
 java.net.Socket createSocket(java.lang.String host, int port, java.net.InetAddress localAddress, int localPort, org.apache.commons.httpclient.params.HttpConnectionParams params)
           
 HTTPErrorsType getHttperror()
          Return the HTTPS error that may have been triggered while checking the SSL certificate.
 MobileOKTrustManager getTrustManager()
           
private  void verifyHostname(java.lang.String host, javax.net.ssl.SSLSocket socket)
          Ensure that the hostname that was used to create the SSLSocket matches the one of the certificate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sslContext

private javax.net.ssl.SSLContext sslContext

trustManager

private MobileOKTrustManager trustManager

httperror

private HTTPErrorsType httperror
Constructor Detail

MobileOKSSLProtocolSocketFactory

public MobileOKSSLProtocolSocketFactory()
Method Detail

getTrustManager

public MobileOKTrustManager getTrustManager()

createSocket

public java.net.Socket createSocket(java.lang.String host,
                                    int port,
                                    java.net.InetAddress clientHost,
                                    int clientPort)
                             throws java.io.IOException
Specified by:
createSocket in interface org.apache.commons.httpclient.protocol.ProtocolSocketFactory
Throws:
java.io.IOException

createSocket

public java.net.Socket createSocket(java.lang.String host,
                                    int port,
                                    java.net.InetAddress localAddress,
                                    int localPort,
                                    org.apache.commons.httpclient.params.HttpConnectionParams params)
                             throws java.io.IOException
Specified by:
createSocket in interface org.apache.commons.httpclient.protocol.ProtocolSocketFactory
Throws:
java.io.IOException

createSocket

public java.net.Socket createSocket(java.lang.String host,
                                    int port)
                             throws java.io.IOException
Specified by:
createSocket in interface org.apache.commons.httpclient.protocol.ProtocolSocketFactory
Throws:
java.io.IOException

createSocket

public java.net.Socket createSocket(java.net.Socket socket,
                                    java.lang.String host,
                                    int port,
                                    boolean autoClose)
                             throws java.io.IOException
Specified by:
createSocket in interface org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory
Throws:
java.io.IOException

verifyHostname

private void verifyHostname(java.lang.String host,
                            javax.net.ssl.SSLSocket socket)
Ensure that the hostname that was used to create the SSLSocket matches the one of the certificate.

The method is a wrapper to the HostnameVerifier DEFAULT implementation.

Parameters:
host - the hostname that was used to create the SSLSocket
socket - the SSLSocket that contains the certificate to check against the hostname

getHttperror

public HTTPErrorsType getHttperror()
Return the HTTPS error that may have been triggered while checking the SSL certificate.