##### Coverage Report - org.apache.turbine.services.session.SessionService

Classes in this File | Line Coverage | Branch Coverage | Complexity
SessionService |
N/A | N/A
N/A | N/A
| 1.0;1

1 |  |
     package org.apache.turbine.services.session;
2 |  |
3 |  |
4 |  |
     /*
5 |  |
      * Licensed to the Apache Software Foundation (ASF) under one
6 |  |
      * or more contributor license agreements.  See the NOTICE file
7 |  |
      * distributed with this work for additional information
8 |  |
      * regarding copyright ownership.  The ASF licenses this file
9 |  |
      * to you under the Apache License, Version 2.0 (the
10 |  |
      * "License"); you may not use this file except in compliance
11 |  |
      * with the License.  You may obtain a copy of the License at
12 |  |
      *
13 |  |
      *   http://www.apache.org/licenses/LICENSE-2.0
14 |  |
      *
15 |  |
      * Unless required by applicable law or agreed to in writing,
16 |  |
      * software distributed under the License is distributed on an
17 |  |
      * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 |  |
      * KIND, either express or implied.  See the License for the
19 |  |
      * specific language governing permissions and limitations
20 |  |
      * under the License.
21 |  |
      */
22 |  |
23 |  |
24 |  |
     import java.util.Collection;
25 |  |
     import javax.servlet.http.HttpSession;
26 |  |
27 |  |
     import org.apache.turbine.om.security.User;
28 |  |
     import org.apache.turbine.services.Service;
29 |  |
30 |  |
     /**
31 |  |
      * The SessionService allows access to the current sessions of the current context.
32 |  |
      * The session objects that are cached by this service are obtained through
33 |  |
      * a listener.  The listener must be configured in your web.xml file.
34 |  |
      *
35 |  |
      * @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
36 |  |
      * @since 2.3
37 |  |
      * @see org.apache.turbine.services.session.SessionListener
38 |  |
      * @version $Id: SessionService.java 1066925 2011-02-03 19:44:37Z ludwig $
39 |  |
      */
40 |  |
     public interface SessionService extends Service
41 |  |
     {
42 |  |
43 |  |
         /**
44 |  |
          * The key under which this service is stored in TurbineServices.
45 |  |
          */
46 |  |
         static final String SERVICE_NAME = "SessionService";
47 |  |
48 |  |
         /**
49 |  |
          * Gets all active sessions
50 |  |
          *
51 |  |
          * @return Collection of HttpSession objects
52 |  |
          */
53 |  |
         Collection<HttpSession> getActiveSessions();
54 |  |
55 |  |
         /**
56 |  |
          * Adds a session to the current list.  This method should only be
57 |  |
          * called by the listener.
58 |  |
          *
59 |  |
          * @param session Session to add
60 |  |
          */
61 |  |
         void addSession(HttpSession session);
62 |  |
63 |  |
         /**
64 |  |
          * Removes a session from the current list.  This method should only be
65 |  |
          * called by the listener.
66 |  |
          *
67 |  |
          * @param session Session to remove
68 |  |
          */
69 |  |
         void removeSession(HttpSession session);
70 |  |
71 |  |
         /**
72 |  |
          * Determines if a given user is currently logged in.  The actual
73 |  |
          * implementation of the User object must implement the equals()
74 |  |
          * method.  By default, Torque based objects (liek TurbineUser)
75 |  |
          * have an implementation of equals() that will compare the
76 |  |
          * result of getPrimaryKey().
77 |  |
          *
78 |  |
          * @param user User to check for
79 |  |
          * @return true if the user is logged in on one of the
80 |  |
          * active sessions.
81 |  |
          */
82 |  |
         boolean isUserLoggedIn(User user);
83 |  |
84 |  |
         /**
85 |  |
          * Gets a collection of all user objects representing the users currently
86 |  |
          * logged in.  This will exclude any instances of anonymous user that
87 |  |
          * Turbine will use before the user actually logs on.
88 |  |
          *
89 |  |
          * @return collection of org.apache.turbine.om.security.User objects
90 |  |
          */
91 |  |
         Collection<User> getActiveUsers();
92 |  |
93 |  |
         /**
94 |  |
          * Gets the User object of the the specified HttpSession.
95 |  |
          *
96 |  |
          * @param session The session from which to extract a user.
97 |  |
          * @return The Turbine User object.
98 |  |
          */
99 |  |
         User getUserFromSession(HttpSession session);
100 |  |
101 |  |
         /**
102 |  |
          * Gets the HttpSession by the session identifier
103 |  |
          *
104 |  |
          * @param sessionId The unique session identifier.
105 |  |
          * @return The session keyed by the specified identifier.
106 |  |
          */
107 |  |
         HttpSession getSession(String sessionId);
108 |  |
109 |  |
         /**
110 |  |
          * Get a collection of all session on which the given user
111 |  |
          * is logged in.
112 |  |
          *
113 |  |
          * @param user the user
114 |  |
          * @return Collection of HtttSession objects
115 |  |
          */
116 |  |
         Collection<HttpSession> getSessionsForUser(User user);
117 |  |
118 |  |
     }