Coverage Report - org.mule.transport.http.HttpsClientMessageDispatcher
 
Classes in this File Line Coverage Branch Coverage Complexity
HttpsClientMessageDispatcher
0%
0/17
0%
0/2
0
 
 1  
 /*
 2  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.transport.http;
 8  
 
 9  
 import org.mule.api.endpoint.OutboundEndpoint;
 10  
 
 11  
 import java.net.URI;
 12  
 import java.security.GeneralSecurityException;
 13  
 import java.util.Collections;
 14  
 import java.util.HashMap;
 15  
 import java.util.Map;
 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  0
     private final Map<String, Protocol> PROTOCOL = Collections.synchronizedMap(new HashMap<String, Protocol>());
 27  
 
 28  
     public HttpsClientMessageDispatcher(OutboundEndpoint endpoint)
 29  
     {
 30  0
         super(endpoint);
 31  0
     }
 32  
 
 33  
     @Override
 34  
     protected HostConfiguration getHostConfig(URI uri) throws Exception
 35  
     {        
 36  0
         HostConfiguration hostConfig = new MuleHostConfiguration(super.getHostConfig(uri));
 37  0
         String host = uri.getHost();
 38  0
         int port = uri.getPort();
 39  0
         Protocol protocol = getProtocol(uri.getScheme().toLowerCase());
 40  0
         hostConfig.setHost(host, port, protocol);            
 41  
         
 42  0
         return hostConfig;
 43  
     }
 44  
 
 45  
     private Protocol getProtocol(String scheme) throws GeneralSecurityException
 46  
     {
 47  0
         Protocol protocol = PROTOCOL.get(scheme);
 48  0
         if (protocol == null)
 49  
         {
 50  0
             HttpsConnector httpsConnector = (HttpsConnector) httpConnector;
 51  0
             SSLSocketFactory factory = httpsConnector.getSslSocketFactory();
 52  0
             ProtocolSocketFactory protocolSocketFactory = new MuleSecureProtocolSocketFactory(factory);
 53  0
             protocol = new Protocol(scheme, protocolSocketFactory, 443);
 54  0
             PROTOCOL.put(scheme, protocol);
 55  
         }
 56  0
         return protocol;
 57  
     }
 58  
 
 59  
 }
 60  
 
 61