View Javadoc

1   /*
2    * $Id: HttpsClientMessageDispatcher.java 19191 2010-08-25 21:05:23Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.transport.http;
12  
13  import org.mule.api.endpoint.OutboundEndpoint;
14  
15  import java.net.URI;
16  
17  import javax.net.ssl.SSLSocketFactory;
18  
19  import org.apache.commons.httpclient.HostConfiguration;
20  import org.apache.commons.httpclient.protocol.Protocol;
21  import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
22  
23  public class HttpsClientMessageDispatcher extends HttpClientMessageDispatcher
24  {
25      
26      public HttpsClientMessageDispatcher(OutboundEndpoint endpoint)
27      {
28          super(endpoint);
29      }
30  
31      @Override
32      protected HostConfiguration getHostConfig(URI uri) throws Exception
33      {        
34          HostConfiguration hostConfig = new MuleHostConfiguration(super.getHostConfig(uri));
35  
36          HttpsConnector httpsConnector = (HttpsConnector) connector;
37          SSLSocketFactory factory = httpsConnector.getSslSocketFactory();
38          ProtocolSocketFactory protocolSocketFactory = new MuleSecureProtocolSocketFactory(factory);
39          Protocol protocol = new Protocol(uri.getScheme().toLowerCase(), protocolSocketFactory, 443);
40          
41          String host = uri.getHost();
42          int port = uri.getPort();
43          hostConfig.setHost(host, port, protocol);            
44          
45          return hostConfig;
46      }
47  
48  }
49  
50