Interface Authenticator

All Known Implementing Classes:
Authenticator.NoOp, BasicAuthenticator, DigestAuthenticator, FormAuthenticator, LoginAuthenticator, MultiAuthenticator, SPNEGOAuthenticator, SslClientCertAuthenticator

public interface Authenticator
Authenticator Interface

An Authenticator is responsible for checking requests and sending response challenges in order to authenticate a request. Various types of AuthenticationState are returned in order to signal the next step in authentication.

  • Field Details

  • Method Details

    • setConfiguration

      void setConfiguration(Authenticator.Configuration configuration)
      Configure the Authenticator
      Parameters:
      configuration - the configuration
    • getAuthenticationType

      String getAuthenticationType()
      Returns:
      The name of the authentication type
    • prepareRequest

      default org.eclipse.jetty.server.Request prepareRequest(org.eclipse.jetty.server.Request request, AuthenticationState authenticationState)
      Called after validateRequest(Request, Response, Callback) and before calling Request.Handler.handle(Request, Response, Callback) of the nested handler. This may be used by an Authenticator to restore method or content from a previous request that was challenged.
      Parameters:
      request - the request to prepare for handling
      authenticationState - The authentication for the request
    • getConstraintAuthentication

      default Constraint.Authorization getConstraintAuthentication(String pathInContext, Constraint.Authorization existing, Function<Boolean, org.eclipse.jetty.server.Session> getSession)
      Get an Constraint.Authorization applicable to the path for this authenticator. This is typically used to vary protection on special URIs known to a specific Authenticator (e.g. /j_security_check for the FormAuthenticator.
      Parameters:
      pathInContext - The pathInContext to potentially constrain.
      existing - The existing authentication constraint for the pathInContext determined independently of Authenticator
      getSession - Function to get or create a Session.
      Returns:
      The Constraint.Authorization to apply.
    • validateRequest

      AuthenticationState validateRequest(org.eclipse.jetty.server.Request request, org.eclipse.jetty.server.Response response, org.eclipse.jetty.util.Callback callback) throws ServerAuthException
      Attempts to validate the authentication state of the given request.

      If authentication is successful, an AuthenticationState.Succeeded is returned. If the authenticator has already committed a response (for either success or failure), the returned value will implement AuthenticationState.ResponseSent, and the provided Callback will be eventually be completed, otherwise the caller is responsible for completing the Callback.

      A null return value indicates that no authentication state could be established, possibly because the response has already been committed.

      Parameters:
      request - the request to validate.
      response - the response associated with the request.
      callback - the callback to use for writing a response.
      Returns:
      an AuthenticationState, or null if authentication could not be resolved.
      Throws:
      ServerAuthException - if unable to validate request.