Top Description Inners Fields Constructors Methods
io.undertow.servlet.spec

public Class HttpSessionImpl

extends Object
implements HttpSession
Class Inheritance
All Implemented Interfaces
jakarta.servlet.http.HttpSession
Imports
java.security.PrivilegedAction, java.util.Enumeration, .HashSet, .Iterator, .Set, jakarta.servlet.ServletContext, jakarta.servlet.http.HttpSession, io.undertow.server.session.Session, io.undertow.servlet.UndertowServletMessages, io.undertow.servlet.handlers.ServletRequestContext, io.undertow.servlet.util.IteratorEnumeration

The HTTP session implementation. Note that for security reasons no attribute names that start with io.undertow are allowed.
Author
Stuart Douglas

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private volatile boolean
public static final String
private final boolean
private static final RuntimePermission
private final ServletContext
private final ServletRequestContext
private final Session

Constructor Summary

AccessConstructor and Description
private
HttpSessionImpl(final Session session, final ServletContext servletContext, final boolean newSession, ServletRequestContext servletRequestContext)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public static HttpSessionImpl
forSession(final Session session, final ServletContext servletContext, final boolean newSession)

public Object
getAttribute(final String
a string specifying the name of the object
name
)

Implements jakarta.servlet.http.HttpSession.getAttribute.

Returns the object bound with the specified name in this session, or null if no object is bound under the name.

public Enumeration<String>
getAttributeNames()

Implements jakarta.servlet.http.HttpSession.getAttributeNames.

Returns an Enumeration of String objects containing the names of all the objects bound to this session.

public long
getCreationTime()

Implements jakarta.servlet.http.HttpSession.getCreationTime.

Returns the time when this session was created, measured in milliseconds since midnight January 1, 1970 GMT.

private Set<String>
public String
getId()

Implements jakarta.servlet.http.HttpSession.getId.

Returns a string containing the unique identifier assigned to this session.

public long
getLastAccessedTime()

Implements jakarta.servlet.http.HttpSession.getLastAccessedTime.

Returns the last time the client sent a request associated with this session, as the number of milliseconds since midnight January 1, 1970 GMT, and marked by the time the container received the request.

public int
getMaxInactiveInterval()

Implements jakarta.servlet.http.HttpSession.getMaxInactiveInterval.

Returns the maximum time interval, in seconds, that the servlet container will keep this session open between client accesses.

public ServletContext
getServletContext()

Implements jakarta.servlet.http.HttpSession.getServletContext.

Returns the ServletContext to which this session belongs.

public Session
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public void
invalidate()

Implements jakarta.servlet.http.HttpSession.invalidate.

Invalidates this session then unbinds any objects bound to it.

public boolean
public boolean
isNew()

Implements jakarta.servlet.http.HttpSession.isNew.

Returns true if the client does not yet know about the session or if the client chooses not to join the session.

public void
removeAttribute(final String
the name of the object to remove from this session
name
)

Implements jakarta.servlet.http.HttpSession.removeAttribute.

Removes the object bound with the specified name from this session.

public void
setAttribute(final String
the name to which the object is bound; cannot be null
name
,
final Object
the object to be bound
value
)

Implements jakarta.servlet.http.HttpSession.setAttribute.

Binds an object to this session, using the name specified.

public void
setMaxInactiveInterval(final int
An integer specifying the number of seconds
interval
)

Implements jakarta.servlet.http.HttpSession.setMaxInactiveInterval.

Specifies the time, in seconds, between client requests before the servlet container will invalidate this session.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

invalidback to summary
private volatile boolean invalid
IO_UNDERTOWback to summary
public static final String IO_UNDERTOW
newSessionback to summary
private final boolean newSession
PERMISSIONback to summary
private static final RuntimePermission PERMISSION
servletContextback to summary
private final ServletContext servletContext
servletRequestContextback to summary
private final ServletRequestContext servletRequestContext
sessionback to summary
private final Session session

Constructor Detail

HttpSessionImplback to summary
private HttpSessionImpl(final Session session, final ServletContext servletContext, final boolean newSession, ServletRequestContext servletRequestContext)

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
forSessionback to summary
public static HttpSessionImpl forSession(final Session session, final ServletContext servletContext, final boolean newSession)
getAttributeback to summary
public Object getAttribute(final String name)

Implements jakarta.servlet.http.HttpSession.getAttribute.

Doc from jakarta.servlet.http.HttpSession.getAttribute.

Returns the object bound with the specified name in this session, or null if no object is bound under the name.

Parameters
name:String

a string specifying the name of the object

Returns:Object

the object with the specified name

Annotations
@Override
getAttributeNamesback to summary
public Enumeration<String> getAttributeNames()

Implements jakarta.servlet.http.HttpSession.getAttributeNames.

Doc from jakarta.servlet.http.HttpSession.getAttributeNames.

Returns an Enumeration of String objects containing the names of all the objects bound to this session.

Returns:Enumeration<String>

an Enumeration of String objects specifying the names of all the objects bound to this session

Annotations
@Override
getCreationTimeback to summary
public long getCreationTime()

Implements jakarta.servlet.http.HttpSession.getCreationTime.

Doc from jakarta.servlet.http.HttpSession.getCreationTime.

Returns the time when this session was created, measured in milliseconds since midnight January 1, 1970 GMT.

Returns:long

a long specifying when this session was created, expressed in milliseconds since 1/1/1970 GMT

Annotations
@Override
getFilteredAttributeNamesback to summary
private Set<String> getFilteredAttributeNames()
getIdback to summary
public String getId()

Implements jakarta.servlet.http.HttpSession.getId.

Doc from jakarta.servlet.http.HttpSession.getId.

Returns a string containing the unique identifier assigned to this session. The identifier is assigned by the servlet container and is implementation dependent.

Returns:String

a string specifying the identifier assigned to this session

Annotations
@Override
getLastAccessedTimeback to summary
public long getLastAccessedTime()

Implements jakarta.servlet.http.HttpSession.getLastAccessedTime.

Doc from jakarta.servlet.http.HttpSession.getLastAccessedTime.

Returns the last time the client sent a request associated with this session, as the number of milliseconds since midnight January 1, 1970 GMT, and marked by the time the container received the request.

Actions that your application takes, such as getting or setting a value associated with the session, do not affect the access time.

Returns:long

a long representing the last time the client sent a request associated with this session, expressed in milliseconds since 1/1/1970 GMT

Annotations
@Override
getMaxInactiveIntervalback to summary
public int getMaxInactiveInterval()

Implements jakarta.servlet.http.HttpSession.getMaxInactiveInterval.

Doc from jakarta.servlet.http.HttpSession.getMaxInactiveInterval.

Returns the maximum time interval, in seconds, that the servlet container will keep this session open between client accesses. After this interval, the servlet container will invalidate the session. The maximum time interval can be set with the setMaxInactiveInterval method.

A return value of zero or less indicates that the session will never timeout.

Returns:int

an integer specifying the number of seconds this session remains open between client requests

Annotations
@Override
getServletContextback to summary
public ServletContext getServletContext()

Implements jakarta.servlet.http.HttpSession.getServletContext.

Doc from jakarta.servlet.http.HttpSession.getServletContext.

Returns the ServletContext to which this session belongs.

Returns:ServletContext

The ServletContext object for the web application

Annotations
@Override
getSessionback to summary
public Session getSession()
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
invalidateback to summary
public void invalidate()

Implements jakarta.servlet.http.HttpSession.invalidate.

Doc from jakarta.servlet.http.HttpSession.invalidate.

Invalidates this session then unbinds any objects bound to it.

Annotations
@Override
isInvalidback to summary
public boolean isInvalid()
isNewback to summary
public boolean isNew()

Implements jakarta.servlet.http.HttpSession.isNew.

Doc from jakarta.servlet.http.HttpSession.isNew.

Returns true if the client does not yet know about the session or if the client chooses not to join the session. For example, if the server used only cookie-based sessions, and the client had disabled the use of cookies, then a session would be new on each request.

Returns:boolean

true if the server has created a session, but the client has not yet joined

Annotations
@Override
removeAttributeback to summary
public void removeAttribute(final String name)

Implements jakarta.servlet.http.HttpSession.removeAttribute.

Doc from jakarta.servlet.http.HttpSession.removeAttribute.

Removes the object bound with the specified name from this session. If the session does not have an object bound with the specified name, this method does nothing.

After this method executes, and if the object implements HttpSessionBindingListener, the container calls HttpSessionBindingListener.valueUnbound. The container then notifies any HttpSessionAttributeListeners in the web application.

Parameters
name:String

the name of the object to remove from this session

Annotations
@Override
setAttributeback to summary
public void setAttribute(final String name, final Object value)

Implements jakarta.servlet.http.HttpSession.setAttribute.

Doc from jakarta.servlet.http.HttpSession.setAttribute.

Binds an object to this session, using the name specified. If an object of the same name is already bound to the session, the object is replaced.

After this method executes, and if the new object implements HttpSessionBindingListener, the container calls HttpSessionBindingListener.valueBound. The container then notifies any HttpSessionAttributeListeners in the web application.

If an object was already bound to this session of this name that implements HttpSessionBindingListener, its HttpSessionBindingListener.valueUnbound method is called.

If the value passed in is null, this has the same effect as calling removeAttribute().

Parameters
name:String

the name to which the object is bound; cannot be null

value:Object

the object to be bound

Annotations
@Override
setMaxInactiveIntervalback to summary
public void setMaxInactiveInterval(final int interval)

Implements jakarta.servlet.http.HttpSession.setMaxInactiveInterval.

Doc from jakarta.servlet.http.HttpSession.setMaxInactiveInterval.

Specifies the time, in seconds, between client requests before the servlet container will invalidate this session.

An interval value of zero or less indicates that the session should never timeout.

Parameters
interval:int

An integer specifying the number of seconds

Annotations
@Override
io.undertow.servlet.spec back to summary

public Class HttpSessionImpl.UnwrapSessionAction

extends Object
implements PrivilegedAction<Session>
Class Inheritance
All Implemented Interfaces
java.security.PrivilegedAction

Field Summary

Modifier and TypeField and Description
private final HttpSessionImpl

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Session
run()

Implements java.security.PrivilegedAction.run.

Performs the computation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

sessionback to summary
private final HttpSessionImpl session

Constructor Detail

UnwrapSessionActionback to summary
public UnwrapSessionAction(HttpSession session)

Method Detail

runback to summary
public Session run()

Implements java.security.PrivilegedAction.run.

Doc from java.security.PrivilegedAction.run.

Performs the computation. This method will be called by AccessController.doPrivileged after enabling privileges.

Returns:Session

a class-dependent value that may represent the results of the computation. Each class that implements PrivilegedAction should document what (if anything) this value represents.

Annotations
@Override