Thanks, for reply Martin!
Yes I use wicket authentication, my app:
public class HelloWebApplication extends AuthenticatedWebApplication {
As I see it is manual operation, and wicket doesn't support this in API.
Than I should manually create encryptedKey, and set it to cookie value,
and be able to recognize it, yes?
If so, could you please provide more code on your
TakpAuthorizationStrategy class ( registration and implementation)
2nd question is:
In order to use your code I need redirect not logged user with defined
"remember me" cookie from LoginPage to desired page, instead of showing
the LoginPage. But is it possible change this behavior: redirecting not
logged user from base page to login page and then back to base page.TO
THIS: login user automatically in some interceptor when trying to access
base page (without redirecting to LoginPage).
Martin Makundi пишет:
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: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org
--
Khlystov Alexandr
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org