本文整理匯總了Java中org.springframework.social.connect.Connection.createData方法的典型用法代碼示例。如果您正苦於以下問題:Java Connection.createData方法的具體用法?Java Connection.createData怎麽用?Java Connection.createData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.social.connect.Connection
的用法示例。
在下文中一共展示了Connection.createData方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: connectionToUserSocialConnection
import org.springframework.social.connect.Connection; //導入方法依賴的package包/類
private SocialUserConnection connectionToUserSocialConnection(final Connection<?> connection,
final Long rank) {
final ConnectionData connectionData = connection.createData();
return SocialUserConnection.builder()
.userId(userId)
.providerId(connection.getKey().getProviderId())
.providerUserId(connection.getKey().getProviderUserId())
.rank(rank)
.displayName(connection.getDisplayName())
.profileURL(connection.getProfileUrl())
.imageURL(connection.getImageUrl())
.accessToken(connectionData.getAccessToken())
.secret(connectionData.getSecret())
.refreshToken(connectionData.getRefreshToken())
.expireTime(connectionData.getExpireTime())
.build();
}
示例2: updateConnection
import org.springframework.social.connect.Connection; //導入方法依賴的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();
}
示例3: updateConnectionAccessFields
import org.springframework.social.connect.Connection; //導入方法依賴的package包/類
@Test
public void updateConnectionAccessFields() {
insertFacebookConnection();
Connection<TestFacebookApi> facebook = connectionRepository.getPrimaryConnection(TestFacebookApi.class);
assertEquals("234567890", facebook.getApi().getAccessToken());
facebook.refresh();
connectionRepository.updateConnection(facebook);
Connection<TestFacebookApi> facebook2 = connectionRepository.getPrimaryConnection(TestFacebookApi.class);
assertEquals("765432109", facebook2.getApi().getAccessToken());
ConnectionData data = facebook.createData();
assertEquals("654321098", data.getRefreshToken());
}
示例4: signIn
import org.springframework.social.connect.Connection; //導入方法依賴的package包/類
@Override
public String signIn(String localUserId, Connection<?> connection, NativeWebRequest request) {
User user = userRepository.findByUsername(localUserId);
ConnectionData connectionData = connection.createData();
SignInUtils.authorizeUser(user);
SignInUtils.setUserConnection(request, connectionData);
return null;
}
示例5: connectionToAuth
import org.springframework.social.connect.Connection; //導入方法依賴的package包/類
public static SocialAuthentication connectionToAuth(Connection<?> connection) {
SocialAuthentication auth = new SocialAuthentication();
ConnectionData data = connection.createData();
auth.setProviderId(data.getProviderId());
auth.setToken(data.getAccessToken());
auth.setRefreshToken(data.getRefreshToken());
auth.setSecret(data.getSecret());
auth.setProviderUserId(data.getProviderUserId());
return auth;
}
示例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: connectionToUserSocialConnection
import org.springframework.social.connect.Connection; //導入方法依賴的package包/類
private SocialUserConnection connectionToUserSocialConnection(Connection<?> connection, Long rank) {
ConnectionData connectionData = connection.createData();
return new SocialUserConnection(userId, connection.getKey().getProviderId(), connection.getKey().getProviderUserId(),
rank, connection.getDisplayName(), connection.getProfileUrl(), connection.getImageUrl(), connectionData.getAccessToken(),
connectionData.getSecret(), connectionData.getRefreshToken(), connectionData.getExpireTime()
);
}
示例8: updateConnectionAccessFields
import org.springframework.social.connect.Connection; //導入方法依賴的package包/類
@Test
public void updateConnectionAccessFields() {
insertFacebookConnection();
Connection<TestFacebookApi> facebook = connectionRepository.getPrimaryConnection(TestFacebookApi.class);
assertEquals("234567890", facebook.getApi().getAccessToken());
facebook.refresh();
connectionRepository.updateConnection(facebook);
Connection<TestFacebookApi> facebook2 = connectionRepository.getPrimaryConnection(TestFacebookApi.class);
assertEquals("765432109", facebook2.getApi().getAccessToken());
ConnectionData data = facebook.createData();
assertEquals("654321098", data.getRefreshToken());
}
示例9: ProviderSignInAttempt
import org.springframework.social.connect.Connection; //導入方法依賴的package包/類
public ProviderSignInAttempt(Connection<?> connection) {
this.connectionData = connection.createData();
}