org.springframework.social.connect.ConnectionKey Java Examples

The following examples show how to use org.springframework.social.connect.ConnectionKey. 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: AbstractUserConnectionJpaDao.java    From lolibox with Apache License 2.0 6 votes vote down vote up
@Transactional(
    readOnly = false,
    propagation = Propagation.REQUIRED
)
public RemoteUser createRemoteUser(String userId, String providerId, String providerUserId, int rank, String displayName, String profileUrl, String imageUrl, String accessToken, String secret, String refreshToken, Long expireTime) {
    AbstractUserConnection remoteUser = this.createNewUserConnection(userId, providerId, providerUserId, rank, displayName, profileUrl, imageUrl, accessToken, secret, refreshToken, expireTime);

    try {
        RemoteUser e = this.get(userId, providerId, providerUserId);
        if(e != null) {
            throw new DuplicateConnectionException(new ConnectionKey(providerId, providerUserId));
        }
    } catch (EmptyResultDataAccessException var14) {
        ;
    }

    this.save(remoteUser);
    return remoteUser;
}
 
Example #2
Source File: MongoUsersConnectionRepositoryImpl.java    From JiwhizBlogWeb with Apache License 2.0 6 votes vote down vote up
public List<String> findUserIdsWithConnection(Connection<?> connection) {
    ConnectionKey key = connection.getKey();
    List<UserSocialConnection> userSocialConnectionList = 
            this.userSocialConnectionRepository.findByProviderIdAndProviderUserId(key.getProviderId(), key.getProviderUserId());
    List<String> localUserIds = new ArrayList<String>();
    for (UserSocialConnection userSocialConnection : userSocialConnectionList){
        localUserIds.add(userSocialConnection.getUserId());
    }
    
    if (localUserIds.size() == 0 && connectionSignUp != null) {
        String newUserId = connectionSignUp.execute(connection);
        if (newUserId != null)
        {
            createConnectionRepository(newUserId).addConnection(connection);
            return Arrays.asList(newUserId);
        }
    }
    return localUserIds;
}
 
Example #3
Source File: WechatSignInAdapter.java    From spring-social-wechat-sample with Apache License 2.0 5 votes vote down vote up
@Override
public String signIn(String openId, Connection<?> connection, NativeWebRequest request) {
	ConnectionKey key = connection.getKey();
	if ("wechat".equalsIgnoreCase(key.getProviderId()) || "wechatmp".equalsIgnoreCase(key.getProviderId())) { // 这里的if判断可对微信开放平台和微信公众平台帐号登录做不同的逻辑处理,此例子代码处理逻辑相同
		User user = ((Wechat) connection.getApi()).userOperations().getUserProfile(openId); // 默认语言为英文,如果想切换为中文可改为:getUserProfile(openId,WechatLangEnum.ZH_CN);
		System.out.println(user); // 打印微信用户详细信息
	}
	return "/login.htm"; // 返回跳转的url
}
 
Example #4
Source File: JpaConnectionRepository.java    From computoser with GNU Affero General Public License v3.0 5 votes vote down vote up
private Connection<?> getConnection(String providerId, String providerUserId) {
    List<SocialAuthentication> socialAuthentications = userDao.getSocialAuthentications(providerId, providerUserId);
    if (socialAuthentications.isEmpty()) {
        throw new NoSuchConnectionException(new ConnectionKey(providerId, providerUserId));
    }
    return authToConnection(socialAuthentications.get(0));
}
 
Example #5
Source File: MongoConnectionRepositoryImpl.java    From JiwhizBlogWeb with Apache License 2.0 5 votes vote down vote up
public Connection<?> getConnection(ConnectionKey connectionKey) {
    UserSocialConnection userSocialConnection = this.userSocialConnectionRepository
            .findByUserIdAndProviderIdAndProviderUserId(userId, connectionKey.getProviderId(),
                    connectionKey.getProviderUserId());
    if (userSocialConnection != null) {
        return buildConnection(userSocialConnection);
    }
    throw new NoSuchConnectionException(connectionKey);
}
 
Example #6
Source File: SocialUserServiceImpl.java    From cloudstreetmarket.com with GNU General Public License v3.0 4 votes vote down vote up
public List<String> findUserIdsWithConnection(Connection<?> connection) {
    ConnectionKey key = connection.getKey();
    return socialUserRepository.findUserIdsByProviderIdAndProviderUserId(key.getProviderId(), key.getProviderUserId());
}
 
Example #7
Source File: UserService.java    From boot-stateless-social with MIT License 4 votes vote down vote up
@Override
@Transactional(readOnly = true)
public User loadUserByConnectionKey(ConnectionKey connectionKey) {
	final User user = userRepo.findByProviderIdAndProviderUserId(connectionKey.getProviderId(), connectionKey.getProviderUserId());
	return checkUser(user);
}
 
Example #8
Source File: JpaConnectionRepository.java    From computoser with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public Connection<?> getConnection(ConnectionKey connectionKey) {
    return getConnection(connectionKey.getProviderId(), connectionKey.getProviderUserId());
}
 
Example #9
Source File: JpaConnectionRepository.java    From computoser with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void removeConnection(ConnectionKey connectionKey) {
    userService.deleteSocialAuthentication(userId, connectionKey.getProviderId());
}
 
Example #10
Source File: MongoConnectionRepositoryImpl.java    From JiwhizBlogWeb with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
public <A> Connection<A> getConnection(Class<A> apiType, String providerUserId) {
    String providerId = getProviderId(apiType);
    return (Connection<A>) getConnection(new ConnectionKey(providerId, providerUserId));
}
 
Example #11
Source File: MongoConnectionRepositoryImpl.java    From JiwhizBlogWeb with Apache License 2.0 4 votes vote down vote up
public void removeConnection(ConnectionKey connectionKey) {
    UserSocialConnection userSocialConnection = this.userSocialConnectionRepository
            .findByUserIdAndProviderIdAndProviderUserId(userId, connectionKey.getProviderId(), connectionKey.getProviderUserId());
    this.userSocialConnectionRepository.delete(userSocialConnection);
}
 
Example #12
Source File: SocialUserService.java    From boot-stateless-social with MIT License votes vote down vote up
User loadUserByConnectionKey(ConnectionKey connectionKey);