1 package com.atlassian.seraph.service.rememberme;
2
3 import javax.servlet.http.HttpServletRequest;
4 import javax.servlet.http.HttpServletResponse;
5
6 /**
7 * The RememberMeService is the top level entry point for getting and setting remember me cookies
8 */
9 public interface RememberMeService
10 {
11 /**
12 * This method can be called to try and authenticate a user name from a remember me cookie.
13 * <p/>
14 * If the cookie is not present, its token doe not match anything or it has expired, then null will be returned and
15 * any presented remember me cookie in the client will be removed.
16 * <p/>
17 * Otherwise a user name is returned, indicating that the underlying application knows about the user
18 *
19 * @param httpServletRequest the request in play
20 * @param httpServletResponse the response in play
21 *
22 * @return a username if its known about and the remember me cookie is valid
23 */
24 String getRememberMeCookieAuthenticatedUsername(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse);
25
26 /**
27 * This can be called to generate and save a remember me cookie with the application and send it back to the client
28 *
29 * @param httpServletRequest the request in play
30 * @param httpServletResponse the response in play
31 * @param authenticatedUsername the name of the user to generate the remember me cookie for
32 */
33 void addRememberMeCookie(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, String authenticatedUsername);
34
35 /**
36 * This will remove any remember me cookie that may have been presented by the client
37 *
38 * @param httpServletRequest the request in play
39 * @param httpServletResponse the response in play
40 */
41 void removeRememberMeCookie(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse);
42 }