@ApplicationScoped public class Authenticator extends Object
WebsocketAuthenticationException is thrown.
This authenticator includes a cache for sessions, so that if a session and message fulfills the following conditions, the message is accepted and the session is understood as sufficiently authenticated:
| Constructor and Description |
|---|
Authenticator() |
| Modifier and Type | Method and Description |
|---|---|
void |
authenticateWithCredentials(String username,
String password,
String personaId,
javax.websocket.Session session)
Authenticates the user/persona that sent the message based on the credentials or based on previous messages
(looked up via the session ID).
|
void |
authenticateWithMessage(String message,
javax.websocket.Session session)
Authenticates the user/persona that sent the message based on either the message itself or based on previous
messages (looked up via the session ID).
|
void |
authenticateWithToken(String token,
String personaId,
javax.websocket.Session session)
Authenticates the user/persona that sent the message based on the token or based on previous messages (looked
up via the session ID).
|
public void authenticateWithMessage(String message, javax.websocket.Session session) throws WebsocketAuthenticationException
Sample messages:
With token - {"authentication": {"token": "abc123def"}, "mypayload": {"message":"hello world"}}
User/pass - {"authentication":
{"login": {"username": "jdoe", "password":"securepass"}}, "mypayload":{"message":"hello world"}}
message - JSON message with an authentication object, which should include either a token
object or username and password.session - the Web Socket session for this message.WebsocketAuthenticationException - if authentication cannot be inferred from the message nor from the
session.public void authenticateWithToken(String token, String personaId, javax.websocket.Session session) throws WebsocketAuthenticationException
token - the bearer token to be validatedsession - the Web Socket sessionWebsocketAuthenticationException - if authentication cannot be inferred from the token nor from the
session.public void authenticateWithCredentials(String username, String password, String personaId, javax.websocket.Session session) throws WebsocketAuthenticationException
username - the usernamepassword - the passwordsession - the Web Socket sessionWebsocketAuthenticationException - if authentication cannot be inferred from the credentials nor from the
session.Copyright © 2015 Red Hat, Inc.. All rights reserved.