B - the type of the ProviderManagerBuilder that is being configuredpublic class JdbcUserDetailsManagerConfigurer<B extends ProviderManagerBuilder<B>> extends UserDetailsManagerConfigurer<B,JdbcUserDetailsManagerConfigurer<B>>
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.
UserDetailsManagerConfigurer.UserDetailsBuilder| Constructor and Description |
|---|
JdbcUserDetailsManagerConfigurer() |
JdbcUserDetailsManagerConfigurer(JdbcUserDetailsManager manager) |
| Modifier and Type | Method and Description |
|---|---|
JdbcUserDetailsManagerConfigurer<B> |
authoritiesByUsernameQuery(java.lang.String query)
Sets the query to be used for finding a user's authorities by their username.
|
JdbcUserDetailsManagerConfigurer<B> |
dataSource(javax.sql.DataSource dataSource)
Populates the
DataSource to be used. |
protected org.springframework.jdbc.datasource.init.DatabasePopulator |
getDatabasePopulator() |
JdbcUserDetailsManager |
getUserDetailsService()
Gets the
UserDetailsService that is used with the
DaoAuthenticationProvider |
JdbcUserDetailsManagerConfigurer<B> |
groupAuthoritiesByUsername(java.lang.String query)
An SQL statement to query user's group authorities given a username.
|
protected void |
initUserDetailsService()
Populates the users that have been added.
|
C |
passwordEncoder(PasswordEncoder passwordEncoder)
Allows specifying the
PasswordEncoder to use with the
DaoAuthenticationProvider. |
C |
passwordEncoder(PasswordEncoder passwordEncoder)
Allows specifying the
PasswordEncoder to use
with the DaoAuthenticationProvider. |
JdbcUserDetailsManagerConfigurer<B> |
rolePrefix(java.lang.String rolePrefix)
A non-empty string prefix that will be added to role strings loaded from persistent
storage (default is "").
|
JdbcUserDetailsManagerConfigurer<B> |
userCache(UserCache userCache)
Defines the
UserCache to use |
JdbcUserDetailsManagerConfigurer<B> |
usersByUsernameQuery(java.lang.String query)
Sets the query to be used for finding a user by their username.
|
JdbcUserDetailsManagerConfigurer<B> |
withDefaultSchema()
Populates the default schema that allows users and authorities to be stored.
|
C |
withObjectPostProcessor(ObjectPostProcessor<?> objectPostProcessor)
Adds an
ObjectPostProcessor for this class. |
withUserconfigureaddObjectPostProcessor, and, getBuilder, init, postProcess, setBuilderpublic JdbcUserDetailsManagerConfigurer(JdbcUserDetailsManager manager)
public JdbcUserDetailsManagerConfigurer()
public JdbcUserDetailsManagerConfigurer<B> dataSource(javax.sql.DataSource dataSource) throws java.lang.Exception
DataSource to be used. This is the only required attribute.dataSource - the DataSource to be used. Cannot be null.java.lang.Exceptionpublic JdbcUserDetailsManagerConfigurer<B> usersByUsernameQuery(java.lang.String query) throws java.lang.Exception
select username,password,enabled from users where username = ?
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.JdbcUserDetailsManagerConfigurer used for additional
customizationsjava.lang.Exceptionpublic JdbcUserDetailsManagerConfigurer<B> authoritiesByUsernameQuery(java.lang.String query) throws java.lang.Exception
select username,authority from authorities where username = ?
query - The query to use for selecting the username, authority by username.
Must contain a single parameter for the username.JdbcUserDetailsManagerConfigurer used for additional
customizationsjava.lang.Exceptionpublic JdbcUserDetailsManagerConfigurer<B> groupAuthoritiesByUsername(java.lang.String query) throws java.lang.Exception
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
query - The query to use for selecting the authorities by group. Must contain
a single parameter for the username.JdbcUserDetailsManagerConfigurer used for additional
customizationsjava.lang.Exceptionpublic JdbcUserDetailsManagerConfigurer<B> rolePrefix(java.lang.String rolePrefix) throws java.lang.Exception
rolePrefix - java.lang.Exceptionpublic JdbcUserDetailsManagerConfigurer<B> userCache(UserCache userCache) throws java.lang.Exception
UserCache to useuserCache - the UserCache to useJdbcUserDetailsManagerConfigurer for further customizationsjava.lang.Exceptionprotected void initUserDetailsService()
throws java.lang.Exception
UserDetailsManagerConfigurerinitUserDetailsService in class UserDetailsManagerConfigurer<B extends ProviderManagerBuilder<B>,JdbcUserDetailsManagerConfigurer<B extends ProviderManagerBuilder<B>>>java.lang.Exceptionpublic JdbcUserDetailsManager getUserDetailsService()
UserDetailsService that is used with the
DaoAuthenticationProviderUserDetailsService that is used with the
DaoAuthenticationProviderpublic JdbcUserDetailsManagerConfigurer<B> withDefaultSchema()
JdbcUserDetailsManagerConfigurer used for additional
customizationsprotected org.springframework.jdbc.datasource.init.DatabasePopulator getDatabasePopulator()
public C withObjectPostProcessor(ObjectPostProcessor<?> objectPostProcessor)
ObjectPostProcessor for this class.objectPostProcessor - AbstractDaoAuthenticationConfigurer for further customizationspublic C passwordEncoder(PasswordEncoder passwordEncoder)
PasswordEncoder to use with the
DaoAuthenticationProvider. The default is to use plain text.passwordEncoder - The PasswordEncoder to use.public C passwordEncoder(PasswordEncoder passwordEncoder)
PasswordEncoder to use
with the DaoAuthenticationProvider. The default is to use plain text.passwordEncoder - The
PasswordEncoder to
use.SecurityConfigurer for further customizations