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

public final Class Handshake

extends Object
Class Inheritance
Imports
java.net.URI, java.util.ArrayList, .Arrays, .Collections, .List, .Map, jakarta.websocket.Extension, .HandshakeResponse, jakarta.websocket.server.HandshakeRequest, org.glassfish.tyrus.core.extension.ExtendedExtension, org.glassfish.tyrus.core.l10n.LocalizationMessages, org.glassfish.tyrus.spi.UpgradeRequest, .UpgradeResponse

Class responsible for performing and validating handshake.
Authors
Justin Lee, Pavel Bucek

Field Summary

Modifier and TypeField and Description
private ExtendedExtension.ExtensionContext
private List<Extension>
private UpgradeRequest
private RequestContext
private static final int
private SecKey
private List<String>
private static final String

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static void
checkForHeader(String currentValue, String header, String validValue)

public static Handshake

Returns:

handshake instance.
createClientHandshake
(RequestContext
request representation to be modified for use as WebSocket handshake request.
webSocketRequest
)

Client-side handshake.

pack-priv static Handshake

Returns:

created handshake.
createServerHandshake
(UpgradeRequest
received handshake request.
request
,
ExtendedExtension.ExtensionContext
extension context.
extensionContext
)

Server-side handshake.

public RequestContext

Returns:

UpgradeRequest created on this HandShake.
getRequest
()

Client side only - get the UpgradeRequest.

public UpgradeRequest

Returns:

composed UpgradeRequest.
prepareRequest
()

Client side only - compose the UpgradeRequest and store it for further use.

pack-priv List<Extension>
respond(UpgradeRequest request, UpgradeResponse response, TyrusEndpointWrapper endpointWrapper)

public void
setExtensions(List<Extension>
list of supported extensions.
extensions
)

Client side only - set the list of supported extensions.

public void
setSubProtocols(List<String>
list of supported subprotocol.
subProtocols
)

Client side only - set the list of supported subprotocols.

public static void
updateHostAndOrigin(final UpgradeRequest
upgrade request to be updated.
upgradeRequest
)

Client side only - Generate host and origin header and put them to the upgrade request headers.

private static void
validate(String header, String validValue, String value)

public void
validateServerResponse(UpgradeResponse
response to be validated.
response
)

Client side only - validate server response.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

extensionContextback to summary
private ExtendedExtension.ExtensionContext extensionContext
extensionsback to summary
private List<Extension> extensions
incomingRequestback to summary
private UpgradeRequest incomingRequest
requestback to summary
private RequestContext request
RESPONSE_CODE_VALUEback to summary
private static final int RESPONSE_CODE_VALUE
secKeyback to summary
private SecKey secKey
subProtocolsback to summary
private List<String> subProtocols
VERSIONback to summary
private static final String VERSION

Constructor Detail

Handshakeback to summary
private Handshake()
See Also
createClientHandshake(org.glassfish.tyrus.core.RequestContext), createServerHandshake(org.glassfish.tyrus.spi.UpgradeRequest, org.glassfish.tyrus.core.extension.ExtendedExtension.ExtensionContext)

Method Detail

checkForHeaderback to summary
private static void checkForHeader(String currentValue, String header, String validValue) throws HandshakeException
createClientHandshakeback to summary
public static Handshake createClientHandshake(RequestContext webSocketRequest)

Client-side handshake.

Parameters
webSocketRequest:RequestContext

request representation to be modified for use as WebSocket handshake request.

Returns:Handshake

handshake instance.

createServerHandshakeback to summary
pack-priv static Handshake createServerHandshake(UpgradeRequest request, ExtendedExtension.ExtensionContext extensionContext) throws HandshakeException

Server-side handshake.

Parameters
request:UpgradeRequest

received handshake request.

extensionContext:ExtendedExtension.ExtensionContext

extension context.

Returns:Handshake

created handshake.

Exceptions
HandshakeException:
when there is problem with received UpgradeRequest.
getRequestback to summary
public RequestContext getRequest()

Client side only - get the UpgradeRequest.

Returns:RequestContext

UpgradeRequest created on this HandShake.

prepareRequestback to summary
public UpgradeRequest prepareRequest()

Client side only - compose the UpgradeRequest and store it for further use.

Returns:UpgradeRequest

composed UpgradeRequest.

respondback to summary
pack-priv List<Extension> respond(UpgradeRequest request, UpgradeResponse response, TyrusEndpointWrapper endpointWrapper)
setExtensionsback to summary
public void setExtensions(List<Extension> extensions)

Client side only - set the list of supported extensions.

Parameters
extensions:List<Extension>

list of supported extensions.

setSubProtocolsback to summary
public void setSubProtocols(List<String> subProtocols)

Client side only - set the list of supported subprotocols.

Parameters
subProtocols:List<String>

list of supported subprotocol.

updateHostAndOriginback to summary
public static void updateHostAndOrigin(final UpgradeRequest upgradeRequest)

Client side only - Generate host and origin header and put them to the upgrade request headers.

Parameters
upgradeRequest:UpgradeRequest

upgrade request to be updated.

validateback to summary
private static void validate(String header, String validValue, String value) throws HandshakeException
validateServerResponseback to summary
public void validateServerResponse(UpgradeResponse response) throws HandshakeException

Client side only - validate server response.

Parameters
response:UpgradeResponse

response to be validated.

Exceptions
HandshakeException:
when HTTP Status of received response is not 101 - Switching protocols.