Interface MatsSocketServer.IncomingAuthorizationAndAdapter<I,MR,R>

Enclosing interface:
MatsSocketServer
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public static interface MatsSocketServer.IncomingAuthorizationAndAdapter<I,MR,R>
Should handle Authorization evaluation on the supplied Principal and decide whether this message should be forwarded to the Mats fabric (or directly resolved, rejected or denied). If it decides to forward to Mats, it then adapt the incoming MatsSocket message to a message that can be forwarded to the Mats fabric - it is assumed that the type for the incoming MatsSocket message and the type of the incoming Mats message seldom will be identical.

Please make absolutely certain that you understand that these messages originate directly from the hostile Internet, and you cannot assume that any values are benign - they might be tailored specifically to hack or crash your system. Act and code accordingly! Read more at the "Warning" in the MatsSocketServer class JavaDoc.

Note: The messages are immediately read off of the WebSocket and fed over to a thread pool separate from the WebSocket/Servlet Container, which is where the MatsSocketServer.IncomingAuthorizationAndAdapter is executed. This means that albeit you shouldn't hold up the thread for a long time, it is OK to do some computation and IO in this part too - and you may choose to not forward to a Mats endpoint for further processing, but rather just accept and (for requests) reply directly. Note that any such operations MUST just be "getters", as this can in adverse conditions be executed multiple times (i.e. redeliveries in face of lost connections).

Note: It is imperative that this does not perform any state-changes to the system - it should be utterly idempotent, i.e. invoking it a hundred times with the same input should typically yield the same result. (Note: Logging is never considered state changing!)