Interface BayeuxContext
-
- All Known Implementing Classes:
AbstractBayeuxContext
public interface BayeuxContext
The Bayeux Context provides information about the current context of a Bayeux message.
This information may be from an associated HTTP request, or a HTTP request used to originally establish the connection (for example in a websocket handshake).
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Object
getContextAttribute(String name)
Access the ServletContext (if any) attributes.String
getContextInitParameter(String name)
Access the ServletContext (if any) init parameter.String
getContextPath()
String
getCookie(String name)
Get a transport cookie.String
getHeader(String name)
Get a transport header.List<String>
getHeaderValues(String name)
Get a multi valued transport header.Object
getHttpSessionAttribute(String name)
Access the HTTP Session (if any) attributes.String
getHttpSessionId()
Access the HTTP Session (if any) ID.InetSocketAddress
getLocalAddress()
List<Locale>
getLocales()
String
getParameter(String name)
Get a transport parameter.List<String>
getParameterValues(String name)
Get a multi valued transport parameter.String
getProtocol()
InetSocketAddress
getRemoteAddress()
Object
getRequestAttribute(String name)
Access the Request (if any) attributes.String
getURL()
Principal
getUserPrincipal()
void
invalidateHttpSession()
Invalidate the HTTP Session.boolean
isSecure()
boolean
isUserInRole(String role)
void
setHttpSessionAttribute(String name, Object value)
Access the HTTP Session (if any) attributes.
-
-
-
Method Detail
-
getUserPrincipal
Principal getUserPrincipal()
- Returns:
- The user Principal (if any)
-
isUserInRole
boolean isUserInRole(String role)
- Parameters:
role
- the role to check whether the user belongs to- Returns:
- true if there is a known user and they are in the given role.
-
getRemoteAddress
InetSocketAddress getRemoteAddress()
- Returns:
- the remote socket address
-
getLocalAddress
InetSocketAddress getLocalAddress()
- Returns:
- the local socket address
-
getHeader
String getHeader(String name)
Get a transport header.Get a header for any current transport mechanism (eg HTTP request). For transports like websocket, the header may be from the initial handshake.
- Parameters:
name
- The name of the header- Returns:
- The header value or null if no current transport mechanism or no such header.
-
getHeaderValues
List<String> getHeaderValues(String name)
Get a multi valued transport header.Get a header for any current transport mechanism (eg HTTP request). For transports like websocket, the header may be from the initial handshake.
- Parameters:
name
- The name of the header- Returns:
- The header value or null if no current transport mechanism or no such header.
-
getParameter
String getParameter(String name)
Get a transport parameter.Get a parameter for any current transport mechanism (eg HTTP request). For transports like websocket, the parameter may be from the initial handshake.
- Parameters:
name
- The name of the parameter- Returns:
- The parameter value or null if no current transport mechanism or no such parameter.
-
getParameterValues
List<String> getParameterValues(String name)
Get a multi valued transport parameter.Get a parameter for any current transport mechanism (eg HTTP request). For transports like websocket, the parameter may be from the initial handshake.
- Parameters:
name
- The name of the parameter- Returns:
- The parameter value or null if no current transport mechanism or no such parameter.
-
getCookie
String getCookie(String name)
Get a transport cookie.Get a cookie for any current transport mechanism (eg HTTP request). For transports like websocket, the cookie may be from the initial handshake.
- Parameters:
name
- The name of the cookie- Returns:
- The cookie value or null if no current transport mechanism or no such cookie.
-
getHttpSessionId
String getHttpSessionId()
Access the HTTP Session (if any) ID. TheSession.getId()
should be used in preference to the HTTP Session.- Returns:
- HTTP session ID or null
-
getHttpSessionAttribute
Object getHttpSessionAttribute(String name)
Access the HTTP Session (if any) attributes. TheSession.getAttribute(String)
should be used in preference to the HTTP Session.- Parameters:
name
- the attribute name- Returns:
- The attribute value
-
setHttpSessionAttribute
void setHttpSessionAttribute(String name, Object value)
Access the HTTP Session (if any) attributes. TheSession.setAttribute(String, Object)
should be used in preference to the HTTP Session.- Parameters:
name
- the attribute namevalue
- the attribute value
-
invalidateHttpSession
void invalidateHttpSession()
Invalidate the HTTP Session. TheSession.getId()
should be used in preference to the HTTP Session.
-
getRequestAttribute
Object getRequestAttribute(String name)
Access the Request (if any) attributes.- Parameters:
name
- the attribute name- Returns:
- The attribute value
-
getContextAttribute
Object getContextAttribute(String name)
Access the ServletContext (if any) attributes.- Parameters:
name
- the attribute name- Returns:
- The attribute value
-
getContextInitParameter
String getContextInitParameter(String name)
Access the ServletContext (if any) init parameter.- Parameters:
name
- the init parameter name- Returns:
- The attribute value
-
getContextPath
String getContextPath()
- Returns:
- the application context path
-
getURL
String getURL()
- Returns:
- the full request URI complete with query string if present.
-
getLocales
List<Locale> getLocales()
- Returns:
- the request Locales, in order of preference, or the default server Locale if the request Locales are missing.
-
getProtocol
String getProtocol()
- Returns:
- a string containing the protocol name and version number
-
isSecure
boolean isSecure()
- Returns:
- whether the request was made over a secure channel
-
-