de.malowa.rules
Class RuleEvaluator

java.lang.Object
  extended by de.malowa.rules.RuleEvaluator

public final class RuleEvaluator
extends java.lang.Object

The RuleEvaluator is used to evaluate all configured rules for the Greylister. All defined rules are loaded from the ClassPath according to the configuration file rules.properties and will be added to the appropriate rule chain. The rule chains can be queried by using the static methods. The rules will be called in order of appearance in the configuration file.

This class is instantiated only once and therefore the rules are instatiated only once, too.

Author:
Marcel Lohmann

Method Summary
static boolean checkBlacklisting(SMTPInformation info)
          Checks the rule chain if the SMTPInformation should be blacklisted.
static boolean checkWhitelisting(SMTPInformation info)
          Checks the rule chain if the SMTPInformation should not even get to the greylist.
static boolean checkWhitelisting(SMTPInformation info, MailHistory history)
          Checks the rule chain if the SMTPInformation should pass the greylist even if the delay time has not passed.
static java.util.Date getDateToRemoveNoRetry(SMTPInformation info, MailHistory history)
          Checks the rule chain if one rule defines the time when an entry in the greylisting database should be removed.
static java.util.Date getDateToRemovePassedEntry(SMTPInformation info, MailHistory history)
          Checks the rule chain if one rule defines the time when an entry in the greylisting database should be removed.
static int getDelay(SMTPInformation info)
          Queries all configured rules to get the delay time for the given SMTPInformation.
static int getDelayWithHistory(SMTPInformation info, MailHistory history)
          Queries all configured rules to get the delay time for the given SMTPInformation.
static void preInitialize()
          Initializes the evaluator with all the rules.
static void updateRules()
          Calls the DelayRule.update() method of all DelayRules.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

preInitialize

public static void preInitialize()
Initializes the evaluator with all the rules.


getDelay

public static int getDelay(SMTPInformation info)
Queries all configured rules to get the delay time for the given SMTPInformation. The SMTPInformation is seen the first time. The delay times will be added (even negative times).

Parameters:
info - will be passed to all rules
Returns:
the aggregated delay time

getDelayWithHistory

public static int getDelayWithHistory(SMTPInformation info,
                                      MailHistory history)
Queries all configured rules to get the delay time for the given SMTPInformation. The SMTPInformation is seen more than once and has a MailHistory.The delay times will be added (even negative times).

Parameters:
info - will be passed to all rules
history - will be passed to all rules
Returns:
the aggregated delay time

checkWhitelisting

public static boolean checkWhitelisting(SMTPInformation info)
Checks the rule chain if the SMTPInformation should not even get to the greylist. The first rule which is triggered breaks the rule chain.

Parameters:
info - is passed to all rules
Returns:
true if one rule triggered whitelisting

checkWhitelisting

public static boolean checkWhitelisting(SMTPInformation info,
                                        MailHistory history)
Checks the rule chain if the SMTPInformation should pass the greylist even if the delay time has not passed. The first rule which is triggered breaks the rule chain.

Parameters:
info - is passed to all rules
history - is passed to all rules
Returns:
true if one rule triggered whitelisting

getDateToRemovePassedEntry

public static java.util.Date getDateToRemovePassedEntry(SMTPInformation info,
                                                        MailHistory history)
Checks the rule chain if one rule defines the time when an entry in the greylisting database should be removed. The first rule that triggers will break the chain. If no rule triggers, the time is defined as 36 days from now on.

Parameters:
info - will be passed to all rules
history - will be passed to all rules
Returns:
the date when the entry should be removed.

getDateToRemoveNoRetry

public static java.util.Date getDateToRemoveNoRetry(SMTPInformation info,
                                                    MailHistory history)
Checks the rule chain if one rule defines the time when an entry in the greylisting database should be removed. The first rule that triggers will break the chain. If no rule triggers the time is defined as 4 hours from now on.

Parameters:
info - will be passed to all rules
history - will be passed to all rules
Returns:
the date when the entry should be removed.

checkBlacklisting

public static boolean checkBlacklisting(SMTPInformation info)
Checks the rule chain if the SMTPInformation should be blacklisted. The first rule which is triggered breaks the rule chain.

Parameters:
info - is passed to all rules
Returns:
true if one rule triggered blacklisting

updateRules

public static void updateRules()
Calls the DelayRule.update() method of all DelayRules.