01: /* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
02: *
03: * Licensed under the Apache License, Version 2.0 (the "License");
04: * you may not use this file except in compliance with the License.
05: * You may obtain a copy of the License at
06: *
07: * http://www.apache.org/licenses/LICENSE-2.0
08: *
09: * Unless required by applicable law or agreed to in writing, software
10: * distributed under the License is distributed on an "AS IS" BASIS,
11: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: * See the License for the specific language governing permissions and
13: * limitations under the License.
14: */
15:
16: package org.acegisecurity.concurrent;
17:
18: /**
19: * Maintains a registry of <code>SessionInformation</code> instances.
20: *
21: * @author Ben Alex
22: * @version $Id: SessionRegistry.java 1784 2007-02-24 21:00:24Z luke_t $
23: */
24: public interface SessionRegistry {
25: //~ Methods ========================================================================================================
26:
27: /**
28: * Obtains all the known principals in the <code>SessionRegistry</code>.
29: *
30: * @return each of the unique principals, which can then be presented to {@link #getAllSessions(Object, boolean)}.
31: */
32: Object[] getAllPrincipals();
33:
34: /**
35: * Obtains all the known sessions for the specified principal. Sessions that have been destroyed are not
36: * returned. Sessions that have expired may be returned, depending on the passed argument.
37: *
38: * @param principal to locate sessions for (should never be <code>null</code>)
39: * @param includeExpiredSessions if <code>true</code>, the returned sessions will also include those that have
40: * expired for the principal
41: *
42: * @return the matching sessions for this principal, or <code>null</code> if none were found
43: */
44: SessionInformation[] getAllSessions(Object principal,
45: boolean includeExpiredSessions);
46:
47: /**
48: * Obtains the session information for the specified <code>sessionId</code>. Even expired sessions are
49: * returned (although destroyed sessions are never returned).
50: *
51: * @param sessionId to lookup (should never be <code>null</code>)
52: *
53: * @return the session information, or <code>null</code> if not found
54: */
55: SessionInformation getSessionInformation(String sessionId);
56:
57: /**
58: * Updates the given <code>sessionId</code> so its last request time is equal to the present date and time.
59: * Silently returns if the given <code>sessionId</code> cannot be found or the session is marked to expire.
60: *
61: * @param sessionId for which to update the date and time of the last request (should never be <code>null</code>)
62: */
63: void refreshLastRequest(String sessionId);
64:
65: /**
66: * Registers a new session for the specified principal. The newly registered session will not be marked for
67: * expiration.
68: *
69: * @param sessionId to associate with the principal (should never be <code>null</code>)
70: * @param principal to associate with the session (should never be <code>null</code>)
71: *
72: * @throws SessionAlreadyUsedException DOCUMENT ME!
73: */
74: void registerNewSession(String sessionId, Object principal)
75: throws SessionAlreadyUsedException;
76:
77: /**
78: * Deletes all the session information being maintained for the specified <code>sessionId</code>. If the
79: * <code>sessionId</code> is not found, the method gracefully returns.
80: *
81: * @param sessionId to delete information for (should never be <code>null</code>)
82: */
83: void removeSessionInformation(String sessionId);
84: }
|