> Can anyone, please, give an example, or direct wicket API description about
> "remember me" at login page feature.

Are you familiar with regular wicket authentication?

In "remember me" you just use e.g., a cookie id to load the user's
credentials from db.

Nothing special.

  private static Cookie getCookie(String cookieName) {
    WebRequestCycle requestCycle = (WebRequestCycle) RequestCycle.get();
    WebRequest webRequest = (WebRequest) requestCycle.getRequest();
    Cookie cookie = webRequest.getCookie(cookieName);
    if (cookie == null) {
      Map<String, Cookie> cookieMap = threadlocalJUnitTestCookies.get();
      cookie = (cookieMap != null) ? cookieMap.get(cookieName) : null;
    } else if (threadlocalJUnitTestCookies.get() != null) {
      /*
       * We had not yet found a way to support cookies in JUnit testing.
       * threadlocalJUnitTestCookies should not have a value when webRequest
       * contains cookies.
       */
      throw new IllegalStateException("");
    }
    return cookie;
  }

  /**
   * @param user
   */
  public static void bindAuthorizationCookie(Person user) {
    // Fetch current cookie
    Cookie cookie = getAuthorizationCookie();

    String encryptedValue;
    // Check if session already has the user id
    Long cookiePersonId = TakpAuthorizationStrategy.parsePersonId(cookie);

    // Check if the previous id was the current user id
    if ((cookiePersonId != null) && (cookiePersonId.equals(user.getId()))) {
      // Reset the cookie id if it was the current user
      encryptedValue = "-1";
    } else {
      // If it was some other user, keep it as it is
      return;
    }

    // Check if the user already has an authorization cookie
    if (cookie == null) {
      // Set new cookie into user response
      cookie = new Cookie(AUTHORIZATION_COOKIE, encryptedValue);
    } else {
      // Update the authorization key
      cookie.setValue(encryptedValue);
    }

    cookie.setMaxAge(AUTHORIZATION_COOKIE_EXPIRATION);
    cookie.setPath("/");
    setCookie(cookie);
  }


**
Martin

>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to