本文整理匯總了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