Coverage Report - org.mule.providers.http.HttpsConnector
 
Classes in this File Line Coverage Branch Coverage Complexity
HttpsConnector
39%
28/71
N/A
1
 
 1  
 /*
 2  
  * $Id: HttpsConnector.java 7963 2007-08-21 08:53:15Z dirk.olmes $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.providers.http;
 12  
 
 13  
 import org.mule.providers.ssl.SslServerSocketFactory;
 14  
 import org.mule.providers.ssl.SslSocketFactory;
 15  
 import org.mule.umo.lifecycle.InitialisationException;
 16  
 import org.mule.umo.security.TlsDirectKeyStore;
 17  
 import org.mule.umo.security.TlsDirectTrustStore;
 18  
 import org.mule.umo.security.TlsIndirectKeyStore;
 19  
 import org.mule.umo.security.provider.SecurityProviderFactory;
 20  
 import org.mule.umo.security.tls.TlsConfiguration;
 21  
 
 22  
 import java.io.IOException;
 23  
 import java.net.ServerSocket;
 24  
 import java.net.URI;
 25  
 import java.security.Provider;
 26  
 
 27  
 import javax.net.ssl.KeyManagerFactory;
 28  
 import javax.net.ssl.SSLServerSocket;
 29  
 import javax.net.ssl.TrustManagerFactory;
 30  
 
 31  
 /**
 32  
  * <code>HttpsConnector</code> provides Https connectivity
 33  
  */
 34  
 public class HttpsConnector extends HttpConnector 
 35  
 implements TlsDirectKeyStore, TlsIndirectKeyStore, TlsDirectTrustStore
 36  
 {
 37  
     public static final String PEER_CERTIFICATES = "PEER_CERTIFICATES";
 38  
     public static final String LOCAL_CERTIFICATES = "LOCAL_CERTIFICATES";
 39  
 
 40  20
     private TlsConfiguration tls = new TlsConfiguration(TlsConfiguration.DEFAULT_KEYSTORE);
 41  
 
 42  
     public HttpsConnector()
 43  20
     {
 44  20
         setSocketFactory(new SslSocketFactory(tls));
 45  20
         setServerSocketFactory(new SslServerSocketFactory(tls));
 46  
         // setting this true causes problems as socket closes before handshake finishes
 47  20
         setValidateConnections(false);
 48  20
     }
 49  
 
 50  
     // @Override
 51  
     protected ServerSocket getServerSocket(URI uri) throws IOException
 52  
     {
 53  2
         SSLServerSocket serverSocket = (SSLServerSocket) super.getServerSocket(uri);
 54  2
         serverSocket.setNeedClientAuth(isRequireClientAuthentication());
 55  2
         return serverSocket;
 56  
     }
 57  
 
 58  
     protected void doInitialise() throws InitialisationException
 59  
     {
 60  20
         tls.initialise(false, TlsConfiguration.JSSE_NAMESPACE);
 61  20
         super.doInitialise();
 62  20
     }
 63  
 
 64  
     public String getProtocol()
 65  
     {
 66  68
         return "https";
 67  
     }
 68  
 
 69  
     public String getClientKeyStore()
 70  
     {
 71  0
         return tls.getClientKeyStore();
 72  
     }
 73  
 
 74  
     public String getClientKeyStorePassword()
 75  
     {
 76  0
         return tls.getClientKeyStorePassword();
 77  
     }
 78  
 
 79  
     public String getClientKeyStoreType()
 80  
     {
 81  0
         return this.tls.getClientKeyStoreType();
 82  
     }
 83  
 
 84  
     public String getKeyManagerAlgorithm()
 85  
     {
 86  0
         return tls.getKeyManagerAlgorithm();
 87  
     }
 88  
 
 89  
     public KeyManagerFactory getKeyManagerFactory()
 90  
     {
 91  0
         return tls.getKeyManagerFactory();
 92  
     }
 93  
 
 94  
     public String getKeyPassword()
 95  
     {
 96  0
         return tls.getKeyPassword();
 97  
     }
 98  
 
 99  
     public String getKeyStore()
 100  
     {
 101  0
         return tls.getKeyStore();
 102  
     }
 103  
 
 104  
     public String getKeystoreType()
 105  
     {
 106  0
         return tls.getKeystoreType();
 107  
     }
 108  
 
 109  
     public String getProtocolHandler()
 110  
     {
 111  0
         return tls.getProtocolHandler();
 112  
     }
 113  
 
 114  
     public Provider getProvider()
 115  
     {
 116  0
         return tls.getProvider();
 117  
     }
 118  
 
 119  
     public SecurityProviderFactory getSecurityProviderFactory()
 120  
     {
 121  0
         return tls.getSecurityProviderFactory();
 122  
     }
 123  
 
 124  
     public String getSslType()
 125  
     {
 126  0
         return tls.getSslType();
 127  
     }
 128  
 
 129  
     public String getStorePassword()
 130  
     {
 131  0
         return tls.getStorePassword();
 132  
     }
 133  
 
 134  
     public String getTrustManagerAlgorithm()
 135  
     {
 136  0
         return tls.getTrustManagerAlgorithm();
 137  
     }
 138  
 
 139  
     public TrustManagerFactory getTrustManagerFactory()
 140  
     {
 141  0
         return tls.getTrustManagerFactory();
 142  
     }
 143  
 
 144  
     public String getTrustStore()
 145  
     {
 146  0
         return tls.getTrustStore();
 147  
     }
 148  
 
 149  
     public String getTrustStorePassword()
 150  
     {
 151  0
         return tls.getTrustStorePassword();
 152  
     }
 153  
 
 154  
     public String getTrustStoreType()
 155  
     {
 156  0
         return tls.getTrustStoreType();
 157  
     }
 158  
 
 159  
     public boolean isExplicitTrustStoreOnly()
 160  
     {
 161  0
         return tls.isExplicitTrustStoreOnly();
 162  
     }
 163  
 
 164  
     public boolean isRequireClientAuthentication()
 165  
     {
 166  2
         return tls.isRequireClientAuthentication();
 167  
     }
 168  
 
 169  
     public void setClientKeyStore(String clientKeyStore) throws IOException
 170  
     {
 171  18
         tls.setClientKeyStore(clientKeyStore);
 172  18
     }
 173  
 
 174  
     public void setClientKeyStorePassword(String clientKeyStorePassword)
 175  
     {
 176  18
         tls.setClientKeyStorePassword(clientKeyStorePassword);
 177  18
     }
 178  
 
 179  
     public void setClientKeyStoreType(String clientKeyStoreType)
 180  
     {
 181  0
         this.tls.setClientKeyStoreType(clientKeyStoreType);
 182  0
     }
 183  
 
 184  
     public void setExplicitTrustStoreOnly(boolean explicitTrustStoreOnly)
 185  
     {
 186  0
         tls.setExplicitTrustStoreOnly(explicitTrustStoreOnly);
 187  0
     }
 188  
 
 189  
     public void setKeyManagerAlgorithm(String keyManagerAlgorithm)
 190  
     {
 191  0
         tls.setKeyManagerAlgorithm(keyManagerAlgorithm);
 192  0
     }
 193  
 
 194  
     public void setKeyPassword(String keyPassword)
 195  
     {
 196  20
         tls.setKeyPassword(keyPassword);
 197  20
     }
 198  
 
 199  
     public void setKeyStore(String keyStore) throws IOException
 200  
     {
 201  20
         tls.setKeyStore(keyStore);
 202  20
     }
 203  
 
 204  
     public void setKeystoreType(String keystoreType)
 205  
     {
 206  0
         tls.setKeystoreType(keystoreType);
 207  0
     }
 208  
 
 209  
     public void setProtocolHandler(String protocolHandler)
 210  
     {
 211  0
         tls.setProtocolHandler(protocolHandler);
 212  0
     }
 213  
 
 214  
     public void setProvider(Provider provider)
 215  
     {
 216  0
         tls.setProvider(provider);
 217  0
     }
 218  
 
 219  
     public void setRequireClientAuthentication(boolean requireClientAuthentication)
 220  
     {
 221  0
         tls.setRequireClientAuthentication(requireClientAuthentication);
 222  0
     }
 223  
 
 224  
     public void setSecurityProviderFactory(SecurityProviderFactory spFactory)
 225  
     {
 226  0
         tls.setSecurityProviderFactory(spFactory);
 227  0
     }
 228  
 
 229  
     public void setSslType(String sslType)
 230  
     {
 231  0
         tls.setSslType(sslType);
 232  0
     }
 233  
 
 234  
     public void setStorePassword(String storePassword)
 235  
     {
 236  20
         tls.setStorePassword(storePassword);
 237  20
     }
 238  
 
 239  
     public void setTrustManagerAlgorithm(String trustManagerAlgorithm)
 240  
     {
 241  0
         tls.setTrustManagerAlgorithm(trustManagerAlgorithm);
 242  0
     }
 243  
 
 244  
     public void setTrustManagerFactory(TrustManagerFactory trustManagerFactory)
 245  
     {
 246  0
         tls.setTrustManagerFactory(trustManagerFactory);
 247  0
     }
 248  
 
 249  
     public void setTrustStore(String trustStore) throws IOException
 250  
     {
 251  20
         tls.setTrustStore(trustStore);
 252  20
     }
 253  
 
 254  
     public void setTrustStorePassword(String trustStorePassword)
 255  
     {
 256  20
         tls.setTrustStorePassword(trustStorePassword);
 257  20
     }
 258  
 
 259  
     public void setTrustStoreType(String trustStoreType)
 260  
     {
 261  0
         tls.setTrustStoreType(trustStoreType);
 262  0
     }
 263  
 
 264  
 }