com.jalios.jcms.authentication
Class AuthenticationContext

java.lang.Object
  extended by com.jalios.jcms.authentication.AuthenticationContext

public final class AuthenticationContext
extends Object

Object used by AuthenticationHandler when implementing AuthenticationHandler.login(AuthenticationContext) or AuthenticationHandler.logout(AuthenticationContext)

Use the AuthenticationContext to :


A new instance of this class is used per login/logout chain invokation.

Since:
jcms-5.7.0
Version:
$Revision: 27753 $
Author:
Olivier Jaquemet
See Also:
AuthenticationHandler

Field Summary
protected static Channel channel
           
static String REVISION
           
 
Method Summary
 void doChain()
          Causes the next handler in the chain to be invoked, or if the calling handler is the last handler in the chain, end the chain invokation.
 Object getAttribute(String name)
          Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.
 Map<String,Object> getAttributeMap()
          Returns a java.util.Map of the attributes of this contexts.
 Member getLoggedMember()
          Retrieve the member that was previously authenticated by previous AuthenticationHandler of the chain.
 String getLogin()
          Return the login received from the form.
May not be available if isCredentialProvided() returns false.
 String getPassword()
          Return the clear text password received from the form.
May not be available if isCredentialProvided() returns false.
 javax.servlet.http.HttpServletRequest getRequest()
          Return the current HttpServletRequest available for this authentication.
Warning: this method may return a fake request, with partial implementation of the Servlet specification, if the authentication process is called in a context where no servlet request is available (for example from a "ftp plugin").
 javax.servlet.http.HttpServletResponse getResponse()
          Return the current HttpServletResponse available for this authentication.
Warning: this method may return a fake response, with partial implementation of the Servlet specification, if the authentication process is called in a context where no servlet response is available (for example from a "ftp plugin").
 String getUserLang()
          Return the current user language guessed from browser preference or session.
 boolean isCredentialProvided()
          Checks if the credential (login/password) have been provided.
 boolean isLogged()
          Checks if a member is already logged in or if any authentication handler has logged a member, during the chain invokation, till the call to this method.
 boolean isPersistent()
          Return whether a persistent authentication was asked by the user in the login form.
 Object removeAttribute(String name)
          Removes an attribute from this context.
 void sendRedirect(String url)
          Redirect to the given url, using a 303 (HttpServletResponse.SC_SEE_OTHER) status code.

Doing a 303 redirect will ensure that the next request will be a GET and not a POST (which would submit all parameters again and break the authentication process)
 Object setAttribute(String name, Object obj)
          Stores an attribute in this context.
 void setErrorMsg(String key)
          Set JCMS error message for current request (displayed through doMessageBox.jsp)
 void setInformationMsg(String key)
          Set JCMS information message for current request (displayed through doMessageBox.jsp)
 void setLoggedMember(Member mbr)
          Set the member that will be authenticated at the end of this login chain.
Because handler can override a previously saved Member, you cannot be guaranteed your Member will be used unless you interrupt the chain.
 void setWarningMsg(String key)
          Set JCMS warning message for current request (displayed through doMessageBox.jsp)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REVISION

public static final String REVISION
See Also:
Constant Field Values

channel

protected static final Channel channel
Method Detail

doChain

public void doChain()
             throws IOException
Causes the next handler in the chain to be invoked, or if the calling handler is the last handler in the chain, end the chain invokation.

Throws:
IOException
Since:
jcms-5.7.0

getRequest

public javax.servlet.http.HttpServletRequest getRequest()
Return the current HttpServletRequest available for this authentication.
Warning: this method may return a fake request, with partial implementation of the Servlet specification, if the authentication process is called in a context where no servlet request is available (for example from a "ftp plugin"). It will usually happends when calling AuthenticationManager.login(String, String).

Returns:
an instance of HttpServletRequest, never return null.

getResponse

public javax.servlet.http.HttpServletResponse getResponse()
Return the current HttpServletResponse available for this authentication.
Warning: this method may return a fake response, with partial implementation of the Servlet specification, if the authentication process is called in a context where no servlet response is available (for example from a "ftp plugin"). It will usually happends when calling AuthenticationManager.login(String, String).

Returns:
an instance of HttpServletResponse, never return null.

getUserLang

public String getUserLang()
Return the current user language guessed from browser preference or session.

Returns:
an ISO-639 language code, never return null.

getLogin

public String getLogin()
Return the login received from the form.
May not be available if isCredentialProvided() returns false.

Returns:
a string containing the login provided through the login form or null if not available.

getPassword

public String getPassword()
Return the clear text password received from the form.
May not be available if isCredentialProvided() returns false.

Returns:
a string containing the password provided through the login form or null if not available.

isPersistent

public boolean isPersistent()
Return whether a persistent authentication was asked by the user in the login form. May not be correct if isCredentialProvided() returns false.

Returns:
true if a persistent login was asked, false otherwise. default value is false.

isCredentialProvided

public boolean isCredentialProvided()
Checks if the credential (login/password) have been provided.
Usually true after a login form submit (even if login or password empty), but can also be true if the proper parameters have been provided.

Returns:
true if a credential have been provided, false otherwise. Also returns true when the login form was submitted with empty login/password.

setLoggedMember

public void setLoggedMember(Member mbr)
Set the member that will be authenticated at the end of this login chain.
Because handler can override a previously saved Member, you cannot be guaranteed your Member will be used unless you interrupt the chain.

Parameters:
mbr - the mbr to authenticate.
Since:
jcms-5.7.0

getLoggedMember

public Member getLoggedMember()
Retrieve the member that was previously authenticated by previous AuthenticationHandler of the chain.

Returns:
the authentication member or null if no member has been authenticated.
Since:
jcms-5.7.0

isLogged

public boolean isLogged()
Checks if a member is already logged in or if any authentication handler has logged a member, during the chain invokation, till the call to this method.

Returns:
true if a member is logged in, false otherwise

setInformationMsg

public final void setInformationMsg(String key)
Set JCMS information message for current request (displayed through doMessageBox.jsp)

Parameters:
key - the property key of the message to display, e.g "ui.msg.my-information-msg"

setWarningMsg

public final void setWarningMsg(String key)
Set JCMS warning message for current request (displayed through doMessageBox.jsp)

Parameters:
key - the property key of the message to display, e.g "ui.msg.my-warning-msg"

setErrorMsg

public final void setErrorMsg(String key)
Set JCMS error message for current request (displayed through doMessageBox.jsp)

Parameters:
key - the property key of the message to display, e.g "ui.msg.my-error-msg"

sendRedirect

public final void sendRedirect(String url)
                        throws IOException
Redirect to the given url, using a 303 (HttpServletResponse.SC_SEE_OTHER) status code.

Doing a 303 redirect will ensure that the next request will be a GET and not a POST (which would submit all parameters again and break the authentication process)

Parameters:
url - the URL to redirect to, absolute (e.g. "http://www.jalios.com/") or relative to the webapp base url (e.g. "work/index.jsp").
Throws:
IOException - if the response header could not be set

setAttribute

public Object setAttribute(String name,
                           Object obj)
Stores an attribute in this context.
If the object passed in is null, the effect is the same as calling removeAttribute(java.lang.String).

Parameters:
name - a String specifying the name of the attribute
obj - the Object to be stored
Returns:
previous value associated with specified name, or null if there was no mapping for name. A null return can also indicate that null was associated with the specified name.
Since:
jcms-6.1.0

removeAttribute

public Object removeAttribute(String name)
Removes an attribute from this context.

Parameters:
name - a String specifying
Returns:
previous value associated with specified name, or null if there was no mapping for name. A null return can also indicate that null was associated with the specified name.
Since:
jcms-6.1.0

getAttribute

public Object getAttribute(String name)
Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.

Parameters:
name - a String specifying the name of the attribute
Returns:
an Object containing the value of the attribute, or null if the attribute does not exist
Since:
jcms-6.1.0

getAttributeMap

public Map<String,Object> getAttributeMap()
Returns a java.util.Map of the attributes of this contexts.

Returns:
the internal Map used by this contexts, modify with care.
Since:
jcms-6.1.0


Copyright © 2001-2010 Jalios SA. All Rights Reserved.