Module one.jpro.platform.auth.core
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBasicAuthenticationProvider(@NotNull UserManager userManager, @Nullable Set<String> roles, @Nullable Map<String, Object> attributes) Constructs a newBasicAuthenticationProviderwith specified roles and attributes. -
Method Summary
Modifier and TypeMethodDescriptionauthenticate(@NotNull UsernamePasswordCredentials credentials) Authenticates the user based on the providedUsernamePasswordCredentials.Gets the attributes associated with this authentication provider.@NotNull StringGets the authorization path URI for basic authentication.getRoles()Gets the set of roles associated with this authentication provider.@NotNull UserManagerGets the user manager associated with this authentication provider.voidsetAttributes(@Nullable Map<String, Object> attributes) Sets the attributes to be associated with this authentication provider.voidsetAuthorizationPath(@NotNull String authorizationPath) Sets the authorization path for basic authentication.voidSets the roles to be associated with this authentication provider.voidsetUserManager(@NotNull UserManager userManager) Sets the user manager to be associated with this authentication provider.
-
Field Details
-
DEFAULT_AUTHORIZATION_PATH
- See Also:
-
-
Constructor Details
-
BasicAuthenticationProvider
public BasicAuthenticationProvider(@NotNull @NotNull UserManager userManager, @Nullable @Nullable Set<String> roles, @Nullable @Nullable Map<String, Object> attributes) Constructs a newBasicAuthenticationProviderwith specified roles and attributes.- Parameters:
userManager- the user manager to be used for authenticationroles- the set of roles to be associated with the authenticated user, may benullattributes- the map of attributes to be associated with the authenticated user, may benull
-
-
Method Details
-
authenticate
public CompletableFuture<User> authenticate(@NotNull @NotNull UsernamePasswordCredentials credentials) throws AuthenticationException, CredentialValidationException Authenticates the user based on the providedUsernamePasswordCredentials.- Specified by:
authenticatein interfaceAuthenticationProvider<UsernamePasswordCredentials>- Parameters:
credentials- the credentials containing the username and password- Returns:
- a
CompletableFuturethat, when completed, provides the authenticatedUser - Throws:
CredentialValidationException- if the credentials are not validAuthenticationException
-
getUserManager
Gets the user manager associated with this authentication provider.- Returns:
- the user manager
-
setUserManager
Sets the user manager to be associated with this authentication provider.- Parameters:
userManager- the user manager
-
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
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
Gets the set of roles associated with this authentication provider.- Returns:
- the set of roles, may be
null
-
setRoles
Sets the roles to be associated with this authentication provider.- Parameters:
roles- the set of roles, may benull
-
getAttributes
Gets the attributes associated with this authentication provider.- Returns:
- the attributes, may be
null
-
setAttributes
Sets the attributes to be associated with this authentication provider.- Parameters:
attributes- the map of attributes, may benull
-