# Class WsHandshakeRequest

java.lang.Object
org.apache.tomcat.websocket.server.WsHandshakeRequest

All Implemented Interfaces:
  `HandshakeRequest`

public class WsHandshakeRequest extends Object implements HandshakeRequest
Represents the request that this session was opened under.

- ## Field Summary

  ### Fields inherited from interface HandshakeRequest

  `SEC_WEBSOCKET_EXTENSIONS, SEC_WEBSOCKET_KEY, SEC_WEBSOCKET_PROTOCOL, SEC_WEBSOCKET_VERSION`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `WsHandshakeRequest(HttpServletRequest request, Map<String,String> pathParams)`
  Constructs a new WsHandshakeRequest.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Map<String, List<String>>`
  `getHeaders()`
  Returns the HTTP headers from the handshake request.
  `Object`
  `getHttpSession()`
  Get the HTTP Session object associated with this request.
  `Map<String, List<String>>`
  `getParameterMap()`
  Returns the query parameters from the handshake request.
  `String`
  `getQueryString()`
  Returns the query string from the handshake request.
  `URI`
  `getRequestURI()`
  Returns the URI of the handshake request.
  `Principal`
  `getUserPrincipal()`
  Returns the principal of the user associated with this request, or `null` if the user is not authenticated.
  `boolean`
  `isUserInRole(String role)`
  Returns whether the user associated with this request is in the given role.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### WsHandshakeRequest

    public WsHandshakeRequest(HttpServletRequest request, Map<String,String> pathParams)
    Constructs a new WsHandshakeRequest.
    Parameters:
      `request` - The HTTP servlet request
      `pathParams` - The path parameters

- ## Method Details

  - ### getRequestURI

    public URI getRequestURI()
    Description copied from interface: `jakarta.websocket.server.HandshakeRequest`
    Returns the URI of the handshake request.
    Specified by:
      `getRequestURI` in interface `HandshakeRequest`
    Returns:
      The request URI

  - ### getParameterMap

    public Map<String, List<String>> getParameterMap()
    Description copied from interface: `jakarta.websocket.server.HandshakeRequest`
    Returns the query parameters from the handshake request.
    Specified by:
      `getParameterMap` in interface `HandshakeRequest`
    Returns:
      The query parameter map

  - ### getQueryString

    public String getQueryString()
    Description copied from interface: `jakarta.websocket.server.HandshakeRequest`
    Returns the query string from the handshake request.
    Specified by:
      `getQueryString` in interface `HandshakeRequest`
    Returns:
      The query string

  - ### getUserPrincipal

    public Principal getUserPrincipal()
    Description copied from interface: `jakarta.websocket.server.HandshakeRequest`
    Returns the principal of the user associated with this request, or `null` if the user is not authenticated.
    Specified by:
      `getUserPrincipal` in interface `HandshakeRequest`
    Returns:
      The user principal

  - ### getHeaders

    public Map<String, List<String>> getHeaders()
    Description copied from interface: `jakarta.websocket.server.HandshakeRequest`
    Returns the HTTP headers from the handshake request.
    Specified by:
      `getHeaders` in interface `HandshakeRequest`
    Returns:
      The HTTP headers

  - ### isUserInRole

    public boolean isUserInRole(String role)
    Description copied from interface: `jakarta.websocket.server.HandshakeRequest`
    Returns whether the user associated with this request is in the given role.
    Specified by:
      `isUserInRole` in interface `HandshakeRequest`
    Parameters:
      `role` - The role to check
    Returns:
      `true` if the user is in the specified role

  - ### getHttpSession

    public Object getHttpSession()
    Description copied from interface: `jakarta.websocket.server.HandshakeRequest`
    Get the HTTP Session object associated with this request. Object is used to avoid a direct dependency on the Servlet API.
    Specified by:
      `getHttpSession` in interface `HandshakeRequest`
    Returns:
      The jakarta.servlet.http.HttpSession object associated with this request, if any.