1 package org.jent.checksmtp;
4 import java.io.FileInputStream;
5 import java.io.FileNotFoundException;
6 import java.io.FileOutputStream;
7 import java.io.IOException;
9 import java.util.Properties;
13 * <P>This class hold application properties.</P>
14 * <P>"$user.home/.checksmtp.properties" was used to stored data file.</P>
17 * <DT> -.port <DD>Service port number. (Default:8725)
18 * <DT> -.enableRemoteConnect <DD>Permit connect from remote host. (Default:false)
19 * <DT> -.serverHost <DD>STMP Server host name. (Default:mail)
20 * <DT> -.serverPort <DD>STMP Server port. (Default:25)
21 * <DT> -.ladp <DD>If "true" use LDAP search. (Default:false)
22 * <DT> -.ldap.providerUrl <DD>LDAP Provider URL (Default:ldap://localhost:389
23 * <DT> -.ldap.baseDn <DD>LDAP Search root (Default:C=JP)
24 * <DT> -.ldap.isSjis<DD>Addhoc patch: When LDAP Server use SJIS, this propertiy set "true" (Default:false)
25 * <DT> -.ldap.attribues<DD>LDAP Search attribues separate by space (Defaut:cn)
28 public class ApplicationProperties
30 private static final String PREFIX = "org.jent.checksmtp";
31 private static final String SMTP_PORT = PREFIX + ".port";
32 private static final String SMTP_ENEBLE_REMOTE_CONNECT = PREFIX + ".enableRemoteConnect";
33 private static final String SMTP_SERVER_HOST = PREFIX + ".serverHost";
34 private static final String SMTP_SERVER_PORT = PREFIX + ".serverPort";
35 private static final String LDAP_PREFIX = PREFIX + ".ldap";
36 private static final String LDAP_PROVIDER_URL = LDAP_PREFIX + ".providerUrl";
37 private static final String LDAP_ROOT = LDAP_PREFIX + ".baseDn";
38 private static final String LDAP_IS_SJIS = LDAP_PREFIX + ".isSjis";
39 private static final String LDAP_IS_ATTRIBUTES = LDAP_PREFIX + ".attributes";
41 private static final String PROPERTIES_FILENAME = ".checksmtp.properties";
43 private static Properties applicationProperties = new Properties();
45 private static String fileName = PROPERTIES_FILENAME;
50 //InputStream is = ApplicationProperties.class.getClassLoader().getResourceAsStream("checksmtp.properties");
51 fileName = System.getProperty("user.home") + File.separator + PROPERTIES_FILENAME;
52 FileInputStream is = new FileInputStream(fileName);
53 applicationProperties.load(is);
58 System.err.println("No checksmtp.properties in " + fileName);
62 private ApplicationProperties()
67 * Application Properties Save
69 public static void save()
74 fos = new FileOutputStream(fileName);
75 applicationProperties.store(fos, "Appliction Properties");
80 System.err.println(fileName + "was occrred save error.");
85 public static String getSmtpServerHost()
87 return applicationProperties.getProperty(SMTP_SERVER_HOST, "mail");
90 public static void setSmtpServerHost(String obj)
92 applicationProperties.setProperty(SMTP_SERVER_HOST, obj);
95 public static int getSmtpServerPort()
97 return Integer.parseInt(applicationProperties.getProperty(SMTP_SERVER_PORT, "25"));
100 public static void setSmtpServerPort(int port)
102 applicationProperties.setProperty(SMTP_SERVER_PORT, new Integer(port).toString());
105 public static int getSmtpPort()
107 return Integer.parseInt(applicationProperties.getProperty(SMTP_PORT, "8725"));
110 public static void setSmtpPort(int port)
112 applicationProperties.setProperty(SMTP_PORT, new Integer(port).toString());
115 public static boolean getSmtpEnebleRemoteConnect()
117 String str = applicationProperties.getProperty(SMTP_ENEBLE_REMOTE_CONNECT);
118 return new Boolean(str).booleanValue();
121 public static void setSmtpEnableRemoteConnect(boolean obj)
123 applicationProperties.setProperty(SMTP_ENEBLE_REMOTE_CONNECT, Boolean.toString(obj));
126 public static String getLdapProviderURL()
128 return applicationProperties.getProperty(LDAP_PROVIDER_URL, "ldap://localhost:389");
131 public static void setLdapProviderURL(String obj)
133 applicationProperties.setProperty(LDAP_PROVIDER_URL, obj);
136 public static String getLdapRoot()
138 return applicationProperties.getProperty(LDAP_ROOT, "C=JP");
141 public static void setLdapRoot(String obj)
143 applicationProperties.setProperty(LDAP_ROOT, obj);
146 public static boolean getLdapIsSjis()
148 return new Boolean(applicationProperties.getProperty(LDAP_IS_SJIS)).booleanValue();
151 public static void setLdapRoot(boolean obj)
153 applicationProperties.setProperty(LDAP_IS_SJIS, Boolean.toString(obj));
156 public static boolean getLdap()
158 String str = applicationProperties.getProperty(LDAP_PREFIX);
159 Boolean flg = new Boolean(str);
160 return flg.booleanValue();
163 public static void setLdap(boolean obj)
165 applicationProperties.setProperty(LDAP_PREFIX, Boolean.toString(obj));
168 public static String getLdapAttributes()
170 return applicationProperties.getProperty(LDAP_IS_ATTRIBUTES, "cn");
173 public static void setLdapAttributes(String obj)
175 applicationProperties.setProperty(LDAP_IS_ATTRIBUTES, obj);