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


Java Connection.getKey方法代码示例

本文整理汇总了Java中org.springframework.social.connect.Connection.getKey方法的典型用法代码示例。如果您正苦于以下问题:Java Connection.getKey方法的具体用法?Java Connection.getKey怎么用?Java Connection.getKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.social.connect.Connection的用法示例。


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

示例1: createRegistrationDTO

import org.springframework.social.connect.Connection; //导入方法依赖的package包/类
/**
 * Creates the form object used in the registration form.
 * @param connection
 * @return  If a user is signing in by using a social provider, this method returns a form
 *          object populated by the values given by the provider. Otherwise this method returns
 *          an empty form object (normal form registration).
 */
private RegistrationForm createRegistrationDTO(Connection<?> connection) {
    RegistrationForm dto = new RegistrationForm();

    if (connection != null) {
        UserProfile socialMediaProfile = connection.fetchUserProfile();
        dto.setEmail(socialMediaProfile.getEmail());
        dto.setFirstName(socialMediaProfile.getFirstName());
        dto.setLastName(socialMediaProfile.getLastName());

        ConnectionKey providerKey = connection.getKey();
        dto.setSignInProvider(SocialMediaService.valueOf(providerKey.getProviderId().toUpperCase()));
    }

    return dto;
}
 
开发者ID:eduyayo,项目名称:gamesboard,代码行数:23,代码来源:RegistrationController.java

示例2: findUserIdsWithConnection

import org.springframework.social.connect.Connection; //导入方法依赖的package包/类
public List<String> findUserIdsWithConnection(Connection<?> connection) {
	ConnectionKey key = connection.getKey();
	final String sql = "select userId from UserConnection where providerId = ? and providerUserId = ?";
	final String[] selectionArgs = {key.getProviderId(), key.getProviderUserId()};
	SQLiteDatabase db = repositoryHelper.getReadableDatabase();
	Cursor c = db.rawQuery(sql, selectionArgs);
	List<String> localUserIds = new ArrayList<String>();
	c.moveToFirst();
	for (int i = 0; i < c.getCount(); i++) {
		localUserIds.add(c.getString(c.getColumnIndex("userId")));
		c.moveToNext();
	}
	c.close();
	db.close();

	if (localUserIds.size() == 0 && connectionSignUp != null) {
	    String newUserId = connectionSignUp.execute(connection);
	    if (newUserId != null) {
			createConnectionRepository(newUserId).addConnection(connection);
			return Arrays.asList(newUserId);
		}
	}
	return localUserIds;
}
 
开发者ID:bestarandyan,项目名称:ShoppingMall,代码行数:25,代码来源:SQLiteUsersConnectionRepository.java

示例3: findUserIdsWithConnection

import org.springframework.social.connect.Connection; //导入方法依赖的package包/类
@Override
public List<String> findUserIdsWithConnection(final Connection<?> connection) {
    final ConnectionKey key = connection.getKey();
    final List<SocialUserConnection> socialUserConnections = socialUserConnectionRepository
            .findAllByProviderIdAndProviderUserId(key.getProviderId(), key.getProviderUserId());

    return socialUserConnections.
            stream()
            .map(SocialUserConnection::getUserId)
            .collect(Collectors.toList());
}
 
开发者ID:vlsidlyarevich,项目名称:unity,代码行数:12,代码来源:CustomSocialUsersConnectionRepository.java

示例4: findUserIdsWithConnection

import org.springframework.social.connect.Connection; //导入方法依赖的package包/类
@Override
public List<String> findUserIdsWithConnection(Connection<?> connection) {
  ConnectionKey key = connection.getKey();
  User user = userRepository.findOneByAuthProviderUserId(
      key.getProviderId(),
      key.getProviderUserId());
  if (user == null) {
    return ImmutableList.of(connectionSignUp.execute(connection));
  }
  return ImmutableList.of(user.getPrimaryEmail());
}
 
开发者ID:cs71-caffeine,项目名称:awesome-agile,代码行数:12,代码来源:AwesomeAgileUsersConnectionRepository.java

示例5: createUserFromProfile

import org.springframework.social.connect.Connection; //导入方法依赖的package包/类
private User createUserFromProfile(Connection<?> connection) {
  UserProfile profile = connection.fetchUserProfile();
  ConnectionKey key = connection.getKey();
  return new User()
      .setPrimaryEmail(profile.getEmail())
      .setDisplayName(connection.getDisplayName())
      .setIsVisible(true)
      .setStatus(UserStatus.ACTIVE)
      .setAvatar(connection.getImageUrl())
      .setAuthProviderId(key.getProviderId())
      .setAuthProviderUserId(key.getProviderUserId());
}
 
开发者ID:cs71-caffeine,项目名称:awesome-agile,代码行数:13,代码来源:AwesomeAgileConnectionSignup.java

示例6: addConnection

import org.springframework.social.connect.Connection; //导入方法依赖的package包/类
public void addConnection(Connection<?> connection) {
	try {
		ConnectionData data = connection.createData();
		SQLiteDatabase db = repositoryHelper.getWritableDatabase();

		// generate rank
		final String sql = "select coalesce(max(rank) + 1, 1) as rank from UserConnection where userId = ? and providerId = ?";
		final String[] selectionArgs = { userId, data.getProviderId() };
		Cursor c = db.rawQuery(sql, selectionArgs);
		c.moveToFirst();
		int rank = c.getInt(c.getColumnIndex("rank"));
		c.close();

		// insert connection
		ContentValues values = new ContentValues();
		values.put("userId", userId);
		values.put("providerId", data.getProviderId());
		values.put("providerUserId", data.getProviderUserId());
		values.put("rank", rank);
		values.put("displayName", data.getDisplayName());
		values.put("profileUrl", data.getProfileUrl());
		values.put("imageUrl", data.getImageUrl());
		values.put("accessToken", encrypt(data.getAccessToken()));
		values.put("secret", encrypt(data.getSecret()));
		values.put("refreshToken", encrypt(data.getRefreshToken()));
		values.put("expireTime", data.getExpireTime());
		db.insertOrThrow("UserConnection", null, values);
		db.close();
	} catch (SQLiteConstraintException e) {
		throw new DuplicateConnectionException(connection.getKey());
	}
}
 
开发者ID:bestarandyan,项目名称:ShoppingMall,代码行数:33,代码来源:SQLiteConnectionRepository.java

示例7: findUserIdsWithConnection

import org.springframework.social.connect.Connection; //导入方法依赖的package包/类
@Override
public List<String> findUserIdsWithConnection(Connection<?> connection) {
  ConnectionKey key = connection.getKey();
  List<SocialUserConnection> socialUserConnections =
    socialUserConnectionRepository.findAllByProviderIdAndProviderUserId(key.getProviderId(), key.getProviderUserId());
  return socialUserConnections.stream().map(SocialUserConnection::getUserId).collect(Collectors.toList());
}
 
开发者ID:priitl,项目名称:p2p-webtv,代码行数:8,代码来源:CustomSocialUsersConnectionRepository.java

示例8: findUserIdsWithConnection

import org.springframework.social.connect.Connection; //导入方法依赖的package包/类
public List<String> findUserIdsWithConnection(Connection<?> connection) {
    ConnectionKey key = connection.getKey();
    return socialUserRepository.findUserIdsByProviderIdAndProviderUserId(key.getProviderId(), key.getProviderUserId());
}
 
开发者ID:alex-bretet,项目名称:cloudstreetmarket.com,代码行数:5,代码来源:SocialUserServiceImpl.java


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