toolbox.allegato
Class MailConfig

Package class diagram package MailConfig
java.lang.Object
  extended by toolbox.allegato.MailConfig

public class MailConfig
extends java.lang.Object

Class to encapsulate JavaMail Session configuration settings and Session creation. Mail configuration settings are obtained from a XML configuration document.


Nested Class Summary
(package private)  class MailConfig.SimpleMailAuthenticator
          Authenticator subclass to perform user name/password authentication.
 
Constructor Summary
MailConfig()
          Default constructor
MailConfig(java.lang.String name, XMLProperties xmlProps)
          Create a new MailConfig instance with the given name and mail configuration.
 
Method Summary
 javax.mail.Session createSessionForSMTP()
          Create and return a mail Session for SMTP based on the SMTP properties of this MailConfig instance.
 java.lang.String getSMTPAuth()
          Return the SMTP auth required flag.
 java.lang.String getSMTPHost()
          Return the SMTP host name.
 java.lang.String getSMTPPassword()
          Return the SMTP user password.
 java.lang.String getSMTPPort()
          Return the SMTP port number.
 java.util.Map getSMTPProperties()
          Return additional supported SMTP properties.
 java.lang.String getSMTPProtocol()
          Return the SMTP protocol.
 java.lang.String getSMTPUser()
          Return the SMTP user name.
 void setSMTPAuth(java.lang.String auth)
          Set the the SMTP auth required flag.
 void setSMTPHost(java.lang.String host)
          Set the SMTP host name.
 void setSMTPPassword(java.lang.String password)
          Set the SMTP user password.
 void setSMTPPort(java.lang.String port)
          Set the SMTP port number.
 void setSMTPProperty(java.lang.String name, java.lang.String val)
          Set an additional supported SMTP property.
 void setSMTPProtocol(java.lang.String proto)
          Set the SMTP protocol.
 void setSMTPUser(java.lang.String user)
          Set the SMTP user name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MailConfig

public MailConfig()
Default constructor


MailConfig

public MailConfig(java.lang.String name,
                  XMLProperties xmlProps)
           throws ConfException
Create a new MailConfig instance with the given name and mail configuration.

Parameters:
name - String containing the name of the mail configuration.
xmlProps - XML configuration properties.
Throws:
ConfException - if the configuration cannot be initialised.
Method Detail

getSMTPProtocol

public java.lang.String getSMTPProtocol()
Return the SMTP protocol.

Returns:
String containing SMTP protocol.

getSMTPHost

public java.lang.String getSMTPHost()
Return the SMTP host name.

Returns:
String containing SMTP server name.

getSMTPPort

public java.lang.String getSMTPPort()
Return the SMTP port number.

Returns:
String containing SMTP port number.

getSMTPAuth

public java.lang.String getSMTPAuth()
Return the SMTP auth required flag.

Returns:
String containing the SMTP auth flag. true|false.

getSMTPUser

public java.lang.String getSMTPUser()
Return the SMTP user name.

Returns:
String containing SMTP user name.

getSMTPPassword

public java.lang.String getSMTPPassword()
Return the SMTP user password.

Returns:
String containing the password of the SMTP user.

getSMTPProperties

public java.util.Map getSMTPProperties()
Return additional supported SMTP properties. See JavaMail documentation.

Returns:
Map containing the the SMTP properties.

setSMTPProtocol

public void setSMTPProtocol(java.lang.String proto)
Set the SMTP protocol.

Parameters:
proto - String containing SMTP protocol.

setSMTPHost

public void setSMTPHost(java.lang.String host)
Set the SMTP host name.

Parameters:
host - String containing SMTP server name.

setSMTPPort

public void setSMTPPort(java.lang.String port)
Set the SMTP port number.

Parameters:
port - String containing SMTP port number.

setSMTPAuth

public void setSMTPAuth(java.lang.String auth)
Set the the SMTP auth required flag.

Parameters:
auth - String containing the SMTP auth flag. true|false.

setSMTPUser

public void setSMTPUser(java.lang.String user)
Set the SMTP user name.

Parameters:
user - String containing SMTP user name.

setSMTPPassword

public void setSMTPPassword(java.lang.String password)
Set the SMTP user password.

Parameters:
password - String containing the password of the SMTP user.

setSMTPProperty

public void setSMTPProperty(java.lang.String name,
                            java.lang.String val)
Set an additional supported SMTP property. See JavaMail documentation.

Parameters:
name - String containig the name of the SMTP property.
val - String containing the value of the SMTP property.

createSessionForSMTP

public javax.mail.Session createSessionForSMTP()
Create and return a mail Session for SMTP based on the SMTP properties of this MailConfig instance.

Returns:
Session instance based on this config instance properties.