org.springframework.security.provisioning.JdbcUserDetailsManager Java Examples
The following examples show how to use
org.springframework.security.provisioning.JdbcUserDetailsManager.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SecurityConfig.java From Spring-Security-Third-Edition with MIT License | 6 votes |
/** * The parent method from {@link WebSecurityConfigurerAdapter} (public UserDetailsService userDetailsService()) * originally returns a {@link UserDetailsService}, but this needs to be a {@link UserDetailsManager} * UserDetailsManager vs UserDetailsService */ @Bean @Override public UserDetailsManager userDetailsService() { return new JdbcUserDetailsManager() {{ setDataSource(dataSource); // Override default SQL for JdbcUserDetailsManager setGroupAuthoritiesByUsernameQuery(CUSTOM_GROUP_AUTHORITIES_BY_USERNAME_QUERY); setUsersByUsernameQuery(CUSTOM_USERS_BY_USERNAME_QUERY); setAuthoritiesByUsernameQuery(CUSTOM_AUTHORITIES_BY_USERNAME_QUERY); // TODO: This is not available through AuthenticationManagerBuilder setCreateUserSql(CUSTOM_CREATE_USER_SQL); }}; }
Example #2
Source File: SecurityConfig.java From Spring-Security-Third-Edition with MIT License | 6 votes |
/** * The parent method from {@link WebSecurityConfigurerAdapter} (public UserDetailsService userDetailsService()) * originally returns a {@link UserDetailsService}, but this needs to be a {@link UserDetailsManager} * UserDetailsManager vs UserDetailsService */ @Bean @Override public UserDetailsManager userDetailsService() { return new JdbcUserDetailsManager() {{ setDataSource(dataSource); // Override default SQL for JdbcUserDetailsManager setGroupAuthoritiesByUsernameQuery(CUSTOM_GROUP_AUTHORITIES_BY_USERNAME_QUERY); setUsersByUsernameQuery(CUSTOM_USERS_BY_USERNAME_QUERY); setAuthoritiesByUsernameQuery(CUSTOM_AUTHORITIES_BY_USERNAME_QUERY); // TODO: This is not available through AuthenticationManagerBuilder setCreateUserSql(CUSTOM_CREATE_USER_SQL); }}; }
Example #3
Source File: MultiHttpSecurityConfig.java From enhanced-pet-clinic with Apache License 2.0 | 6 votes |
@Override public void init(AuthenticationManagerBuilder auth) throws Exception { //@formatter:off String authoritiesByUsernameQuery = "select username, authority from user_authorities " + "inner join users on user_authorities.user_id = users.id " + "inner join authorities on user_authorities.authority_id = authorities.id " + "where username = ?"; JdbcUserDetailsManager userDetailsService = new JdbcUserDetailsManager(); userDetailsService.setDataSource(dataSource); userDetailsService.setAuthoritiesByUsernameQuery(authoritiesByUsernameQuery); PasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); auth .userDetailsService(userDetailsService) .passwordEncoder(passwordEncoder) .and() .jdbcAuthentication() .authoritiesByUsernameQuery(authoritiesByUsernameQuery) .passwordEncoder(passwordEncoder) .dataSource(dataSource) ; //@formatter:on }
Example #4
Source File: SecurityConfig.java From Spring-Security-Third-Edition with MIT License | 5 votes |
/** * The parent method from {@link WebSecurityConfigurerAdapter} (public UserDetailsService userDetailsService()) * originally returns a {@link UserDetailsService}, but this needs to be a {@link UserDetailsManager} * UserDetailsManager vs UserDetailsService */ @Bean @Override public UserDetailsManager userDetailsService() { return new JdbcUserDetailsManager() {{ setDataSource(dataSource); // Override default SQL for JdbcUserDetailsManager setGroupAuthoritiesByUsernameQuery(CUSTOM_GROUP_AUTHORITIES_BY_USERNAME_QUERY); setUsersByUsernameQuery(CUSTOM_USERS_BY_USERNAME_QUERY); setAuthoritiesByUsernameQuery(CUSTOM_AUTHORITIES_BY_USERNAME_QUERY); // TODO: This is not available through AuthenticationManagerBuilder setCreateUserSql(CUSTOM_CREATE_USER_SQL); }}; }
Example #5
Source File: SecurityConfig.java From Spring-Security-Third-Edition with MIT License | 5 votes |
/** * The parent method from {@link WebSecurityConfigurerAdapter} (public UserDetailsService userDetailsService()) * originally returns a {@link UserDetailsService}, but this needs to be a {@link UserDetailsManager} * UserDetailsManager vs UserDetailsService */ @Bean @Override public UserDetailsManager userDetailsService() { return new JdbcUserDetailsManager() {{ setDataSource(dataSource); }}; }
Example #6
Source File: SecurityConfig.java From Spring-Security-Third-Edition with MIT License | 5 votes |
/** * The parent method from {@link WebSecurityConfigurerAdapter} (public UserDetailsService userDetailsService()) * originally returns a {@link UserDetailsService}, but this needs to be a {@link UserDetailsManager} * UserDetailsManager vs UserDetailsService */ @Bean @Override public UserDetailsManager userDetailsService() { return new JdbcUserDetailsManager() {{ setDataSource(dataSource); // Override default SQL for JdbcUserDetailsManager setGroupAuthoritiesByUsernameQuery(CUSTOM_GROUP_AUTHORITIES_BY_USERNAME_QUERY); setUsersByUsernameQuery(CUSTOM_USERS_BY_USERNAME_QUERY); setAuthoritiesByUsernameQuery(CUSTOM_AUTHORITIES_BY_USERNAME_QUERY); // TODO: This is not available through AuthenticationManagerBuilder setCreateUserSql(CUSTOM_CREATE_USER_SQL); }}; }
Example #7
Source File: SecurityConfig.java From Spring-Security-Third-Edition with MIT License | 5 votes |
/** * The parent method from {@link WebSecurityConfigurerAdapter} (public UserDetailsService userDetailsService()) * originally returns a {@link UserDetailsService}, but this needs to be a {@link UserDetailsManager} * UserDetailsManager vs UserDetailsService */ @Bean @Override public UserDetailsManager userDetailsService() { return new JdbcUserDetailsManager() {{ setDataSource(dataSource); // Override default SQL for JdbcUserDetailsManager setGroupAuthoritiesByUsernameQuery(CUSTOM_GROUP_AUTHORITIES_BY_USERNAME_QUERY); // TODO: This is not available through AuthenticationManagerBuilder setCreateUserSql(CUSTOM_CREATE_USER_SQL); }}; }
Example #8
Source File: SecurityConfig.java From Spring-Security-Third-Edition with MIT License | 5 votes |
/** * The parent method from {@link WebSecurityConfigurerAdapter} (public UserDetailsService userDetailsService()) * originally returns a {@link UserDetailsService}, but this needs to be a {@link UserDetailsManager} * UserDetailsManager vs UserDetailsService */ @Bean @Override public UserDetailsManager userDetailsService() { return new JdbcUserDetailsManager() {{ setDataSource(dataSource); // Override default SQL for JdbcUserDetailsManager setGroupAuthoritiesByUsernameQuery(CUSTOM_GROUP_AUTHORITIES_BY_USERNAME_QUERY); setUsersByUsernameQuery(CUSTOM_USERS_BY_USERNAME_QUERY); setAuthoritiesByUsernameQuery(CUSTOM_AUTHORITIES_BY_USERNAME_QUERY); // TODO: This is not available through AuthenticationManagerBuilder setCreateUserSql(CUSTOM_CREATE_USER_SQL); }}; }
Example #9
Source File: SecurityConfig.java From Spring-Security-Third-Edition with MIT License | 5 votes |
/** * The parent method from {@link WebSecurityConfigurerAdapter} (public UserDetailsService userDetailsService()) * originally returns a {@link UserDetailsService}, but this needs to be a {@link UserDetailsManager} * UserDetailsManager vs UserDetailsService */ @Bean @Override public UserDetailsManager userDetailsService() { return new JdbcUserDetailsManager() {{ setDataSource(dataSource); // Override default SQL for JdbcUserDetailsManager setGroupAuthoritiesByUsernameQuery(CUSTOM_GROUP_AUTHORITIES_BY_USERNAME_QUERY); setUsersByUsernameQuery(CUSTOM_USERS_BY_USERNAME_QUERY); setAuthoritiesByUsernameQuery(CUSTOM_AUTHORITIES_BY_USERNAME_QUERY); // TODO: This is not available through AuthenticationManagerBuilder setCreateUserSql(CUSTOM_CREATE_USER_SQL); }}; }
Example #10
Source File: SecurityConfig.java From Spring-Security-Third-Edition with MIT License | 5 votes |
/** * The parent method from {@link WebSecurityConfigurerAdapter} (public UserDetailsService userDetailsService()) * originally returns a {@link UserDetailsService}, but this needs to be a {@link UserDetailsManager} * UserDetailsManager vs UserDetailsService */ @Bean @Override public UserDetailsManager userDetailsService() { return new JdbcUserDetailsManager() {{ setDataSource(dataSource); // Override default SQL for JdbcUserDetailsManager setGroupAuthoritiesByUsernameQuery(CUSTOM_GROUP_AUTHORITIES_BY_USERNAME_QUERY); setUsersByUsernameQuery(CUSTOM_USERS_BY_USERNAME_QUERY); setAuthoritiesByUsernameQuery(CUSTOM_AUTHORITIES_BY_USERNAME_QUERY); // TODO: This is not available through AuthenticationManagerBuilder setCreateUserSql(CUSTOM_CREATE_USER_SQL); }}; }
Example #11
Source File: MultiHttpSecurityConfig.java From enhanced-pet-clinic with Apache License 2.0 | 5 votes |
@Bean public RememberMeServices getRememberMeServices() { JdbcUserDetailsManager jdbcUserDetailsManager = new JdbcUserDetailsManager(); jdbcUserDetailsManager.setDataSource(dataSource); JdbcTokenRepositoryImpl jdbcTokenRepositoryImpl = new JdbcTokenRepositoryImpl(); jdbcTokenRepositoryImpl.setDataSource(dataSource); PersistentTokenBasedRememberMeServices services = new PersistentTokenBasedRememberMeServices( rememberMeToken, jdbcUserDetailsManager, jdbcTokenRepositoryImpl); services.setParameter(rememberMeParameter); return services; }
Example #12
Source File: SecurityConfig.java From tutorials with MIT License | 4 votes |
@Bean public JdbcUserDetailsManager userDetailsManager() { JdbcUserDetailsManager manager = new JdbcUserDetailsManager(); manager.setDataSource(dataSource); return manager; }
Example #13
Source File: SpringSecurityUserManager.java From tutorials with MIT License | 4 votes |
public SpringSecurityUserManager(ProcessEngineConfigurationImpl processEngineConfiguration, UserDataManager userDataManager, JdbcUserDetailsManager userManager) { super(processEngineConfiguration, userDataManager); this.userManager = userManager; }
Example #14
Source File: SpringSecurityUserManager.java From tutorials with MIT License | 4 votes |
public void setUserManager(JdbcUserDetailsManager userManager) { this.userManager = userManager; }
Example #15
Source File: SpringSecurityGroupManager.java From tutorials with MIT License | 4 votes |
public void setUserManager(JdbcUserDetailsManager userManager) { this.userManager = userManager; }
Example #16
Source File: WebSecurityConfig.java From tutorials with MIT License | 4 votes |
@Bean public UserDetailsService jdbcUserDetailsService(DataSource dataSource) { JdbcUserDetailsManager manager = new JdbcUserDetailsManager(); manager.setDataSource(dataSource); return manager; }