KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > providers > email > Pop3sConnector


1 /*
2  * $Id: Pop3sConnector.java 3798 2006-11-04 04:07:14Z aperepel $
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 MuleSource MPL
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
15 /**
16  * Creates a secure connection to a POP3 mailbox
17  */

18 public class Pop3sConnector extends Pop3Connector
19 {
20     public static final String JavaDoc DEFAULT_SOCKET_FACTORY = "javax.net.ssl.SSLSocketFactory";
21
22     private String JavaDoc socketFactory = DEFAULT_SOCKET_FACTORY;
23     private String JavaDoc socketFactoryFallback = "false";
24     private String JavaDoc trustStore = null;
25     private String JavaDoc trustStorePassword = null;
26
27     public static final int DEFAULT_POP3S_PORT = 995;
28
29     public String JavaDoc getProtocol()
30     {
31         return "pop3s";
32     }
33
34     public int getDefaultPort()
35     {
36         return DEFAULT_POP3S_PORT;
37     }
38
39     public void doInitialise() throws InitialisationException
40     {
41         super.doInitialise();
42         System.setProperty("mail." + getProtocol() + ".ssl", "true");
43         System.setProperty("mail." + getProtocol() + ".socketFactory.class", getSocketFactory());
44         System.setProperty("mail." + getProtocol() + ".socketFactory.fallback", getSocketFactoryFallback());
45
46         if (getTrustStore() != null)
47         {
48             System.setProperty("javax.net.ssl.trustStore", getTrustStore());
49             if (getTrustStorePassword() != null)
50             {
51                 System.setProperty("javax.net.ssl.trustStorePassword", getTrustStorePassword());
52             }
53         }
54     }
55
56     public String JavaDoc getSocketFactory()
57     {
58         return socketFactory;
59     }
60
61     public void setSocketFactory(String JavaDoc sslSocketFactory)
62     {
63         this.socketFactory = sslSocketFactory;
64     }
65
66     public String JavaDoc getSocketFactoryFallback()
67     {
68         return socketFactoryFallback;
69     }
70
71     public void setSocketFactoryFallback(String JavaDoc socketFactoryFallback)
72     {
73         this.socketFactoryFallback = socketFactoryFallback;
74     }
75
76     public String JavaDoc getTrustStore()
77     {
78         return trustStore;
79     }
80
81     public void setTrustStore(String JavaDoc trustStore)
82     {
83         this.trustStore = trustStore;
84     }
85
86     public String JavaDoc getTrustStorePassword()
87     {
88         return trustStorePassword;
89     }
90
91     public void setTrustStorePassword(String JavaDoc trustStorePassword)
92     {
93         this.trustStorePassword = trustStorePassword;
94     }
95 }
96
Popular Tags