001 /**
002 * Copyright 2005-2012 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.rice.kim.sesn.timeouthandlers;
017
018 import java.util.Map;
019
020 import org.apache.commons.logging.Log;
021 import org.apache.commons.logging.LogFactory;
022
023 /**
024 * This class uses the same timeout for all authentication methods and applications
025 *
026 * @author Kuali Rice Team (rice.collab@kuali.org)
027 *
028 */
029 public class GlobalTimeoutHandler extends AbstractTimeoutHandler {
030 private int timeoutPeriod;
031
032 private static final Log logger = LogFactory.getLog(GlobalTimeoutHandler.class);
033
034 /**
035 * @return the timeoutPeriod
036 */
037 public int getTimeoutPeriod() {
038 return this.timeoutPeriod;
039 }
040
041 /**
042 * @param timeoutPeriod the timeoutPeriod to set
043 */
044 public void setTimeoutPeriod(int timeoutPeriod) {
045 this.timeoutPeriod = timeoutPeriod;
046 }
047
048 /**
049 * Determines the timeout based on the context and initiator
050 *
051 * @param args the args in this implementation aren't used
052 *
053 * @return the timeout in seconds
054 */
055 public int getTimeout(Map args) {
056 return timeoutPeriod;
057 }
058
059 /**
060 *
061 * Examines results from session to determine if timeout has expired
062 *
063 * @see org.kuali.rice.kim.client.timeouthandlers.TimeoutHandler#hasTimedOut(java.lang.Object[])
064 */
065 public boolean hasTimedOut(Map args) {
066 boolean bRet = true;
067 Long maxIdleTime = (Long)args.get("maxIdleTime");
068
069 if (maxIdleTime <= timeoutPeriod) {
070 logger.debug("Not timed out: " + maxIdleTime + " " + timeoutPeriod);
071 bRet = false;
072 } else {
073 logger.debug("Timed out: " + maxIdleTime + " " + timeoutPeriod);
074 }
075 return bRet;
076 }
077
078 }
079