001: /*
002: * JOSSO: Java Open Single Sign-On
003: *
004: * Copyright 2004-2008, Atricore, Inc.
005: *
006: * This is free software; you can redistribute it and/or modify it
007: * under the terms of the GNU Lesser General Public License as
008: * published by the Free Software Foundation; either version 2.1 of
009: * the License, or (at your option) any later version.
010: *
011: * This software is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this software; if not, write to the Free
018: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
019: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
020: */
021: package org.josso.gateway.session.service;
022:
023: import org.josso.gateway.session.SSOSession;
024: import org.josso.gateway.session.exceptions.NoSuchSessionException;
025: import org.josso.gateway.session.exceptions.SSOSessionException;
026: import org.josso.gateway.session.exceptions.TooManyOpenSessionsException;
027: import org.josso.gateway.session.service.store.SessionStore;
028: import org.josso.gateway.assertion.exceptions.AssertionNotValidException;
029:
030: import java.util.Collection;
031:
032: /**
033: * SSO Session Manager Business interface.
034: *
035: * @author <a href="mailto:gbrigand@josso.org">Gianluca Brigandi</a>
036: * @version CVS $Id: SSOSessionManager.java 508 2008-02-18 13:32:29Z sgonzalez $
037: */
038: public interface SSOSessionManager extends java.io.Serializable {
039:
040: /**
041: * Initiates a new session. The session id is returned.
042: *
043: * @return the new session identifier.
044: * @throws TooManyOpenSessionsException if the number of open sessions is exceeded.
045: */
046: String initiateSession(String username) throws SSOSessionException,
047: TooManyOpenSessionsException;
048:
049: /**
050: * This method accesss the session associated to the received id.
051: * This resets the session last access time and updates the access count.
052: *
053: * @param sessionId the session id previously returned by initiateSession.
054: * @throws NoSuchSessionException if the session id is not valid or the session is not valid.
055: */
056: void accessSession(String sessionId) throws NoSuchSessionException,
057: SSOSessionException;
058:
059: /**
060: * Gets an SSO session based on its id.
061: *
062: * @param sessionId the session id previously returned by initiateSession.
063: * @throws org.josso.gateway.session.exceptions.NoSuchSessionException if the session id is not related to any sso session.
064: */
065: SSOSession getSession(String sessionId)
066: throws NoSuchSessionException, SSOSessionException;
067:
068: /**
069: * Gets all SSO sessions.
070: */
071: Collection getSessions() throws SSOSessionException;
072:
073: /**
074: * Gets an SSO session based on the associated user.
075: *
076: * @param username the username used when initiating the session.
077: * @throws org.josso.gateway.session.exceptions.NoSuchSessionException if the session id is not related to any sso session.
078: */
079: Collection getUserSessions(String username)
080: throws NoSuchSessionException, SSOSessionException;
081:
082: /**
083: * Invalidates all open sessions.
084: */
085: void invalidateAll() throws SSOSessionException;
086:
087: /**
088: * Invalidates a session.
089: *
090: * @param sessionId the session id previously returned by initiateSession.
091: * @throws org.josso.gateway.session.exceptions.NoSuchSessionException if the session id is not related to any sso session.
092: */
093: void invalidate(String sessionId) throws NoSuchSessionException,
094: SSOSessionException;
095:
096: /**
097: * Check all sessions and remove those that are not valid from the store.
098: * This method is invoked periodically to update sessions state.
099: */
100: void checkValidSessions();
101:
102: /**
103: * SessionStore instance is injected before initializing the manager.
104: */
105: void setSessionStore(SessionStore ss);
106:
107: /**
108: * SessionIdGenerator instance is injected before initializing the manager.
109: */
110: void setSessionIdGenerator(SessionIdGenerator g);
111:
112: /**
113: * Initialize this manager
114: */
115: void initialize();
116:
117: int getSessionCount() throws SSOSessionException;
118:
119: }
|