本文整理了Java中org.springframework.social.connect.Connection.getKey()
方法的一些代码示例,展示了Connection.getKey()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Connection.getKey()
方法的具体详情如下:
包路径:org.springframework.social.connect.Connection
类名称:Connection
方法名:getKey
[英]The key identifying this connection.
[中]标识此连接的密钥。
代码示例来源:origin: org.springframework.social/spring-social-core
@SuppressWarnings("rawtypes")
public boolean equals(Object o) {
if (!(o instanceof Connection)) {
return false;
}
Connection other = (Connection) o;
return key.equals(other.getKey());
}
代码示例来源:origin: at.molindo.social/spring-social-core
@SuppressWarnings("rawtypes")
public boolean equals(Object o) {
if (!(o instanceof Connection)) {
return false;
}
Connection other = (Connection) o;
return key.equals(other.getKey());
}
代码示例来源:origin: org.zalando.zauth/spring-social-zauth
@SuppressWarnings("rawtypes")
public boolean equals(Object o) {
if (!(o instanceof Connection)) {
return false;
}
Connection other = (Connection) o;
return key.equals(other.getKey());
}
代码示例来源:origin: org.springframework.social/spring-social-web
private UserProfile getProfileIfConnected(Map<String, Object> model) {
@SuppressWarnings("unchecked")
List<Connection<?>> connections = (List<Connection<?>>) model.get("connections");
if (connections != null) {
for (Connection<?> connection : connections) {
if (connection.getKey().getProviderId().equals(providerId)) {
return connection.fetchUserProfile();
}
}
}
return null;
}
代码示例来源:origin: spring-projects/spring-social-facebook
public void addConnection(Connection<?> connection) {
providerIdConnectionMap.add(connection.getKey().getProviderId(), connection);
connectionKeyConnectionMap.add(connection.getKey(), connection);
}
代码示例来源:origin: at.molindo.social/spring-social-core
public void removeConnection(ConnectionKey connectionKey) {
String providerId = connectionKey.getProviderId();
if (connections.containsKey(providerId)) {
List<Connection<?>> providerConnections = connections.get(providerId);
for (Connection<?> connection : providerConnections) {
if (connection.getKey().equals(connectionKey)) {
providerConnections.remove(connection);
}
}
}
}
代码示例来源:origin: org.springframework.social/spring-social-core
public void removeConnection(ConnectionKey connectionKey) {
String providerId = connectionKey.getProviderId();
if (connections.containsKey(providerId)) {
List<Connection<?>> providerConnections = connections.get(providerId);
for (Connection<?> connection : providerConnections) {
if (connection.getKey().equals(connectionKey)) {
providerConnections.remove(connection);
}
}
}
}
代码示例来源:origin: org.springframework.social/spring-social-core
public void addConnection(Connection<?> connection) {
try {
ConnectionKey connectionKey = connection.getKey();
getConnection(connectionKey);
throw new DuplicateConnectionException(connectionKey);
} catch (NoSuchConnectionException e) {
connections.add(connection.createData().getProviderId(), connection);
}
}
代码示例来源:origin: at.molindo.social/spring-social-core
public void addConnection(Connection<?> connection) {
try {
ConnectionKey connectionKey = connection.getKey();
getConnection(connectionKey);
throw new DuplicateConnectionException(connectionKey);
} catch (NoSuchConnectionException e) {
connections.add(connection.createData().getProviderId(), connection);
}
}
代码示例来源:origin: socialsignin/spring-social-security
public Authentication updateAuthenticationForNewConnection(
Authentication existingAuthentication, Connection<?> connection) {
return createNewAuthentication(
existingAuthentication.getName(),
existingAuthentication.getCredentials() == null ? null : existingAuthentication.getCredentials().toString(),
addAuthority(existingAuthentication, userAuthoritiesService
.getProviderAuthority(connection.getKey())));
}
代码示例来源:origin: org.springframework.social/spring-social-core
public List<String> findUserIdsWithConnection(Connection<?> connection) {
ConnectionKey key = connection.getKey();
List<String> localUserIds = jdbcTemplate.queryForList("select userId from " + tablePrefix + "UserConnection where providerId = ? and providerUserId = ?", String.class, key.getProviderId(), key.getProviderUserId());
if (localUserIds.size() == 0 && connectionSignUp != null) {
String newUserId = connectionSignUp.execute(connection);
if (newUserId != null)
{
createConnectionRepository(newUserId).addConnection(connection);
return Arrays.asList(newUserId);
}
}
return localUserIds;
}
代码示例来源:origin: at.molindo.social/spring-social-core
public List<String> findUserIdsWithConnection(Connection<?> connection) {
ConnectionKey key = connection.getKey();
List<String> localUserIds = jdbcTemplate.queryForList("select userId from " + tablePrefix + "UserConnection where providerId = ? and providerUserId = ?", String.class, key.getProviderId(), key.getProviderUserId());
if (localUserIds.size() == 0 && connectionSignUp != null) {
String newUserId = connectionSignUp.execute(connection);
if (newUserId != null)
{
createConnectionRepository(newUserId).addConnection(connection);
return Arrays.asList(newUserId);
}
}
return localUserIds;
}
代码示例来源:origin: org.springframework.social/spring-social-core
public Connection<?> getConnection(ConnectionKey connectionKey) {
if (connections.containsKey(connectionKey.getProviderId())) {
List<Connection<?>> providerConnections = connections.get(connectionKey.getProviderId());
for (Connection<?> connection : providerConnections) {
if (connection.getKey().equals(connectionKey)) {
return connection;
}
}
}
throw new NoSuchConnectionException(connectionKey);
}
代码示例来源:origin: at.molindo.social/spring-social-core
public Connection<?> getConnection(ConnectionKey connectionKey) {
if (connections.containsKey(connectionKey.getProviderId())) {
List<Connection<?>> providerConnections = connections.get(connectionKey.getProviderId());
for (Connection<?> connection : providerConnections) {
if (connection.getKey().equals(connectionKey)) {
return connection;
}
}
}
throw new NoSuchConnectionException(connectionKey);
}
代码示例来源:origin: org.springframework.social/spring-social-core
@Transactional
public void addConnection(Connection<?> connection) {
try {
ConnectionData data = connection.createData();
int rank = jdbcTemplate.queryForObject("select coalesce(max(rank) + 1, 1) as rank from " + tablePrefix + "UserConnection where userId = ? and providerId = ?", new Object[]{ userId, data.getProviderId() }, Integer.class);
jdbcTemplate.update("insert into " + tablePrefix + "UserConnection (userId, providerId, providerUserId, rank, displayName, profileUrl, imageUrl, accessToken, secret, refreshToken, expireTime) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
userId, data.getProviderId(), data.getProviderUserId(), rank, data.getDisplayName(), data.getProfileUrl(), data.getImageUrl(), encrypt(data.getAccessToken()), encrypt(data.getSecret()), encrypt(data.getRefreshToken()), data.getExpireTime());
} catch (DuplicateKeyException e) {
throw new DuplicateConnectionException(connection.getKey());
}
}
代码示例来源:origin: at.molindo.social/spring-social-core
@Transactional
public void addConnection(Connection<?> connection) {
try {
ConnectionData data = connection.createData();
int rank = jdbcTemplate.queryForObject("select coalesce(max(rank) + 1, 1) as rank from " + tablePrefix + "UserConnection where userId = ? and providerId = ?", new Object[]{ userId, data.getProviderId() }, Integer.class);
jdbcTemplate.update("insert into " + tablePrefix + "UserConnection (userId, providerId, providerUserId, rank, displayName, profileUrl, imageUrl, accessToken, secret, refreshToken, expireTime) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
userId, data.getProviderId(), data.getProviderUserId(), rank, data.getDisplayName(), data.getProfileUrl(), data.getImageUrl(), encrypt(data.getAccessToken()), encrypt(data.getSecret()), encrypt(data.getRefreshToken()), data.getExpireTime());
} catch (DuplicateKeyException e) {
throw new DuplicateConnectionException(connection.getKey());
}
}
代码示例来源:origin: io.loli.social/custom-social-core-extension
@Test
public void findConnectionByApiToUser() {
insertFacebookConnection();
insertFacebookConnection2();
assertFacebookConnection(connectionRepository.getConnection(
TestFacebookApi.class, "9"));
assertEquals("10",
connectionRepository.getConnection(TestFacebookApi.class, "10")
.getKey().getProviderUserId());
}
代码示例来源:origin: spring-projects/spring-social-facebook
public void removeConnection(ConnectionKey connectionKey) {
connectionKeyConnectionMap.remove(connectionKey);
List<Connection<?>> connections = providerIdConnectionMap.get(connectionKey.getProviderId());
providerIdConnectionMap.remove(connectionKey.getProviderId()); // remove them all
for (Connection<?> connection : connections) { // add back any that don't have the same key
if (!connection.getKey().equals(connectionKey)) {
providerIdConnectionMap.add(connectionKey.getProviderId(), connection);
}
}
}
代码示例来源:origin: io.loli.social/custom-social-core-extension
private void assertTwitterConnection(Connection<TestTwitterApi> twitter) {
assertEquals(new ConnectionKey("twitter", "1"), twitter.getKey());
assertEquals("@kdonald", twitter.getDisplayName());
assertEquals("http://twitter.com/kdonald", twitter.getProfileUrl());
assertEquals("http://twitter.com/kdonald/picture",
twitter.getImageUrl());
TestTwitterApi twitterApi = twitter.getApi();
assertEquals("123456789", twitterApi.getAccessToken());
assertEquals("987654321", twitterApi.getSecret());
twitter.sync();
assertEquals("http://twitter.com/kdonald/a_new_picture",
twitter.getImageUrl());
}
代码示例来源:origin: io.loli.social/custom-social-core-extension
private void assertFacebookConnection(Connection<TestFacebookApi> facebook) {
assertEquals(new ConnectionKey("facebook", "9"), facebook.getKey());
assertEquals(null, facebook.getDisplayName());
assertEquals(null, facebook.getProfileUrl());
assertEquals(null, facebook.getImageUrl());
TestFacebookApi facebookApi = facebook.getApi();
assertEquals("234567890", facebookApi.getAccessToken());
facebook.sync();
assertEquals("Keith Donald", facebook.getDisplayName());
assertEquals("http://facebook.com/keith.donald",
facebook.getProfileUrl());
assertEquals("http://facebook.com/keith.donald/picture",
facebook.getImageUrl());
}
内容来源于网络,如有侵权,请联系作者删除!