Class JdbcUserDetailsManagerConfigurer<B extends ProviderManagerBuilder<B>>
java.lang.Object
org.springframework.security.config.annotation.SecurityConfigurerAdapter<AuthenticationManager,B>
org.springframework.security.config.annotation.authentication.configurers.userdetails.UserDetailsAwareConfigurer<B,U>
org.springframework.security.config.annotation.authentication.configurers.userdetails.AbstractDaoAuthenticationConfigurer<B,C,U>
org.springframework.security.config.annotation.authentication.configurers.userdetails.UserDetailsServiceConfigurer<B,C,UserDetailsManager>
org.springframework.security.config.annotation.authentication.configurers.provisioning.UserDetailsManagerConfigurer<B,JdbcUserDetailsManagerConfigurer<B>>
org.springframework.security.config.annotation.authentication.configurers.provisioning.JdbcUserDetailsManagerConfigurer<B>
- Type Parameters:
B- the type of theProviderManagerBuilderthat is being configured
- All Implemented Interfaces:
SecurityConfigurer<AuthenticationManager,B>
public class JdbcUserDetailsManagerConfigurer<B extends ProviderManagerBuilder<B>>
extends UserDetailsManagerConfigurer<B,JdbcUserDetailsManagerConfigurer<B>>
Configures an
AuthenticationManagerBuilder
to have JDBC authentication. It also allows easily adding users to the database used
for authentication and setting up the schema.
The only required method is the dataSource(javax.sql.DataSource) all other
methods have reasonable defaults.
- Since:
- 3.2
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.security.config.annotation.authentication.configurers.provisioning.UserDetailsManagerConfigurer
UserDetailsManagerConfigurer.UserDetailsBuilder -
Constructor Summary
ConstructorsConstructorDescription -
Method Summary
Modifier and TypeMethodDescriptionauthoritiesByUsernameQuery(String query) Sets the query to be used for finding a user's authorities by their username.dataSource(DataSource dataSource) Populates theDataSourceto be used.protected org.springframework.jdbc.datasource.init.DatabasePopulatorGets theUserDetailsServicethat is used with theDaoAuthenticationProvidergroupAuthoritiesByUsername(String query) An SQL statement to query user's group authorities given a username.protected voidPopulates the users that have been added.rolePrefix(String rolePrefix) A non-empty string prefix that will be added to role strings loaded from persistent storage (default is "").Defines theUserCacheto useusersByUsernameQuery(String query) Sets the query to be used for finding a user by their username.Populates the default schema that allows users and authorities to be stored.Methods inherited from class org.springframework.security.config.annotation.authentication.configurers.provisioning.UserDetailsManagerConfigurer
withUser, withUser, withUserMethods inherited from class org.springframework.security.config.annotation.authentication.configurers.userdetails.UserDetailsServiceConfigurer
configureMethods inherited from class org.springframework.security.config.annotation.authentication.configurers.userdetails.AbstractDaoAuthenticationConfigurer
passwordEncoder, userDetailsPasswordManager, withObjectPostProcessor, withObjectPostProcessorMethods inherited from class org.springframework.security.config.annotation.SecurityConfigurerAdapter
addObjectPostProcessor, addObjectPostProcessor, and, getBuilder, init, postProcess, setBuilder
-
Constructor Details
-
JdbcUserDetailsManagerConfigurer
-
JdbcUserDetailsManagerConfigurer
public JdbcUserDetailsManagerConfigurer()
-
-
Method Details
-
dataSource
Populates theDataSourceto be used. This is the only required attribute.- Parameters:
dataSource- theDataSourceto be used. Cannot be null.- Returns:
- The
JdbcUserDetailsManagerConfigurerused for additional customizations
-
usersByUsernameQuery
Sets the query to be used for finding a user by their username. For example:select username,password,enabled from users where username = ?- Parameters:
query- The query to use for selecting the username, password, and if the user is enabled by username. Must contain a single parameter for the username.- Returns:
- The
JdbcUserDetailsManagerConfigurerused for additional customizations
-
authoritiesByUsernameQuery
Sets the query to be used for finding a user's authorities by their username. For example:select username,authority from authorities where username = ?- Parameters:
query- The query to use for selecting the username, authority by username. Must contain a single parameter for the username.- Returns:
- The
JdbcUserDetailsManagerConfigurerused for additional customizations
-
groupAuthoritiesByUsername
An SQL statement to query user's group authorities given a username. For example:select g.id, g.group_name, ga.authority from groups g, group_members gm, group_authorities ga where gm.username = ? and g.id = ga.group_id and g.id = gm.group_id- Parameters:
query- The query to use for selecting the authorities by group. Must contain a single parameter for the username.- Returns:
- The
JdbcUserDetailsManagerConfigurerused for additional customizations
-
rolePrefix
A non-empty string prefix that will be added to role strings loaded from persistent storage (default is "").- Parameters:
rolePrefix-- Returns:
- The
JdbcUserDetailsManagerConfigurerused for additional customizations
-
userCache
Defines theUserCacheto use- Parameters:
userCache- theUserCacheto use- Returns:
- the
JdbcUserDetailsManagerConfigurerfor further customizations
-
initUserDetailsService
Description copied from class:UserDetailsManagerConfigurerPopulates the users that have been added.- Overrides:
initUserDetailsServicein classUserDetailsManagerConfigurer<B extends ProviderManagerBuilder<B>,JdbcUserDetailsManagerConfigurer<B extends ProviderManagerBuilder<B>>> - Throws:
Exception
-
getUserDetailsService
Description copied from class:AbstractDaoAuthenticationConfigurerGets theUserDetailsServicethat is used with theDaoAuthenticationProvider- Overrides:
getUserDetailsServicein classAbstractDaoAuthenticationConfigurer<B extends ProviderManagerBuilder<B>,JdbcUserDetailsManagerConfigurer<B extends ProviderManagerBuilder<B>>, UserDetailsManager> - Returns:
- the
UserDetailsServicethat is used with theDaoAuthenticationProvider
-
withDefaultSchema
Populates the default schema that allows users and authorities to be stored.- Returns:
- The
JdbcUserDetailsManagerConfigurerused for additional customizations
-
getDatabasePopulator
protected org.springframework.jdbc.datasource.init.DatabasePopulator getDatabasePopulator()
-