|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--dtw.webmail.JwmaSession
Class that models the state of a jwma session.
Each instance stores the state and provides accessor and mutator operations for retrieving and changing.
The reference to the instance itself is stored in the HttpSession as session attribute.
Note that this class is actually the bridge between the web session and the mail client session, and that instances have the responsibility to manage the state of both.
Constructor Summary | |
JwmaSession(javax.servlet.http.HttpSession session)
Constructs a JwmaSession instance. |
Method Summary | |
boolean |
authenticate(java.lang.String username,
java.lang.String password,
boolean newAccount)
Authenticates the given user by initializing the mail session, thus authenticating against the post office of this session. |
void |
end()
Ends this session, by cleaning up user related data and resources. |
void |
ensureAdministrator()
Tests whether the user associated with this session is allowed to administrate jwma and throws a JwmaException if not, thus ensuring an administrative user. |
void |
ensureAuthenticated()
Tests wheter this session is authenticated, throwing a JwmaException if not, thus ensuring an authenticated session. |
void |
ensurePostOfficeConnection()
Tests wheter a connection to the post office exists, throwing a JwmaException if not, thus it ensures that a connection to the post office exists. |
void |
finalize()
Overrides the superclass method to call end(). |
JwmaStoreImpl |
getJwmaStore()
Returns the actual mailsession's JwmaStoreImpl. |
JwmaTransportImpl |
getJwmaTransport()
Returns the actual mailsession's JwmaTransportImpl. |
java.lang.String |
getLastLogin()
Returns a String representing the user's last login date and originating host. |
javax.mail.Session |
getMailSession()
Returns this instances mailsession. |
MailTransportAgent |
getMTA()
|
PostOffice |
getPostOffice()
|
JwmaPreferencesImpl |
getPreferences()
Returns the JwmaPreferencesImpl instance of this session instance's user. |
javax.servlet.http.HttpServletRequest |
getRequest()
Returns the reference to the actual HttpServletRequest instance. |
java.lang.String |
getRequestParameter(java.lang.String name)
Returns the value of a request parameter from this session's HttpServletRequest. |
java.lang.String[] |
getRequestParameters(java.lang.String name)
Returns the values of a request parameter from this session's HttpServletRequest. |
javax.servlet.http.HttpServletResponse |
getResponse()
Returns the reference to the actual HttpServletResponse instance. |
java.lang.String |
getUserIdentity()
Returns the assembled user's identity as String. |
java.lang.String |
getUserIdentity(java.lang.String username)
Returns the assembled user's identity as String. |
java.lang.String |
getUsername()
Returns the username associated with this JwmaSession. |
javax.servlet.http.HttpSession |
getWebSession()
Returns the reference to the actual HttpSession instance. |
boolean |
isAdministrator()
Tests if this session's associated user is an administrator. |
boolean |
isAuthenticated()
Tests if this session is authenticated. |
boolean |
isPostOfficeConnected()
Tests if this session has a connection to the post office. |
boolean |
isValidWebSession()
Tests if the associated web session is valid. |
void |
redirect(java.lang.String view)
Redirects the the actual HttpServletRequest to an abstract view. |
void |
redirectToActual()
Redirects the the actual HttpServletRequest to the present view. |
void |
redirectToLast()
Redirects the the actual HttpServletRequest to the last view. |
void |
removeBean(java.lang.String name)
Removes a reference to a bean (model) in the actual HttpSession. |
java.lang.Object |
retrieveBean(java.lang.String name)
Returns a reference to a bean(model) in the actual HttpSession. |
boolean |
savePreferences()
Saves the JwmaPreferencesImpl instance of this session instance's user. |
void |
setLocale()
Sets the Locale of this Session to the one that is stored in the user's preferences. |
void |
setMTA(MailTransportAgent MTA)
|
void |
setPostOffice(PostOffice office)
|
void |
setRequest(javax.servlet.http.HttpServletRequest request)
Sets the reference to the actual HttpServletRequest instance. |
void |
setResponse(javax.servlet.http.HttpServletResponse response)
Sets the reference to the actual HttpServletResponse instance. |
void |
setWebSession(javax.servlet.http.HttpSession websession)
Sets the reference to the actual HttpSession instance. |
void |
storeBean(java.lang.String name,
java.lang.Object bean)
Stores a reference to a bean(model) in the actual HttpSession. |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public JwmaSession(javax.servlet.http.HttpSession session)
session
- reference to the actual HttpSession instance.Method Detail |
public void setRequest(javax.servlet.http.HttpServletRequest request)
request
- reference to the actual incoming
HttpServletRequest instance.public javax.servlet.http.HttpServletRequest getRequest()
public void setResponse(javax.servlet.http.HttpServletResponse response)
public javax.servlet.http.HttpServletResponse getResponse()
public javax.servlet.http.HttpSession getWebSession()
public boolean isValidWebSession()
public void setWebSession(javax.servlet.http.HttpSession websession)
public java.lang.String getRequestParameter(java.lang.String name)
public java.lang.String[] getRequestParameters(java.lang.String name)
public void redirect(java.lang.String view)
The String parameter passed in has to be one of the defined abstract view constants.
view
- representing one of the constants defining an abstract
view.JwmaKernel.LOGIN_VIEW
,
JwmaKernel.ERROR_VIEW
,
JwmaKernel.LOGOUT_VIEW
,
JwmaKernel.FOLDER_VIEW
,
JwmaKernel.MESSAGE_VIEW
,
JwmaKernel.PREFERENCES_VIEW
,
JwmaKernel.COMPOSE_VIEW
,
JwmaKernel.FIRSTTIME_VIEW
,
JwmaKernel.CONTACTS_VIEW
public void redirectToLast()
The last view is traced by a simple history mechanism implemented in the redirect() method.
public void redirectToActual()
The actual view is traced by a simple history mechanism implemented in the redirect() method. This method helps to acquire an updated view of the actual view.
public void storeBean(java.lang.String name, java.lang.Object bean)
All stored beans are traced, so that they can be properly removed.
name
- the unique identifier of bean to be stored as
session attribute.bean
- the reference to the bean to be stored as session
attribute.public java.lang.Object retrieveBean(java.lang.String name)
If no bean with the given name/identifyer is stored in the actual session, then it returns null.
name
- the unique identifier of bean to be stored as
session attribute.
public void removeBean(java.lang.String name)
name
- the unique identifier of bean to be stored as
session attribute.public java.lang.String getLastLogin()
public javax.mail.Session getMailSession()
Session
public JwmaStoreImpl getJwmaStore()
JwmaStoreImpl
public JwmaTransportImpl getJwmaTransport()
JwmaTransportImpl
public MailTransportAgent getMTA()
public void setMTA(MailTransportAgent MTA)
public PostOffice getPostOffice()
public void setPostOffice(PostOffice office)
public void ensurePostOfficeConnection() throws JwmaException
JwmaException
- if there is no connection to
the post office.public boolean isPostOfficeConnected()
public void setLocale()
public java.lang.String getUserIdentity(java.lang.String username)
username
- the user's name as String.
public java.lang.String getUserIdentity()
public java.lang.String getUsername()
public JwmaPreferencesImpl getPreferences()
public boolean savePreferences() throws JwmaException
JwmaException
PreferencesPersistencePlugin.savePreferences(JwmaPreferencesImpl)
public boolean isAuthenticated()
public void ensureAuthenticated() throws JwmaException
JwmaException
- if the session is not authenticated.public boolean isAdministrator()
public void ensureAdministrator() throws JwmaException
JwmaException
- if the associated username is not an
admin.public boolean authenticate(java.lang.String username, java.lang.String password, boolean newAccount) throws JwmaException
username
- the name of this session's user as
String.password
- the related credentials as String.newAccount
- a flag that denotes whether a jwma account
already exists (false) or not (true).
JwmaException
- if initializing a mailsession or
authenticating against the post office fails.public void end()
isAuthenticated()
,
savePreferences()
public void finalize()
finalize
in class java.lang.Object
end()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |