| <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../../jacoco-resources/report.gif" type="image/gif"/><title>AbstractSessionManager.java</title><link rel="stylesheet" href="../../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../../index.html" class="el_report">Apache Shiro :: All (aggregate jar)</a> > <a href="../index.html" class="el_bundle">shiro-core</a> > <a href="index.source.html" class="el_package">org.apache.shiro.session.mgt</a> > <span class="el_source">AbstractSessionManager.java</span></div><h1>AbstractSessionManager.java</h1><pre class="source lang-java linenums">/* |
| * Licensed to the Apache Software Foundation (ASF) under one |
| * or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. The ASF licenses this file |
| * to you under the Apache License, Version 2.0 (the |
| * "License"); you may not use this file except in compliance |
| * with the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, |
| * software distributed under the License is distributed on an |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| * KIND, either express or implied. See the License for the |
| * specific language governing permissions and limitations |
| * under the License. |
| */ |
| package org.apache.shiro.session.mgt; |
| |
| import org.apache.shiro.session.Session; |
| |
| /** |
| * Base abstract class of the {@link SessionManager SessionManager} interface, enabling configuration of an |
| * application-wide {@link #getGlobalSessionTimeout() globalSessionTimeout}. Default global session timeout is |
| * {@code 30} minutes. |
| * |
| * @since 0.1 |
| */ |
| //TODO - deprecate this class (see SHIRO-240): |
| //This is only here to make available a common attribute 'globalSessionTimeout' to subclasses, particularly to make it |
| //available to both AbstractNativeSessionManager and ServletContainerSessionManager subclass trees. However, the |
| //ServletContainerSessionManager implementation does not use this value |
| //(see https://issues.apache.org/jira/browse/SHIRO-240 for why). That means that only the Native session managers |
| //need a globalSessionTimeout property, making this class unnecessary. |
| public abstract class AbstractSessionManager implements SessionManager { |
| |
| protected static final long MILLIS_PER_SECOND = 1000; |
| protected static final long MILLIS_PER_MINUTE = 60 * MILLIS_PER_SECOND; |
| protected static final long MILLIS_PER_HOUR = 60 * MILLIS_PER_MINUTE; |
| |
| /** |
| * Default main session timeout value, equal to {@code 30} minutes. |
| */ |
| public static final long DEFAULT_GLOBAL_SESSION_TIMEOUT = 30 * MILLIS_PER_MINUTE; |
| |
| <span class="fc" id="L47"> private long globalSessionTimeout = DEFAULT_GLOBAL_SESSION_TIMEOUT;</span> |
| |
| <span class="fc" id="L49"> public AbstractSessionManager() {</span> |
| <span class="fc" id="L50"> }</span> |
| |
| /** |
| * Returns the system-wide default time in milliseconds that any session may remain idle before expiring. This |
| * value is the main default for all sessions and may be overridden on a <em>per-session</em> basis by calling |
| * {@code Subject.getSession().}{@link Session#setTimeout setTimeout(long)} if so desired. |
| * <ul> |
| * <li>A negative return value means sessions never expire.</li> |
| * <li>A non-negative return value (0 or greater) means session timeout will occur as expected.</li> |
| * </ul> |
| * <p/> |
| * Unless overridden via the {@link #setGlobalSessionTimeout} method, the default value is |
| * {@link #DEFAULT_GLOBAL_SESSION_TIMEOUT}. |
| * |
| * @return the time in milliseconds that any session may remain idle before expiring. |
| */ |
| public long getGlobalSessionTimeout() { |
| <span class="fc" id="L67"> return this.globalSessionTimeout;</span> |
| } |
| |
| /** |
| * Sets the system-wide default time in milliseconds that any session may remain idle before expiring. This |
| * value is the main default for all sessions and may be overridden on a <em>per-session</em> basis by calling |
| * {@code Subject.getSession().}{@link Session#setTimeout setTimeout(long)} if so desired. |
| * <p/> |
| * <ul> |
| * <li>A negative return value means sessions never expire.</li> |
| * <li>A non-negative return value (0 or greater) means session timeout will occur as expected.</li> |
| * </ul> |
| * <p/> |
| * Unless overridden by calling this method, the default value is {@link #DEFAULT_GLOBAL_SESSION_TIMEOUT}. |
| * |
| * @param globalSessionTimeout the time in milliseconds that any session may remain idle before expiring. |
| */ |
| public void setGlobalSessionTimeout(long globalSessionTimeout) { |
| <span class="fc" id="L85"> this.globalSessionTimeout = globalSessionTimeout;</span> |
| <span class="fc" id="L86"> }</span> |
| } |
| </pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.3.201901230119</span></div></body></html> |