All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.springframework.security.core.session.SessionRegistry Maven / Gradle / Ivy

There is a newer version: 6.3.3
Show newest version
/*
 * Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
 *
 * Licensed 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
 *
 *      https://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.springframework.security.core.session;

import java.util.List;

/**
 * Maintains a registry of SessionInformation instances.
 *
 * @author Ben Alex
 */
public interface SessionRegistry {

	/**
	 * Obtains all the known principals in the SessionRegistry.
	 * @return each of the unique principals, which can then be presented to
	 * {@link #getAllSessions(Object, boolean)}.
	 */
	List getAllPrincipals();

	/**
	 * Obtains all the known sessions for the specified principal. Sessions that have been
	 * destroyed are not returned. Sessions that have expired may be returned, depending
	 * on the passed argument.
	 * @param principal to locate sessions for (should never be null)
	 * @param includeExpiredSessions if true, the returned sessions will also
	 * include those that have expired for the principal
	 * @return the matching sessions for this principal (should not return null).
	 */
	List getAllSessions(Object principal, boolean includeExpiredSessions);

	/**
	 * Obtains the session information for the specified sessionId. Even
	 * expired sessions are returned (although destroyed sessions are never returned).
	 * @param sessionId to lookup (should never be null)
	 * @return the session information, or null if not found
	 */
	SessionInformation getSessionInformation(String sessionId);

	/**
	 * Updates the given sessionId so its last request time is equal to the
	 * present date and time. Silently returns if the given sessionId cannot
	 * be found or the session is marked to expire.
	 * @param sessionId for which to update the date and time of the last request (should
	 * never be null)
	 */
	void refreshLastRequest(String sessionId);

	/**
	 * Registers a new session for the specified principal. The newly registered session
	 * will not be marked for expiration.
	 * @param sessionId to associate with the principal (should never be null
	 * )
	 * @param principal to associate with the session (should never be null)
	 */
	void registerNewSession(String sessionId, Object principal);

	/**
	 * Deletes all the session information being maintained for the specified
	 * sessionId. If the sessionId is not found, the method
	 * gracefully returns.
	 * @param sessionId to delete information for (should never be null)
	 */
	void removeSessionInformation(String sessionId);

}