Class BasicAuthenticationProvider

java.lang.Object
one.jpro.platform.auth.core.basic.provider.BasicAuthenticationProvider
All Implemented Interfaces:
AuthenticationProvider<UsernamePasswordCredentials>

public class BasicAuthenticationProvider extends Object implements AuthenticationProvider<UsernamePasswordCredentials>
The BasicAuthenticationProvider class implements the AuthenticationProvider interface to provide basic authentication using username and password credentials.
  • Field Details

  • Constructor Details

    • BasicAuthenticationProvider

      public BasicAuthenticationProvider(@NotNull @NotNull UserManager userManager, @Nullable @Nullable Set<String> roles, @Nullable @Nullable Map<String,Object> attributes)
      Constructs a new BasicAuthenticationProvider with specified roles and attributes.
      Parameters:
      userManager - the user manager to be used for authentication
      roles - the set of roles to be associated with the authenticated user, may be null
      attributes - the map of attributes to be associated with the authenticated user, may be null
  • Method Details

    • authenticate

      public CompletableFuture<User> authenticate(@NotNull @NotNull UsernamePasswordCredentials credentials) throws AuthenticationException, CredentialValidationException
      Authenticates the user based on the provided UsernamePasswordCredentials.
      Specified by:
      authenticate in interface AuthenticationProvider<UsernamePasswordCredentials>
      Parameters:
      credentials - the credentials containing the username and password
      Returns:
      a CompletableFuture that, when completed, provides the authenticated User
      Throws:
      CredentialValidationException - if the credentials are not valid
      AuthenticationException
    • getUserManager

      @NotNull public @NotNull UserManager getUserManager()
      Gets the user manager associated with this authentication provider.
      Returns:
      the user manager
    • setUserManager

      public void setUserManager(@NotNull @NotNull UserManager userManager)
      Sets the user manager to be associated with this authentication provider.
      Parameters:
      userManager - the user manager
    • getAuthorizationPath

      @NotNull public @NotNull String getAuthorizationPath()
      Gets the authorization path URI for basic authentication. This is the URI path that the users will be redirected to if they need to be authenticated.
      Returns:
      the authorization path string
    • setAuthorizationPath

      public void setAuthorizationPath(@NotNull @NotNull String authorizationPath)
      Sets the authorization path for basic authentication. This is the URI path that the users will be redirected to if they need to be authenticated.
      Parameters:
      authorizationPath - the authorization path string
    • getRoles

      @Nullable public @Nullable Set<String> getRoles()
      Gets the set of roles associated with this authentication provider.
      Returns:
      the set of roles, may be null
    • setRoles

      public void setRoles(@Nullable @Nullable Set<String> roles)
      Sets the roles to be associated with this authentication provider.
      Parameters:
      roles - the set of roles, may be null
    • getAttributes

      @Nullable public @Nullable Map<String,Object> getAttributes()
      Gets the attributes associated with this authentication provider.
      Returns:
      the attributes, may be null
    • setAttributes

      public void setAttributes(@Nullable @Nullable Map<String,Object> attributes)
      Sets the attributes to be associated with this authentication provider.
      Parameters:
      attributes - the map of attributes, may be null