View Javadoc

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