Package org.apache.shiro.session
Class ProxiedSession
- java.lang.Object
-
- org.apache.shiro.session.ProxiedSession
-
- All Implemented Interfaces:
Session
- Direct Known Subclasses:
ImmutableProxiedSession
public class ProxiedSession extends Object implements Session
SimpleSession
implementation that immediately delegates all corresponding calls to an underlying proxied session instance. This class is mostly useful for framework subclassing to intercept certainSession
calls and perform additional logic.- Since:
- 0.9
-
-
Constructor Summary
Constructors Constructor Description ProxiedSession(Session target)
Constructs an instance that proxies the specifiedtarget
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
getAttribute(Object key)
Immediately delegates to the underlying proxied session.Collection<Object>
getAttributeKeys()
Immediately delegates to the underlying proxied session.String
getHost()
Immediately delegates to the underlying proxied session.Serializable
getId()
Immediately delegates to the underlying proxied session.Date
getLastAccessTime()
Immediately delegates to the underlying proxied session.Date
getStartTimestamp()
Immediately delegates to the underlying proxied session.long
getTimeout()
Immediately delegates to the underlying proxied session.Object
removeAttribute(Object key)
Immediately delegates to the underlying proxied session.void
setAttribute(Object key, Object value)
Immediately delegates to the underlying proxied session.void
setTimeout(long maxIdleTimeInMillis)
Immediately delegates to the underlying proxied session.void
stop()
Immediately delegates to the underlying proxied session.void
touch()
Immediately delegates to the underlying proxied session.
-
-
-
Constructor Detail
-
ProxiedSession
public ProxiedSession(Session target)
Constructs an instance that proxies the specifiedtarget
. Subclasses may access this target via theprotected final 'delegate'
attribute, i.e.this.delegate
.- Parameters:
target
- the specified targetSession
to proxy.
-
-
Method Detail
-
getId
public Serializable getId()
Immediately delegates to the underlying proxied session.
-
getStartTimestamp
public Date getStartTimestamp()
Immediately delegates to the underlying proxied session.- Specified by:
getStartTimestamp
in interfaceSession
- Returns:
- The time the system created the session.
-
getLastAccessTime
public Date getLastAccessTime()
Immediately delegates to the underlying proxied session.- Specified by:
getLastAccessTime
in interfaceSession
- Returns:
- The time the user last interacted with the system.
- See Also:
Session.touch()
-
getTimeout
public long getTimeout() throws InvalidSessionException
Immediately delegates to the underlying proxied session.- Specified by:
getTimeout
in interfaceSession
- Returns:
- the time in milliseconds the session may remain idle before expiring.
- Throws:
InvalidSessionException
- if the session has been stopped or expired prior to calling this method.
-
setTimeout
public void setTimeout(long maxIdleTimeInMillis) throws InvalidSessionException
Immediately delegates to the underlying proxied session.- Specified by:
setTimeout
in interfaceSession
- 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
Immediately delegates to the underlying proxied session.- Specified by:
touch
in interfaceSession
- Throws:
InvalidSessionException
- if this session has stopped or expired prior to calling this method.
-
stop
public void stop() throws InvalidSessionException
Immediately delegates to the underlying proxied session.- Specified by:
stop
in interfaceSession
- Throws:
InvalidSessionException
- if this session has stopped or expired prior to calling this method.
-
getAttributeKeys
public Collection<Object> getAttributeKeys() throws InvalidSessionException
Immediately delegates to the underlying proxied session.- Specified by:
getAttributeKeys
in interfaceSession
- Returns:
- the keys of all attributes stored under this session, or an empty collection if there are no session attributes.
- Throws:
InvalidSessionException
- if this session has stopped or expired prior to calling this method.
-
getAttribute
public Object getAttribute(Object key) throws InvalidSessionException
Immediately delegates to the underlying proxied session.- Specified by:
getAttribute
in interfaceSession
- Parameters:
key
- the unique name of the object bound to this session- Returns:
- the object bound under the specified
key
name ornull
if there is no object bound under that name. - Throws:
InvalidSessionException
- if this session has stopped or expired prior to calling this method.
-
setAttribute
public void setAttribute(Object key, Object value) throws InvalidSessionException
Immediately delegates to the underlying proxied session.- Specified by:
setAttribute
in interfaceSession
- 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
Immediately delegates to the underlying proxied session.- Specified by:
removeAttribute
in interfaceSession
- 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.
-
-