本文整理汇总了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"));
}
示例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;
}
示例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;
}
示例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());
}
示例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());
}
示例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;
}
示例7: loadUserByUserId
import org.springframework.social.security.SocialUserDetails; //导入依赖的package包/类
@Override
public SocialUserDetails loadUserByUserId(String userId) {
return new SocialUserEntity(userRepository.findOne(userId));
}
示例8: loadUserByUserId
import org.springframework.social.security.SocialUserDetails; //导入依赖的package包/类
@Override
public SocialUserDetails loadUserByUserId(String userId) throws UsernameNotFoundException {
return new SocialUser(userId, "", Collections.emptyList());
}
示例9: loadUserByUserId
import org.springframework.social.security.SocialUserDetails; //导入依赖的package包/类
@Override
public SocialUserDetails loadUserByUserId(String userId) throws UsernameNotFoundException, DataAccessException {
return userDAO.findById(userId);
}
示例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"));
}
示例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());
}
示例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