de.malowa.greylister
Class Constants

java.lang.Object
  extended by de.malowa.greylister.Constants

public class Constants
extends java.lang.Object

Constants store many runtime information for the PostfixService. It is implemented as a Singleton to provide global access to constant parameters. It offers the possibility to log information to internal log files.

Author:
Marcel Lohmann

Method Summary
 boolean doSecureCleanup()
          Returns if the *all* old entries in the greylist database should be deleted (false) or only those where only one delivery attempt occured (true).
protected  void finalize()
          Ensures that all resources will be released
 java.lang.String getAcceptAction()
          Returns the string which should be communicated to the Postfix daemon.
 java.sql.Connection getConnection()
          Returns new database connection to the greylist database.
 ExternalWhitelist getGlobalWhitelist()
          Returns the current whitelist implementation
static Constants getInstance()
          Returns one and only the one instance of Constants class.
 int getMinimumOccurrencesBeforeWhitelist()
           
 SpamTrap getSpamTrap()
          Returns current spam trap implementation
 void initialize()
          Ensures that all constants will be initialized.
 void invalidate()
          Releases all resources used by the connection pool and forces the Constants to be initialized again.
 void logDebug(java.lang.String message)
          Logs debugging message to log file.
 void logError(java.lang.Exception exception)
          Logs exception to exception log file.
 void logError(java.lang.String message)
          Logs error message to exception log file.
 void logInfo(java.lang.String message)
          Logs informational message to log file.
 void logWarn(java.lang.String message)
          Logs warning message to log file.
 boolean useDerby()
          Returns if the internal Apache Derby database should be used for greylist data.
 boolean useHSQLDB()
          Returns if the internal HSQLDB database should be used for greylist data.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

logInfo

public void logInfo(java.lang.String message)
Logs informational message to log file.

Parameters:
message -

logWarn

public void logWarn(java.lang.String message)
Logs warning message to log file.

Parameters:
message -

logDebug

public void logDebug(java.lang.String message)
Logs debugging message to log file.

Parameters:
message -

logError

public void logError(java.lang.Exception exception)
Logs exception to exception log file.

Parameters:
exception -

logError

public void logError(java.lang.String message)
Logs error message to exception log file.

Parameters:
message -

getInstance

public static Constants getInstance()
Returns one and only the one instance of Constants class.

Returns:
the Constants

finalize

protected void finalize()
                 throws java.lang.Throwable
Ensures that all resources will be released

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

initialize

public void initialize()
Ensures that all constants will be initialized. Reads the properties, creates database connections, initializes spam traps and whitelists.


invalidate

public void invalidate()
Releases all resources used by the connection pool and forces the Constants to be initialized again.


getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Returns new database connection to the greylist database.

Returns:
new connection from pool
Throws:
java.sql.SQLException - if no connection could be established

getSpamTrap

public SpamTrap getSpamTrap()
Returns current spam trap implementation

Returns:
the implementation

getAcceptAction

public java.lang.String getAcceptAction()
Returns the string which should be communicated to the Postfix daemon. Is one of the strings defined in the access(5) Postfix manual.

Returns:
the action to perform

getGlobalWhitelist

public ExternalWhitelist getGlobalWhitelist()
Returns the current whitelist implementation

Returns:
the current implementation

useDerby

public boolean useDerby()
Returns if the internal Apache Derby database should be used for greylist data.

Returns:
true if internal database should be used

useHSQLDB

public boolean useHSQLDB()
Returns if the internal HSQLDB database should be used for greylist data.

Returns:
true if internal database should be used

doSecureCleanup

public boolean doSecureCleanup()
Returns if the *all* old entries in the greylist database should be deleted (false) or only those where only one delivery attempt occured (true).

Returns:
true if not all entries should be deleted

getMinimumOccurrencesBeforeWhitelist

public int getMinimumOccurrencesBeforeWhitelist()
Returns:
the necessary amount of different combinations of sender and recipient from one IP before the IP is automatically whitelisted.