org.springframework.security.provisioning.UserDetailsManager Java Examples

The following examples show how to use org.springframework.security.provisioning.UserDetailsManager. 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: DefaultCalendarService.java    From Spring-Security-Third-Edition with MIT License 6 votes vote down vote up
@Autowired
public DefaultCalendarService(final EventDao eventDao,
                              final CalendarUserDao userDao,
                              final UserDetailsManager userDetailsManager) {
    if (eventDao == null) {
        throw new IllegalArgumentException("eventDao cannot be null");
    }
    if (userDao == null) {
        throw new IllegalArgumentException("userDao cannot be null");
    }
    if (userDetailsManager == null) {
        throw new IllegalArgumentException("userDetailsManager cannot be null");
    }
    this.eventDao = eventDao;
    this.userDao = userDao;
    this.userDetailsManager = userDetailsManager;
}
 
Example #2
Source File: DefaultCalendarService.java    From Spring-Security-Third-Edition with MIT License 6 votes vote down vote up
@Autowired
public DefaultCalendarService(final EventDao eventDao,
                              final CalendarUserDao userDao,
                              final UserDetailsManager userDetailsManager) {
    if (eventDao == null) {
        throw new IllegalArgumentException("eventDao cannot be null");
    }
    if (userDao == null) {
        throw new IllegalArgumentException("userDao cannot be null");
    }
    if (userDetailsManager == null) {
        throw new IllegalArgumentException("userDetailsManager cannot be null");
    }

    this.eventDao = eventDao;
    this.userDao = userDao;
    this.userDetailsManager = userDetailsManager;
}
 
Example #3
Source File: SecurityConfig.java    From Spring-Security-Third-Edition with MIT License 6 votes vote down vote up
/**
 * 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 #4
Source File: SecurityConfig.java    From Spring-Security-Third-Edition with MIT License 6 votes vote down vote up
/**
 * 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 vote down vote up
/**
 * 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 #6
Source File: DefaultCalendarService.java    From maven-framework-project with MIT License 5 votes vote down vote up
@Autowired
public DefaultCalendarService(EventDao eventDao, CalendarUserDao userDao, UserDetailsManager userDetailsManager) {
    if (eventDao == null) {
        throw new IllegalArgumentException("eventDao cannot be null");
    }
    if (userDao == null) {
        throw new IllegalArgumentException("userDao cannot be null");
    }
    if (userDetailsManager == null) {
        throw new IllegalArgumentException("userDetailsManager cannot be null");
    }
    this.eventDao = eventDao;
    this.userDao = userDao;
    this.userDetailsManager = userDetailsManager;
}
 
Example #7
Source File: WebAnnoSecurity.java    From webanno with Apache License 2.0 5 votes vote down vote up
@Bean
public UserDetailsManager userDetailsService()
{
    OverridableUserDetailsManager manager = new OverridableUserDetailsManager();
    manager.setDataSource(dataSource);
    manager.setAuthenticationManager(authenticationManager);
    return manager;
}
 
Example #8
Source File: SecurityConfig.java    From Spring-Security-Third-Edition with MIT License 5 votes vote down vote up
/**
 * 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() {
    InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager();
    manager.createUser(User.withUsername("user").password("password").roles("USER").build());
    manager.createUser(User.withUsername("admin").password("admin").roles("USER", "ADMIN").build());
    manager.createUser(User.withUsername("[email protected]").password("user1").roles("USER").build());
    manager.createUser(User.withUsername("[email protected]").password("admin1").roles("USER", "ADMIN").build());
    return manager;
}
 
Example #9
Source File: SecurityConfig.java    From Spring-Security-Third-Edition with MIT License 5 votes vote down vote up
/**
 * 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() {
    InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager();
    manager.createUser(User.withUsername("user").password("password").roles("USER").build());
    manager.createUser(User.withUsername("admin").password("admin").roles("USER", "ADMIN").build());
    manager.createUser(User.withUsername("[email protected]").password("user1").roles("USER").build());
    manager.createUser(User.withUsername("[email protected]").password("admin1").roles("USER", "ADMIN").build());
    return manager;
}
 
Example #10
Source File: SecurityConfig.java    From Spring-Security-Third-Edition with MIT License 5 votes vote down vote up
/**
 * 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: DefaultCalendarService.java    From Spring-Security-Third-Edition with MIT License 5 votes vote down vote up
@Autowired
public DefaultCalendarService(EventDao eventDao, CalendarUserDao userDao, UserDetailsManager userDetailsManager) {
    if (eventDao == null) {
        throw new IllegalArgumentException("eventDao cannot be null");
    }
    if (userDao == null) {
        throw new IllegalArgumentException("userDao cannot be null");
    }
    if (userDetailsManager == null) {
        throw new IllegalArgumentException("userDetailsManager cannot be null");
    }
    this.eventDao = eventDao;
    this.userDao = userDao;
    this.userDetailsManager = userDetailsManager;
}
 
Example #12
Source File: SecurityConfig.java    From Spring-Security-Third-Edition with MIT License 5 votes vote down vote up
/**
 * 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 #13
Source File: SecurityConfig.java    From Spring-Security-Third-Edition with MIT License 5 votes vote down vote up
/**
 * 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 #14
Source File: DefaultCalendarService.java    From Spring-Security-Third-Edition with MIT License 5 votes vote down vote up
@Autowired
public DefaultCalendarService(EventDao eventDao, CalendarUserDao userDao, UserDetailsManager userDetailsManager) {
    if (eventDao == null) {
        throw new IllegalArgumentException("eventDao cannot be null");
    }
    if (userDao == null) {
        throw new IllegalArgumentException("userDao cannot be null");
    }
    if (userDetailsManager == null) {
        throw new IllegalArgumentException("userDetailsManager cannot be null");
    }
    this.eventDao = eventDao;
    this.userDao = userDao;
    this.userDetailsManager = userDetailsManager;
}
 
Example #15
Source File: SecurityConfig.java    From Spring-Security-Third-Edition with MIT License 5 votes vote down vote up
/**
 * 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 #16
Source File: SecurityConfig.java    From Spring-Security-Third-Edition with MIT License 5 votes vote down vote up
/**
 * 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 #17
Source File: DefaultCalendarService.java    From Spring-Security-Third-Edition with MIT License 5 votes vote down vote up
@Autowired
public DefaultCalendarService(EventDao eventDao, CalendarUserDao userDao, UserDetailsManager userDetailsManager) {
    if (eventDao == null) {
        throw new IllegalArgumentException("eventDao cannot be null");
    }
    if (userDao == null) {
        throw new IllegalArgumentException("userDao cannot be null");
    }
    if (userDetailsManager == null) {
        throw new IllegalArgumentException("userDetailsManager cannot be null");
    }
    this.eventDao = eventDao;
    this.userDao = userDao;
    this.userDetailsManager = userDetailsManager;
}
 
Example #18
Source File: SecurityConfig.java    From Spring-Security-Third-Edition with MIT License 5 votes vote down vote up
/**
 * 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 #19
Source File: SecurityConfig.java    From Spring-Security-Third-Edition with MIT License 5 votes vote down vote up
/**
 * 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() {
    InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager();
    manager.createUser(User.withUsername("[email protected]").password("user1").roles("USER").build());
    manager.createUser(User.withUsername("[email protected]").password("admin1").roles("USER", "ADMIN").build());
    return manager;
}
 
Example #20
Source File: InceptionSecurity.java    From inception with Apache License 2.0 5 votes vote down vote up
@Bean
public UserDetailsManager userDetailsService()
{
    OverridableUserDetailsManager manager = new OverridableUserDetailsManager();
    manager.setDataSource(dataSource);
    manager.setAuthenticationManager(authenticationManager);
    return manager;
}
 
Example #21
Source File: SecurityConfig.java    From Spring-Security-Third-Edition with MIT License 4 votes vote down vote up
/**
 * 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 InMemoryUserDetailsManager();
}
 
Example #22
Source File: AuthenticationApplication.java    From Spring with Apache License 2.0 4 votes vote down vote up
@Bean
@Profile("memory")
UserDetailsManager memory() {
    log.info("starting the memory " + InMemoryUserDetailsManager.class.getName());
    return new InMemoryUserDetailsManager();
}
 
Example #23
Source File: ApplicationConnectionSignUp.java    From pazuzu-registry with MIT License 4 votes vote down vote up
public ApplicationConnectionSignUp(UserDetailsManager userDetailsManager) {
    this.userDetailsManager = userDetailsManager;
}
 
Example #24
Source File: SimpleSocialUserDetailsService.java    From pazuzu-registry with MIT License 4 votes vote down vote up
public SimpleSocialUserDetailsService(UserDetailsManager userDetailsManager) {
    this.userDetailsManager = userDetailsManager;
}
 
Example #25
Source File: SecurityConfig.java    From NFVO with Apache License 2.0 4 votes vote down vote up
@Bean(name = "inMemManager")
public UserDetailsManager userDetailsManager() {
  return new InMemoryUserDetailsManager(new Properties());
}
 
Example #26
Source File: ShibbolethRequestHeaderAuthenticationFilter.java    From webanno with Apache License 2.0 4 votes vote down vote up
public void setUserDetailsManager(UserDetailsManager aUserDetailsManager)
{
    userDetailsManager = aUserDetailsManager;
}
 
Example #27
Source File: UserDetailsServiceTestBaseClass.java    From Spring with Apache License 2.0 4 votes vote down vote up
Initializer(PasswordEncoder passwordEncoder, UserDetailsManager userDetailsManager) {
	this.passwordEncoder = passwordEncoder;
	this.userDetailsManager = userDetailsManager;
}