Package rife.authentication.elements
Class Authenticated
java.lang.Object
rife.authentication.elements.Identified
rife.authentication.elements.Authenticated
- All Implemented Interfaces:
SessionAttributes,Element
Requires that the user has a valid authentication session before access
is allowed.
- Since:
- 1.0
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedThis constructor is meant to be used when extending theAuthenticatedelement with your custom authenticated class.Authenticated(AuthConfig config) This constructor is meant to be used when theAuthenticatedelement is used directly as a route in your site. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcreateAuthAttributeName(Route route, 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.getAttribute(String key) Retrieves the value of a particular attribute.booleanhasAttribute(String key) Checks if a certain attribute is present.protected voidHook method that is called at the start of the element's processing.voidProcess the providedContextwith this element.protected voidsessionNotValid(String authCookieName, String authCookieValue, int validityId) Hook method that is called when theSessionValidatordoesn't accept the authentication ID that a user provides after having been logged in.Methods inherited from class rife.authentication.elements.Identified
getAuthConfig, getIdentifiedElementInRequest, getIdentity, initializeIdentified, setIdentityAttribute
-
Constructor Details
-
Authenticated
protected Authenticated()This constructor is meant to be used when extending theAuthenticatedelement with your custom authenticated class.Don't forget to also override the `getAuthConfig()` methodss.
- Since:
- 1.0
-
Authenticated
This constructor is meant to be used when theAuthenticatedelement is used directly as a route in your site.When extending this element, use the default constructor instead and override the `getAuthConfig()` method.
- Parameters:
config- the auth config to use- Since:
- 1.0
-
-
Method Details
-
initializeAuthenticated
Hook method that is called at the start of the element's processing.- Parameters:
c- the element processing context- Since:
- 1.0
-
sessionNotValid
Hook method that is called when theSessionValidatordoesn'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.
- Parameters:
authCookieName- the name of the cookie that contains the authentication IDauthCookieValue- the value of the cookie with the authentication IDvalidityId- a number that indicates the validation state of the session, as used by theSessionValidator, more information can be found here:SessionValidator.validateSession(java.lang.String, java.lang.String, rife.authentication.SessionAttributes)- Since:
- 1.0
-
process
Description copied from interface:ElementProcess the providedContextwith this element.- Specified by:
processin interfaceElement- Overrides:
processin classIdentified- Parameters:
c- the provided request/response context- Throws:
Exception- when an error occurs
-
hasAttribute
Description copied from interface:SessionAttributesChecks if a certain attribute is present.- Specified by:
hasAttributein interfaceSessionAttributes- Parameters:
key- The key that identifies the attribute.- Returns:
trueif the attribute was present; orfalseotherwise.- See Also:
-
getAttribute
Description copied from interface:SessionAttributesRetrieves the value of a particular attribute.- Specified by:
getAttributein interfaceSessionAttributes- Parameters:
key- The key that identifies the attribute.- Returns:
- A
Stringinstance with the value of the requested attribute; ornullif the attribute couldn't be found. - See Also:
-
createAuthAttributeName
Creates a name for the current authentication context that can be used to cache the authentication process' result as a request attribute. This name is built from the login route path, the name of the authentication cookie and its value.- Parameters:
route- the login routename- the name of the authentication cookievalue- the value of the authentication cookie- Returns:
- the created name
- Since:
- 1.0
-