Email Answering System
Version 1.0

com.ninecode.email.connector
Class EmailAuthenticator

java.lang.Object
  |
  +--javax.mail.Authenticator
        |
        +--com.ninecode.email.connector.EmailAuthenticator
All Implemented Interfaces:
Serializable

public class EmailAuthenticator
extends Authenticator
implements Serializable

An authenticator for email connection attempts. Differs from the model because this doesn't interact with the user (yeah, that'd be good in the J2EE environment eh?) and must be pre-charged with all the information it may need when asked. This class holds two sets of user names and passwords, one for the Transport provider and one for the Store provider. It uses the protocol to determine which to return to the caller.

Author:
Derrick Oswald
See Also:
Serialized Form

Field Summary
protected  String mStorePassword
          The current value of Store password.
protected  String mStoreUserName
          The current value of Store user name.
protected  String mTransportPassword
          The current value of Transport password.
protected  String mTransportUserName
          The current value of Transport user name.
 
Constructor Summary
protected EmailAuthenticator()
          Creates a default instance of EmailAuthenticator.
protected EmailAuthenticator(String transport_username, String transport_password, String store_username, String store_password)
          Creates a new instance of an EmailAuthenticator with the user names and passwords given.
 
Method Summary
 PasswordAuthentication getPasswordAuthentication()
          Get authentication details.
protected  String getStorePassword()
          Getter for property storePassword.
protected  String getStoreUserName()
          Getter for property storeUserName.
protected  String getTransportPassword()
          Getter for property transportPassword.
protected  String getTransportUserName()
          Getter for property transportUserName.
protected  void setStorePassword(String password)
          Setter for property storePassword.
protected  void setStoreUserName(String user)
          Setter for property storeUserName.
protected  void setTransportPassword(String password)
          Setter for property transportPassword.
protected  void setTransportUserName(String user)
          Setter for property transportUserName.
 
Methods inherited from class javax.mail.Authenticator
getDefaultUserName, getRequestingPort, getRequestingPrompt, getRequestingProtocol, getRequestingSite
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mTransportUserName

protected String mTransportUserName
The current value of Transport user name.


mTransportPassword

protected String mTransportPassword
The current value of Transport password.


mStoreUserName

protected String mStoreUserName
The current value of Store user name.


mStorePassword

protected String mStorePassword
The current value of Store password.

Constructor Detail

EmailAuthenticator

protected EmailAuthenticator()
Creates a default instance of EmailAuthenticator. The user names are set to the user.name property from the System properties, and the passwords are set to empty strings. Useful only if the user names and passwords are set later.

See Also:
setTransportUserName(java.lang.String), setTransportPassword(java.lang.String), setStoreUserName(java.lang.String), setStorePassword(java.lang.String)

EmailAuthenticator

protected EmailAuthenticator(String transport_username,
                             String transport_password,
                             String store_username,
                             String store_password)
Creates a new instance of an EmailAuthenticator with the user names and passwords given.

Parameters:
transport_username - The user name to authenticate Transport protocols with.
transport_password - The password to authenticate Transport protocols with.
store_username - The user name to authenticate Store protocols with.
store_password - The password to authenticate Store protocols with.
Method Detail

getTransportUserName

protected String getTransportUserName()
Getter for property transportUserName.

Returns:
Value of property transportUserName.

setTransportUserName

protected void setTransportUserName(String user)
Setter for property transportUserName.

Parameters:
user - New value of property transportUserName.
Throws:
IllegalArgumentException - if the user name is null.

getTransportPassword

protected String getTransportPassword()
Getter for property transportPassword.

Returns:
Value of property transportPassword.

setTransportPassword

protected void setTransportPassword(String password)
Setter for property transportPassword.

Parameters:
password - New value of property transportPassword.
Throws:
IllegalArgumentException - if the password is null.

getStoreUserName

protected String getStoreUserName()
Getter for property storeUserName.

Returns:
Value of property storeUserName.

setStoreUserName

protected void setStoreUserName(String user)
Setter for property storeUserName.

Parameters:
user - New value of property storeUserName.
Throws:
IllegalArgumentException - if the user name is null.

getStorePassword

protected String getStorePassword()
Getter for property storePassword.

Returns:
Value of property storePassword.

setStorePassword

protected void setStorePassword(String password)
Setter for property storePassword.

Parameters:
password - New value of property storePassword.
Throws:
IllegalArgumentException - if the password is null.

getPasswordAuthentication

public PasswordAuthentication getPasswordAuthentication()
Get authentication details. Called when password authentication is needed. Depending on the protocol requested, returns either the Transport or Store user name and password:

Protocol User/Password
smtp Transport
pop3 Store
imap Store

If the protocol is unrecognized, it attempts to match the default user name with the Store and Transport user names, if one matches it is returned, otherwise the Store user name and password are returned. TODORemove System.out.println.

Overrides:
getPasswordAuthentication in class Authenticator
Returns:
The PasswordAuthentication based on protocol.
See Also:
getRequestingProtocol(), getDefaultUserName()

Email Answering System
Version 1.0

Copyright © 2003 Derrick Oswald. All rights reserved.