Class CombineAuthenticationProvider

java.lang.Object
one.jpro.platform.auth.core.authentication.CombineAuthenticationProvider
All Implemented Interfaces:
AuthenticationProvider<Credentials>

public class CombineAuthenticationProvider extends Object implements AuthenticationProvider<Credentials>
This class allows for the aggregation of multiple authentication providers, where the authentication process can be tailored to succeed based on the success of either all (AND logic) or any (OR logic) of the included providers.
  • Method Details

    • all

      public static CombineAuthenticationProvider all()
      Creates a combined authentication provider that will resolve if all contained authentication providers are successful. This is equivalent to an AND operation among all providers.
      Returns:
      new instance of CombineAuthenticationProvider set to require all providers to succeed.
    • any

      public static CombineAuthenticationProvider any()
      Creates a combined authentication provider that will resolve if any contained authentication provider is successful. This is equivalent to an OR operation among all providers.
      Returns:
      new instance of CombineAuthenticationProvider set to require any provider to succeed.
    • add

      Adds an authentication provider to this combined authentication provider.

      This method allows for the dynamic addition of authentication providers into the combined provider. The added provider will participate in the authentication process according to the logic (all/any) set for this combined provider.

      Parameters:
      other - the authentication provider to add
      Returns:
      self-reference for method chaining
    • authenticate

      public CompletableFuture<User> authenticate(@NotNull @NotNull Credentials credentials)
      Description copied from interface: AuthenticationProvider
      Authenticate a user with the given credentials.
      Specified by:
      authenticate in interface AuthenticationProvider<Credentials>
      Parameters:
      credentials - a Credentials object containing the information for authenticating the user.
      Returns:
      the result future