mulesoft/mule — pull request #376 by dmiorandi (2014-02-13 07:27:09+00:00)
Title: SslV2Hello is not supported in https connector

When using an https connector is not possible to choose SslV2Hello (disabled by default in java 1.7). This service override sample show up how to add this support to an https connector, but should be nice to have a parameter on https
to choose wich protocol enable disable (ssl,tls, sslV2HEllo,...)
This is important to connecto to some ws (such as legacyTibco) that accept only sslv2hello

Here there are patched classes

```java
package it.clesius.esb.common.overrides.http;
/*
* $Id: HttpsClientMessageCustomProtocolDispatcher.java,v 1.1 2013/07/12 07:33:05 d_miorandi Exp $
* --------------------------------------------------------------------------------------
*
* (c) 2003-2010 MuleSoft, Inc. This software is protected under international copyright
* law. All use of this software is subject to MuleSoft's Master Subscription Agreement
* (or other master license agreement) separately entered into in writing between you and
* MuleSoft. If such an agreement is not in place, you may not use the software.
*/

import org.mule.api.endpoint.OutboundEndpoint;
import org.mule.transport.http.HttpClientMessageDispatcher;
import org.mule.transport.http.HttpsConnector;
import org.mule.transport.tcp.TcpConnector;

import java.net.URI;
import java.net.URL;

import javax.net.ssl.SSLSocketFactory;

import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.contrib.ssl.AuthSSLProtocolSocketFactory;
import org.apache.commons.httpclient.protocol.Protocol;

public class HttpsClientMessageCustomProtocolDispatcher extends HttpClientMessageDispatcher
{
public HttpsClientMessageCustomProtocolDispatcher(OutboundEndpoint endpoint)
{
super(endpoint);
}

@Override
protected HostConfiguration getHostConfig(URI uri) throws Exception
{
final String protocolName="https";
// Force ssl mode to enable also SSLv2Hello that is disabled by default in java >= 7
final String []sslMode=new String []{"SSLv3","TLSv1","SSLv2Hello"};
HostConfiguration hostConfiguration = super.getHostConfig(uri);
HttpsConnector httpsConnector=(HttpsConnector)httpConnector;

// Configure directly on Apache HttpClient SSL
AuthSSLProtocolSocketFactory authSSLProtocolSocketFactory=new AuthSSLProtocolSocketFactory(
new URL(String.format("file:%s",httpsConnector.getKeyStore())), httpsConnector.getKeyStorePassword(),
new URL(String.format("file:%s",httpsConnector.getTrustStore())), httpsConnector.getTrustStorePassword());
authSSLProtocolSocketFactory.setEnabledProtocols(sslMode);
Protocol authhttps = new Protocol(protocolName, authSSLProtocolSocketFactory, uri.getPort());
Protocol.registerProtocol(protocolName, authhttps);
return hostConfiguration;
}
}
```

```java
package it.clesius.esb.common.overrides.http;
/*
* $Id: HttpsClientMessageCustomProtocolDispatcherFactory.java,v 1.1 2013/07/12 07:33:05 d_miorandi Exp $
* --------------------------------------------------------------------------------------
*
* (c) 2003-2010 MuleSoft, Inc. This software is protected under international copyright
* law. All use of this software is subject to MuleSoft's Master Subscription Agreement
* (or other master license agreement) separately entered into in writing between you and
* MuleSoft. If such an agreement is not in place, you may not use the software.
*/

import org.mule.api.MuleException;
import org.mule.api.endpoint.OutboundEndpoint;
import org.mule.api.transport.MessageDispatcher;
import org.mule.transport.AbstractMessageDispatcherFactory;

/**
* Creates a HttpsClientMessageDispatcher to make client requests
*/
public class HttpsClientMessageCustomProtocolDispatcherFactory extends AbstractMessageDispatcherFactory
{

@Override
public MessageDispatcher create(OutboundEndpoint endpoint) throws MuleException
{
return new HttpsClientMessageCustomProtocolDispatcher(endpoint);
}

}
```