com.ericdaugherty.mail.server.configuration
Class ConfigurationManager

java.lang.Object
  extended by com.ericdaugherty.mail.server.configuration.ConfigurationManager
All Implemented Interfaces:
ConfigurationParameterConstants

public class ConfigurationManager
extends java.lang.Object
implements ConfigurationParameterConstants

Provides a centralized repository for all configuration information.

All configuration information should be retrieved here for every use. The ConfigurationManager will reload configuration changes dynamically.

Classes may cache the reference to the ConfigurationManager instance, as only one will ever be created.

Author:
Eric Daugherty, Andreas Kyrmegalos (2.x branch)

Nested Class Summary
 class ConfigurationManager.DomainWithPassword
           
static class ConfigurationManager.RetrievalMode
           
static class ConfigurationManager.TransferMode
           
 
Field Summary
 ConfigurationManager.RetrievalMode retrievalMode
           
 ConfigurationManager.TransferMode transferMode
           
static java.lang.String USER_PROPERTIES_HEADER
           
 
Fields inherited from interface com.ericdaugherty.mail.server.configuration.ConfigurationParameterConstants
ACTIVATE_AMAVISD, ADD_PCT_RCPT, ALLOWCLEARTEXT, ALWAYS, AMAVISD_FILTERED_SMTPPORT, AMAVISD_INCOMING_DIRECTORY, AMAVISD_LISTEN_ADDRESS, AMAVISD_SMTPPORT, CLIENTAUTH_TYPE, CONFIG_ADDRESS, CONFIG_PORT, DEFAULT_MAILBOX, DEFAULT_SMTP_SERVERS, DISABLE_WARNING, DOMAINS, ENABLE_HELO, ENABLE_SECURITYMANAGER, ENABLED_CIPHERS, ENABLED_PROTOCOLS, ENCRYPTEDONLY, EXECUTE_THREADS, EXTERNAL_DELEGATED, FILE_ENCODING, KEYSTORELOCATION, KEYSTOREPROVIDER, KEYSTORETYPE, LISTEN_ADDRESS, LOCALE_COUNTRY, LOCALE_LANGUAGE, LOGGING_DEFAULT_THRESHOLD, MAIL_RETRIEVAL_MODE, MAIL_TRANSFER_MODE, MAX_ERROR_COUNT, MAX_PASS_ATTEMPTS, MAX_VALID_RCPT, MIME8BIT, MIN_PCT_FAIL_RCPT, MIN_TOT_FAIL_RCPT, NEVER, NOTIFY_DEFAULT, OS_NAME, OUTGOINGSECURE, POP3PORT, REALM_DEF_PREFIX, REJECT_NON_EXISTENT_LOCAL, RELAY_ADDRESSLIST, RELAY_EMAILSLIST, RELAY_POP_BEFORE_SMTP, RELAY_POP_BEFORE_SMTP_TIMEOUT, SASL_DIGEST_MD5_CIPHERS, SASL_DIGEST_MD5_ENABLE, SASL_GSS_ENABLE, SASL_GSS_KDC, SASL_GSS_KEYTAB, SASL_GSS_PRINCIPAL, SASL_GSS_REALM, SASL_GSS_STOREKEY, SASL_GSS_USEKEYTAB, SASL_QOP, SECURE_EXECUTE_THREADS, SECUREACTIVE, SECUREPOP3PORT, SECURESMTPPORT, SMTP_DELIVERY_INTERVAL, SMTP_DELIVERY_THRESHOLD, SMTP_MAX_MESSAGE_SIZE, SMTPDIRECTORY, SMTPPORT, STANDARDPOP3SECURE, STANDARDSMTPSECURE, TESTING_DESTINATION, TRUSTSTORELOCATION, TRUSTSTOREPROVIDER, TRUSTSTORETYPE, USER_DEF_PREFIX, USER_FILE_FORWARDS, USER_PROPERTY_PREFIX, USERSDIRECTORY, VERIFY_IP
 
Method Summary
 int allowClearTextPOP3()
          Check whether or not clear text passwords are allowed in POP3 sessions.
 int allowClearTextSMTP()
          Check whether or not clear text passwords are allowed in SMTP sessions.
 int getAddPctRCPT()
           
 int getAmavisFilteredSMTPPort()
           
 java.net.InetAddress getAmavisListenAddress()
           
 java.lang.String getAmavisSMTPDirectory()
           
 int getAmavisSMTPPort()
           
 long getAuthenticationTimeoutMilliseconds()
          The timeout length for authenticated ip addresses
 java.lang.String getBackupDirectory()
          The directory used to store backup files.
 java.lang.String getClientAuth()
          Check whether the standard SMTP/POP3 modules are to use TLS/SSL security.
 java.net.InetAddress getConfigurationAddress()
           
 int getConfigurationPort()
           
 EmailAddress getDefaultMailbox(java.lang.String domain)
           
 DefaultSMTPServer[] getDefaultSmtpServers()
          The servers to send all outoing mail through
 int getDeliveryAttemptThreshold()
          Get the max number of delivvery attempts before message is considered 'undeliverable' and moved to 'failed' folder
 long getDeliveryIntervalSeconds()
          The number of seconds to wait between delivery attempts
 long getDeliveryIntervealMilliseconds()
          The number of milliseconds to wait between delivery attempts
 java.lang.String getDigestMD5Ciphers()
           
 int getExecuteThreadCount()
          The number of threads to use for each listener.
 java.lang.String getFailedDirectory()
          The directory used to store failed e-mails.
 java.lang.String getGSSPrincipal()
           
static ConfigurationManager getInstance()
          Provides access to the singleton instance.
 java.lang.String getKeystoreLocation()
          The location of the keystore containg the server's certificates and private key.
 java.lang.String getKeystoreProvider()
          The provider of the keystore containg the server's certificates and private key.
 java.lang.String getKeystoreType()
          The type of the keystore containg the server's certificates and private key.
 java.net.InetAddress getListenAddress()
          The local IP address to lisen on.
 java.util.Set<java.lang.String> getLocalDomains()
          Array of domains that the SMTP server should accept mail for local delivery
 java.util.Map getMappedPorts()
           
 int getMaxErrorCount()
          The maximum number of errors during a POP3 or SMTP server session.
 int getMaximumMessageSize()
          The maximum size (in megabytes) allowed for email attachments.
 int getMaxPassAttempts()
           
 int getMaxValidRCPT()
           
 int getMinPctFailRCPT()
           
 int getMinTotFailRCPT()
           
 int getPOP3Port()
          The port the POP3 server listens on.
 Realm getRealm(java.lang.String realmName)
          Returns the specified realm, or null if the realm does not exist.
 ConfigurationManager.DomainWithPassword getRealmPassword(java.lang.String realmName, java.lang.String username)
           
 java.util.Map getRealms()
           
 java.lang.String[] getRelayApprovedEmailAddresses()
          Email Addresses that are allowed to relay mail.
 java.lang.String[] getRelayApprovedIPAddresses()
          IP Addresses that are allowed to relay mail.
 ConfigurationManager.RetrievalMode getRetrievalMode()
           
 java.lang.String[] getReverseDNSservers()
          Array of domains that the SMTP server should alter the initial greeting reported domain
 java.lang.String getRootDirectory()
          The root directory used to store the incoming and outgoing messages.
 java.lang.String getSaslQOP()
           
 int getSecureExecuteThreadCount()
          The number of threads to use for each secure listener.
 int getSecurePOP3Port()
          The port the secure POP3 server listens on.
 int getSecureSMTPPort()
          The port the secure SMTP server listens on.
 java.lang.String getSecurityDirectory()
          The root directory used to store the server certificate and private key.
 java.lang.String getSMTPDirectory()
          The directory used to store incoming e-mails.
 int getSMTPPort()
          The port the SMTP server listens on.
 javax.net.ssl.SSLContext getSSLContext()
           
 javax.net.ssl.SSLSocketFactory getSSLSocketFactory()
           
 java.lang.String getTestingDirectory()
           
 ConfigurationManager.TransferMode getTransferMode()
           
 java.lang.String getTruststoreLocation()
          The location of the truststore containg the server's certificates and private key.
 java.lang.String getTruststoreProvider()
          The provider of the truststore containg the server's certificates and private key.
 java.lang.String getTruststoreType()
          The type of the truststore containg the server's certificates and private key.
 User getUser(EmailAddress address)
          Returns the specified user, or null if the user does not exist.
 java.lang.String getUsersDirectory()
          The directory used to store the user accounts.
static ConfigurationManager initialize(java.lang.String rootDirectory)
          Initializes the ConfigurationManager to use the specified directory.
 boolean is8bitMIME()
          A flag to indicate if 8BITMIME is to be used
 boolean isAmavisSupportActive()
           
 boolean isDebugSSL()
           
 boolean isDefaultSmtpServerEnabled()
          True if all outgoing mail should go though the default server
 boolean isDigestMD5Enabled()
           
 boolean isEnablePOPBeforeSMTP()
          True if POP Before SMTP is a valid relay option
 boolean isGSSEnabled()
           
 boolean isHELOEnabled()
           
 boolean isLocalDomain(java.lang.String domain)
          Checks the local domains to see if the specified parameter matches.
 boolean isLocalTestingMode()
           
 boolean isNonExistentLocalRejected()
           
 boolean isOutgoingSecure()
          Check whether to use TLS/SSL for an outbound SMTP message
 boolean isSecureActive()
          Check whether the secure POP3 modules are active/to be activated.
static boolean isSecurityManagerEnabled()
           
 boolean isStandardPOP3Secure()
          Check whether the standard POP3 modules are to use TLS/SSL security.
 boolean isStandardSMTPSecure()
          Check whether the standard SMTP modules are to use TLS/SSL security.
 boolean isVerifyIP()
           
 void persistUpdates()
           
 void requestDirCreation(java.lang.String directory)
           
static void shutdown()
           
static java.lang.String[] tokenize(java.lang.String value, boolean clearWhiteSpace)
          Loads the values of the specified key from the configuration file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

transferMode

public ConfigurationManager.TransferMode transferMode

retrievalMode

public ConfigurationManager.RetrievalMode retrievalMode

USER_PROPERTIES_HEADER

public static final java.lang.String USER_PROPERTIES_HEADER
Method Detail

initialize

public static ConfigurationManager initialize(java.lang.String rootDirectory)
                                       throws java.lang.RuntimeException
Initializes the ConfigurationManager to use the specified directory. This method should only be called once during startup, and then never again. The file path can not be re-initialized!

Parameters:
rootDirectory - the directory JES was installed into.
Returns:
returns the singleton instance of the ConfigurationManager.
Throws:
java.lang.RuntimeException - thrown if called more than once, the file does not exist, or there is an error loading the file.

getInstance

public static ConfigurationManager getInstance()
Provides access to the singleton instance.

Returns:
the singleton instance.

shutdown

public static void shutdown()

isDebugSSL

public boolean isDebugSSL()

getTransferMode

public ConfigurationManager.TransferMode getTransferMode()

getRetrievalMode

public ConfigurationManager.RetrievalMode getRetrievalMode()

getRootDirectory

public java.lang.String getRootDirectory()
The root directory used to store the incoming and outgoing messages.

Returns:
String

getBackupDirectory

public java.lang.String getBackupDirectory()
The directory used to store backup files.

Returns:
backupDirectory String

getSMTPDirectory

public java.lang.String getSMTPDirectory()
The directory used to store incoming e-mails.

Returns:
SMTPDirectory String

getUsersDirectory

public java.lang.String getUsersDirectory()
The directory used to store the user accounts.

Returns:
String

getSecurityDirectory

public java.lang.String getSecurityDirectory()
The root directory used to store the server certificate and private key.

Returns:
securityDirectory String

getFailedDirectory

public java.lang.String getFailedDirectory()
The directory used to store failed e-mails.

Returns:
failedDirectory String

requestDirCreation

public void requestDirCreation(java.lang.String directory)

getConfigurationAddress

public java.net.InetAddress getConfigurationAddress()

getConfigurationPort

public int getConfigurationPort()

getListenAddress

public java.net.InetAddress getListenAddress()
The local IP address to lisen on. Null for all addresses

Returns:
null for all addresses.

getSMTPPort

public int getSMTPPort()
The port the SMTP server listens on.

Returns:
port number

getPOP3Port

public int getPOP3Port()
The port the POP3 server listens on.

Returns:
port number

getExecuteThreadCount

public int getExecuteThreadCount()
The number of threads to use for each listener.

Returns:
int

getMaximumMessageSize

public int getMaximumMessageSize()
The maximum size (in megabytes) allowed for email attachments.


getDeliveryIntervalSeconds

public long getDeliveryIntervalSeconds()
The number of seconds to wait between delivery attempts


getDeliveryIntervealMilliseconds

public long getDeliveryIntervealMilliseconds()
The number of milliseconds to wait between delivery attempts


getDeliveryAttemptThreshold

public int getDeliveryAttemptThreshold()
Get the max number of delivvery attempts before message is considered 'undeliverable' and moved to 'failed' folder

Returns:
int

getLocalDomains

public java.util.Set<java.lang.String> getLocalDomains()
Array of domains that the SMTP server should accept mail for local delivery

Returns:
String array

isLocalDomain

public boolean isLocalDomain(java.lang.String domain)
Checks the local domains to see if the specified parameter matches.

Parameters:
domain - a domain to check.
Returns:
true if and only if it matches exactly an existing domain.

getDefaultMailbox

public EmailAddress getDefaultMailbox(java.lang.String domain)

isDefaultSmtpServerEnabled

public boolean isDefaultSmtpServerEnabled()
True if all outgoing mail should go though the default server


getDefaultSmtpServers

public DefaultSMTPServer[] getDefaultSmtpServers()
The servers to send all outoing mail through


isEnablePOPBeforeSMTP

public boolean isEnablePOPBeforeSMTP()
True if POP Before SMTP is a valid relay option


getAuthenticationTimeoutMilliseconds

public long getAuthenticationTimeoutMilliseconds()
The timeout length for authenticated ip addresses


getRelayApprovedIPAddresses

public java.lang.String[] getRelayApprovedIPAddresses()
IP Addresses that are allowed to relay mail.


getRelayApprovedEmailAddresses

public java.lang.String[] getRelayApprovedEmailAddresses()
Email Addresses that are allowed to relay mail.


is8bitMIME

public boolean is8bitMIME()
A flag to indicate if 8BITMIME is to be used

Returns:
boolean mime8bit

isSecureActive

public boolean isSecureActive()
Check whether the secure POP3 modules are active/to be activated.

Returns:
boolean standardsecure

getSecureSMTPPort

public int getSecureSMTPPort()
The port the secure SMTP server listens on.

Returns:
int secureSMTPPort

getSecurePOP3Port

public int getSecurePOP3Port()
The port the secure POP3 server listens on.

Returns:
port number

getSecureExecuteThreadCount

public int getSecureExecuteThreadCount()
The number of threads to use for each secure listener.

Returns:
int

getKeystoreLocation

public java.lang.String getKeystoreLocation()
The location of the keystore containg the server's certificates and private key.

Returns:
String keystoreLocation

getKeystoreProvider

public java.lang.String getKeystoreProvider()
The provider of the keystore containg the server's certificates and private key.

Returns:
String keystoreProvider

getKeystoreType

public java.lang.String getKeystoreType()
The type of the keystore containg the server's certificates and private key.

Returns:
String keystoreType

getTruststoreLocation

public java.lang.String getTruststoreLocation()
The location of the truststore containg the server's certificates and private key.

Returns:
String truststoreLocation

getTruststoreProvider

public java.lang.String getTruststoreProvider()
The provider of the truststore containg the server's certificates and private key.

Returns:
String truststoreProvider

getTruststoreType

public java.lang.String getTruststoreType()
The type of the truststore containg the server's certificates and private key.

Returns:
String truststoreType

getSSLSocketFactory

public javax.net.ssl.SSLSocketFactory getSSLSocketFactory()

isSecurityManagerEnabled

public static boolean isSecurityManagerEnabled()

isHELOEnabled

public boolean isHELOEnabled()

getClientAuth

public java.lang.String getClientAuth()
Check whether the standard SMTP/POP3 modules are to use TLS/SSL security.

Returns:
boolean standardsecure

isOutgoingSecure

public boolean isOutgoingSecure()
Check whether to use TLS/SSL for an outbound SMTP message

Returns:
boolean outgoingSecure

isStandardSMTPSecure

public boolean isStandardSMTPSecure()
Check whether the standard SMTP modules are to use TLS/SSL security.

Returns:
boolean standardSMTPsecure

isStandardPOP3Secure

public boolean isStandardPOP3Secure()
Check whether the standard POP3 modules are to use TLS/SSL security.

Returns:
boolean standardPOP3secure

allowClearTextSMTP

public int allowClearTextSMTP()
Check whether or not clear text passwords are allowed in SMTP sessions.

Returns:
int allowClearText

allowClearTextPOP3

public int allowClearTextPOP3()
Check whether or not clear text passwords are allowed in POP3 sessions.

Returns:
int allowClearText

isNonExistentLocalRejected

public boolean isNonExistentLocalRejected()

getMaxErrorCount

public int getMaxErrorCount()
The maximum number of errors during a POP3 or SMTP server session.

Returns:
int maxErrorCount

getMaxPassAttempts

public int getMaxPassAttempts()

getMaxValidRCPT

public int getMaxValidRCPT()

getAddPctRCPT

public int getAddPctRCPT()

getMinTotFailRCPT

public int getMinTotFailRCPT()

getMinPctFailRCPT

public int getMinPctFailRCPT()

isVerifyIP

public boolean isVerifyIP()

getSaslQOP

public java.lang.String getSaslQOP()

getDigestMD5Ciphers

public java.lang.String getDigestMD5Ciphers()

isDigestMD5Enabled

public boolean isDigestMD5Enabled()

isGSSEnabled

public boolean isGSSEnabled()

getGSSPrincipal

public java.lang.String getGSSPrincipal()

isAmavisSupportActive

public boolean isAmavisSupportActive()

getAmavisSMTPDirectory

public java.lang.String getAmavisSMTPDirectory()

getAmavisListenAddress

public java.net.InetAddress getAmavisListenAddress()

getAmavisSMTPPort

public int getAmavisSMTPPort()

getAmavisFilteredSMTPPort

public int getAmavisFilteredSMTPPort()

isLocalTestingMode

public boolean isLocalTestingMode()

getTestingDirectory

public java.lang.String getTestingDirectory()

getReverseDNSservers

public java.lang.String[] getReverseDNSservers()
Array of domains that the SMTP server should alter the initial greeting reported domain

Returns:
String array

getUser

public User getUser(EmailAddress address)
Returns the specified user, or null if the user does not exist.

Parameters:
address - the user's full email address.
Returns:
null if the user does not exist.

getRealms

public java.util.Map getRealms()

getRealm

public Realm getRealm(java.lang.String realmName)
Returns the specified realm, or null if the realm does not exist.

Parameters:
realmName - the realm's full name.
Returns:
null if the realm does not exist.

getRealmPassword

public ConfigurationManager.DomainWithPassword getRealmPassword(java.lang.String realmName,
                                                                java.lang.String username)

getSSLContext

public javax.net.ssl.SSLContext getSSLContext()

getMappedPorts

public final java.util.Map getMappedPorts()

persistUpdates

public void persistUpdates()

tokenize

public static java.lang.String[] tokenize(java.lang.String value,
                                          boolean clearWhiteSpace)
Loads the values of the specified key from the configuration file. This method parses the value into a String array using the comma (,) as a delimiter. This method returns an array of size 0 if the the value string was null or empty.

Parameters:
value - the string to tokenize into an array.
Returns:
a String[] of the values, or an empty array if the key could not be found.