Package org.apache.shiro.session.mgt
Class ImmutableProxiedSession
- java.lang.Object
-
- org.apache.shiro.session.ProxiedSession
-
- org.apache.shiro.session.mgt.ImmutableProxiedSession
-
- All Implemented Interfaces:
Session
public class ImmutableProxiedSession extends ProxiedSession
Implementation of theSessioninterface that proxies anotherSession, but does not allow any 'write' operations to the underlying session. It allows 'read' operations only. TheSessionwrite operations are defined as follows. A call to any of these methods on this proxy will immediately result in anInvalidSessionExceptionbeing thrown:Session.setTimeout(long)Session.touch()Session.stop()Session.setAttribute(key,value)Session.removeAttribute(key)
Session.- Since:
- 0.9
-
-
Field Summary
-
Fields inherited from class org.apache.shiro.session.ProxiedSession
delegate
-
-
Constructor Summary
Constructors Constructor Description ImmutableProxiedSession(Session target)Constructs a new instance of this class proxying the specifiedSession.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectremoveAttribute(Object key)ImmediatelythrowsanInvalidSessionExceptionin all cases because this proxy is immutable.voidsetAttribute(Object key, Object value)ImmediatelythrowsanInvalidSessionExceptionin all cases because this proxy is immutable.voidsetTimeout(long maxIdleTimeInMillis)ImmediatelythrowsanInvalidSessionExceptionin all cases because this proxy is immutable.voidstop()ImmediatelythrowsanInvalidSessionExceptionin all cases because this proxy is immutable.protected voidthrowImmutableException()Simply throws anInvalidSessionExceptionindicating that this proxy is immutable.voidtouch()ImmediatelythrowsanInvalidSessionExceptionin all cases because this proxy is immutable.-
Methods inherited from class org.apache.shiro.session.ProxiedSession
getAttribute, getAttributeKeys, getHost, getId, getLastAccessTime, getStartTimestamp, getTimeout
-
-
-
-
Constructor Detail
-
ImmutableProxiedSession
public ImmutableProxiedSession(Session target)
Constructs a new instance of this class proxying the specifiedSession.- Parameters:
target- the targetSessionto proxy.
-
-
Method Detail
-
throwImmutableException
protected void throwImmutableException() throws InvalidSessionExceptionSimply throws anInvalidSessionExceptionindicating that this proxy is immutable. Used only in the Session's 'write' methods documented in the top class-level JavaDoc.- Throws:
InvalidSessionException- in all cases - used by the Session 'write' method implementations.
-
setTimeout
public void setTimeout(long maxIdleTimeInMillis) throws InvalidSessionExceptionImmediatelythrowsanInvalidSessionExceptionin all cases because this proxy is immutable.- Specified by:
setTimeoutin interfaceSession- Overrides:
setTimeoutin classProxiedSession- Parameters:
maxIdleTimeInMillis- the time in milliseconds that the session may remain idle before expiring.- Throws:
InvalidSessionException- if the session has been stopped or expired prior to calling this method.
-
touch
public void touch() throws InvalidSessionExceptionImmediatelythrowsanInvalidSessionExceptionin all cases because this proxy is immutable.- Specified by:
touchin interfaceSession- Overrides:
touchin classProxiedSession- Throws:
InvalidSessionException- if this session has stopped or expired prior to calling this method.
-
stop
public void stop() throws InvalidSessionExceptionImmediatelythrowsanInvalidSessionExceptionin all cases because this proxy is immutable.- Specified by:
stopin interfaceSession- Overrides:
stopin classProxiedSession- Throws:
InvalidSessionException- if this session has stopped or expired prior to calling this method.
-
setAttribute
public void setAttribute(Object key, Object value) throws InvalidSessionException
ImmediatelythrowsanInvalidSessionExceptionin all cases because this proxy is immutable.- Specified by:
setAttributein interfaceSession- Overrides:
setAttributein classProxiedSession- Parameters:
key- the name under which thevalueobject will be bound in this sessionvalue- the object to bind in this session.- Throws:
InvalidSessionException- if this session has stopped or expired prior to calling this method.
-
removeAttribute
public Object removeAttribute(Object key) throws InvalidSessionException
ImmediatelythrowsanInvalidSessionExceptionin all cases because this proxy is immutable.- Specified by:
removeAttributein interfaceSession- Overrides:
removeAttributein classProxiedSession- Parameters:
key- the name uniquely identifying the object to remove- Returns:
- the object removed or
nullif there was no object bound under the namekey. - Throws:
InvalidSessionException- if this session has stopped or expired prior to calling this method.
-
-