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
SimpleSessionimplementation that immediately delegates all corresponding calls to an underlying proxied session instance. This class is mostly useful for framework subclassing to intercept certainSessioncalls 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 ObjectgetAttribute(Object key)Immediately delegates to the underlying proxied session.Collection<Object>getAttributeKeys()Immediately delegates to the underlying proxied session.StringgetHost()Immediately delegates to the underlying proxied session.SerializablegetId()Immediately delegates to the underlying proxied session.DategetLastAccessTime()Immediately delegates to the underlying proxied session.DategetStartTimestamp()Immediately delegates to the underlying proxied session.longgetTimeout()Immediately delegates to the underlying proxied session.ObjectremoveAttribute(Object key)Immediately delegates to the underlying proxied session.voidsetAttribute(Object key, Object value)Immediately delegates to the underlying proxied session.voidsetTimeout(long maxIdleTimeInMillis)Immediately delegates to the underlying proxied session.voidstop()Immediately delegates to the underlying proxied session.voidtouch()Immediately delegates to the underlying proxied session.
-
-
-
Field Detail
-
delegate
protected final Session delegate
The proxied instance
-
-
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 targetSessionto 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:
getStartTimestampin interfaceSession- Returns:
- The time the system created the session.
-
getLastAccessTime
public Date getLastAccessTime()
Immediately delegates to the underlying proxied session.- Specified by:
getLastAccessTimein interfaceSession- Returns:
- The time the user last interacted with the system.
- See Also:
Session.touch()
-
getTimeout
public long getTimeout() throws InvalidSessionExceptionImmediately delegates to the underlying proxied session.- Specified by:
getTimeoutin 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 InvalidSessionExceptionImmediately delegates to the underlying proxied session.- Specified by:
setTimeoutin 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.
-
getHost
public String getHost()
Immediately delegates to the underlying proxied session.
-
touch
public void touch() throws InvalidSessionExceptionImmediately delegates to the underlying proxied session.- Specified by:
touchin interfaceSession- Throws:
InvalidSessionException- if this session has stopped or expired prior to calling this method.
-
stop
public void stop() throws InvalidSessionExceptionImmediately delegates to the underlying proxied session.- Specified by:
stopin 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:
getAttributeKeysin 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:
getAttributein interfaceSession- Parameters:
key- the unique name of the object bound to this session- Returns:
- the object bound under the specified
keyname ornullif 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:
setAttributein interfaceSession- 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
Immediately delegates to the underlying proxied session.- Specified by:
removeAttributein interfaceSession- 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.
-
-