Class AnyUserLoginService

java.lang.Object
org.eclipse.jetty.security.AnyUserLoginService
All Implemented Interfaces:
LoginService

public class AnyUserLoginService extends Object implements LoginService
A LoginService which allows unknown users to be authenticated.

This is useful for authentication protocols like OpenID Connect and Sign in With Ethereum, where Jetty doesn't store a collection of user credentials and passwords. Once the user proves authenticates themselves through the respective protocol, Jetty does not have to validate any credential.

This can delegate to a nested LoginService which can supply roles for known users. This nested LoginService is supplied to the constructor, and this will first attempt to log in with the nested LoginService and only create a new UserIdentity if none was found with LoginService.login(String, Object, Request, Function)

This LoginService does not check credentials, a UserIdentity will be produced for any username provided in login(String, Object, Request, Function).

  • Constructor Details

    • AnyUserLoginService

      public AnyUserLoginService(String realm, LoginService loginService)
      Parameters:
      realm - the realm name.
      loginService - optional LoginService which can be used to assign roles to known users.
  • Method Details

    • getName

      public String getName()
      Specified by:
      getName in interface LoginService
      Returns:
      Get the name of the login service (aka Realm name)
    • login

      public UserIdentity login(String username, Object credentials, Request request, Function<Boolean,Session> getOrCreateSession)
      Description copied from interface: LoginService
      Login a user.
      Specified by:
      login in interface LoginService
      Parameters:
      username - The username.
      credentials - The users credentials.
      request - The request or null
      getOrCreateSession - function to retrieve or create a session.
      Returns:
      A UserIdentity if the credentials matched, otherwise null
    • validate

      public boolean validate(UserIdentity user)
      Description copied from interface: LoginService
      Validate a user identity. Validate that a UserIdentity previously created by a call to LoginService.login(String, Object, Request, Function) is still valid.
      Specified by:
      validate in interface LoginService
      Parameters:
      user - The user to validate
      Returns:
      true if authentication has not been revoked for the user.
    • getIdentityService

      public IdentityService getIdentityService()
      Description copied from interface: LoginService
      Get the IdentityService associated with this Login Service.
      Specified by:
      getIdentityService in interface LoginService
      Returns:
      the IdentityService associated with this Login Service.
    • setIdentityService

      public void setIdentityService(IdentityService service)
      Description copied from interface: LoginService
      Set the IdentityService associated with this Login Service.
      Specified by:
      setIdentityService in interface LoginService
      Parameters:
      service - the IdentityService associated with this Login Service.
    • logout

      public void logout(UserIdentity user)
      Specified by:
      logout in interface LoginService