public interface HandshakeRequest
The handshake request represents the WebSocket defined HTTP GET request for the opening handshake of a WebSocket
session.
- Author:
- dannycoward
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionReturn the read only map of HTTP headers to header values that came with the handshake request.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 the address of the interface on which the WebSocket handshake request was received.Returns the host name associated with the interface on which the WebSocket handshake request was received.intReturns the Internet Protocol (IP) port number of the interface on which the WebSocket handshake request was received.Return the request parameters associated with the request.Returns the preferredLocalethat the client will accept content in, based on the Accept-Language header.Return the query string associated with the request.Returns the address of the interface of the client or last proxy which sent the WebSocket handshake request.Returns the host name associated with the client or last proxy which sent the WebSocket handshake request.intReturns the Internet Protocol (IP) port number of the interface of the client or last proxy which sent the WebSocket handshake request.Return the request URI of the handshake request.Return the authenticated user ornullif no user is authenticated for this handshake.Returns the client certificate chain associated with this request, if any.booleanisUserInRole(String role) Checks whether the current user is in the given role.
-
Field Details
-
SEC_WEBSOCKET_KEY
The Sec-WebSocket-Key header name- See Also:
-
SEC_WEBSOCKET_PROTOCOL
The Sec-WebSocket-Protocol header name- See Also:
-
SEC_WEBSOCKET_VERSION
The Sec-WebSocket-Version header name- See Also:
-
SEC_WEBSOCKET_EXTENSIONS
The Sec-WebSocket-Extensions header name- See Also:
-
-
Method Details
-
getHeaders
Return the read only map of HTTP headers to header values that came with the handshake request. Note that the lookup of header names will be performed in a case insensitive manner.- Returns:
- the list of headers.
-
getUserPrincipal
Principal getUserPrincipal()Return the authenticated user ornullif no user is authenticated for this handshake.- Returns:
- the user principal.
-
getRequestURI
URI getRequestURI()Return the request URI of the handshake request.- Returns:
- the request uri of the handshake request.
-
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 returnsfalse.- Parameters:
role- the role being checked.- Returns:
- whether the authenticated user is in the role, or false if the user has not been authenticated.
-
getHttpSession
Object 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:
- the http session or
nullif either the websocket implementation is not part of a Java EE web container, or there is no HttpSession associated with the opening handshake request.
-
getParameterMap
Return the request parameters associated with the request.- Returns:
- the unmodifiable map of the request parameters.
-
getQueryString
String getQueryString()Return the query string associated with the request.- Returns:
- the query string.
-
getUserX509CertificateChain
X509Certificate[] getUserX509CertificateChain()Returns the client certificate chain associated with this request, if any. The array is ordered in ascending order of trust. The first certificate in the array is the one that identifies the client. The next certificate is is for the certificate authority that issued the first. And so on to the root certificate authority.- Returns:
- An ordered array of client certificates, with the client's own certificate first followed by any
certificate authorities or
nullif the client did not present a certificate. - Since:
- WebSocket 2.3
-
getLocalAddress
String getLocalAddress()Returns the address of the interface on which the WebSocket handshake request was received. The representation is determined by the underlying connection features of the WebSocket implementation. It is not safe to assume that it will always be an IP address (either IPv4 or IPv6). It could be some other connection representation such as a Unix Socket.- Returns:
- the address of the interface on which the WebSocket handshake request was received
- Since:
- WebSocket 2.3
-
getLocalHostName
String getLocalHostName()Returns the host name associated with the interface on which the WebSocket handshake request was received.- Returns:
- the host name associated with the interface on which the WebSocket handshake request was received.
- Since:
- WebSocket 2.3
-
getLocalPort
int getLocalPort()Returns the Internet Protocol (IP) port number of the interface on which the WebSocket handshake request was received. If the request was not received via an IP connection, -1 will be returned.- Returns:
- the Internet Protocol (IP) port number of the interface on which the WebSocket handshake request was received or -1 if not applicable
- Since:
- WebSocket 2.3
-
getRemoteAddress
String getRemoteAddress()Returns the address of the interface of the client or last proxy which sent the WebSocket handshake request. The representation is determined by the underlying connection features of the WebSocket implementation. It is not safe to assume that it will always be an IP address (either IPv4 or IPv6). It could be some other connection representation such as a Unix Socket.- Returns:
- the address of the interface of the client or last proxy which sent the WebSocket handshake request
- Since:
- WebSocket 2.3
-
getRemoteHostName
String getRemoteHostName()Returns the host name associated with the client or last proxy which sent the WebSocket handshake request.- Returns:
- the host name associated with the client or last proxy which sent the WebSocket handshake request.
- Since:
- WebSocket 2.3
-
getRemotePort
int getRemotePort()Returns the Internet Protocol (IP) port number of the interface of the client or last proxy which sent the WebSocket handshake request. If the request was not sent via an IP connection, -1 will be returned.- Returns:
- the Internet Protocol (IP) port number of the interface of the client or last proxy which sent the WebSocket handshake request or -1 if not applicable
- Since:
- WebSocket 2.3
-
getPreferredLocale
Locale getPreferredLocale()Returns the preferredLocalethat the client will accept content in, based on the Accept-Language header. If the WebSocket handshake request doesn't provide an Accept-Language header, this method returns the default locale for the server.- Returns:
- the preferred
Localefor the client - Since:
- WebSocket 2.3
-