View Javadoc

1   /*
2    * Copyright 2007-2008 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kim.sesn.timeouthandlers;
17  
18  import java.util.Map;
19  
20  import org.apache.commons.logging.Log;
21  import org.apache.commons.logging.LogFactory;
22  
23  /**
24   * This class uses the same timeout for all authentication methods and applications
25   * 
26   * @author Kuali Rice Team (rice.collab@kuali.org)
27   *
28   */
29  public class GlobalTimeoutHandler extends AbstractTimeoutHandler {
30      private int timeoutPeriod;
31      
32      private static final Log logger = LogFactory.getLog(GlobalTimeoutHandler.class);
33  
34      /**
35       * @return the timeoutPeriod
36       */
37      public int getTimeoutPeriod() {
38          return this.timeoutPeriod;
39      }
40  
41      /**
42       * @param timeoutPeriod the timeoutPeriod to set
43       */
44      public void setTimeoutPeriod(int timeoutPeriod) {
45          this.timeoutPeriod = timeoutPeriod;
46      }
47  
48      /**
49       * Determines the timeout based on the context and initiator
50       *
51       * @param args the args in this implementation aren't used
52       *
53       * @return the timeout in seconds
54       */
55      public int getTimeout(Map args) {
56          return timeoutPeriod; 
57      }
58      
59      /**
60       * 
61       * Examines results from session to determine if timeout has expired 
62       * 
63       * @see org.kuali.rice.kim.client.timeouthandlers.TimeoutHandler#hasTimedOut(java.lang.Object[])
64       */
65      public boolean hasTimedOut(Map args) {
66          boolean bRet = true;
67          Long maxIdleTime = (Long)args.get("maxIdleTime");
68          
69          if (maxIdleTime <= timeoutPeriod) {
70              logger.debug("Not timed out: " + maxIdleTime + " " + timeoutPeriod);
71              bRet = false;
72          } else {
73              logger.debug("Timed out: " + maxIdleTime + " " + timeoutPeriod);
74          }
75          return bRet;
76      }
77  
78  }
79