1 package org.apache.turbine.services.session;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.Collection;
23 import javax.servlet.http.HttpSession;
24
25 import org.apache.turbine.om.security.User;
26 import org.apache.turbine.services.Service;
27
28 /***
29 * The SessionService allows access to the current sessions of the current context.
30 * The session objects that are cached by this service are obtained through
31 * a listener. The listener must be configured in your web.xml file.
32 *
33 * @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
34 * @since 2.3
35 * @see org.apache.turbine.services.session.SessionListener
36 * @version $Id: SessionService.java 534527 2007-05-02 16:10:59Z tv $
37 */
38 public interface SessionService extends Service
39 {
40
41 /***
42 * The key under which this service is stored in TurbineServices.
43 */
44 String SERVICE_NAME = "SessionService";
45
46 /***
47 * Gets all active sessions
48 *
49 * @return Collection of HttpSession objects
50 */
51 Collection getActiveSessions();
52
53 /***
54 * Adds a session to the current list. This method should only be
55 * called by the listener.
56 *
57 * @param session Session to add
58 */
59 void addSession(HttpSession session);
60
61 /***
62 * Removes a session from the current list. This method should only be
63 * called by the listener.
64 *
65 * @param session Session to remove
66 */
67 void removeSession(HttpSession session);
68
69 /***
70 * Determines if a given user is currently logged in. The actual
71 * implementation of the User object must implement the equals()
72 * method. By default, Torque based objects (liek TurbineUser)
73 * have an implementation of equals() that will compare the
74 * result of getPrimaryKey().
75 *
76 * @param user User to check for
77 * @return true if the user is logged in on one of the
78 * active sessions.
79 */
80 boolean isUserLoggedIn(User user);
81
82 /***
83 * Gets a collection of all user objects representing the users currently
84 * logged in. This will exclude any instances of anonymous user that
85 * Turbine will use before the user actually logs on.
86 *
87 * @return collection of org.apache.turbine.om.security.User objects
88 */
89 Collection getActiveUsers();
90
91 /***
92 * Gets the User object of the the specified HttpSession.
93 *
94 * @param session The session from which to extract a user.
95 * @return The Turbine User object.
96 */
97 User getUserFromSession(HttpSession session);
98
99 /***
100 * Gets the HttpSession by the session identifier
101 *
102 * @param sessionId The unique session identifier.
103 * @return The session keyed by the specified identifier.
104 */
105 HttpSession getSession(String sessionId);
106
107 /***
108 * Get a collection of all session on which the given user
109 * is logged in.
110 *
111 * @param user the user
112 * @return Collection of HtttSession objects
113 */
114 Collection getSessionsForUser(User user);
115
116 }