Class DefaultAuthenticationManager
java.lang.Object
org.tentackle.session.auth.DefaultAuthenticationManager
- All Implemented Interfaces:
AuthenticationManager
@Service(AuthenticationManager.class)
public class DefaultAuthenticationManager
extends Object
implements AuthenticationManager
The default authentication manager.
Collects all AuthenticationProviders along the classpath and orders them by
priority, then by class name, so that the chain is
deterministic regardless of the order in which the modules happen to be discovered.
- Author:
- harald
-
Constructor Summary
ConstructorsModifierConstructorDescriptionCreates an authentication manager.
Collects all AuthenticationProvider services.protectedDefaultAuthenticationManager(List<AuthenticationProvider> providers) Creates an authentication manager for an explicit chain.
Useful for applications that wire their providers themselves, and for tests. -
Method Summary
Modifier and TypeMethodDescriptionauthenticate(Credentials credentials) Authenticates the credentials presented by a client.protected static List<AuthenticationProvider> Collects all authentication providers along the classpath.Gets the provider chain in the order it is asked.protected voidresolveUser(Authentication authentication) Determines the application's user for a proven identity.
-
Constructor Details
-
DefaultAuthenticationManager
public DefaultAuthenticationManager()Creates an authentication manager.
Collects all AuthenticationProvider services. -
DefaultAuthenticationManager
Creates an authentication manager for an explicit chain.
Useful for applications that wire their providers themselves, and for tests.The chain is copied and frozen:
authenticate(Credentials)iterates it on every login, from every request thread, and must never see it change underneath.- Parameters:
providers- the providers, in any order
-
-
Method Details
-
discoverProviders
Collects all authentication providers along the classpath.- Returns:
- the providers, never null
-
getProviders
Description copied from interface:AuthenticationManagerGets the provider chain in the order it is asked.The chain is fixed once the manager is created, since
AuthenticationManager.authenticate(Credentials)iterates it concurrently. Implementations must therefore not hand out a list a caller could modify.- Specified by:
getProvidersin interfaceAuthenticationManager- Returns:
- the providers, never null, unmodifiable
-
authenticate
Description copied from interface:AuthenticationManagerAuthenticates the credentials presented by a client.- Specified by:
authenticatein interfaceAuthenticationManager- Parameters:
credentials- the credentials, null if the client presented none- Returns:
- the proven identity, never null
-
resolveUser
Determines the application's user for a proven identity.Providers that know the application's user (such as a password provider that looked it up anyway) set the ids themselves. For all others the application's
UserResolveris applied.- Parameters:
authentication- the proven identity
-