本文整理汇总了Java中org.springframework.security.core.userdetails.UserDetailsService类的典型用法代码示例。如果您正苦于以下问题:Java UserDetailsService类的具体用法?Java UserDetailsService怎么用?Java UserDetailsService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UserDetailsService类属于org.springframework.security.core.userdetails包,在下文中一共展示了UserDetailsService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: OAuthConfig
import org.springframework.security.core.userdetails.UserDetailsService; //导入依赖的package包/类
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);
}
示例2: userDetailsService
import org.springframework.security.core.userdetails.UserDetailsService; //导入依赖的package包/类
@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);
};
}
示例3: userDetailsService
import org.springframework.security.core.userdetails.UserDetailsService; //导入依赖的package包/类
@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");
}
}
};
}
示例4: SpringSecurityUserContext
import org.springframework.security.core.userdetails.UserDetailsService; //导入依赖的package包/类
@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;
}
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:13,代码来源:SpringSecurityUserContext.java
示例5: userDetailsService
import org.springframework.security.core.userdetails.UserDetailsService; //导入依赖的package包/类
@Bean
UserDetailsService userDetailsService() {
return new InMemoryUserDetailsManager(
User
.withUsername("user")
.password("password")
.roles("USER").build());
}
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:9,代码来源:LearningSpringBootEurekaServerApplication.java
示例6: configuresADefaultUser
import org.springframework.security.core.userdetails.UserDetailsService; //导入依赖的package包/类
@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();
});
}
开发者ID:michael-simons,项目名称:configurable-single-user-spring-boot-starter,代码行数:11,代码来源:UserDetailsServiceConfigurationTest.java
示例7: UaaWebSecurityConfiguration
import org.springframework.security.core.userdetails.UserDetailsService; //导入依赖的package包/类
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;
}
示例8: daoAuthenticationProvider
import org.springframework.security.core.userdetails.UserDetailsService; //导入依赖的package包/类
@Bean
public DaoAuthenticationProvider daoAuthenticationProvider(UserDetailsService userDetailsService,
PasswordEncoder passwordEncoder) {
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
provider.setUserDetailsService(userDetailsService);
provider.setPasswordEncoder(passwordEncoder);
return provider;
}
示例9: SpringSecurityUserContext
import org.springframework.security.core.userdetails.UserDetailsService; //导入依赖的package包/类
@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;
}
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:12,代码来源:SpringSecurityUserContext.java
示例10: SecurityConfiguration
import org.springframework.security.core.userdetails.UserDetailsService; //导入依赖的package包/类
public SecurityConfiguration(AuthenticationManagerBuilder authenticationManagerBuilder, UserDetailsService userDetailsService,
TokenProvider tokenProvider,
CorsFilter corsFilter) {
this.authenticationManagerBuilder = authenticationManagerBuilder;
this.userDetailsService = userDetailsService;
this.tokenProvider = tokenProvider;
this.corsFilter = corsFilter;
}
示例11: AuthServiceImpl
import org.springframework.security.core.userdetails.UserDetailsService; //导入依赖的package包/类
@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;
}
示例12: SecurityConfiguration
import org.springframework.security.core.userdetails.UserDetailsService; //导入依赖的package包/类
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;
}
示例13: SecurityConfiguration
import org.springframework.security.core.userdetails.UserDetailsService; //导入依赖的package包/类
public SecurityConfiguration(AuthenticationManagerBuilder authenticationManagerBuilder, UserDetailsService userDetailsService, TokenProvider tokenProvider, CorsFilter corsFilter) {
this.authenticationManagerBuilder = authenticationManagerBuilder;
this.userDetailsService = userDetailsService;
this.tokenProvider = tokenProvider;
this.corsFilter = corsFilter;
}
示例14: AccountController
import org.springframework.security.core.userdetails.UserDetailsService; //导入依赖的package包/类
@Autowired
public AccountController(UserDetailsService userDetailsService) {
if (userDetailsService == null) {
throw new IllegalArgumentException("userDetailsService cannot be null");
}
this.userDetailsService = userDetailsService;
}
示例15: SpringSecurityUserContext
import org.springframework.security.core.userdetails.UserDetailsService; //导入依赖的package包/类
@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;
}
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:13,代码来源:SpringSecurityUserContext.java