Top Description Inners Fields Constructors Methods
org.glassfish.tyrus.core

public final Class RequestContext

extends UpgradeRequest
Class Inheritance
Imports
java.net.URI, java.security.Principal, java.util.Arrays, .Collections, .HashMap, .List, .Map, .TreeMap, org.glassfish.tyrus.spi.UpgradeRequest

Implementation of all possible request interfaces. Should be the only point of truth.
Author
Pavel Bucek

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private Map<String, List<String>>
private final Object
private final RequestContext.Builder.IsUserInRoleDelegate
private Map<String, List<String>>
private final String
private final String
private final URI
private final boolean
private final String
private final int
private final TyrusConfiguration
private final Principal
Inherited from org.glassfish.tyrus.spi.UpgradeRequest:
AUTHORIZATIONCLUSTER_CONNECTION_ID_HEADERCONNECTIONENABLE_TRACING_HEADERHOSTORIGIN_HEADERRESPONSE_CODE_MESSAGESEC_WS_ORIGIN_HEADERSERVER_KEY_HASHTRACING_THRESHOLDUPGRADEWEBSOCKET

Constructor Summary

AccessConstructor and Description
private
RequestContext(URI requestURI, String queryString, Object httpSession, boolean secure, Principal userPrincipal, RequestContext.Builder.IsUserInRoleDelegate IsUserInRoleDelegate, String remoteAddr, String serverAddr, int serverPort, Map<String, List<String>> parameterMap, Map<String, List<String>> headers, Map<String, Object> tyrusProperties)

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

List of header values iff found, null otherwise.
getHeader
(String
header name.
name
)

Implements abstract org.glassfish.tyrus.spi.UpgradeRequest.getHeader.

Returns the header value corresponding to the name.

public Map<String, List<String>>

Returns:

headers map. List items are corresponding to header declaration in HTTP request.
getHeaders
()

Implements jakarta.websocket.server.HandshakeRequest.getHeaders.

Get headers.

public Object
getHttpSession()

Implements jakarta.websocket.server.HandshakeRequest.getHttpSession.

Return a reference to the HttpSession that the web socket handshake that started this conversation was part of, if the implementation is part of a Java EE web container.

public Map<String, List<String>>
getParameterMap()

Implements jakarta.websocket.server.HandshakeRequest.getParameterMap.

Return the request parameters associated with the request.

public String
getQueryString()

Implements jakarta.websocket.server.HandshakeRequest.getQueryString.

Return the query string associated with the request.

public String

Returns:

a String containing the IP address of the client that sent the request or null when method is called on client-side.
getRemoteAddr
()

Get the Internet Protocol (IP) address of the client or last proxy that sent the request.

public URI
getRequestURI()

Implements jakarta.websocket.server.HandshakeRequest.getRequestURI.

Return the request URI of the handshake request.

public String
getRequestUri()

Implements abstract org.glassfish.tyrus.spi.UpgradeRequest.getRequestUri.

Get the undecoded request uri (up to the query string) of underlying HTTP handshake request.

public String

Returns:

a String Returns the host name of the server to which the request was sent or null when method is called on client-side.
getServerAddr
()

Returns the host name of the server to which the request was sent.

public int

Returns:

a port of the client that sent the request.
getServerPort
()

Get the port of the last client or proxy that sent the request.

pack-priv TyrusConfiguration
public Principal
getUserPrincipal()

Implements jakarta.websocket.server.HandshakeRequest.getUserPrincipal.

Return the authenticated user or null if no user is authenticated for this handshake.

public boolean
isSecure()

Implements abstract org.glassfish.tyrus.spi.UpgradeRequest.isSecure.

Indicates whether this request was made using a secure channel (such as HTTPS).

public boolean
isUserInRole(String
the role being checked.
role
)

Implements jakarta.websocket.server.HandshakeRequest.isUserInRole.

Checks whether the current user is in the given role.

public void
lock()

Make headers and parameter map read-only.

Field Detail

headersback to summary
private Map<String, List<String>> headers
httpSessionback to summary
private final Object httpSession
isUserInRoleDelegateback to summary
private final RequestContext.Builder.IsUserInRoleDelegate isUserInRoleDelegate
parameterMapback to summary
private Map<String, List<String>> parameterMap
queryStringback to summary
private final String queryString
remoteAddrback to summary
private final String remoteAddr
requestURIback to summary
private final URI requestURI
secureback to summary
private final boolean secure
serverAddrback to summary
private final String serverAddr
serverPortback to summary
private final int serverPort
tyrusConfigurationback to summary
private final TyrusConfiguration tyrusConfiguration
userPrincipalback to summary
private final Principal userPrincipal

Constructor Detail

RequestContextback to summary
private RequestContext(URI requestURI, String queryString, Object httpSession, boolean secure, Principal userPrincipal, RequestContext.Builder.IsUserInRoleDelegate IsUserInRoleDelegate, String remoteAddr, String serverAddr, int serverPort, Map<String, List<String>> parameterMap, Map<String, List<String>> headers, Map<String, Object> tyrusProperties)

Method Detail

getHeaderback to summary
public String getHeader(String name)

Implements abstract org.glassfish.tyrus.spi.UpgradeRequest.getHeader.

Returns the header value corresponding to the name.

Parameters
name:String

header name.

Returns:String

List of header values iff found, null otherwise.

Annotations
@Override
getHeadersback to summary
public Map<String, List<String>> getHeaders()

Implements jakarta.websocket.server.HandshakeRequest.getHeaders.

Get headers.

Returns:Map<String, List<String>>

headers map. List items are corresponding to header declaration in HTTP request.

Annotations
@Override
getHttpSessionback to summary
public Object getHttpSession()

Implements jakarta.websocket.server.HandshakeRequest.getHttpSession.

Doc from jakarta.websocket.server.HandshakeRequest.getHttpSession.

Return a reference to the HttpSession that the web socket handshake that started this conversation was part of, if the implementation is part of a Java EE web container.

Returns:Object

the http session or null if either the websocket implementation is not part of a Java EE web container, or there is no HttpSession associated with the opening handshake request.

Annotations
@Override
getParameterMapback to summary
public Map<String, List<String>> getParameterMap()

Implements jakarta.websocket.server.HandshakeRequest.getParameterMap.

Doc from jakarta.websocket.server.HandshakeRequest.getParameterMap.

Return the request parameters associated with the request.

Returns:Map<String, List<String>>

the unmodifiable map of the request parameters.

Annotations
@Override
getQueryStringback to summary
public String getQueryString()

Implements jakarta.websocket.server.HandshakeRequest.getQueryString.

Doc from jakarta.websocket.server.HandshakeRequest.getQueryString.

Return the query string associated with the request.

Returns:String

the query string.

Annotations
@Override
getRemoteAddrback to summary
public String getRemoteAddr()

Get the Internet Protocol (IP) address of the client or last proxy that sent the request.

Returns:String

a String containing the IP address of the client that sent the request or null when method is called on client-side.

getRequestURIback to summary
public URI getRequestURI()

Implements jakarta.websocket.server.HandshakeRequest.getRequestURI.

Doc from jakarta.websocket.server.HandshakeRequest.getRequestURI.

Return the request URI of the handshake request.

Returns:URI

the request uri of the handshake request.

Annotations
@Override
getRequestUriback to summary
public String getRequestUri()

Implements abstract org.glassfish.tyrus.spi.UpgradeRequest.getRequestUri.

Doc from org.glassfish.tyrus.spi.UpgradeRequest.getRequestUri.

Get the undecoded request uri (up to the query string) of underlying HTTP handshake request.

Returns:String

request uri.

Annotations
@Override
getServerAddrback to summary
public String getServerAddr()

Returns the host name of the server to which the request was sent.

Returns:String

a String Returns the host name of the server to which the request was sent or null when method is called on client-side.

getServerPortback to summary
public int getServerPort()

Get the port of the last client or proxy that sent the request.

Returns:int

a port of the client that sent the request.

getTyrusConfigurationback to summary
pack-priv TyrusConfiguration getTyrusConfiguration()
getUserPrincipalback to summary
public Principal getUserPrincipal()

Implements jakarta.websocket.server.HandshakeRequest.getUserPrincipal.

Doc from jakarta.websocket.server.HandshakeRequest.getUserPrincipal.

Return the authenticated user or null if no user is authenticated for this handshake.

Returns:Principal

the user principal.

Annotations
@Override
isSecureback to summary
public boolean isSecure()

Implements abstract org.glassfish.tyrus.spi.UpgradeRequest.isSecure.

Doc from org.glassfish.tyrus.spi.UpgradeRequest.isSecure.

Indicates whether this request was made using a secure channel (such as HTTPS).

Returns:boolean

true if the request was made using secure channel, false otherwise.

Annotations
@Override
isUserInRoleback to summary
public boolean isUserInRole(String role)

Implements jakarta.websocket.server.HandshakeRequest.isUserInRole.

Doc from jakarta.websocket.server.HandshakeRequest.isUserInRole.

Checks whether the current user is in the given role. Roles and role membership can be defined using deployment descriptors of the containing WAR file, if running in a Java EE web container. If the user has not been authenticated, the method returns false.

Parameters
role:String

the role being checked.

Returns:boolean

whether the authenticated user is in the role, or false if the user has not been authenticated.

Annotations
@Override
lockback to summary
public void lock()

Make headers and parameter map read-only.

org.glassfish.tyrus.core back to summary

public final Class RequestContext.Builder

extends Object
Class Inheritance

RequestContext builder.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface

Field Summary

Modifier and TypeField and Description
private Map<String, List<String>>
private Object
private RequestContext.Builder.IsUserInRoleDelegate
private Map<String, List<String>>
private String
private String
private URI
private boolean
private String
private int
private Map<String, Object>
private Principal

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public RequestContext

Returns:

created RequestContext.
build
()

Build RequestContext from given properties.

public static RequestContext.Builder

Returns:

empty builder instance.
create
()

Create empty builder.

public static RequestContext.Builder

Returns:

builder instance.
create
(RequestContext
request context.
requestContext
)

Create builder instance based on provided RequestContext.

public RequestContext.Builder

Returns:

updated RequestContext.Builder instance.
httpSession
(Object
jakarta.servlet.http.HttpSession session to be set.
httpSession
)

Set http session.

public RequestContext.Builder
public RequestContext.Builder

Returns:

updated RequestContext.Builder instance.
parameterMap
(Map<String, String[]>
parameter map. Takes map returned from ServletRequest#getParameterMap.
parameterMap
)

Set parameter map.

public RequestContext.Builder

Returns:

updated RequestContext.Builder instance.
queryString
(String
query string to be set.
queryString
)

Set query string.

public RequestContext.Builder

Returns:

updated RequestContext.Builder instance.
remoteAddr
(String
remote address to be set.
remoteAddr
)

Set remote address.

public RequestContext.Builder

Returns:

updated RequestContext.Builder instance.
requestURI
(URI
request URI to be set.
requestURI
)

Set request URI.

public RequestContext.Builder

Returns:

updated RequestContext.Builder instance.
secure
(boolean
secure state to be set.
secure
)

Set secure state.

public RequestContext.Builder

Returns:

updated RequestContext.Builder instance.
serverAddr
(String
server address to be set.
serverAddr
)

Set server address or hostname.

public RequestContext.Builder

Returns:

updated RequestContext.Builder instance.
serverPort
(int
server port to be set.
serverPort
)

Set server port.

public RequestContext.Builder
tyrusProperties(Map<String, Object> tyrusProperties)

Set properties for Tyrus framework.

public RequestContext.Builder

Returns:

updated RequestContext.Builder instance.
userPrincipal
(Principal
principal to be set.
principal
)

Set Principal.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

headersback to summary
private Map<String, List<String>> headers
httpSessionback to summary
private Object httpSession
isUserInRoleDelegateback to summary
private RequestContext.Builder.IsUserInRoleDelegate isUserInRoleDelegate
parameterMapback to summary
private Map<String, List<String>> parameterMap
queryStringback to summary
private String queryString
remoteAddrback to summary
private String remoteAddr
requestURIback to summary
private URI requestURI
secureback to summary
private boolean secure
serverAddrback to summary
private String serverAddr
serverPortback to summary
private int serverPort
tyrusPropertiesback to summary
private Map<String, Object> tyrusProperties
userPrincipalback to summary
private Principal userPrincipal

Constructor Detail

Builderback to summary
public Builder()

Method Detail

buildback to summary
public RequestContext build()

Build RequestContext from given properties.

Returns:RequestContext

created RequestContext.

createback to summary
public static RequestContext.Builder create()

Create empty builder.

Returns:RequestContext.Builder

empty builder instance.

createback to summary
public static RequestContext.Builder create(RequestContext requestContext)

Create builder instance based on provided RequestContext.

Parameters
requestContext:RequestContext

request context.

Returns:RequestContext.Builder

builder instance.

httpSessionback to summary
public RequestContext.Builder httpSession(Object httpSession)

Set http session.

Parameters
httpSession:Object

jakarta.servlet.http.HttpSession session to be set.

Returns:RequestContext.Builder

updated RequestContext.Builder instance.

isUserInRoleDelegateback to summary
public RequestContext.Builder isUserInRoleDelegate(RequestContext.Builder.IsUserInRoleDelegate isUserInRoleDelegate)

Set delegate for RequestContext#isUserInRole(String) method.

Parameters
isUserInRoleDelegate:RequestContext.Builder.IsUserInRoleDelegate

delegate for RequestContext#isUserInRole(String).

Returns:RequestContext.Builder

updated RequestContext.Builder instance.

parameterMapback to summary
public RequestContext.Builder parameterMap(Map<String, String[]> parameterMap)

Set parameter map.

Parameters
parameterMap:Map<String, String[]>

parameter map. Takes map returned from ServletRequest#getParameterMap.

Returns:RequestContext.Builder

updated RequestContext.Builder instance.

queryStringback to summary
public RequestContext.Builder queryString(String queryString)

Set query string.

Parameters
queryString:String

query string to be set.

Returns:RequestContext.Builder

updated RequestContext.Builder instance.

remoteAddrback to summary
public RequestContext.Builder remoteAddr(String remoteAddr)

Set remote address.

Parameters
remoteAddr:String

remote address to be set.

Returns:RequestContext.Builder

updated RequestContext.Builder instance.

requestURIback to summary
public RequestContext.Builder requestURI(URI requestURI)

Set request URI.

Parameters
requestURI:URI

request URI to be set.

Returns:RequestContext.Builder

updated RequestContext.Builder instance.

secureback to summary
public RequestContext.Builder secure(boolean secure)

Set secure state.

Parameters
secure:boolean

secure state to be set.

Returns:RequestContext.Builder

updated RequestContext.Builder instance.

serverAddrback to summary
public RequestContext.Builder serverAddr(String serverAddr)

Set server address or hostname.

Parameters
serverAddr:String

server address to be set.

Returns:RequestContext.Builder

updated RequestContext.Builder instance.

serverPortback to summary
public RequestContext.Builder serverPort(int serverPort)

Set server port.

Parameters
serverPort:int

server port to be set.

Returns:RequestContext.Builder

updated RequestContext.Builder instance.

tyrusPropertiesback to summary
public RequestContext.Builder tyrusProperties(Map<String, Object> tyrusProperties)

Set properties for Tyrus framework.

userPrincipalback to summary
public RequestContext.Builder userPrincipal(Principal principal)

Set Principal.

Parameters
principal:Principal

principal to be set.

Returns:RequestContext.Builder

updated RequestContext.Builder instance.

org.glassfish.tyrus.core back to summary

public Interface RequestContext.Builder.IsUserInRoleDelegate


Is user in role delegate.

Cannot easily query ServletContext or HttpServletRequest for this information, since it is stored only as object.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

a boolean indicating whether the user making this request belongs to a given role; false if the user has not been authenticated.
isUserInRole
(String
a String specifying the name of the role.
role
)

Returns a boolean indicating whether the authenticated user is included in the specified logical "role".

Method Detail

isUserInRoleback to summary
public boolean isUserInRole(String role)

Returns a boolean indicating whether the authenticated user is included in the specified logical "role". Roles and role membership can be defined using deployment descriptors. If the user has not been authenticated, the method returns false.

Parameters
role:String

a String specifying the name of the role.

Returns:boolean

a boolean indicating whether the user making this request belongs to a given role; false if the user has not been authenticated.