本文整理汇总了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;
}
示例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;
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
}
示例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());
}
示例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());
}