Package ninja.websockets.jsr356
Class Jsr356HandshakePrincipal
- java.lang.Object
-
- ninja.websockets.jsr356.Jsr356HandshakePrincipal
-
- All Implemented Interfaces:
Principal
public class Jsr356HandshakePrincipal extends Object implements Principal
JSR-356 has a design flaw where you have no method of getting any value ( attribute, original headers, etc.) across the endpoint config -> configurator -> new instance -> onOpen flow. An excellent discussion of the nuances/design flaw of JSR-356 with regards to fetching the original HTTP request/response for the handshake. https://stackoverflow.com/questions/17936440/accessing-httpsession-from-httpservletrequest-in-a-web-socket-serverendpoint Since Ninja does not actually use the "Principal" for request handling and that value is guaranteed to be passed correctly across the entire handshake process, we'll hijack the use of it to store whatever data we need to pass along as a websocket connection is established. We'll then unwrap the data inJsr356DelegatingEndpoint
before calling the user's endpoint.
-
-
Constructor Summary
Constructors Constructor Description Jsr356HandshakePrincipal(Principal principal, Jsr356Handshake handshake)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Jsr356Handshake
getHandshake()
String
getName()
Principal
getPrincipal()
static Optional<Jsr356Handshake>
unwrapHandshake(javax.websocket.Session session)
-
-
-
Constructor Detail
-
Jsr356HandshakePrincipal
public Jsr356HandshakePrincipal(Principal principal, Jsr356Handshake handshake)
-
-
Method Detail
-
getPrincipal
public Principal getPrincipal()
-
getHandshake
public Jsr356Handshake getHandshake()
-
unwrapHandshake
public static Optional<Jsr356Handshake> unwrapHandshake(javax.websocket.Session session)
-
-