Coverage Report - org.apache.turbine.services.session.TurbineSession
 
Classes in this File Line Coverage Branch Coverage Complexity
TurbineSession
0%
0/12
N/A
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  
 
 26  
 import javax.servlet.http.HttpSession;
 27  
 
 28  
 import org.apache.turbine.om.security.User;
 29  
 import org.apache.turbine.services.TurbineServices;
 30  
 
 31  
 /**
 32  
  * This is a conveience class provided to allow access to the SessionService
 33  
  * through static methods.  The SessionService should ALWAYS be accessed
 34  
  * through this class.
 35  
  *
 36  
  * @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
 37  
  * @version $Id: TurbineSession.java 1706239 2015-10-01 13:18:35Z tv $
 38  
  * @see org.apache.turbine.services.session.SessionService
 39  
  */
 40  0
 public abstract class TurbineSession
 41  
 {
 42  
     /**
 43  
      * Gets a list of the active sessions
 44  
      *
 45  
      * @return List of HttpSession objects
 46  
      */
 47  
     public static Collection<HttpSession> getActiveSessions()
 48  
     {
 49  0
         return getService().getActiveSessions();
 50  
     }
 51  
 
 52  
     /**
 53  
      * Adds a session to the current list.  This method should only be
 54  
      * called by the listener.
 55  
      *
 56  
      * @param session Session to add
 57  
      */
 58  
     public static void addSession(HttpSession session)
 59  
     {
 60  0
         getService().addSession(session);
 61  0
     }
 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  
     public static void removeSession(HttpSession session)
 70  
     {
 71  0
         getService().removeSession(session);
 72  0
     }
 73  
 
 74  
     /**
 75  
      * Determines if a given user is currently logged in.  The actual
 76  
      * implementation of the User object must implement the equals()
 77  
      * method.  By default, Torque based objects (liek TurbineUser)
 78  
      * have an implementation of equals() that will compare the
 79  
      * result of getPrimaryKey().
 80  
      *
 81  
      * @param user User to check for
 82  
      * @return true if the user is logged in on one of the
 83  
      * active sessions.
 84  
      */
 85  
     public static boolean isUserLoggedIn(User user)
 86  
     {
 87  0
         return getService().isUserLoggedIn(user);
 88  
     }
 89  
 
 90  
     /**
 91  
      * Gets a collection of all user objects representing the users currently
 92  
      * logged in.  This will exclude any instances of anonymous user that
 93  
      * Turbine will use before the user actually logs on.
 94  
      *
 95  
      * @return collection of org.apache.turbine.om.security.User objects
 96  
      */
 97  
     public static Collection<User> getActiveUsers()
 98  
     {
 99  0
         return getService().getActiveUsers();
 100  
     }
 101  
 
 102  
     /**
 103  
      * Utility method for accessing the service
 104  
      * implementation
 105  
      *
 106  
      * @return a IntakeService implementation instance
 107  
      */
 108  
     private static SessionService getService()
 109  
     {
 110  0
         return (SessionService) TurbineServices
 111  
                 .getInstance().getService(SessionService.SERVICE_NAME);
 112  
     }
 113  
 
 114  
     /**
 115  
      * Gets the User object of the the specified HttpSession.
 116  
      *
 117  
      * @param session
 118  
      * @return the user from the session
 119  
      */
 120  
     public static User getUserFromSession(HttpSession session)
 121  
     {
 122  0
         return getService().getUserFromSession(session);
 123  
     }
 124  
 
 125  
     /**
 126  
      * Gets the HttpSession by the session identifier
 127  
      *
 128  
      * @param sessionId the id of the session
 129  
      * @return the session for the given id
 130  
      */
 131  
     public static HttpSession getSession(String sessionId)
 132  
     {
 133  0
         return getService().getSession(sessionId);
 134  
     }
 135  
 
 136  
     /**
 137  
      * Get a collection of all session on which the given user
 138  
      * is logged in.
 139  
      *
 140  
      * @param user the user
 141  
      * @return Collection of HtttSession objects
 142  
      */
 143  
     public static Collection<HttpSession> getSessionsForUser(User user)
 144  
     {
 145  0
         return getService().getSessionsForUser(user);
 146  
     }
 147  
 }