Class DelegatingAuthenticationProvider
- java.lang.Object
-
- io.micronaut.security.authentication.providers.DelegatingAuthenticationProvider
-
- All Implemented Interfaces:
AuthenticationProvider
@Requires(beans={UserFetcher.class,PasswordEncoder.class,AuthoritiesFetcher.class}) @Singleton public class DelegatingAuthenticationProvider extends java.lang.Object implements AuthenticationProviderAuthenticationProvider typically used with a persistence mechanism such as a DB.- Since:
- 1.0
- Author:
- Sergio del Amo
-
-
Field Summary
Fields Modifier and Type Field Description protected AuthoritiesFetcherauthoritiesFetcherprotected PasswordEncoderpasswordEncoderprotected UserFetcheruserFetcher
-
Constructor Summary
Constructors Constructor Description DelegatingAuthenticationProvider(UserFetcher userFetcher, PasswordEncoder passwordEncoder, AuthoritiesFetcher authoritiesFetcher)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.reactivestreams.Publisher<AuthenticationResponse>authenticate(AuthenticationRequest authenticationRequest)Attempts to authenticate a user.protected org.reactivestreams.Publisher<AuthenticationResponse>createSuccessfulAuthenticationResponse(AuthenticationRequest authenticationRequest, UserState user)Create a successfulAuthenticationResponse.protected AuthenticationResponsecreateSuccessfulAuthenticationResponse(AuthenticationRequest authenticationRequest, UserState user, java.util.List<java.lang.String> authorities)Create a successfulAuthenticationResponse.protected org.reactivestreams.Publisher<UserState>fetchUserState(AuthenticationRequest authenticationRequest)
-
-
-
Field Detail
-
userFetcher
protected final UserFetcher userFetcher
-
passwordEncoder
protected final PasswordEncoder passwordEncoder
-
authoritiesFetcher
protected final AuthoritiesFetcher authoritiesFetcher
-
-
Constructor Detail
-
DelegatingAuthenticationProvider
public DelegatingAuthenticationProvider(UserFetcher userFetcher, PasswordEncoder passwordEncoder, AuthoritiesFetcher authoritiesFetcher)
- Parameters:
userFetcher- Fetches users from persistencepasswordEncoder- Collaborator which checks if a raw password matches an encoded passwordauthoritiesFetcher- Fetches authorities for a particular user
-
-
Method Detail
-
authenticate
public org.reactivestreams.Publisher<AuthenticationResponse> authenticate(AuthenticationRequest authenticationRequest)
Attempts to authenticate a user.- Specified by:
authenticatein interfaceAuthenticationProvider- Parameters:
authenticationRequest- The authentication request data- Returns:
- An AuthenticationResponse object which encapsulates the authentication result.
-
fetchUserState
protected org.reactivestreams.Publisher<UserState> fetchUserState(AuthenticationRequest authenticationRequest)
- Parameters:
authenticationRequest- The authentication request data- Returns:
UserState. A representation of the state of a user after authentication.
-
createSuccessfulAuthenticationResponse
protected org.reactivestreams.Publisher<AuthenticationResponse> createSuccessfulAuthenticationResponse(AuthenticationRequest authenticationRequest, UserState user)
Create a successfulAuthenticationResponse.- Parameters:
authenticationRequest- The authentication request datauser- A representation of the state of a user after authentication.- Returns:
- An AuthenticationResponse object which encapsulates a successful authentication result.
-
createSuccessfulAuthenticationResponse
protected AuthenticationResponse createSuccessfulAuthenticationResponse(AuthenticationRequest authenticationRequest, UserState user, java.util.List<java.lang.String> authorities)
Create a successfulAuthenticationResponse.- Parameters:
authenticationRequest- The authentication request datauser- A representation of the state of a user after authentication.authorities- A list of authorities granted to authenticated user.- Returns:
- An AuthenticationResponse object which encapsulates a successful authentication result.
-
-