Class 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 in Jsr356DelegatingEndpoint before calling the user's endpoint.