当前位置: 首页>>代码示例>>Java>>正文


Java UserDetailsService类代码示例

本文整理汇总了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);
}
 
开发者ID:kflauri2312lffds,项目名称:Android_watch_magpie,代码行数:16,代码来源:OAuth2SecurityConfiguration.java

示例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);
       };
}
 
开发者ID:adessoAG,项目名称:JenkinsHue,代码行数:20,代码来源:SecurityConfiguration.java

示例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");
            }
        }
    };
}
 
开发者ID:2DV603NordVisaProject,项目名称:nordvisa_calendar,代码行数:24,代码来源:WebSecurityConfig.java

示例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;
}
 
开发者ID:xm-online,项目名称:xm-uaa,代码行数:10,代码来源:UaaWebSecurityConfiguration.java

示例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;
}
 
开发者ID:xm-online,项目名称:xm-uaa,代码行数:9,代码来源:UaaConfiguration.java

示例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;
}
 
开发者ID:IBM,项目名称:Microservices-with-JHipster-and-Spring-Boot,代码行数:10,代码来源:SecurityConfiguration.java

示例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;
}
 
开发者ID:DigAg,项目名称:digag-server,代码行数:14,代码来源:AuthServiceImpl.java

示例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;
}
 
开发者ID:yuexine,项目名称:loafer,代码行数:12,代码来源:SecurityConfiguration.java

示例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;
    }
 
开发者ID:megadotnet,项目名称:SpringBootDemoApp,代码行数:8,代码来源:SecurityConfiguration.java

示例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;
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:8,代码来源:AccountController.java

示例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


注:本文中的org.springframework.security.core.userdetails.UserDetailsService类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。