org.springframework.social.security.SocialUserDetails Java Examples

The following examples show how to use org.springframework.social.security.SocialUserDetails. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FebsUserDetailService.java    From FEBS-Security with Apache License 2.0 6 votes vote down vote up
@Override
public SocialUserDetails loadUserByUserId(String userId) {
    MyUser user = this.userService.findByNameOrMobile(userId);
    if (user != null) {
        String permissions = this.menuService.findUserPermissions(user.getUsername());
        boolean notLocked = false;
        if (StringUtils.equals(MyUser.STATUS_VALID, user.getStatus()))
            notLocked = true;
        FebsSocialUserDetails userDetails = new FebsSocialUserDetails(user.getUsername(), user.getPassword(), true, true, true, notLocked,
                AuthorityUtils.commaSeparatedStringToAuthorityList(permissions));
        userDetails.setTheme(user.getTheme());
        userDetails.setAvatar(user.getAvatar());
        userDetails.setEmail(user.getEmail());
        userDetails.setMobile(user.getMobile());
        userDetails.setSsex(user.getSsex());
        userDetails.setUsersId(user.getUserId());
        userDetails.setPassword(user.getPassword());
        userDetails.setLoginTime(DateUtil.getDateFormat(new Date(), DateUtil.FULL_DATE_FORMAT));
        return userDetails;
    } else {
        return null;
    }
}
 
Example #2
Source File: SocialUserDetailsServiceImpl.java    From cola with MIT License 5 votes vote down vote up
@Override
public SocialUserDetails loadUserByUserId(String userId) throws UsernameNotFoundException {
	UserDto user = userService.findByUsername(userId);
	if (user == null) {
		throw new UsernameNotFoundException("User " + userId + " can not be found");
	}

	return buildSsoUser(user);

}
 
Example #3
Source File: UserDetailsServiceImpl.java    From pre with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 社交登录
 *
 * @param userId
 * @return
 * @throws UsernameNotFoundException
 */
@Override
public SocialUserDetails loadUserByUserId(String userId) throws UsernameNotFoundException {
    SysUser sysUser = new SysUser();
    sysUser.setUserId(Integer.valueOf(userId));
    //根据用户名查找用户信息
    SysUser user = userService.findSecurityUserByUser(sysUser);
    if (ObjectUtil.isNull(user)) {
        log.info("社交登录userId:" + userId);
        throw new UsernameNotFoundException("社交登录userId:" + userId + " 不存在");
    }
    Collection<? extends GrantedAuthority> authorities = getUserAuthorities(user.getUserId());
    return new PreSocialUser(user.getUserId(), user.getUsername(), user.getPassword(), authorities);
}
 
Example #4
Source File: UserDetailServiceImpl.java    From microservices-platform with Apache License 2.0 4 votes vote down vote up
@Override
public SocialUserDetails loadUserByUserId(String openId) {
    LoginAppUser loginAppUser = userService.findByOpenId(openId);
    return checkUser(loginAppUser);
}
 
Example #5
Source File: SimpleSocialUserDetailsService.java    From pazuzu-registry with MIT License 4 votes vote down vote up
@Override
public SocialUserDetails loadUserByUserId(String username) throws UsernameNotFoundException {
    UserDetails details = userDetailsManager.loadUserByUsername(username);
    return new SocialUser(details.getUsername(), "", AuthorityUtils.createAuthorityList("USER"));
}
 
Example #6
Source File: SimpleSocialUsersDetailService.java    From blog-social-login-with-spring-social with Apache License 2.0 4 votes vote down vote up
@Override
public SocialUserDetails loadUserByUserId(String userId) throws UsernameNotFoundException, DataAccessException {
    UserDetails userDetails = userDetailsService.loadUserByUsername(userId);
    return new SocialUser(userDetails.getUsername(), userDetails.getPassword(), userDetails.getAuthorities());
}
 
Example #7
Source File: DefaultSocialUserDetailsServiceImpl.java    From paascloud-master with Apache License 2.0 2 votes vote down vote up
/**
 * Load user by user id social user details.
 *
 * @param userId the user id
 *
 * @return the social user details
 *
 * @throws UsernameNotFoundException the username not found exception
 */
@Override
public SocialUserDetails loadUserByUserId(String userId) throws UsernameNotFoundException {
	log.warn("请配置 SocialUserDetailsService 接口的实现.");
	throw new UsernameNotFoundException(userId);
}