Class Authenticated

java.lang.Object
rife.authentication.elements.Identified
rife.authentication.elements.Authenticated
All Implemented Interfaces:
SessionAttributes, Element

public class Authenticated extends Identified implements SessionAttributes
Requires that the user has a valid authentication session before access is allowed.
Since:
1.0
  • Constructor Details

    • Authenticated

      protected Authenticated()
      This constructor is meant to be used when extending the Authenticated element with your custom authenticated class.

      Don't forget to also override the `getAuthConfig()` methodss.

      Since:
      1.0
    • Authenticated

      public Authenticated(AuthConfig config)
      This constructor is meant to be used when the Authenticated 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

      protected void initializeAuthenticated(Context c)
      Hook method that is called at the start of the element's processing.
      Parameters:
      c - the element processing context
      Since:
      1.0
    • sessionNotValid

      protected void sessionNotValid(String authCookieName, String authCookieValue, 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.

      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 ID
      authCookieValue - the value of the cookie with the authentication ID
      validityId - 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, rife.authentication.SessionAttributes)
      Since:
      1.0
    • process

      public void process(Context c) throws Exception
      Description copied from interface: Element
      Process the provided Context with this element.
      Specified by:
      process in interface Element
      Overrides:
      process in class Identified
      Parameters:
      c - the provided request/response context
      Throws:
      Exception - when an error occurs
    • hasAttribute

      public boolean hasAttribute(String key)
      Description copied from interface: SessionAttributes
      Checks if a certain attribute is present.
      Specified by:
      hasAttribute in interface SessionAttributes
      Parameters:
      key - The key that identifies the attribute.
      Returns:
      true if the attribute was present; or

      false otherwise.

      See Also:
    • getAttribute

      public String getAttribute(String key)
      Description copied from interface: SessionAttributes
      Retrieves the value of a particular attribute.
      Specified by:
      getAttribute in interface SessionAttributes
      Parameters:
      key - The key that identifies the attribute.
      Returns:
      A String instance with the value of the requested attribute; or

      null if the attribute couldn't be found.

      See Also:
    • createAuthAttributeName

      public static 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. This name is built from the login route path, the name of the authentication cookie and its value.
      Parameters:
      route - the login route
      name - the name of the authentication cookie
      value - the value of the authentication cookie
      Returns:
      the created name
      Since:
      1.0