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 theSession
interface that proxies anotherSession
, but does not allow any 'write' operations to the underlying session. It allows 'read' operations only. TheSession
write operations are defined as follows. A call to any of these methods on this proxy will immediately result in anInvalidSessionException
being 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 Object
removeAttribute(Object key)
Immediatelythrows
anInvalidSessionException
in all cases because this proxy is immutable.void
setAttribute(Object key, Object value)
Immediatelythrows
anInvalidSessionException
in all cases because this proxy is immutable.void
setTimeout(long maxIdleTimeInMillis)
Immediatelythrows
anInvalidSessionException
in all cases because this proxy is immutable.void
stop()
Immediatelythrows
anInvalidSessionException
in all cases because this proxy is immutable.protected void
throwImmutableException()
Simply throws anInvalidSessionException
indicating that this proxy is immutable.void
touch()
Immediatelythrows
anInvalidSessionException
in 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 targetSession
to proxy.
-
-
Method Detail
-
throwImmutableException
protected void throwImmutableException() throws InvalidSessionException
Simply throws anInvalidSessionException
indicating 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 InvalidSessionException
Immediatelythrows
anInvalidSessionException
in all cases because this proxy is immutable.- Specified by:
setTimeout
in interfaceSession
- Overrides:
setTimeout
in 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 InvalidSessionException
Immediatelythrows
anInvalidSessionException
in all cases because this proxy is immutable.- Specified by:
touch
in interfaceSession
- Overrides:
touch
in classProxiedSession
- Throws:
InvalidSessionException
- if this session has stopped or expired prior to calling this method.
-
stop
public void stop() throws InvalidSessionException
Immediatelythrows
anInvalidSessionException
in all cases because this proxy is immutable.- Specified by:
stop
in interfaceSession
- Overrides:
stop
in 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
Immediatelythrows
anInvalidSessionException
in all cases because this proxy is immutable.- Specified by:
setAttribute
in interfaceSession
- Overrides:
setAttribute
in classProxiedSession
- Parameters:
key
- the name under which thevalue
object 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
Immediatelythrows
anInvalidSessionException
in all cases because this proxy is immutable.- Specified by:
removeAttribute
in interfaceSession
- Overrides:
removeAttribute
in classProxiedSession
- Parameters:
key
- the name uniquely identifying the object to remove- Returns:
- the object removed or
null
if there was no object bound under the namekey
. - Throws:
InvalidSessionException
- if this session has stopped or expired prior to calling this method.
-
-