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


Java SocialUserDetails类代码示例

本文整理汇总了Java中org.springframework.social.security.SocialUserDetails的典型用法代码示例。如果您正苦于以下问题:Java SocialUserDetails类的具体用法?Java SocialUserDetails怎么用?Java SocialUserDetails使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SocialUserDetails类属于org.springframework.social.security包,在下文中一共展示了SocialUserDetails类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadUserByUserId

import org.springframework.social.security.SocialUserDetails; //导入依赖的package包/类
@Override
@Transactional(readOnly = true)
public SocialUserDetails loadUserByUserId(final String uuid) throws UsernameNotFoundException, DataAccessException {
    log.debug("Authenticating {} from social login", uuid);

    Optional<User> userFromDatabase = userRepository.findOneByUuid(uuid);

    return userFromDatabase.map(user -> {
        if (!user.isActivated()) {
            throw new UserNotActivatedException("User " + uuid + " was not activated");
        }
        List<GrantedAuthority> grantedAuthorities = user.getAuthorities().stream()
            .map(authority -> new SimpleGrantedAuthority(authority.name()))
            .collect(Collectors.toList());
        log.debug("Login successful");
        return new SocialUser(uuid,
            UUID.randomUUID().toString(),
            grantedAuthorities);
    }).orElseThrow(() -> new UsernameNotFoundException("User " + uuid + " was not found in the database"));
}
 
开发者ID:esutoniagodesu,项目名称:egd-web,代码行数:21,代码来源:SimpleSocialUserDetailsService.java

示例2: loadUserByUserId

import org.springframework.social.security.SocialUserDetails; //导入依赖的package包/类
/**
 * Loads the username by using the account ID of the user.
 * @param userId    The account ID of the requested user.
 * @return  The information of the requested user.
 * @throws UsernameNotFoundException    Thrown if no user is found.
 * @throws DataAccessException
 */
@Override
public SocialUserDetails loadUserByUserId(String userId) throws UsernameNotFoundException, DataAccessException {
    logger.debug("Loading user by user id: {}", userId);

    UserDetails userDetails = userDetailsService.loadUserByUsername(userId);
    logger.debug("Found user details: {}", userDetails);

    return (SocialUserDetails) userDetails;
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:17,代码来源:SimpleSocialUserDetailsService.java

示例3: loadUserByUserId

import org.springframework.social.security.SocialUserDetails; //导入依赖的package包/类
/**
 * Loads the username by using the account ID of the user.
 * @param userId    The account ID of the requested user.
 * @return  The information of the requested user.
 * @throws UsernameNotFoundException    Thrown if no user is found.
 * @throws DataAccessException
 */
@Override
public SocialUserDetails loadUserByUserId(String userId) throws UsernameNotFoundException, DataAccessException {
    LOGGER.debug("Loading user by user id: {}", userId);

    UserDetails userDetails = userDetailsService.loadUserByUsername(userId);
    LOGGER.debug("Found user details: {}", userDetails);

    return (SocialUserDetails) userDetails;
}
 
开发者ID:eduyayo,项目名称:gamesboard,代码行数:17,代码来源:SimpleSocialUserDetailsService.java

示例4: loadUserByUserId

import org.springframework.social.security.SocialUserDetails; //导入依赖的package包/类
@Override
public SocialUserDetails loadUserByUserId(String userId)
    throws UsernameNotFoundException, DataAccessException {
  User user = userRepository.findOneByPrimaryEmail(userId);
  if (user == null) {
    throw new UsernameNotFoundException(String.format("User with ID %s was not found", userId));
  }
  return new AwesomeAgileSocialUser(user, ImmutableSet.<GrantedAuthority>of());
}
 
开发者ID:cs71-caffeine,项目名称:awesome-agile,代码行数:10,代码来源:AwesomeAgileSocialUserDetailsService.java

示例5: testLoadUserByUserIdFound

import org.springframework.social.security.SocialUserDetails; //导入依赖的package包/类
@Test
public void testLoadUserByUserIdFound() throws Exception {
  when(userRepository.findOneByPrimaryEmail(SocialTestUtils.USER_EMAIL_TWO)).
      thenReturn(SocialTestUtils.USER_TWO);
  SocialUserDetails socialUserDetails =
      service.loadUserByUserId(SocialTestUtils.USER_EMAIL_TWO);
  assertNotNull(socialUserDetails);
  assertTrue(socialUserDetails instanceof AwesomeAgileSocialUser);
  assertEquals(SocialTestUtils.USER_TWO,
      ((AwesomeAgileSocialUser)socialUserDetails).getUser());
  assertEquals(SocialTestUtils.USER_EMAIL_TWO, socialUserDetails.getUserId());
  assertEquals("", socialUserDetails.getPassword());
}
 
开发者ID:cs71-caffeine,项目名称:awesome-agile,代码行数:14,代码来源:AwesomeAgileSocialUserDetailsServiceTest.java

示例6: signIn

import org.springframework.social.security.SocialUserDetails; //导入依赖的package包/类
@Override
public String signIn(String localUserId, Connection<?> connection, NativeWebRequest request) {
    log.debug("signin {}", localUserId);
    SocialUserDetails userDetails = socialUserDetailsService.loadUserByUserId(localUserId);
    Authentication token = new SocialAuthenticationToken(connection, userDetails, null, userDetails.getAuthorities());
    SecurityContextHolder.getContext().setAuthentication(token);
    return null;
}
 
开发者ID:esutoniagodesu,项目名称:egd-web,代码行数:9,代码来源:SimpleSignInAdapter.java

示例7: loadUserByUserId

import org.springframework.social.security.SocialUserDetails; //导入依赖的package包/类
@Override
public SocialUserDetails loadUserByUserId(String userId) {
	return new SocialUserEntity(userRepository.findOne(userId));
}
 
开发者ID:codenergic,项目名称:theskeleton,代码行数:5,代码来源:SocialUserService.java

示例8: loadUserByUserId

import org.springframework.social.security.SocialUserDetails; //导入依赖的package包/类
@Override
public SocialUserDetails loadUserByUserId(String userId) throws UsernameNotFoundException {
    return new SocialUser(userId, "", Collections.emptyList());
}
 
开发者ID:Turbots,项目名称:SpringOne2016,代码行数:5,代码来源:SimpleSocialUserDetailsService.java

示例9: loadUserByUserId

import org.springframework.social.security.SocialUserDetails; //导入依赖的package包/类
@Override
public SocialUserDetails loadUserByUserId(String userId) throws UsernameNotFoundException, DataAccessException {
    return userDAO.findById(userId);
}
 
开发者ID:DmitriyLy,项目名称:travel_portal,代码行数:5,代码来源:SocialUserDetailsServiceImpl.java

示例10: loadUserByUserId

import org.springframework.social.security.SocialUserDetails; //导入依赖的package包/类
@Override
public SocialUserDetails loadUserByUserId(final String email) throws UsernameNotFoundException, DataAccessException {
    Optional<User> userOptional = userService.findByEmail(email);
    return userOptional.orElseThrow(() -> new UsernameNotFoundException(email));
}
 
开发者ID:leon,项目名称:spring-oauth-social-microservice-starter,代码行数:6,代码来源:SocialUserDetailsServiceImpl.java

示例11: loadUserByUserId

import org.springframework.social.security.SocialUserDetails; //导入依赖的package包/类
@Override
public SocialUserDetails loadUserByUserId(String username) throws UsernameNotFoundException {
    UserDetails details = userDetailsManager.loadUserByUsername(username);
    return new SocialUser(details.getUsername(), "", AuthorityUtils.createAuthorityList("USER"));
}
 
开发者ID:pazuzu-io,项目名称:pazuzu-registry,代码行数:6,代码来源:SimpleSocialUserDetailsService.java

示例12: loadUserByUserId

import org.springframework.social.security.SocialUserDetails; //导入依赖的package包/类
@Override
public SocialUserDetails loadUserByUserId(String userId) throws UsernameNotFoundException, DataAccessException {
    UserDetails userDetails = userDetailsService.loadUserByUsername(userId);
    return new SocialUser(userDetails.getUsername(), userDetails.getPassword(), userDetails.getAuthorities());
}
 
开发者ID:miosman,项目名称:kotoby,代码行数:6,代码来源:SimpleSocialUsersDetailService.java

示例13: loadUserByUserId

import org.springframework.social.security.SocialUserDetails; //导入依赖的package包/类
@Override
public SocialUserDetails loadUserByUserId(String userId) throws UsernameNotFoundException, DataAccessException {
	UserDetails userDetails = userDetailsService.loadUserByUsername(userId);
	return new SocialUser(userDetails.getUsername(), userDetails.getPassword(), userDetails.getAuthorities());
}
 
开发者ID:markoradinovic,项目名称:Vaadin4Spring-MVP-Sample-SpringSecuritySocial,代码行数:6,代码来源:SimpleSocialUsersDetailService.java


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