Coverage Report - org.mule.providers.email.AbstractTlsRetrieveMailConnector
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractTlsRetrieveMailConnector
0%
0/36
N/A
1
 
 1  
 /*
 2  
  * $Id: AbstractTlsRetrieveMailConnector.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.email;
 12  
 
 13  
 import org.mule.umo.lifecycle.InitialisationException;
 14  
 import org.mule.umo.security.TlsIndirectKeyStore;
 15  
 import org.mule.umo.security.TlsIndirectTrustStore;
 16  
 import org.mule.umo.security.tls.TlsConfiguration;
 17  
 import org.mule.umo.security.tls.TlsPropertiesMapper;
 18  
 
 19  
 import java.io.IOException;
 20  
 import java.util.Properties;
 21  
 
 22  
 import javax.mail.URLName;
 23  
 
 24  
 /**
 25  
  * Support for connecting to and receiving email from a secure mailbox (the exact protocol depends on
 26  
  * the subclass).
 27  
  */
 28  
 public abstract class AbstractTlsRetrieveMailConnector 
 29  
 extends AbstractRetrieveMailConnector implements TlsIndirectTrustStore, TlsIndirectKeyStore
 30  
 {
 31  
 
 32  
     private String namespace;
 33  
     private String socketFactory;
 34  0
     private String socketFactoryFallback = "false";
 35  0
     private TlsConfiguration tls = new TlsConfiguration(TlsConfiguration.DEFAULT_KEYSTORE);
 36  
 
 37  
     protected AbstractTlsRetrieveMailConnector(int defaultPort, String namespace, Class defaultSocketFactory)
 38  
     {
 39  0
         super(defaultPort);
 40  0
         this.namespace = namespace;
 41  0
         socketFactory = defaultSocketFactory.getName();
 42  
         
 43  
         // see comment below
 44  
 //        this.namespace = TlsConfiguration.JSSE_NAMESPACE;
 45  
 //        socketFactory = SSLServerSocketFactory.class.getName();
 46  0
     }
 47  
     
 48  
     protected void doInitialise() throws InitialisationException
 49  
     {
 50  0
         tls.initialise(true, null);
 51  0
         super.doInitialise();
 52  0
     }
 53  
 
 54  
     // @Override
 55  
     protected void extendPropertiesForSession(Properties global, Properties local, URLName url)
 56  
     {
 57  0
         super.extendPropertiesForSession(global, local, url);
 58  
 
 59  0
         local.setProperty("mail." + getProtocol() + ".ssl", "true");
 60  0
         local.setProperty("mail." + getProtocol() + ".socketFactory.class", getSocketFactory());
 61  0
         local.setProperty("mail." + getProtocol() + ".socketFactory.fallback", getSocketFactoryFallback());
 62  
         
 63  0
         new TlsPropertiesMapper(namespace).writeToProperties(global, tls);
 64  
 
 65  
         // this, instead of the line above, and with the constructor changes,
 66  
         // would have changed to local SSL configuration, if that was possible
 67  
         // (it didn't work)
 68  
 //        new TlsPropertiesMapper(namespace).writeToProperties(local, tls);
 69  0
     }
 70  
     
 71  
     public String getSocketFactory()
 72  
     {
 73  0
         return socketFactory;
 74  
     }
 75  
 
 76  
     public void setSocketFactory(String sslSocketFactory)
 77  
     {
 78  0
         this.socketFactory = sslSocketFactory;
 79  0
     }
 80  
 
 81  
     public String getSocketFactoryFallback()
 82  
     {
 83  0
         return socketFactoryFallback;
 84  
     }
 85  
 
 86  
     public void setSocketFactoryFallback(String socketFactoryFallback)
 87  
     {
 88  0
         this.socketFactoryFallback = socketFactoryFallback;
 89  0
     }
 90  
 
 91  
     public String getTrustStore()
 92  
     {
 93  0
         return tls.getTrustStore();
 94  
     }
 95  
 
 96  
     public String getTrustStorePassword()
 97  
     {
 98  0
         return tls.getTrustStorePassword();
 99  
     }
 100  
 
 101  
     public void setTrustStore(String trustStore) throws IOException
 102  
     {
 103  0
         tls.setTrustStore(trustStore);
 104  0
     }
 105  
 
 106  
     public void setTrustStorePassword(String trustStorePassword)
 107  
     {
 108  0
         tls.setTrustStorePassword(trustStorePassword);
 109  0
     }
 110  
 
 111  
     // these were not present before, but could be set implicitly via global properties
 112  
     // that is no longer true, so i have added them in here
 113  
 
 114  
     public String getClientKeyStore()
 115  
     {
 116  0
         return this.tls.getClientKeyStore();
 117  
     }
 118  
 
 119  
     public String getClientKeyStorePassword()
 120  
     {
 121  0
         return this.tls.getClientKeyStorePassword();
 122  
     }
 123  
 
 124  
     public String getClientKeyStoreType()
 125  
     {
 126  0
         return this.tls.getClientKeyStoreType();
 127  
     }
 128  
 
 129  
     public void setClientKeyStore(String name) throws IOException
 130  
     {
 131  0
         this.tls.setClientKeyStore(name);
 132  0
     }
 133  
 
 134  
     public void setClientKeyStorePassword(String clientKeyStorePassword)
 135  
     {
 136  0
         this.tls.setClientKeyStorePassword(clientKeyStorePassword);
 137  0
     }
 138  
 
 139  
     public void setClientKeyStoreType(String clientKeyStoreType)
 140  
     {
 141  0
         this.tls.setClientKeyStoreType(clientKeyStoreType);
 142  0
     }
 143  
 
 144  
 }