infoservice.mailsystem.central
Class MailContext

java.lang.Object
  extended by infoservice.mailsystem.central.MailContext

public class MailContext
extends java.lang.Object

This class stores the configuration for the JAP mailsystem (Singleton).


Field Summary
static long BAN_PERIOD
          The period a recipient will be banned after we have received to many requests for his address.
private static long INFOSERVICE_TIMEOUT
          The time in ms until the InfoServices loaded from the config file are outdated.
private  int m_centralProcessPort
          Stores the port where this central mailsystem process is listening for mail requests.
private  javax.mail.Session m_mailSession
          This stores the Session instance of the Java Mail API.
static long MAIL_ADDRESSES_TIMEOUT
          Defines the period mail addresses will be stored in the local database to prevent DoS attacks.
static int MAXIMUM_NUMBER_OF_REQUESTS
          Defines how many requests are processed within the MAIL_ADDRESS_TIMEOUT without banning the mailaddress of the recipient.
private static MailContext ms_mcInstance
          This stores the instance of MailContext (Singleton).
 
Constructor Summary
private MailContext(java.lang.String a_configFile)
          Creates a new instance of MailContext.
 
Method Summary
static void createInstance(java.lang.String a_configFile)
          Creates an instance of MailContext, if there is already one, the old one is overwritten (Singleton).
 int getCentralProcessPort()
          Retruns the port where this central mailsystem process is listening for mail requests.
static MailContext getInstance()
          Returns the instance of MailContext (Singleton).
 javax.mail.Session getSession()
          Returns the initialized Session instance for the Java Mail API.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAIL_ADDRESSES_TIMEOUT

public static final long MAIL_ADDRESSES_TIMEOUT
Defines the period mail addresses will be stored in the local database to prevent DoS attacks. The default is 10 minutes, if you change it also update the ban warning message sent to the users.

See Also:
Constant Field Values

MAXIMUM_NUMBER_OF_REQUESTS

public static final int MAXIMUM_NUMBER_OF_REQUESTS
Defines how many requests are processed within the MAIL_ADDRESS_TIMEOUT without banning the mailaddress of the recipient. If we receive more requests, the address of the recipient will be banned for some time. The default is 5 messages, if you change it also update the ban warning message sent to the users.

See Also:
Constant Field Values

BAN_PERIOD

public static final long BAN_PERIOD
The period a recipient will be banned after we have received to many requests for his address. The default is 10 minutes, if you change it also update the ban warning message sent to the users.

See Also:
Constant Field Values

INFOSERVICE_TIMEOUT

private static final long INFOSERVICE_TIMEOUT
The time in ms until the InfoServices loaded from the config file are outdated. This should never occur (1000 years should be enough).

See Also:
Constant Field Values

ms_mcInstance

private static MailContext ms_mcInstance
This stores the instance of MailContext (Singleton).


m_mailSession

private javax.mail.Session m_mailSession
This stores the Session instance of the Java Mail API. All mails should be sended using this session instance, because the configuration for the Java Mail API is only stored here.


m_centralProcessPort

private int m_centralProcessPort
Stores the port where this central mailsystem process is listening for mail requests. Only mail requests from localhost are accepted.

Constructor Detail

MailContext

private MailContext(java.lang.String a_configFile)
             throws java.lang.Exception
Creates a new instance of MailContext. We load the configuration from the specified file and configure the Java Mail API and the InfoServiceDatabase. If there occurs an error while loading the configuration, an Exception is thrown.

Parameters:
a_configFile - The path and the filename of the configuration file.
Throws:
java.lang.Exception
Method Detail

createInstance

public static void createInstance(java.lang.String a_configFile)
                           throws java.lang.Exception
Creates an instance of MailContext, if there is already one, the old one is overwritten (Singleton).

Parameters:
a_configFile - The path and the filename of the configuration file to use for the new instance.
Throws:
java.lang.Exception

getInstance

public static MailContext getInstance()
Returns the instance of MailContext (Singleton). If there was no one created until yet, null is returned.

Returns:
The instance of MailContext.

getSession

public javax.mail.Session getSession()
Returns the initialized Session instance for the Java Mail API.

Returns:
The Session instance to use with the Java Mail API.

getCentralProcessPort

public int getCentralProcessPort()
Retruns the port where this central mailsystem process is listening for mail requests. Only mail requests from localhost are accepted.

Returns:
The port on localhost where this central mailsystem process is listening for mail requests.