01: package dtw.webmail.util.config;
02:
03: import java.util.Properties;
04: import java.io.Serializable;
05:
06: /**
07: * Class encapsulating the secure connection information
08: * and setup.
09: * <p>
10: * @author Dieter Wimberger (wimpi)
11: * @version (created Feb 27, 2003)
12: */
13: public class Security implements Serializable {
14:
15: private String m_SSLFactory = "javax.net.ssl.SSLSocketFactory";
16:
17: public Security() {
18: }//constructor
19:
20: /**
21: * Returns the <tt>SocketFactory</tt> class to be used
22: * for creating secure communication sockets.
23: *
24: * @return the factory class as <tt>String</tt>.
25: */
26: public String getSecureSocketFactory() {
27: return m_SSLFactory;
28: }//getSecureSocketFactory
29:
30: /**
31: * Sets the <tt>SocketFactory</tt> class to be used
32: * for creating secure communication sockets.
33: *
34: * @param factory the factory class as <tt>String</tt>.
35: */
36: public void setSecureSocketFactory(String factory) {
37: if (factory != null && factory.length() > 0) {
38: m_SSLFactory = factory;
39: }
40: }//setSecureSocketFactory
41:
42: public void addSocketProperties(String protocol, int port) {
43:
44: Properties props = System.getProperties();
45: props.setProperty("mail." + protocol + ".socketFactory.class",
46: m_SSLFactory);
47: props.setProperty("mail." + protocol
48: + ".socketFactory.fallback", "false");
49: props.setProperty("mail." + protocol + ".socketFactory.port",
50: "" + port);
51: props.setProperty("mail." + protocol + ".port", "" + port);
52:
53: }//prepareProperties
54:
55: }//class Security
|