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
ModifierConstructorDescriptionprotected
This constructor is meant to be used when extending theAuthenticated
element with your custom authenticated class.Authenticated
(AuthConfig config) This constructor is meant to be used when theAuthenticated
element is used directly as a route in your site. -
Method Summary
Modifier and TypeMethodDescriptionstatic String
createAuthAttributeName
(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.boolean
hasAttribute
(String key) Checks if a certain attribute is present.protected void
Hook method that is called at the start of the element's processing.void
Process the providedContext
with this element.protected void
sessionNotValid
(String authCookieName, String authCookieValue, int validityId) Hook method that is called when theSessionValidator
doesn'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 theAuthenticated
element 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 theAuthenticated
element 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 theSessionValidator
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.
- 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:Element
Process the providedContext
with this element.- Specified by:
process
in interfaceElement
- Overrides:
process
in classIdentified
- Parameters:
c
- the provided request/response context- Throws:
Exception
- when an error occurs
-
hasAttribute
Description copied from interface:SessionAttributes
Checks if a certain attribute is present.- Specified by:
hasAttribute
in interfaceSessionAttributes
- Parameters:
key
- The key that identifies the attribute.- Returns:
true
if the attribute was present; orfalse
otherwise.- See Also:
-
getAttribute
Description copied from interface:SessionAttributes
Retrieves the value of a particular attribute.- Specified by:
getAttribute
in interfaceSessionAttributes
- Parameters:
key
- The key that identifies the attribute.- Returns:
- A
String
instance with the value of the requested attribute; ornull
if 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
-