public final class AuthenticationContext
extends java.lang.Object
AuthenticationHandler
when implementing
AuthenticationHandler.login(AuthenticationContext)
or AuthenticationHandler.logout(AuthenticationContext)
AuthenticationHandler
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
AUTHENTICATION_HANDLER_CLASS
Request attribute name used to store the
Class<? extends AuthenticationHandler>
of the AuthenticationHandler that was used to authenticate the member for the request. |
protected static Channel |
channel |
static java.lang.String |
FORCED_INVALID_SETLOGGEDMEMBER
Request attribute name used to store a
Member which even though it
is invalid (disabled or contact), is allowed to log in.AuthenticationHandler wishing to log in disabled member (which is not advised!!) must perform two operations : invoke setLoggedMember(Member) as usual
store the member in the request attribute using this constant request.setAttribute(FORCED_INVALID_SETLOGGEDMEMBER, theDisableMember);
|
static java.lang.String |
INVALID_SETLOGGEDMEMBER_STACKTRACE
Request attribute name used to store the
StackTraceElement[] during
which setLoggedMember(Member) was invoked with an invalid member. |
static java.lang.String |
REVISION |
Modifier and Type | Method and Description |
---|---|
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.
|
java.lang.Object |
getAttribute(java.lang.String name)
Returns the value of the named attribute as an
Object ,
or null if no attribute of the given name exists. |
java.util.Map<java.lang.String,java.lang.Object> |
getAttributeMap()
Returns a java.util.Map of the attributes of this contexts.
|
java.lang.Class<? extends AuthenticationHandler> |
getAuthenticationHandlerClass()
Retrieve the
Class<? extends AuthenticationHandler> of the AuthenticationHandler
that was used to authenticate the member for this request, by invoking setLoggedMember(Member) . |
static java.lang.Class<? extends AuthenticationHandler> |
getAuthenticationHandlerClass(javax.servlet.http.HttpServletRequest request)
Retrieve the
Class<? extends AuthenticationHandler> of the AuthenticationHandler
that was used to authenticate the member for this request, by invoking setLoggedMember(Member) . |
Member |
getLoggedMember()
Retrieve the member that was previously authenticated
by previous
AuthenticationHandler of the chain. |
java.lang.String |
getLogin()
Return the login received from the form.
May not be available if isCredentialProvided() returns false. |
java.lang.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"). |
java.lang.String |
getUserCountry()
Return the current user country guessed from browser preference or session.
|
java.lang.String |
getUserLang()
Return the current user language guessed from browser preference or session.
|
java.util.Locale |
getUserLocale()
Return the current user Locale guessed from browser preference or session.
|
void |
invalidateSession()
Invalidate the current session when appropriate.
|
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.
|
java.lang.Object |
removeAttribute(java.lang.String name)
Removes an attribute from this context.
|
void |
sendRedirect(java.lang.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) |
java.lang.Object |
setAttribute(java.lang.String name,
java.lang.Object obj)
Stores an attribute in this context.
|
void |
setCredentialProvided(boolean provided)
Define whether the login/password credential have been provided.
|
void |
setErrorMsg(java.lang.String key)
Set JCMS error message for current request (displayed through doMessageBox.jsp)
|
void |
setInformationMsg(java.lang.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 |
setLogin(java.lang.String login)
Define the login to be used during the authentication.
|
void |
setPassword(java.lang.String password)
Define the (clear text) password to be used during the authentication.
|
void |
setWarningMsg(java.lang.String key)
Set JCMS warning message for current request (displayed through doMessageBox.jsp)
|
public static final java.lang.String REVISION
protected static final Channel channel
public static final java.lang.String AUTHENTICATION_HANDLER_CLASS
Class<? extends AuthenticationHandler>
of the AuthenticationHandler
that was used to authenticate the member for the request.public static final java.lang.String INVALID_SETLOGGEDMEMBER_STACKTRACE
StackTraceElement[]
during
which setLoggedMember(Member)
was invoked with an invalid member.public static final java.lang.String FORCED_INVALID_SETLOGGEDMEMBER
Member
which even though it
is invalid (disabled or contact), is allowed to log in.setLoggedMember(Member)
as usualrequest.setAttribute(FORCED_INVALID_SETLOGGEDMEMBER, theDisableMember);
public void doChain() throws java.io.IOException
java.io.IOException
public javax.servlet.http.HttpServletRequest getRequest()
AuthenticationManager.login(String, String)
.public javax.servlet.http.HttpServletResponse getResponse()
AuthenticationManager.login(String, String)
.public java.lang.String getUserLang()
public java.lang.String getUserCountry()
public java.util.Locale getUserLocale()
public java.lang.String getLogin()
isCredentialProvided()
returns false.public void setLogin(java.lang.String login)
login
- a string containing the user login.public java.lang.String getPassword()
isCredentialProvided()
returns false.public void setPassword(java.lang.String password)
password
- a string containing the user password.public boolean isPersistent()
isCredentialProvided()
returns false.public boolean isCredentialProvided()
public void setCredentialProvided(boolean provided)
provided
- true if the crediential have been provided, false otherwise.public void setLoggedMember(Member mbr)
mbr
- the mbr to authenticate.public Member getLoggedMember()
AuthenticationHandler
of the chain.public boolean isLogged()
public java.lang.Class<? extends AuthenticationHandler> getAuthenticationHandlerClass()
Class<? extends AuthenticationHandler>
of the AuthenticationHandler
that was used to authenticate the member for this request, by invoking setLoggedMember(Member)
.
You may also retrieve the same information without from the current request using getAuthenticationHandlerClass(HttpServletRequest)
Class<? extends AuthenticationHandler>
, or null if authentication was not yet performedpublic static java.lang.Class<? extends AuthenticationHandler> getAuthenticationHandlerClass(javax.servlet.http.HttpServletRequest request)
Class<? extends AuthenticationHandler>
of the AuthenticationHandler
that was used to authenticate the member for this request, by invoking setLoggedMember(Member)
.Class<? extends AuthenticationHandler>
, or null if authentication was not yet performedpublic final void setInformationMsg(java.lang.String key)
key
- the property key of the message to display, e.g "ui.msg.my-information-msg"
public final void setWarningMsg(java.lang.String key)
key
- the property key of the message to display, e.g "ui.msg.my-warning-msg"
public final void setErrorMsg(java.lang.String key)
key
- the property key of the message to display, e.g "ui.msg.my-error-msg"
public final void sendRedirect(java.lang.String url) throws java.io.IOException
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"
).java.io.IOException
- if the response header could not be setpublic java.lang.Object setAttribute(java.lang.String name, java.lang.Object obj)
removeAttribute(java.lang.String)
.name
- a String
specifying the name of the attributeobj
- the Object
to be storednull
if there was no mapping for name. A null
return can
also indicate that null
was associated
with the specified name.public java.lang.Object removeAttribute(java.lang.String name)
name
- a String
specifyingnull
if there was no mapping for name. A null
return can
also indicate that null
was associated
with the specified name.public java.lang.Object getAttribute(java.lang.String name)
Object
,
or null
if no attribute of the given name exists.name
- a String
specifying the name of the attributeObject
containing the value of the attribute,
or null
if the attribute does not existpublic java.util.Map<java.lang.String,java.lang.Object> getAttributeMap()
public void invalidateSession()
Copyright © 2001-2021 Jalios SA. All Rights Reserved.