1 package com.atlassian.seraph.spi.rememberme;
2
3 import com.atlassian.seraph.service.rememberme.RememberMeToken;
4
5 import java.util.List;
6
7 /**
8 * Each Seraph ready application needs to provide a spi Dao to hold and return remember me cookie information against a
9 * user.
10 */
11 public interface RememberMeTokenDao
12 {
13 /**
14 * Finds the token with the given id. A caller must validate the token as it might be expired.
15 * <p/>
16 *
17 * @param tokenId the id of the token
18 *
19 * @return a RememberMeToken or null if one cant be found.
20 */
21 RememberMeToken findById(Long tokenId);
22
23 /**
24 * This will be called to save the presented token to the database against the specified user. The id field will
25 * need to be filled out during this process.
26 *
27 * @param token the token in play
28 *
29 * @return a persisted token that has the correct database id filled out
30 */
31 RememberMeToken save(RememberMeToken token);
32
33 /**
34 * This will return a list of the RememberMeToken that a user currently has.
35 * A caller must validate the tokens as they might be expired.
36 * <p/>
37 * This method is not used by the Seraph code per se but its specified as part of the Atlassian RememberMe tech
38 * spec.
39 *
40 * @param userName the username to look up tokens for
41 * @return a List or {@link com.atlassian.seraph.service.rememberme.RememberMeToken}s or an EMPTY list if there are none
42 */
43 List<RememberMeToken> findForUserName(String userName);
44
45 /**
46 * Removes the specific token given the id
47 * <p/>
48 *
49 * @param tokenId the id of the token to remove
50 */
51 void remove(Long tokenId);
52
53 /**
54 * Called to remove ALL tokens that are stored for the specificed user
55 * <p/>
56 * This method is not used by the Seraph code per se but its specified as part of the Atlassian RememberMe tech
57 * spec.
58 *
59 * @param username the username in question
60 */
61 void removeAllForUser(String username);
62
63 /**
64 * Can be called to remove all tokens for all users.
65 * <p/>
66 * This method is not used by the Seraph code per se but its specified as part of the Atlassian RememberMe tech
67 * spec.
68 */
69 void removeAll();
70 }