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 theProviderManagerBuilder
that 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 theDataSource
to be used.protected org.springframework.jdbc.datasource.init.DatabasePopulator
Gets theUserDetailsService
that is used with theDaoAuthenticationProvider
groupAuthoritiesByUsername
(String query) An SQL statement to query user's group authorities given a username.protected void
Populates 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 theUserCache
to 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, withUser
Methods inherited from class org.springframework.security.config.annotation.authentication.configurers.userdetails.UserDetailsServiceConfigurer
configure
Methods inherited from class org.springframework.security.config.annotation.authentication.configurers.userdetails.AbstractDaoAuthenticationConfigurer
passwordEncoder, userDetailsPasswordManager, withObjectPostProcessor, withObjectPostProcessor
Methods 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 theDataSource
to be used. This is the only required attribute.- Parameters:
dataSource
- theDataSource
to be used. Cannot be null.- Returns:
- The
JdbcUserDetailsManagerConfigurer
used 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
JdbcUserDetailsManagerConfigurer
used 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
JdbcUserDetailsManagerConfigurer
used 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
JdbcUserDetailsManagerConfigurer
used 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
JdbcUserDetailsManagerConfigurer
used for additional customizations
-
userCache
Defines theUserCache
to use- Parameters:
userCache
- theUserCache
to use- Returns:
- the
JdbcUserDetailsManagerConfigurer
for further customizations
-
initUserDetailsService
Description copied from class:UserDetailsManagerConfigurer
Populates the users that have been added.- Overrides:
initUserDetailsService
in classUserDetailsManagerConfigurer<B extends ProviderManagerBuilder<B>,
JdbcUserDetailsManagerConfigurer<B extends ProviderManagerBuilder<B>>> - Throws:
Exception
-
getUserDetailsService
Description copied from class:AbstractDaoAuthenticationConfigurer
Gets theUserDetailsService
that is used with theDaoAuthenticationProvider
- Overrides:
getUserDetailsService
in classAbstractDaoAuthenticationConfigurer<B extends ProviderManagerBuilder<B>,
JdbcUserDetailsManagerConfigurer<B extends ProviderManagerBuilder<B>>, UserDetailsManager> - Returns:
- the
UserDetailsService
that is used with theDaoAuthenticationProvider
-
withDefaultSchema
Populates the default schema that allows users and authorities to be stored.- Returns:
- The
JdbcUserDetailsManagerConfigurer
used for additional customizations
-
getDatabasePopulator
protected org.springframework.jdbc.datasource.init.DatabasePopulator getDatabasePopulator()
-