org.springframework.social.connect.Connection.createData()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(10.2k)|赞(0)|评价(0)|浏览(185)

本文整理了Java中org.springframework.social.connect.Connection.createData()方法的一些代码示例,展示了Connection.createData()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Connection.createData()方法的具体详情如下:
包路径:org.springframework.social.connect.Connection
类名称:Connection
方法名:createData

Connection.createData介绍

[英]Creates a data transfer object that can be used to persist the state of this connection. Used to support the transfer of connection state between layers of the application, such as to the database layer.
[中]创建可用于持久化此连接状态的数据传输对象。用于支持应用程序各层之间的连接状态传输,例如到数据库层。

代码示例

代码示例来源:origin: org.springframework.social/spring-social-web

public ProviderSignInAttempt(Connection<?> connection) {
  this.connectionData = connection.createData();	
}

代码示例来源:origin: at.molindo.social/spring-social-core

public void updateConnection(Connection<?> connection) {
  connections.add(connection.createData().getProviderId(), connection);
}

代码示例来源:origin: org.craftercms/crafter-profile-social-medial-integration

@Override
public void addConnection(Connection<?> connection) {
  addConnectionData(profile, connection.createData(), encryptor);
  updateProfile();
}

代码示例来源:origin: org.craftercms/crafter-profile-social-services-integration

@Override
public void addConnection(Connection<?> connection) {
  addConnectionData(profile, connection.createData(), encryptor);
  updateProfile();
}

代码示例来源:origin: socialsignin/spring-social-security

private Set<ConnectionKey> toConnectionKeySet(
    List<Connection<?>> connections,boolean includeExpiredConnections) {
  Set<ConnectionKey> connectionKeys = new HashSet<ConnectionKey>();
  for (Connection<?> connection : connections) {
    if (includeExpiredConnections || !connection.hasExpired()) {
      ConnectionData connectionData = connection.createData();
      connectionKeys.add(new ConnectionKey(connectionData
          .getProviderId(), connectionData.getProviderUserId()));
    }
  }
  return connectionKeys;
}

代码示例来源:origin: tigerphz/tgcloud-master

/**
 * 需要注册时跳到这里,返回401和用户信息给前端
 *
 * @param request the request
 * @return social user info
 */
@GetMapping(SecurityConstants.DEFAULT_SOCIAL_USER_INFO_URL)
@ResponseStatus(HttpStatus.UNAUTHORIZED)
public SocialUserInfo getSocialUserInfo(HttpServletRequest request) {
  Connection<?> connection = providerSignInUtils.getConnectionFromSession(new ServletWebRequest(request));
  appSingUpUtils.saveConnectionData(new ServletWebRequest(request), connection.createData());
  return buildSocialUserInfo(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: io.loli.social/custom-social-core-extension

@Override
public void addConnection(Connection<?> connection) {
  ConnectionData connectionData = connection.createData();
  getInMemoryProviderConnectionRepository(connectionData.getProviderId())
      .add(connectionData);
}

代码示例来源: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: socialsignin/spring-social-security

public P create(Connection<?> connection)
{
  P profile = instantiate();
  UserProfile userProfile = connection.fetchUserProfile();
  init(profile,userProfile,connection.createData());
  return profile;
  
}
public void init(P profile,UserProfile userProfile,ConnectionData connectionData)

代码示例来源:origin: io.loli.social/custom-social-core-extension

@Override
public void updateConnection(Connection<?> connection) {
  ConnectionData data = connection.createData();
  getInMemoryProviderConnectionRepository(data.getProviderId())
      .updateByProviderUserId(data, data.getProviderUserId());
}

代码示例来源:origin: org.springframework.social/spring-social-core

@Transactional
public void updateConnection(Connection<?> connection) {
  ConnectionData data = connection.createData();
  jdbcTemplate.update("update " + tablePrefix + "UserConnection set displayName = ?, profileUrl = ?, imageUrl = ?, accessToken = ?, secret = ?, refreshToken = ?, expireTime = ? where userId = ? and providerId = ? and providerUserId = ?",
      data.getDisplayName(), data.getProfileUrl(), data.getImageUrl(), encrypt(data.getAccessToken()), encrypt(data.getSecret()), encrypt(data.getRefreshToken()), data.getExpireTime(), userId, data.getProviderId(), data.getProviderUserId());
}

代码示例来源:origin: at.molindo.social/spring-social-core

@Transactional
public void updateConnection(Connection<?> connection) {
  ConnectionData data = connection.createData();
  jdbcTemplate.update("update " + tablePrefix + "UserConnection set displayName = ?, profileUrl = ?, imageUrl = ?, accessToken = ?, secret = ?, refreshToken = ?, expireTime = ? where userId = ? and providerId = ? and providerUserId = ?",
      data.getDisplayName(), data.getProfileUrl(), data.getImageUrl(), encrypt(data.getAccessToken()), encrypt(data.getSecret()), encrypt(data.getRefreshToken()), data.getExpireTime(), userId, data.getProviderId(), data.getProviderUserId());
}

代码示例来源: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: org.craftercms/crafter-security-provider

protected Profile updateProfileConnectionData(String tenant, Connection<?> connection, Profile profile) {
  try {
    ConnectionUtils.addConnectionData(profile, connection.createData(), textEncryptor);
    return profileService.updateAttributes(profile.getId().toString(), profile.getAttributes());
  } catch (CryptoException | ProfileException e) {
    throw new AuthenticationException("Unable to update connection data of user '" + profile.getUsername() +
                     "' of tenant '" + tenant + "'", e);
  }
}

代码示例来源:origin: org.craftercms/crafter-security-provider

protected Profile createProfile(String tenant, Connection<?> connection, Profile userData) {
  try {
    ConnectionUtils.addConnectionData(userData, connection.createData(), textEncryptor);
    return profileService.createProfile(tenant, userData.getUsername(), null, userData.getEmail(), true,
                      userData.getRoles(), userData.getAttributes(), null);
  } catch (CryptoException | ProfileException e) {
    throw new AuthenticationException("Unable to create profile of user '" + userData.getUsername() +
                     "' in tenant '" + tenant + "'", e);
  }
}

代码示例来源:origin: io.loli.social/custom-social-core-extension

@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());
}

代码示例来源:origin: alex-bretet/cloudstreetmarket.com

public void updateConnection(Connection<?> connection) {
  ConnectionData data = connection.createData();
  
  SocialUser su = socialUserRepository.findFirstByUserIdAndProviderIdAndProviderUserId(userId,data.getProviderId(),data.getProviderUserId());
  if(su != null){
    su.setDisplayName(data.getDisplayName());
    su.setProfileUrl(data.getProfileUrl());
    su.setImageUrl(data.getImageUrl());
    su.setAccessToken(encrypt(data.getAccessToken()));
    su.setSecret(encrypt(data.getSecret()));
    su.setRefreshToken(encrypt(data.getRefreshToken()));
    su.setExpireTime(data.getExpireTime());
    
    su = socialUserRepository.save(su);
  }
}

代码示例来源:origin: jiwhiz/JiwhizBlogWeb

public void updateConnection(Connection<?> connection) {
  ConnectionData data = connection.createData();
  UserSocialConnection userSocialConnection = this.userSocialConnectionRepository
      .findByUserIdAndProviderIdAndProviderUserId(userId, connection.getKey().getProviderId(), connection
          .getKey().getProviderUserId());
  if (userSocialConnection != null) {
    userSocialConnection.setDisplayName(data.getDisplayName());
    userSocialConnection.setProfileUrl(data.getProfileUrl());
    userSocialConnection.setImageUrl(data.getImageUrl());
    userSocialConnection.setAccessToken(encrypt(data.getAccessToken()));
    userSocialConnection.setSecret(encrypt(data.getSecret()));
    userSocialConnection.setRefreshToken(encrypt(data.getRefreshToken()));
    userSocialConnection.setExpireTime(data.getExpireTime());
    this.userSocialConnectionRepository.save(userSocialConnection);
  }
}

相关文章