Java 类org.springframework.security.core.userdetails.UserDetailsService 实例源码

项目:JenkinsHue    文件:SecurityConfiguration.java   
@Bean
public UserDetailsService userDetailsService() {
    return userName -> {
           UserDTO user = userAuthenticationProvider.userService.findByLogin(userName.toLowerCase());
           if (user == null) {
               throw new UsernameNotFoundException(userName);
           }

           Set<SimpleGrantedAuthority> userAuthorities = new HashSet<>();
           List<Role> roles = user.getRoles();
           if (roles != null) {
               for (Role role : roles) {
                   userAuthorities.add(new SimpleGrantedAuthority(role.toString()));
               }
           }

           return new User(userName, userName /* TODO use password */, userAuthorities);
       };
}
项目:nordvisa_calendar    文件:WebSecurityConfig.java   
@Bean
public UserDetailsService userDetailsService() {
    return new UserDetailsService() {
        public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException {
            User user = dao.getUserByEmail(email);

            if(user != null) {
                return new org.springframework.security.core.userdetails.User(
                        user.getEmail(),
                        user.getPassword(),
                        user.valid(),
                        true,
                        true,
                        true,
                        AuthorityUtils.createAuthorityList(user.fetchAuthorities())
                );
            }
            else {
                throw new UsernameNotFoundException("Could not find that user");
            }
        }
    };
}
项目:Spring-Security-Third-Edition    文件:SpringSecurityUserContext.java   
@Autowired
public SpringSecurityUserContext(final CalendarService calendarService,
                                 final UserDetailsService userDetailsService) {
    if (calendarService == null) {
        throw new IllegalArgumentException("calendarService cannot be null");
    }
    if (userDetailsService == null) {
        throw new IllegalArgumentException("userDetailsService cannot be null");
    }
    this.calendarService = calendarService;
    this.userDetailsService = userDetailsService;
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:LearningSpringBootEurekaServerApplication.java   
@Bean
UserDetailsService userDetailsService() {
    return new InMemoryUserDetailsManager(
        User
            .withUsername("user")
            .password("password")
            .roles("USER").build());
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:LearningSpringBootConfigServer.java   
@Bean
UserDetailsService userDetailsService() {
    return new InMemoryUserDetailsManager(
        User
            .withUsername("user")
            .password("password")
            .roles("USER").build());
}
项目:configurable-single-user-spring-boot-starter    文件:UserDetailsServiceConfigurationTest.java   
@Test
public void configuresADefaultUser() {
    contextRunner
            .withPropertyValues("singleuser.name=michael")
            .withConfiguration(AutoConfigurations.of(SecurityAutoConfiguration.class, SingleUserAutoConfiguration.class))
            .run(context -> {
                assertThat(context.getBean(UserDetailsService.class).loadUserByUsername("michael")).isNotNull();
                assertThat(context).getBean(ReactiveUserDetailsService.class).isNull();
            });
}
项目:xm-uaa    文件:UaaWebSecurityConfiguration.java   
public UaaWebSecurityConfiguration(UserDetailsService userDetailsService,
    AuthenticationManagerBuilder authenticationManagerBuilder,
    @Qualifier("authenticationProviderResolver") AuthenticationProviderResolver authenticationProviderResolver,
    @Lazy PasswordEncoder passwordEncoder) {
    this.userDetailsService = userDetailsService;
    this.authenticationManagerBuilder = authenticationManagerBuilder;
    this.authenticationProviderResolver = authenticationProviderResolver;
    this.passwordEncoder = passwordEncoder;
}
项目:xm-uaa    文件:UaaConfiguration.java   
@Bean
public DaoAuthenticationProvider daoAuthenticationProvider(UserDetailsService userDetailsService,
    PasswordEncoder passwordEncoder) {
    DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
    provider.setUserDetailsService(userDetailsService);
    provider.setPasswordEncoder(passwordEncoder);
    return provider;
}
项目:Spring-Security-Third-Edition    文件:SpringSecurityUserContext.java   
@Autowired
public SpringSecurityUserContext(CalendarService calendarService,UserDetailsService userDetailsService) {
    if (calendarService == null) {
        throw new IllegalArgumentException("calendarService cannot be null");
    }
    if (userDetailsService == null) {
        throw new IllegalArgumentException("userDetailsService cannot be null");
    }
    this.calendarService = calendarService;
    this.userDetailsService = userDetailsService;
}
项目:Spring-Security-Third-Edition    文件:SpringSecurityUserContext.java   
@Autowired
public SpringSecurityUserContext(CalendarService calendarService,UserDetailsService userDetailsService) {
    if (calendarService == null) {
        throw new IllegalArgumentException("calendarService cannot be null");
    }
    if (userDetailsService == null) {
        throw new IllegalArgumentException("userDetailsService cannot be null");
    }
    this.calendarService = calendarService;
    this.userDetailsService = userDetailsService;
}
项目:Spring-Security-Third-Edition    文件:SpringSecurityUserContext.java   
@Autowired
public SpringSecurityUserContext(final CalendarService calendarService,
                                 final UserDetailsService userDetailsService) {
    if (calendarService == null) {
        throw new IllegalArgumentException("calendarService cannot be null");
    }
    if (userDetailsService == null) {
        throw new IllegalArgumentException("userDetailsService cannot be null");
    }
    this.calendarService = calendarService;
    this.userDetailsService = userDetailsService;
}
项目:Spring-Security-Third-Edition    文件:SpringSecurityUserContext.java   
@Autowired
public SpringSecurityUserContext(CalendarService calendarService,UserDetailsService userDetailsService) {
    if (calendarService == null) {
        throw new IllegalArgumentException("calendarService cannot be null");
    }
    if (userDetailsService == null) {
        throw new IllegalArgumentException("userDetailsService cannot be null");
    }
    this.calendarService = calendarService;
    this.userDetailsService = userDetailsService;
}
项目:Spring-Security-Third-Edition    文件:SpringSecurityUserContext.java   
@Autowired
public SpringSecurityUserContext(final CalendarService calendarService,
                                 final UserDetailsService userDetailsService) {
    if (calendarService == null) {
        throw new IllegalArgumentException("calendarService cannot be null");
    }
    if (userDetailsService == null) {
        throw new IllegalArgumentException("userDetailsService cannot be null");
    }
    this.calendarService = calendarService;
    this.userDetailsService = userDetailsService;
}
项目:Spring-Security-Third-Edition    文件:SpringSecurityUserContext.java   
@Autowired
public SpringSecurityUserContext(final CalendarService calendarService,
                                 final UserDetailsService userDetailsService) {
    if (calendarService == null) {
        throw new IllegalArgumentException("calendarService cannot be null");
    }
    if (userDetailsService == null) {
        throw new IllegalArgumentException("userDetailsService cannot be null");
    }
    this.calendarService = calendarService;
    this.userDetailsService = userDetailsService;
}
项目:Microservices-with-JHipster-and-Spring-Boot    文件:SecurityConfiguration.java   
public SecurityConfiguration(AuthenticationManagerBuilder authenticationManagerBuilder, UserDetailsService userDetailsService,
        TokenProvider tokenProvider,
    CorsFilter corsFilter) {

    this.authenticationManagerBuilder = authenticationManagerBuilder;
    this.userDetailsService = userDetailsService;
    this.tokenProvider = tokenProvider;
    this.corsFilter = corsFilter;
}
项目:digag-server    文件:AuthServiceImpl.java   
@Autowired
public AuthServiceImpl(
        AuthenticationManager authenticationManager,
        UserDetailsService userDetailsService,
        JwtTokenUtil jwtTokenUtil,
        UserRepository userRepository,
        RoleRepository roleRepository) {
    this.authenticationManager = authenticationManager;
    this.userDetailsService = userDetailsService;
    this.jwtTokenUtil = jwtTokenUtil;
    this.userRepository = userRepository;
    this.roleRepository = roleRepository;
}
项目:Armory    文件:SecurityConfiguration.java   
public SecurityConfiguration(AuthenticationManagerBuilder authenticationManagerBuilder, UserDetailsService userDetailsService,
        TokenProvider tokenProvider,
    CorsFilter corsFilter) {

    this.authenticationManagerBuilder = authenticationManagerBuilder;
    this.userDetailsService = userDetailsService;
    this.tokenProvider = tokenProvider;
    this.corsFilter = corsFilter;
}
项目:loafer    文件:SecurityConfiguration.java   
public SecurityConfiguration(AuthenticationManagerBuilder authenticationManagerBuilder,
                             UserDetailsService userDetailsService,
                             CorsFilter corsFilter,
                             UnauthorisedEntryPoint unauthorisedEntryPoint,
                             TokenAuthenticationFilter tokenAuthenticationFilter) {
    this.authenticationManagerBuilder = authenticationManagerBuilder;
    this.userDetailsService = userDetailsService;
    this.corsFilter = corsFilter;
    this.unauthorisedEntryPoint = unauthorisedEntryPoint;
    this.tokenAuthenticationFilter = tokenAuthenticationFilter;
}
项目:Android_watch_magpie    文件:OAuth2SecurityConfiguration.java   
public OAuthConfig() throws Exception {

    ClientDetailsService csvc = new InMemoryClientDetailsServiceBuilder()
                    .withClient("mobile").authorizedGrantTypes("password")
                    .authorities("ROLE_CLIENT", "ROLE_TRUSTED_CLIENT")
                    .scopes("read","write").resourceIds("prublisher")
                    .accessTokenValiditySeconds(3600).and().build();

    UserDetailsService svc = new InMemoryUserDetailsManager(
            Arrays.asList(
                            User.create("publisher", "publisher", MobileClient.ROLE_PUBLISHER),
                            User.create("subscriber", "subscriber", MobileClient.ROLE_SUBSCRIBER)));

    combinedService_ = new ClientAndUserDetailsService(csvc,svc);
}
项目:Spring-Security-Third-Edition    文件:SpringSecurityUserContext.java   
@Autowired
public SpringSecurityUserContext(CalendarService calendarService,UserDetailsService userDetailsService) {
    if (calendarService == null) {
        throw new IllegalArgumentException("calendarService cannot be null");
    }
    if (userDetailsService == null) {
        throw new IllegalArgumentException("userDetailsService cannot be null");
    }
    this.calendarService = calendarService;
    this.userDetailsService = userDetailsService;
}
项目:Spring-Security-Third-Edition    文件:SpringSecurityUserContext.java   
@Autowired
public SpringSecurityUserContext(CalendarService calendarService,UserDetailsService userDetailsService) {
    if (calendarService == null) {
        throw new IllegalArgumentException("calendarService cannot be null");
    }
    if (userDetailsService == null) {
        throw new IllegalArgumentException("userDetailsService cannot be null");
    }
    this.calendarService = calendarService;
    this.userDetailsService = userDetailsService;
}
项目:SpringBootDemoApp    文件:SecurityConfiguration.java   
public SecurityConfiguration(AuthenticationManagerBuilder authenticationManagerBuilder, UserDetailsService userDetailsService, TokenProvider tokenProvider, CorsFilter corsFilter) {

        this.authenticationManagerBuilder = authenticationManagerBuilder;
        this.userDetailsService = userDetailsService;
        this.tokenProvider = tokenProvider;
        this.corsFilter = corsFilter;
    }
项目:Spring-Security-Third-Edition    文件:SpringSecurityUserContext.java   
@Autowired
public SpringSecurityUserContext(final CalendarService calendarService,
                                 final UserDetailsService userDetailsService) {
    if (calendarService == null) {
        throw new IllegalArgumentException("calendarService cannot be null");
    }
    if (userDetailsService == null) {
        throw new IllegalArgumentException("userDetailsService cannot be null");
    }
    this.calendarService = calendarService;
    this.userDetailsService = userDetailsService;
}
项目:Spring-Security-Third-Edition    文件:AccountController.java   
@Autowired
public AccountController(UserDetailsService userDetailsService) {
    if (userDetailsService == null) {
        throw new IllegalArgumentException("userDetailsService cannot be null");
    }
    this.userDetailsService = userDetailsService;
}
项目:Spring-Security-Third-Edition    文件:SpringSecurityUserContext.java   
@Autowired
public SpringSecurityUserContext(CalendarService calendarService,
                                 UserDetailsService userDetailsService) {
    if (calendarService == null) {
        throw new IllegalArgumentException("calendarService cannot be null");
    }
    if (userDetailsService == null) {
        throw new IllegalArgumentException("userDetailsService cannot be null");
    }
    this.calendarService = calendarService;
    this.userDetailsService = userDetailsService;
}
项目:Spring-Security-Third-Edition    文件:SpringSecurityUserContext.java   
@Autowired
public SpringSecurityUserContext(CalendarService calendarService,UserDetailsService userDetailsService) {
    if (calendarService == null) {
        throw new IllegalArgumentException("calendarService cannot be null");
    }
    if (userDetailsService == null) {
        throw new IllegalArgumentException("userDetailsService cannot be null");
    }
    this.calendarService = calendarService;
    this.userDetailsService = userDetailsService;
}
项目:nixmash-blog    文件:SecurityRequestPostProcessors.java   
private UsernamePasswordAuthenticationToken authentication(ServletContext servletContext) {
    ApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
    UserDetailsService userDetailsService = userDetailsService(context);
    UserDetails userDetails = userDetailsService.loadUserByUsername(this.username);
    return new UsernamePasswordAuthenticationToken(
            userDetails, userDetails.getPassword(), userDetails.getAuthorities());
}
项目:Spring-Security-Third-Edition    文件:SpringSecurityUserContext.java   
@Autowired
public SpringSecurityUserContext(final CalendarService calendarService,
                                 final UserDetailsService userDetailsService) {
    if (calendarService == null) {
        throw new IllegalArgumentException("calendarService cannot be null");
    }
    if (userDetailsService == null) {
        throw new IllegalArgumentException("userDetailsService cannot be null");
    }
    this.calendarService = calendarService;
    this.userDetailsService = userDetailsService;
}
项目:Spring-Security-Third-Edition    文件:SpringSecurityUserContext.java   
@Autowired
public SpringSecurityUserContext(CalendarService calendarService,UserDetailsService userDetailsService) {
    if (calendarService == null) {
        throw new IllegalArgumentException("calendarService cannot be null");
    }
    if (userDetailsService == null) {
        throw new IllegalArgumentException("userDetailsService cannot be null");
    }
    this.calendarService = calendarService;
    this.userDetailsService = userDetailsService;
}
项目:bdf2    文件:TaskReminderMessageSender.java   
public void afterPropertiesSet() throws Exception {
    Collection<UserDetailsService> userDetailsServices=this.getApplicationContext().getBeansOfType(UserDetailsService.class).values();
    if(userDetailsServices.size()==0){
        throw new RuntimeException("You must implementation["+UserDetailsService.class.getName()+"] interface and config it in spring context when use bdf2-jbpm4 module");
    }
    userDetailsService=userDetailsServices.iterator().next();
    senders=this.getApplicationContext().getBeansOfType(IMessageSender.class).values();
}
项目:Spring-Security-Third-Edition    文件:SpringSecurityUserContext.java   
@Autowired
public SpringSecurityUserContext(CalendarService calendarService,UserDetailsService userDetailsService) {
    if (calendarService == null) {
        throw new IllegalArgumentException("calendarService cannot be null");
    }
    if (userDetailsService == null) {
        throw new IllegalArgumentException("userDetailsService cannot be null");
    }
    this.calendarService = calendarService;
    this.userDetailsService = userDetailsService;
}
项目:Code4Health-Platform    文件:SecurityConfiguration.java   
public SecurityConfiguration(AuthenticationManagerBuilder authenticationManagerBuilder, UserDetailsService userDetailsService,
        TokenProvider tokenProvider,
    CorsFilter corsFilter) {

    this.authenticationManagerBuilder = authenticationManagerBuilder;
    this.userDetailsService = userDetailsService;
    this.tokenProvider = tokenProvider;
    this.corsFilter = corsFilter;
}
项目:OAuth2Spring    文件:OAuth2SpringApplication.java   
@Bean
public UserDetailsService userDetailsService(final UserRepository repository) {
    return new UserDetailsService() {
        @Override
        public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
            return new UserDetailsImpl(repository.findByUsername(username));
        }
    };
}
项目:Spring-Security-Third-Edition    文件:SpringSecurityUserContext.java   
@Autowired
public SpringSecurityUserContext(final CalendarService calendarService,
                                 final UserDetailsService userDetailsService) {
    if (calendarService == null) {
        throw new IllegalArgumentException("calendarService cannot be null");
    }
    if (userDetailsService == null) {
        throw new IllegalArgumentException("userDetailsService cannot be null");
    }
    this.calendarService = calendarService;
    this.userDetailsService = userDetailsService;
}
项目:Spring-Security-Third-Edition    文件:SpringSecurityUserContext.java   
@Autowired
public SpringSecurityUserContext(final CalendarService calendarService,
                                 final UserDetailsService userDetailsService) {
    if (calendarService == null) {
        throw new IllegalArgumentException("calendarService cannot be null");
    }
    if (userDetailsService == null) {
        throw new IllegalArgumentException("userDetailsService cannot be null");
    }
    this.calendarService = calendarService;
    this.userDetailsService = userDetailsService;
}
项目:Spring-Security-Third-Edition    文件:SpringSecurityUserContext.java   
@Autowired
public SpringSecurityUserContext(final CalendarService calendarService,
                                 final UserDetailsService userDetailsService) {
    if (calendarService == null) {
        throw new IllegalArgumentException("calendarService cannot be null");
    }
    if (userDetailsService == null) {
        throw new IllegalArgumentException("userDetailsService cannot be null");
    }
    this.calendarService = calendarService;
    this.userDetailsService = userDetailsService;
}
项目:Spring-Security-Third-Edition    文件:SpringSecurityUserContext.java   
@Autowired
public SpringSecurityUserContext(CalendarService calendarService,UserDetailsService userDetailsService) {
    if (calendarService == null) {
        throw new IllegalArgumentException("calendarService cannot be null");
    }
    if (userDetailsService == null) {
        throw new IllegalArgumentException("userDetailsService cannot be null");
    }
    this.calendarService = calendarService;
    this.userDetailsService = userDetailsService;
}
项目:configurable-single-user-spring-boot-starter    文件:ReactiveUserDetailsServiceConfigurationTest.java   
@Test
public void configuresADefaultUser() {

    contextRunner
            .withUserConfiguration(TestConfig.class)
            .withPropertyValues("singleuser.name=michael")
            .withConfiguration(AutoConfigurations.of(ReactiveSecurityAutoConfiguration.class, SingleUserAutoConfiguration.class))
            .run(context -> {
                assertThat(context.getBean(ReactiveUserDetailsService.class).findByUsername("michael").block()).isNotNull();
                assertThat(context).getBean(UserDetailsService.class).isNull();
            });
}
项目:readingList    文件:SecurityConfig.java   
@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth.userDetailsService(new UserDetailsService() {
        @Override
        public UserDetails loadUserByUsername(String userName) throws UsernameNotFoundException {
            return readerRepository.findOne(userName);
        }
    });
}
项目:Spring-Security-Third-Edition    文件:SpringSecurityUserContext.java   
@Autowired
public SpringSecurityUserContext(final CalendarService calendarService,
                                 final UserDetailsService userDetailsService) {
    if (calendarService == null) {
        throw new IllegalArgumentException("calendarService cannot be null");
    }
    if (userDetailsService == null) {
        throw new IllegalArgumentException("userDetailsService cannot be null");
    }
    this.calendarService = calendarService;
    this.userDetailsService = userDetailsService;
}