2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
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.
17 package org
.argeo
.security
.mvc
;
19 import javax
.servlet
.http
.Cookie
;
20 import javax
.servlet
.http
.HttpServletRequest
;
21 import javax
.servlet
.http
.HttpServletResponse
;
23 import org
.springframework
.security
.ui
.rememberme
.TokenBasedRememberMeServices
;
25 public class ArgeoRememberMeServices
extends TokenBasedRememberMeServices
{
26 public final static String DEFAULT_COOKIE_NAME
= "ARGEO_SECURITY";
28 public ArgeoRememberMeServices() {
29 setCookieName(DEFAULT_COOKIE_NAME
);
33 * Sets a "cancel cookie" (with maxAge = 0) on the response to disable
39 protected void cancelCookie(HttpServletRequest request
,
40 HttpServletResponse response
) {
41 Cookie cookie
= new Cookie(getCookieName(), null);
45 response
.addCookie(cookie
);
49 * Sets the cookie on the response
52 * the tokens which will be encoded to make the cookie value.
54 * the value passed to {@link Cookie#setMaxAge(int)}
58 * the response to add the cookie to.
60 protected void setCookie(String
[] tokens
, int maxAge
,
61 HttpServletRequest request
, HttpServletResponse response
) {
62 String cookieValue
= encodeCookie(tokens
);
63 Cookie cookie
= new Cookie(getCookieName(), cookieValue
);
64 cookie
.setMaxAge(maxAge
);
66 response
.addCookie(cookie
);