public class AuthenticationManagerBuilder extends AbstractConfiguredSecurityBuilder<AuthenticationManager,AuthenticationManagerBuilder> implements ProviderManagerBuilder<AuthenticationManagerBuilder>
SecurityBuilder used to create an AuthenticationManager.
Allows for easily building in memory authentication, LDAP authentication,
JDBC based authentication, adding UserDetailsService, and adding
AuthenticationProvider's.| Constructor and Description |
|---|
AuthenticationManagerBuilder(ObjectPostProcessor<Object> objectPostProcessor)
Creates a new instance
|
apply, apply, beforeConfigure, beforeInit, doBuild, getConfigurer, getConfigurers, getOrBuild, getSharedObject, getSharedObjects, objectPostProcessor, postProcess, removeConfigurer, removeConfigurers, setSharedObjectbuild, getObjectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitbuildpublic AuthenticationManagerBuilder(ObjectPostProcessor<Object> objectPostProcessor)
the - ObjectPostProcessor instance to use.public AuthenticationManagerBuilder parentAuthenticationManager(AuthenticationManager authenticationManager)
AuthenticationManager that will be
tried if this AuthenticationManager was unable to attempt to
authenticate the provided Authentication.authenticationManager - the AuthenticationManager that should be used if the
current AuthenticationManager was unable to attempt to
authenticate the provided Authentication.AuthenticationManagerBuilder for further adding types
of authenticationpublic AuthenticationManagerBuilder authenticationEventPublisher(AuthenticationEventPublisher eventPublisher)
AuthenticationEventPublishereventPublisher - the AuthenticationEventPublisher to useAuthenticationManagerBuilder for further
customizationspublic AuthenticationManagerBuilder eraseCredentials(boolean eraseCredentials)
eraseCredentials - true if AuthenticationManager should clear the
credentials from the Authentication object after
authenticatingAuthenticationManagerBuilder for further customizationspublic InMemoryUserDetailsManagerConfigurer<AuthenticationManagerBuilder> inMemoryAuthentication() throws Exception
AuthenticationManagerBuilder
and return a InMemoryUserDetailsManagerConfigurer to
allow customization of the in memory authentication.
This method also ensure that a UserDetailsService is available
for the getDefaultUserDetailsService() method. Note that
additional UserDetailsService's may override this
UserDetailsService as the default.
InMemoryUserDetailsManagerConfigurer to allow
customization of the in memory authenticationException - if an error occurs when adding the in memory authenticationpublic JdbcUserDetailsManagerConfigurer<AuthenticationManagerBuilder> jdbcAuthentication() throws Exception
AuthenticationManagerBuilder and
return a JdbcUserDetailsManagerConfigurer to allow customization
of the JDBC authentication.
When using with a persistent data store, it is best to add users external of configuration using something like Flyway or Liquibase to create the schema and adding users to ensure these steps are only done once and that the optimal SQL is used.
This method also ensure that a UserDetailsService is available
for the getDefaultUserDetailsService() method. Note that
additional UserDetailsService's may override this
UserDetailsService as the default. See the User Schema section of the reference for the default schema.
JdbcUserDetailsManagerConfigurer to allow customization
of the JDBC authenticationException - if an error occurs when adding the JDBC authenticationpublic <T extends UserDetailsService> DaoAuthenticationConfigurer<AuthenticationManagerBuilder,T> userDetailsService(T userDetailsService) throws Exception
UserDetailsService that
is passed in. It then returns a DaoAuthenticationConfigurer to
allow customization of the authentication.
This method also ensure that the UserDetailsService is available
for the getDefaultUserDetailsService() method. Note that
additional UserDetailsService's may override this
UserDetailsService as the default.
DaoAuthenticationConfigurer to allow customization
of the DAO authenticationException - if an error occurs when adding the UserDetailsService
based authenticationpublic LdapAuthenticationProviderConfigurer<AuthenticationManagerBuilder> ldapAuthentication() throws Exception
AuthenticationManagerBuilder and
return a LdapAuthenticationProviderConfigurer to allow
customization of the LDAP authentication.
This method does NOT ensure that a UserDetailsService is
available for the getDefaultUserDetailsService() method.
LdapAuthenticationProviderConfigurer to allow
customization of the LDAP authenticationException - if an error occurs when adding the LDAP authenticationpublic AuthenticationManagerBuilder authenticationProvider(AuthenticationProvider authenticationProvider)
AuthenticationProvider
that is passed in. Since the AuthenticationProvider
implementation is unknown, all customizations must be done externally and
the AuthenticationManagerBuilder is returned immediately.
This method does NOT ensure that the UserDetailsService is
available for the getDefaultUserDetailsService() method.
authenticationProvider in interface ProviderManagerBuilder<AuthenticationManagerBuilder>AuthenticationManagerBuilder to allow further authentication
to be provided to the AuthenticationManagerBuilderException - if an error occurs when adding the AuthenticationProviderprotected ProviderManager performBuild() throws Exception
AbstractConfiguredSecurityBuilderperformBuild in class AbstractConfiguredSecurityBuilder<AuthenticationManager,AuthenticationManagerBuilder>Exceptionpublic boolean isConfigured()
AuthenticationManagerBuilder is configured to
build a non null AuthenticationManager. This means that either a
non-null parent is specified or at least one
AuthenticationProvider has been specified.
When using SecurityConfigurer instances, the
AuthenticationManagerBuilder will not be configured until the
SecurityConfigurer.configure(SecurityBuilder) methods. This means
a SecurityConfigurer that is last could check this method and
provide a default configuration in the
SecurityConfigurer.configure(SecurityBuilder) method.
public UserDetailsService getDefaultUserDetailsService()
UserDetailsService for the
AuthenticationManagerBuilder. The result may be null in some
circumstances.UserDetailsService for the
AuthenticationManagerBuilder