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