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(String query)
Sets the query to be used for finding a user's authorities by their username.
|
JdbcUserDetailsManagerConfigurer<B> |
dataSource(DataSource dataSource)
Populates the
DataSource to be used. |
protected DatabasePopulator |
getDatabasePopulator() |
JdbcUserDetailsManager |
getUserDetailsService()
Gets the
UserDetailsService that is used with the
DaoAuthenticationProvider |
JdbcUserDetailsManagerConfigurer<B> |
groupAuthoritiesByUsername(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(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(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. |
withUser
configure
addObjectPostProcessor, and, getBuilder, init, postProcess, setBuilder
public JdbcUserDetailsManagerConfigurer(JdbcUserDetailsManager manager)
public JdbcUserDetailsManagerConfigurer()
public JdbcUserDetailsManagerConfigurer<B> dataSource(DataSource dataSource) throws Exception
DataSource
to be used. This is the only required attribute.dataSource
- the DataSource
to be used. Cannot be null.Exception
public JdbcUserDetailsManagerConfigurer<B> usersByUsernameQuery(String query) throws 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
customizationsException
public JdbcUserDetailsManagerConfigurer<B> authoritiesByUsernameQuery(String query) throws 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
customizationsException
public JdbcUserDetailsManagerConfigurer<B> groupAuthoritiesByUsername(String query) throws 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
customizationsException
public JdbcUserDetailsManagerConfigurer<B> rolePrefix(String rolePrefix) throws Exception
rolePrefix
- Exception
public JdbcUserDetailsManagerConfigurer<B> userCache(UserCache userCache) throws Exception
UserCache
to useuserCache
- the UserCache
to useJdbcUserDetailsManagerConfigurer
for further customizationsException
protected void initUserDetailsService() throws Exception
UserDetailsManagerConfigurer
initUserDetailsService
in class UserDetailsManagerConfigurer<B extends ProviderManagerBuilder<B>,JdbcUserDetailsManagerConfigurer<B extends ProviderManagerBuilder<B>>>
Exception
public JdbcUserDetailsManager getUserDetailsService()
UserDetailsService
that is used with the
DaoAuthenticationProvider
UserDetailsService
that is used with the
DaoAuthenticationProvider
public JdbcUserDetailsManagerConfigurer<B> withDefaultSchema()
JdbcUserDetailsManagerConfigurer
used for additional
customizationsprotected 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 is to use plain text.passwordEncoder
- The PasswordEncoder
to use.public C passwordEncoder(PasswordEncoder passwordEncoder)
PasswordEncoder
to use
with the DaoAuthenticationProvider
. The default is is to use plain text.passwordEncoder
- The
PasswordEncoder
to
use.SecurityConfigurer
for further customizations