|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.uwyn.rife.engine.ElementSupport
com.uwyn.rife.engine.Element
com.uwyn.rife.authentication.elements.Identified
com.uwyn.rife.authentication.elements.Authenticated
public abstract class Authenticated
Requires that the user have a valid authentication session before access to a child element is allowed. This class contains the logic for restoring remembered sessions and displaying a template (typically a login form) if the user is not authenticated.
The following properties may be set:
The child element implementation may distinguish an anonymous user
from an authenticated one by calling
{@link #getRequestAttribute(String)
getRequestAttribute(Identified.IDENTITY_ATTRIBUTE_NAME)}.
This is similar to using an {@link Identified} element,
but expired sessions will automatically be recreated if the user has
the appropriate "remember me" cookie set and "remember me" is enabled.
To customize the behavior of the authentication, it's the easiest to override one of the hook methods.
| Field Summary | |
|---|---|
protected String |
mTemplateName
|
| Fields inherited from class com.uwyn.rife.authentication.elements.Identified |
|---|
IDENTITY_ATTRIBUTE_NAME |
| Constructor Summary | |
|---|---|
protected |
Authenticated()
|
| Method Summary | |
|---|---|
protected void |
acceptedCredentials(Credentials credentials)
Hook method that is called when valid credentials have been accepted by the CredentialsManager that backs this authentication element. |
protected void |
authenticated(long userId)
Hook method that is called after a new authentication session has been successfully created. |
boolean |
childTriggered(String name,
String[] values)
Called by the engine when a child trigger occurs, this method should never be called explicitly. |
static String |
createAuthenticationRequestAttributeName(ElementInfo elementInfo,
String name,
String value)
Creates a name for the current authentication context that can be used to cache the authentication process' result as a request attribute. |
protected void |
entrance(Template template)
Hook method that is called after the template instance has been instantiated. |
ElementInfo |
getAuthElement()
Returns the ElementInfo of this authentication element. |
String |
getAuthenticatedElementId()
Returns the ID of this authentication element. |
Class<? extends Credentials> |
getCredentialsClass()
Returns the class that is used for handling the credentials. |
SessionValidator |
getSessionValidator()
Returns the class that is used for handling the credentials. |
protected void |
initializeAuthentication()
Hook method that is called at the start of the element's execution. |
void |
processElement()
The default entry point that will be called when a request arrives. |
protected void |
refusedCredentials(Template template,
Credentials credentials)
Hook method that is called when valid credentials have been rejected by the CredentialsManager that backs this authentication element. |
protected void |
sessionCreationError(Template template,
Credentials credentials)
Hook method that is called when the SessionManager couldn't
create a new authentication session of valid and accepted credentials. |
protected void |
sessionNotValid(String childTriggerName,
String[] childTriggerValues,
int validityId)
Hook method that is called when the SessionValidator doesn't
accept the authentication ID that a user provides after having been logged
in. |
protected void |
setTemplateName(String name)
Allows a custom template name to be set. |
protected void |
unvalidatedCredentials(Template template,
Credentials credentials)
Hook method that is called on login form submission when validation of the credentials produces validation errors. |
protected void |
validatedCredentials(Credentials credentials)
Hook method that is called on login form submission when the credentials are validated without errors |
| Methods inherited from class com.uwyn.rife.authentication.elements.Identified |
|---|
getAuthElementId, getIdentity, setIdentityAttribute |
| Methods inherited from class com.uwyn.rife.engine.Element |
|---|
clone, noticeElement |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.uwyn.rife.authentication.SessionAttributes |
|---|
getAttribute, hasAttribute |
| Field Detail |
|---|
protected String mTemplateName
| Constructor Detail |
|---|
protected Authenticated()
| Method Detail |
|---|
public String getAuthenticatedElementId()
public ElementInfo getAuthElement()
ElementInfo of this authentication element.
getAuthElement in class IdentifiedElementInfopublic Class<? extends Credentials> getCredentialsClass()
public SessionValidator getSessionValidator()
protected void setTemplateName(String name)
This method is typically called during the implementation of method hooks to change the template that will be used by this authentication element.
name - the name of the templateprotected void initializeAuthentication()
protected void entrance(Template template)
template - the template instance that has been instantiated
protected void unvalidatedCredentials(Template template,
Credentials credentials)
template - this authentication element's templatecredentials - the credentials object that was invalidprotected void validatedCredentials(Credentials credentials)
credentials - the credentials object that was validprotected void acceptedCredentials(Credentials credentials)
CredentialsManager that backs this authentication element.
credentials - the credentials object that was acceptedprotected void authenticated(long userId)
userId - the user ID of the user that was successfully authenticated
protected void refusedCredentials(Template template,
Credentials credentials)
CredentialsManager that backs this authentication element.
This can for example happen when the password is not correct.
Note that there is already a default implementation of this hook method that simply adds a validation error to the credentials object. If you want to preserve this when you implement your own hook method, you need to call the super class's method in your implementation.
template - this authentication element's templatecredentials - the credentials object that was rejected
protected void sessionCreationError(Template template,
Credentials credentials)
SessionManager couldn't
create a new authentication session of valid and accepted credentials.
Note that there is already a default implementation of this hook method that simply adds a validation error to the credentials object. If you want to preserve this when you implement your own hook method, you need to call the super class's method in your implementation.
template - this authentication element's templatecredentials - the credentials object that was used when creating the
authentication session
protected void sessionNotValid(String childTriggerName,
String[] childTriggerValues,
int validityId)
SessionValidator doesn't
accept the authentication ID that a user provides after having been logged
in.
This can happen for example happen when the maximum duration has expired, when the authentication ID has been tampered with, or when the authentication ID isn't known anymore by the backing store.
childTriggerName - the name of the child trigger that contains
the authentication IDchildTriggerValues - the values of the child trigger with the
authentication IDvalidityId - a number that indicates the validation state of the
session, as used by the SessionValidator, more information can
be found here: SessionValidator.validateSession(java.lang.String, java.lang.String, com.uwyn.rife.authentication.SessionAttributes)public void processElement()
ElementAware
processElement in interface ElementAwareprocessElement in class Identified
public boolean childTriggered(String name,
String[] values)
ElementSupportThe default implementation executes the ElementChildTrigger
that has been registered with ElementSupport.setChildTrigger(com.uwyn.rife.engine.ElementChildTrigger).
childTriggered in class Identifiedname - the name of the variable that initiated the child triggervalues - the values of the variable that initiated the child
trigger
true if the execution should be interrupted and
step down the inheritance stack (ie. when the activation of the child
has been triggered); or
false if the execution should just continue
ElementSupport.setChildTrigger(ElementChildTrigger)
public static String createAuthenticationRequestAttributeName(ElementInfo elementInfo,
String name,
String value)
throws EngineException
elementInfo - the authentication element informationname - the name of the authentication variablevalue - the value of the authentication variable
EngineException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||