2 * Copyright (C) 2007-2012 Mathieu Baudier
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org
.argeo
.security
.mvc
;
18 import javax
.servlet
.http
.Cookie
;
19 import javax
.servlet
.http
.HttpServletRequest
;
20 import javax
.servlet
.http
.HttpServletResponse
;
22 import org
.springframework
.security
.ui
.rememberme
.TokenBasedRememberMeServices
;
24 public class ArgeoRememberMeServices
extends TokenBasedRememberMeServices
{
25 public final static String DEFAULT_COOKIE_NAME
= "ARGEO_SECURITY";
27 public ArgeoRememberMeServices() {
28 setCookieName(DEFAULT_COOKIE_NAME
);
32 * Sets a "cancel cookie" (with maxAge = 0) on the response to disable
38 protected void cancelCookie(HttpServletRequest request
,
39 HttpServletResponse response
) {
40 Cookie cookie
= new Cookie(getCookieName(), null);
44 response
.addCookie(cookie
);
48 * Sets the cookie on the response
51 * the tokens which will be encoded to make the cookie value.
53 * the value passed to {@link Cookie#setMaxAge(int)}
57 * the response to add the cookie to.
59 protected void setCookie(String
[] tokens
, int maxAge
,
60 HttpServletRequest request
, HttpServletResponse response
) {
61 String cookieValue
= encodeCookie(tokens
);
62 Cookie cookie
= new Cookie(getCookieName(), cookieValue
);
63 cookie
.setMaxAge(maxAge
);
65 response
.addCookie(cookie
);