Class AbstractBayeuxContext
- java.lang.Object
-
- org.cometd.websocket.server.common.AbstractBayeuxContext
-
- All Implemented Interfaces:
BayeuxContext
public abstract class AbstractBayeuxContext extends Object implements BayeuxContext
-
-
Constructor Summary
Constructors Constructor Description AbstractBayeuxContext(javax.servlet.ServletContext context, String uri, String query, Map<String,List<String>> headers, Map<String,List<String>> parameters, Principal principal, javax.servlet.http.HttpSession session, InetSocketAddress local, InetSocketAddress remote, List<Locale> locales, String protocol, boolean secure)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectgetContextAttribute(String name)Access the ServletContext (if any) attributes.StringgetContextInitParameter(String name)Access the ServletContext (if any) init parameter.StringgetContextPath()StringgetCookie(String name)Get a transport cookie.StringgetHeader(String name)Get a transport header.List<String>getHeaderValues(String name)Get a multi valued transport header.ObjectgetHttpSessionAttribute(String name)Access the HTTP Session (if any) attributes.StringgetHttpSessionId()Access the HTTP Session (if any) ID.InetSocketAddressgetLocalAddress()List<Locale>getLocales()StringgetParameter(String name)Get a transport parameter.List<String>getParameterValues(String name)Get a multi valued transport parameter.StringgetProtocol()InetSocketAddressgetRemoteAddress()ObjectgetRequestAttribute(String name)Access the Request (if any) attributes.StringgetURL()PrincipalgetUserPrincipal()voidinvalidateHttpSession()Invalidate the HTTP Session.booleanisSecure()booleanisUserInRole(String role)voidsetHttpSessionAttribute(String name, Object value)Access the HTTP Session (if any) attributes.
-
-
-
Constructor Detail
-
AbstractBayeuxContext
public AbstractBayeuxContext(javax.servlet.ServletContext context, String uri, String query, Map<String,List<String>> headers, Map<String,List<String>> parameters, Principal principal, javax.servlet.http.HttpSession session, InetSocketAddress local, InetSocketAddress remote, List<Locale> locales, String protocol, boolean secure)
-
-
Method Detail
-
getURL
public String getURL()
- Specified by:
getURLin interfaceBayeuxContext- Returns:
- the full request URI complete with query string if present.
-
getHeader
public String getHeader(String name)
Description copied from interface:BayeuxContextGet 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.
- Specified by:
getHeaderin interfaceBayeuxContext- Parameters:
name- The name of the header- Returns:
- The header value or null if no current transport mechanism or no such header.
-
getHeaderValues
public List<String> getHeaderValues(String name)
Description copied from interface:BayeuxContextGet 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.
- Specified by:
getHeaderValuesin interfaceBayeuxContext- Parameters:
name- The name of the header- Returns:
- The header value or null if no current transport mechanism or no such header.
-
getParameter
public String getParameter(String name)
Description copied from interface:BayeuxContextGet 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.
- Specified by:
getParameterin interfaceBayeuxContext- Parameters:
name- The name of the parameter- Returns:
- The parameter value or null if no current transport mechanism or no such parameter.
-
getParameterValues
public List<String> getParameterValues(String name)
Description copied from interface:BayeuxContextGet 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.
- Specified by:
getParameterValuesin interfaceBayeuxContext- Parameters:
name- The name of the parameter- Returns:
- The parameter value or null if no current transport mechanism or no such parameter.
-
getUserPrincipal
public Principal getUserPrincipal()
- Specified by:
getUserPrincipalin interfaceBayeuxContext- Returns:
- The user Principal (if any)
-
isUserInRole
public boolean isUserInRole(String role)
- Specified by:
isUserInRolein interfaceBayeuxContext- 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.
-
getHttpSessionId
public String getHttpSessionId()
Description copied from interface:BayeuxContextAccess the HTTP Session (if any) ID. TheSession.getId()should be used in preference to the HTTP Session.- Specified by:
getHttpSessionIdin interfaceBayeuxContext- Returns:
- HTTP session ID or null
-
getHttpSessionAttribute
public Object getHttpSessionAttribute(String name)
Description copied from interface:BayeuxContextAccess the HTTP Session (if any) attributes. TheSession.getAttribute(String)should be used in preference to the HTTP Session.- Specified by:
getHttpSessionAttributein interfaceBayeuxContext- Parameters:
name- the attribute name- Returns:
- The attribute value
-
setHttpSessionAttribute
public void setHttpSessionAttribute(String name, Object value)
Description copied from interface:BayeuxContextAccess the HTTP Session (if any) attributes. TheSession.setAttribute(String, Object)should be used in preference to the HTTP Session.- Specified by:
setHttpSessionAttributein interfaceBayeuxContext- Parameters:
name- the attribute namevalue- the attribute value
-
invalidateHttpSession
public void invalidateHttpSession()
Description copied from interface:BayeuxContextInvalidate the HTTP Session. TheSession.getId()should be used in preference to the HTTP Session.- Specified by:
invalidateHttpSessionin interfaceBayeuxContext
-
getRemoteAddress
public InetSocketAddress getRemoteAddress()
- Specified by:
getRemoteAddressin interfaceBayeuxContext- Returns:
- the remote socket address
-
getLocalAddress
public InetSocketAddress getLocalAddress()
- Specified by:
getLocalAddressin interfaceBayeuxContext- Returns:
- the local socket address
-
getLocales
public List<Locale> getLocales()
- Specified by:
getLocalesin interfaceBayeuxContext- Returns:
- the request Locales, in order of preference, or the default server Locale if the request Locales are missing.
-
getCookie
public String getCookie(String name)
Description copied from interface:BayeuxContextGet 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.
- Specified by:
getCookiein interfaceBayeuxContext- Parameters:
name- The name of the cookie- Returns:
- The cookie value or null if no current transport mechanism or no such cookie.
-
getRequestAttribute
public Object getRequestAttribute(String name)
Description copied from interface:BayeuxContextAccess the Request (if any) attributes.- Specified by:
getRequestAttributein interfaceBayeuxContext- Parameters:
name- the attribute name- Returns:
- The attribute value
-
getContextAttribute
public Object getContextAttribute(String name)
Description copied from interface:BayeuxContextAccess the ServletContext (if any) attributes.- Specified by:
getContextAttributein interfaceBayeuxContext- Parameters:
name- the attribute name- Returns:
- The attribute value
-
getContextInitParameter
public String getContextInitParameter(String name)
Description copied from interface:BayeuxContextAccess the ServletContext (if any) init parameter.- Specified by:
getContextInitParameterin interfaceBayeuxContext- Parameters:
name- the init parameter name- Returns:
- The attribute value
-
getContextPath
public String getContextPath()
- Specified by:
getContextPathin interfaceBayeuxContext- Returns:
- the application context path
-
getProtocol
public String getProtocol()
- Specified by:
getProtocolin interfaceBayeuxContext- Returns:
- a string containing the protocol name and version number
-
isSecure
public boolean isSecure()
- Specified by:
isSecurein interfaceBayeuxContext- Returns:
- whether the request was made over a secure channel
-
-