1 package com.atlassian.seraph.cookie;
2
3 import javax.servlet.http.HttpServletRequest;
4 import javax.servlet.http.HttpServletResponse;
5 import javax.servlet.http.Cookie;
6
7 /**
8 * Encodes and decodes the username and password for remember-me cookies
9 */
10 public interface CookieEncoder
11 {
12 /**
13 * Builds a cookie string containing a username and password, using offsets to customise the encoding.<p>
14 *
15 * @param username The username.
16 * @param password The password.
17 * @param encoding A String used to customise cookie encoding (only the first 3 characters are used)
18 * @return String encoding the input parameters, an empty string if one of
19 * the arguments equals <code>null</code>.
20 */
21 public String encodePasswordCookie(String username, String password, String encoding);
22
23 /**
24 * Decodes a cookie string containing a username and password.
25 * @param cookieVal The cookie value.
26 * @param encoding A String used to customise cookie encoding (only the first 3 characters are used) - should be the same string you used to encode the cookie!
27 * @return String[] containing the username at index 0 and the password at
28 * index 1, or <code>{ null, null }</code> if cookieVal equals
29 * <code>null</code> or the empty string.
30 */
31 public String[] decodePasswordCookie(String cookieVal, String encoding);
32 }