本文整理汇总了Java中org.springframework.social.connect.ConnectionData.getProviderId方法的典型用法代码示例。如果您正苦于以下问题:Java ConnectionData.getProviderId方法的具体用法?Java ConnectionData.getProviderId怎么用?Java ConnectionData.getProviderId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.social.connect.ConnectionData
的用法示例。
在下文中一共展示了ConnectionData.getProviderId方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateConnection
import org.springframework.social.connect.ConnectionData; //导入方法依赖的package包/类
public void updateConnection(Connection<?> connection) {
ConnectionData data = connection.createData();
SQLiteDatabase db = repositoryHelper.getWritableDatabase();
ContentValues values = new ContentValues();
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());
final String whereClause = "userId = ? and providerId = ? and providerUserId = ?";
final String[] whereArgs = { userId, data.getProviderId(), data.getProviderUserId() };
db.update("UserConnection", values, whereClause, whereArgs);
db.close();
}
示例2: addConnection
import org.springframework.social.connect.ConnectionData; //导入方法依赖的package包/类
@Override
@Transactional
public void addConnection(final Connection<?> connection) {
final ConnectionData connectionData = connection.createData();
final String providerId = connectionData.getProviderId();
final String providerUserId = connectionData.getProviderUserId();
final int rank = userConnectionRepository.findRank(user, providerId);
final UserConnection userConnection = Functions.toUserConnection(textEncryptor, rank, user)
.apply(connectionData);
if (userConnectionRepository.findOne(user, providerId, providerUserId) != null) {
throw new DuplicateConnectionException(connection.getKey());
}
userConnectionRepository.save(userConnection);
}
示例3: SocialAuthenticationToken
import org.springframework.social.connect.ConnectionData; //导入方法依赖的package包/类
/**
* @param connection connection data
* @param providerAccountData optional extra account data
*/
public SocialAuthenticationToken(final Connection<?> connection, Map<String, String> providerAccountData) {
super(null);
Assert.notNull(connection);
ConnectionData connectionData = connection.createData();
Assert.notNull(connectionData.getProviderId());
if (connectionData.getExpireTime() != null && connectionData.getExpireTime() < System.currentTimeMillis()) {
throw new IllegalArgumentException("connection.expireTime < currentTime");
}
this.providerId = connectionData.getProviderId();
this.connection = connection;
this.principle = null; //no principal yet
if (providerAccountData != null) {
this.providerAccountData = Collections.unmodifiableMap(new HashMap<String, String>(providerAccountData));
} else {
this.providerAccountData = Collections.emptyMap();
}
super.setAuthenticated(false);
}
示例4: UserConnection
import org.springframework.social.connect.ConnectionData; //导入方法依赖的package包/类
public UserConnection(ConnectionData connectionData, String userId)
{
this.userId = userId;
this.providerId = connectionData.getProviderId();
this.providerUserId = connectionData.getProviderUserId();
this.rank = 1;
this.displayName = connectionData.getDisplayName();
this.profileUrl = connectionData.getProfileUrl();
this.imageUrl = connectionData.getImageUrl();
this.accessToken = connectionData.getAccessToken();
this.secret = connectionData.getSecret();
this.refreshToken = connectionData.getRefreshToken();
this.expireTime = connectionData.getExpireTime();
}
示例5: addConnection
import org.springframework.social.connect.ConnectionData; //导入方法依赖的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());
}
}
示例6: updateConnection
import org.springframework.social.connect.ConnectionData; //导入方法依赖的package包/类
@Override
@Transactional
public void updateConnection(final Connection<?> connection) {
final ConnectionData connectionData = connection.createData();
final String providerId = connectionData.getProviderId();
final String providerUserId = connectionData.getProviderUserId();
final UserConnection userConnection = userConnectionRepository.findOne(user, providerId, providerUserId);
final UserConnection updatedUserConnection = Functions.toUserConnection(userConnection, textEncryptor, user)
.apply(connectionData);
userConnectionRepository.save(updatedUserConnection);
}
示例7: updateConnection
import org.springframework.social.connect.ConnectionData; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public void updateConnection(Connection<?> connection) {
ConnectionData cd = connection.createData();
AppUserSocialConnectionKey primaryKey = new AppUserSocialConnectionKey(findAppUser(), cd.getProviderId(), cd.getProviderUserId());
AppUserSocialConnection ausc = entityManager.find(AppUserSocialConnection.class, primaryKey);
ausc.setDisplayName(cd.getDisplayName());
ausc.setProfileUrl(cd.getProfileUrl());
ausc.setImageUrl(cd.getImageUrl());
ausc.setAccessToken(encrypt(cd.getAccessToken()));
ausc.setSecret(encrypt(cd.getSecret()));
ausc.setRefreshToken(encrypt(cd.getRefreshToken()));
ausc.setExpireTime(cd.getExpireTime());
entityManager.merge(ausc);
}
示例8: addConnection
import org.springframework.social.connect.ConnectionData; //导入方法依赖的package包/类
public void addConnection(Connection<?> connection) {
//check cardinality
SocialAuthenticationService<?> socialAuthenticationService =
this.socialAuthenticationServiceLocator.getAuthenticationService(connection.getKey().getProviderId());
if (socialAuthenticationService.getConnectionCardinality() == ConnectionCardinality.ONE_TO_ONE ||
socialAuthenticationService.getConnectionCardinality() == ConnectionCardinality.ONE_TO_MANY){
List<UserSocialConnection> storedConnections =
this.userSocialConnectionRepository.findByProviderIdAndProviderUserId(
connection.getKey().getProviderId(), connection.getKey().getProviderUserId());
if (storedConnections.size() > 0){
//not allow one providerId/providerUserId connect to multiple userId
throw new DuplicateConnectionException(connection.getKey());
}
}
UserSocialConnection userSocialConnection = this.userSocialConnectionRepository
.findByUserIdAndProviderIdAndProviderUserId(userId, connection.getKey().getProviderId(),
connection.getKey().getProviderUserId());
if (userSocialConnection == null) {
ConnectionData data = connection.createData();
userSocialConnection = new UserSocialConnection(userId, data.getProviderId(), data.getProviderUserId(), 0,
data.getDisplayName(), data.getProfileUrl(), data.getImageUrl(), encrypt(data.getAccessToken()),
encrypt(data.getSecret()), encrypt(data.getRefreshToken()), data.getExpireTime());
this.userSocialConnectionRepository.save(userSocialConnection);
} else {
throw new DuplicateConnectionException(connection.getKey());
}
}