Examples of ConnectionData


Examples of org.springframework.social.connect.ConnectionData

    ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
    ConnectionFactory<TestApi1> connectionFactory1 = new StubOAuth1ConnectionFactory("clientId", "clientSecret");
    connectionFactoryLocator.addConnectionFactory(connectionFactory1);
    StubUsersConnectionRepository usersConnectionRepository = new StubUsersConnectionRepository();
    usersConnectionRepository.createConnectionRepository("habuma").addConnection(connectionFactory1.createConnection(
      new ConnectionData("oauth1Provider", "provider1User1", null, null, null, null, null, null, null)));
    ProviderSignInController providerSignInController = new ProviderSignInController(connectionFactoryLocator, usersConnectionRepository, null);
    providerSignInController.afterPropertiesSet();
    MockMvc mockMvc = standaloneSetup(providerSignInController).build();
    mockMvc.perform(post("/signin/oauth1Provider"))
      .andExpect(redirectedUrl("https://someprovider.com/oauth/authorize?oauth_token=requestToken"))
View Full Code Here

Examples of org.springframework.social.connect.ConnectionData

    ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
    ConnectionFactory<TestApi1> connectionFactory1 = new StubOAuth1ConnectionFactory("clientId", "clientSecret", StubOAuthTemplateBehavior.THROW_EXCEPTION);
    connectionFactoryLocator.addConnectionFactory(connectionFactory1);
    StubUsersConnectionRepository usersConnectionRepository = new StubUsersConnectionRepository();
    usersConnectionRepository.createConnectionRepository("habuma").addConnection(connectionFactory1.createConnection(
      new ConnectionData("oauth1Provider", "provider1User1", null, null, null, null, null, null, null)));
    ProviderSignInController providerSignInController = new ProviderSignInController(connectionFactoryLocator, usersConnectionRepository, null);
    providerSignInController.afterPropertiesSet();
    MockMvc mockMvc = standaloneSetup(providerSignInController).build();
    mockMvc.perform(post("/signin/oauth1Provider"))
      .andExpect(redirectedUrl("/signin?error=provider"));
View Full Code Here

Examples of org.springframework.social.connect.ConnectionData

  public T getApi() {
    return _api;
  }

  public ConnectionData createData() {
    return new ConnectionData(_key.getProviderId(), _key.getProviderUserId(), getDisplayName(),
        getProfileUrl(), getImageUrl(), "access_token", "secret", "refresh_token", System.currentTimeMillis() + 10000);
  }
View Full Code Here

Examples of org.springframework.social.connect.ConnectionData

    ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
    ConnectionFactory<TestApi2> connectionFactory2 = new StubOAuth2ConnectionFactory("clientId", "clientSecret");
    connectionFactoryLocator.addConnectionFactory(connectionFactory2);
    StubUsersConnectionRepository usersConnectionRepository = new StubUsersConnectionRepository();
    usersConnectionRepository.createConnectionRepository("habuma").addConnection(connectionFactory2.createConnection(
      new ConnectionData("oauth2Provider", "provider2User1", null, null, null, null, null, null, null)));
    ProviderSignInController providerSignInController = new ProviderSignInController(connectionFactoryLocator, usersConnectionRepository, null);
    providerSignInController.afterPropertiesSet();
    MockMvc mockMvc = standaloneSetup(providerSignInController).build();
    mockMvc.perform(post("/signin/oauth2Provider"))
      .andExpect(redirectedUrl("https://someprovider.com/oauth/authorize?client_id=clientId&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%2Fsignin%2Foauth2Provider&state=STATE"));
View Full Code Here

Examples of org.springframework.social.connect.ConnectionData

  public static Answer<DummyConnection<Object>> answer() {
    return new Answer<DummyConnection<Object>>() {

      public DummyConnection<Object> answer(InvocationOnMock invocation) throws Throwable {
        ConnectionData data = (ConnectionData) invocation.getArguments()[0];
        return dummy(data.getProviderId(), data.getProviderUserId());
      }
    };
  }
View Full Code Here

Examples of org.springframework.social.connect.ConnectionData

    }
  }

  public ConnectionData createData() {
    synchronized (getMonitor()) {
      return new ConnectionData(getKey().getProviderId(), getKey().getProviderUserId(), getDisplayName(), getProfileUrl(), getImageUrl(), accessToken, null, refreshToken, expireTime);
    }
  }
View Full Code Here

Examples of org.springframework.social.connect.ConnectionData

  }
 
  @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());
    }
  }
View Full Code Here

Examples of org.springframework.social.connect.ConnectionData

    }
  }
 
  @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());
  }
View Full Code Here

Examples of org.springframework.social.connect.ConnectionData

  private final ServiceProviderConnectionMapper connectionMapper = new ServiceProviderConnectionMapper();
 
  private final class ServiceProviderConnectionMapper implements RowMapper<Connection<?>> {
   
    public Connection<?> mapRow(ResultSet rs, int rowNum) throws SQLException {
      ConnectionData connectionData = mapConnectionData(rs);
      ConnectionFactory<?> connectionFactory = connectionFactoryLocator.getConnectionFactory(connectionData.getProviderId());
      return connectionFactory.createConnection(connectionData);
    }
View Full Code Here

Examples of org.springframework.social.connect.ConnectionData

      ConnectionFactory<?> connectionFactory = connectionFactoryLocator.getConnectionFactory(connectionData.getProviderId());
      return connectionFactory.createConnection(connectionData);
    }
   
    private ConnectionData mapConnectionData(ResultSet rs) throws SQLException {
      return new ConnectionData(rs.getString("providerId"), rs.getString("providerUserId"), rs.getString("displayName"), rs.getString("profileUrl"), rs.getString("imageUrl"),
          decrypt(rs.getString("accessToken")), decrypt(rs.getString("secret")), decrypt(rs.getString("refreshToken")), expireTime(rs.getLong("expireTime")));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.