Package io.undertow.server.session
Class SessionCookieConfig
- java.lang.Object
-
- io.undertow.server.session.SessionCookieConfig
-
- All Implemented Interfaces:
SessionConfig
public class SessionCookieConfig extends java.lang.Object implements SessionConfig
Encapsulation of session cookie configuration. This removes the need for the session manager to know about cookie configuration.- Author:
- Stuart Douglas
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.undertow.server.session.SessionConfig
SessionConfig.SessionCookieSource
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DEFAULT_SESSION_ID
-
Fields inherited from interface io.undertow.server.session.SessionConfig
ATTACHMENT_KEY
-
-
Constructor Summary
Constructors Constructor Description SessionCookieConfig()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearSession(HttpServerExchange exchange, java.lang.String sessionId)
Clears this session from the exchange, removing the attachment and making any changes to the response necessary, such as clearing cookies.java.lang.String
findSessionId(HttpServerExchange exchange)
Retrieves a session id of an existing session from an exchange.java.lang.String
getComment()
java.lang.String
getCookieName()
java.lang.String
getDomain()
int
getMaxAge()
java.lang.String
getPath()
boolean
isDiscard()
boolean
isHttpOnly()
boolean
isSecure()
java.lang.String
rewriteUrl(java.lang.String originalUrl, java.lang.String sessionId)
SessionConfig.SessionCookieSource
sessionCookieSource(HttpServerExchange exchange)
SessionCookieConfig
setComment(java.lang.String comment)
SessionCookieConfig
setCookieName(java.lang.String cookieName)
SessionCookieConfig
setDiscard(boolean discard)
SessionCookieConfig
setDomain(java.lang.String domain)
SessionCookieConfig
setHttpOnly(boolean httpOnly)
SessionCookieConfig
setMaxAge(int maxAge)
SessionCookieConfig
setPath(java.lang.String path)
SessionCookieConfig
setSecure(boolean secure)
void
setSessionId(HttpServerExchange exchange, java.lang.String sessionId)
Attaches the session to the exchange.
-
-
-
Field Detail
-
DEFAULT_SESSION_ID
public static final java.lang.String DEFAULT_SESSION_ID
- See Also:
- Constant Field Values
-
-
Method Detail
-
rewriteUrl
public java.lang.String rewriteUrl(java.lang.String originalUrl, java.lang.String sessionId)
- Specified by:
rewriteUrl
in interfaceSessionConfig
-
setSessionId
public void setSessionId(HttpServerExchange exchange, java.lang.String sessionId)
Description copied from interface:SessionConfig
Attaches the session to the exchange. The method should attach the exchange under an attachment key, and should also modify the exchange to allow the session to be re-attached on the next request.Generally this will involve setting a cookie
Once a session has been attached it must be possible to retrieve it via
SessionConfig.findSessionId(io.undertow.server.HttpServerExchange)
- Specified by:
setSessionId
in interfaceSessionConfig
- Parameters:
exchange
- The exchangesessionId
- The session
-
clearSession
public void clearSession(HttpServerExchange exchange, java.lang.String sessionId)
Description copied from interface:SessionConfig
Clears this session from the exchange, removing the attachment and making any changes to the response necessary, such as clearing cookies.- Specified by:
clearSession
in interfaceSessionConfig
- Parameters:
exchange
- The exchangesessionId
- The session id
-
findSessionId
public java.lang.String findSessionId(HttpServerExchange exchange)
Description copied from interface:SessionConfig
Retrieves a session id of an existing session from an exchange.- Specified by:
findSessionId
in interfaceSessionConfig
- Parameters:
exchange
- The exchange- Returns:
- The session id, or null
-
sessionCookieSource
public SessionConfig.SessionCookieSource sessionCookieSource(HttpServerExchange exchange)
- Specified by:
sessionCookieSource
in interfaceSessionConfig
-
getCookieName
public java.lang.String getCookieName()
-
setCookieName
public SessionCookieConfig setCookieName(java.lang.String cookieName)
-
getPath
public java.lang.String getPath()
-
setPath
public SessionCookieConfig setPath(java.lang.String path)
-
getDomain
public java.lang.String getDomain()
-
setDomain
public SessionCookieConfig setDomain(java.lang.String domain)
-
isDiscard
public boolean isDiscard()
-
setDiscard
public SessionCookieConfig setDiscard(boolean discard)
-
isSecure
public boolean isSecure()
-
setSecure
public SessionCookieConfig setSecure(boolean secure)
-
isHttpOnly
public boolean isHttpOnly()
-
setHttpOnly
public SessionCookieConfig setHttpOnly(boolean httpOnly)
-
getMaxAge
public int getMaxAge()
-
setMaxAge
public SessionCookieConfig setMaxAge(int maxAge)
-
getComment
public java.lang.String getComment()
-
setComment
public SessionCookieConfig setComment(java.lang.String comment)
-
-