當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。