本文整理汇总了Java中org.springframework.social.security.SocialUser类的典型用法代码示例。如果您正苦于以下问题:Java SocialUser类的具体用法?Java SocialUser怎么用?Java SocialUser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SocialUser类属于org.springframework.social.security包,在下文中一共展示了SocialUser类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadUserByUserId
import org.springframework.social.security.SocialUser; //导入依赖的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"));
}
示例2: loadUserByUserId
import org.springframework.social.security.SocialUser; //导入依赖的package包/类
@Override
public SocialUserDetails loadUserByUserId(String userId) throws UsernameNotFoundException {
return new SocialUser(userId, "", Collections.emptyList());
}
示例3: loadUserByUserId
import org.springframework.social.security.SocialUser; //导入依赖的package包/类
@Override
public SocialUserDetails loadUserByUserId(String username) throws UsernameNotFoundException {
UserDetails details = userDetailsManager.loadUserByUsername(username);
return new SocialUser(details.getUsername(), "", AuthorityUtils.createAuthorityList("USER"));
}
示例4: loadUserByUserId
import org.springframework.social.security.SocialUser; //导入依赖的package包/类
@Override
public SocialUserDetails loadUserByUserId(String userId) throws UsernameNotFoundException, DataAccessException {
UserDetails userDetails = userDetailsService.loadUserByUsername(userId);
return new SocialUser(userDetails.getUsername(), userDetails.getPassword(), userDetails.getAuthorities());
}
示例5: loadUserByUserId
import org.springframework.social.security.SocialUser; //导入依赖的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