Class Authenticator

java.lang.Object
org.glassfish.tyrus.client.auth.Authenticator

@Beta public abstract class Authenticator extends Object
Authenticator provides a way how to plug-in custom authentication provider.

Authenticator is called when server-side returns HTTP 401 as a reply to handshake response. Tyrus client then looks for authenticator instance registered to authentication scheme provided by server.

Author:
Ondrej Kosatka
See Also:
  • Constructor Details

    • Authenticator

      public Authenticator()
  • Method Details

    • generateAuthorizationHeader

      public abstract String generateAuthorizationHeader(URI uri, String wwwAuthenticateHeader, Credentials credentials) throws AuthenticationException
      Generate value used as ""Authorization"" header value for next request.

      Thrown AuthenticationException will be wrapped as DeploymentException and thrown as a result of WebSocketContainer.connectToServer(...) method call.

      Parameters:
      uri - Uri of the server endpoint.
      wwwAuthenticateHeader - ""WWW-Authenticate"" header value received in a handshake response.
      credentials - credentials passed by property ClientProperties.CREDENTIALS. Can be null when there were no Credentials registered.
      Returns:
      value for "Authorization" header which will be put into next handshake request.
      Throws:
      AuthenticationException - when it is not possible to create ""Authorization"" header.