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:
022: package org.josso.servlet.agent;
023:
024: import org.josso.agent.LocalSession;
025: import org.josso.agent.LocalSessionEvent;
026: import org.josso.agent.LocalSessionListener;
027:
028: import javax.servlet.http.HttpSession;
029: import java.util.ArrayList;
030: import java.util.Iterator;
031:
032: /**
033: * Date: Nov 27, 2007
034: * Time: 11:35:39 AM
035: *
036: * @author <a href="mailto:sgonzalez@josso.org">Sebastian Gonzalez Oyuela</a>
037: */
038: public class LocalSessionImpl implements LocalSession {
039:
040: /**
041: * The session event listeners for this Session.
042: */
043: private transient ArrayList _listeners = new ArrayList();
044: private long _creationTime;
045:
046: private String _id;
047:
048: private long _lastAccessedTime;
049:
050: private int _maxInactiveInterval;
051:
052: private Object _wrapped;
053:
054: public LocalSessionImpl() {
055: }
056:
057: public long getCreationTime() {
058: return _creationTime;
059: }
060:
061: public String getId() {
062: return _id;
063: }
064:
065: public long getLastAccessedTime() {
066: return _lastAccessedTime;
067: }
068:
069: public void setMaxInactiveInterval(int i) {
070: _maxInactiveInterval = i;
071: }
072:
073: public int getMaxInactiveInterval() {
074: return _maxInactiveInterval;
075: }
076:
077: public void expire() {
078:
079: Iterator i = _listeners.iterator();
080: while (i.hasNext()) {
081: LocalSessionListener listener = (LocalSessionListener) i
082: .next();
083:
084: listener.localSessionEvent(new LocalSessionEvent(this ,
085: LocalSession.LOCAL_SESSION_DESTROYED_EVENT, null));
086: }
087: }
088:
089: public void addSessionListener(LocalSessionListener sessionListener) {
090: _listeners.add(sessionListener);
091: }
092:
093: public void removeSessionListener(
094: LocalSessionListener sessionListener) {
095: _listeners.remove(sessionListener);
096: }
097:
098: public void exipre() {
099: ((HttpSession) _wrapped).invalidate();
100: }
101:
102: public void setWrapped(Object wrapped) {
103: _wrapped = wrapped;
104: }
105:
106: public Object getWrapped() {
107: return _wrapped;
108: }
109: }
|