microsoft.exchange.webservices.data.core
Class EwsSSLProtocolSocketFactory

java.lang.Object
  extended by org.apache.http.conn.ssl.SSLConnectionSocketFactory
      extended by microsoft.exchange.webservices.data.core.EwsSSLProtocolSocketFactory
All Implemented Interfaces:
org.apache.http.conn.socket.ConnectionSocketFactory, org.apache.http.conn.socket.LayeredConnectionSocketFactory

public class EwsSSLProtocolSocketFactory
extends org.apache.http.conn.ssl.SSLConnectionSocketFactory

EwsSSLProtocolSocketFactory can be used to create SSL Sockets that accept self-signed certificates.

This socket factory SHOULD NOT be used for productive systems due to security reasons, unless it is a conscious decision and you are perfectly aware of security implications of accepting self-signed certificates

Example of using custom protocol socket factory for a specific host:
     Protocol easyhttps = new Protocol("https", new EasySSLProtocolSocketFactory(), 443);

     URI uri = new URI("https://localhost/", true);
     // use relative url only
     GetMethod httpget = new GetMethod(uri.getPathQuery());
     HostConfiguration hc = new HostConfiguration();
     hc.setHost(uri.getHost(), uri.getPort(), easyhttps);
     HttpClient client = new HttpClient();
     client.executeMethod(hc, httpget);
     

Example of using custom protocol socket factory per default instead of the standard one:

     Protocol easyhttps = new Protocol("https", new EasySSLProtocolSocketFactory(), 443);
     Protocol.registerProtocol("https", easyhttps);

     HttpClient client = new HttpClient();
     GetMethod httpget = new GetMethod("https://localhost/");
     client.executeMethod(httpget);
     

DISCLAIMER: HttpClient developers DO NOT actively support this component. The component is provided as a reference material, which may be inappropriate for use without additional customization.


Field Summary
 
Fields inherited from class org.apache.http.conn.ssl.SSLConnectionSocketFactory
ALLOW_ALL_HOSTNAME_VERIFIER, BROWSER_COMPATIBLE_HOSTNAME_VERIFIER, SSL, SSLV2, STRICT_HOSTNAME_VERIFIER, TLS
 
Constructor Summary
EwsSSLProtocolSocketFactory(SSLContext context, HostnameVerifier hostnameVerifier)
          Constructor for EasySSLProtocolSocketFactory.
 
Method Summary
static EwsSSLProtocolSocketFactory build(TrustManager trustManager)
          Create and configure SSL protocol socket factory using default hostname verifier.
static EwsSSLProtocolSocketFactory build(TrustManager trustManager, HostnameVerifier hostnameVerifier)
          Create and configure SSL protocol socket factory using trust manager and hostname verifier.
static SSLContext createSslContext(TrustManager trustManager)
          Create SSL context and initialize it using specific trust manager.
 boolean equals(Object obj)
           
 SSLContext getContext()
           
 int hashCode()
           
 
Methods inherited from class org.apache.http.conn.ssl.SSLConnectionSocketFactory
connectSocket, createLayeredSocket, createSocket, getDefaultHostnameVerifier, getSocketFactory, getSystemSocketFactory, prepareSocket
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EwsSSLProtocolSocketFactory

public EwsSSLProtocolSocketFactory(SSLContext context,
                                   HostnameVerifier hostnameVerifier)
Constructor for EasySSLProtocolSocketFactory.

Parameters:
context - SSL context
hostnameVerifier - hostname verifier
Method Detail

build

public static EwsSSLProtocolSocketFactory build(TrustManager trustManager)
                                         throws GeneralSecurityException
Create and configure SSL protocol socket factory using default hostname verifier. DEFAULT_HOSTNAME_VERIFIER

Parameters:
trustManager - trust manager
Returns:
socket factory for SSL protocol
Throws:
GeneralSecurityException - on security error

build

public static EwsSSLProtocolSocketFactory build(TrustManager trustManager,
                                                HostnameVerifier hostnameVerifier)
                                         throws GeneralSecurityException
Create and configure SSL protocol socket factory using trust manager and hostname verifier.

Parameters:
trustManager - trust manager
hostnameVerifier - hostname verifier
Returns:
socket factory for SSL protocol
Throws:
GeneralSecurityException - on security error

createSslContext

public static SSLContext createSslContext(TrustManager trustManager)
                                   throws GeneralSecurityException
Create SSL context and initialize it using specific trust manager.

Parameters:
trustManager - trust manager
Returns:
initialized SSL context
Throws:
GeneralSecurityException - on security error

getContext

public SSLContext getContext()
Returns:
SSL context

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2012–2015 Microsoft. All rights reserved.