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