Package org.springframework.social.oauth2

Examples of org.springframework.social.oauth2.OAuth2TokenParameterRequestInterceptor


    assertEquals("2", localUserIds.get(1));
  }

  @Test
  public void findUserIdWithConnectionNoConnection_withWorkingConnectionSignUp() {   
    Connection<TestFacebookApi> connection = connectionFactory.createConnection(new AccessGrant("12345"));
    usersConnectionRepository.setConnectionSignUp(new ConnectionSignUp() {
      public String execute(Connection<?> connection) {
        return "batman";
      }
    });
View Full Code Here


    assertEquals("batman", userIds.get(0));
  }
 
  @Test
  public void findUserIdWithConnectionNoConnection_withConnectionSignUpReturningNull() {   
    Connection<TestFacebookApi> connection = connectionFactory.createConnection(new AccessGrant("12345"));
    usersConnectionRepository.setConnectionSignUp(new ConnectionSignUp() {
      public String execute(Connection<?> connection) {
        return null;
      }
    });
View Full Code Here

    connectionRepository.removeConnection(new ConnectionKey("facebook", "1"));
  }

  @Test
  public void addConnection() {
    Connection<TestFacebookApi> connection = connectionFactory.createConnection(new AccessGrant("123456789", null, "987654321", 3600L));
    connectionRepository.addConnection(connection);
    Connection<TestFacebookApi> restoredConnection = connectionRepository.getPrimaryConnection(TestFacebookApi.class);
    assertEquals(connection, restoredConnection)
    assertNewConnection(restoredConnection);
  }
View Full Code Here

    assertNewConnection(restoredConnection);
  }
 
  @Test(expected=DuplicateConnectionException.class)
  public void addConnectionDuplicate() {
    Connection<TestFacebookApi> connection = connectionFactory.createConnection(new AccessGrant("123456789", null, "987654321", 3600L));
    connectionRepository.addConnection(connection);
    connectionRepository.addConnection(connection);
  }
View Full Code Here

      params.add("state", connectionFactory.generateState()); // TODO: Verify the state value after callback
      throw new SocialAuthenticationRedirectException(getConnectionFactory().getOAuthOperations().buildAuthenticateUrl(params));
    } else if (StringUtils.hasText(code)) {
      try {
        String returnToUrl = buildReturnToUrl(request);
        AccessGrant accessGrant = getConnectionFactory().getOAuthOperations().exchangeForAccess(code, returnToUrl, null);
        // TODO avoid API call if possible (auth using token would be fine)
        Connection<S> connection = getConnectionFactory().createConnection(accessGrant);
        return new SocialAuthenticationToken(connection, null);
      } catch (RestClientException e) {
        logger.debug("failed to exchange for access", e);
View Full Code Here

        }       
        public AccessGrant exchangeCredentialsForAccess(String username, String password, MultiValueMap<String, String> additionalParameters) {
          return null;
        }
        public AccessGrant refreshAccess(String refreshToken, MultiValueMap<String, String> additionalParameters) {
          return new AccessGrant("765432109", "read", "654321098", 3600L);
        }
        @Deprecated
        public AccessGrant refreshAccess(String refreshToken, String scope, MultiValueMap<String, String> additionalParameters) {
          return new AccessGrant("765432109", "read", "654321098", 3600L);
        }
        public AccessGrant authenticateClient() {
          return null;
        }
        public AccessGrant authenticateClient(String scope) {
View Full Code Here

  @Before
  public void setup() {
    AppCredentials app = getAppCredentials();
    FacebookServiceProvider sp = new FacebookServiceProvider(app.getAppId(), app.getAppSecret(), app.getAppNamespace());
    AccessGrant clientGrant = sp.getOAuthOperations().authenticateClient();
    this.CLIENT_FB = new FacebookTemplate(clientGrant.getAccessToken());
    this.testUser = createTestUser("Jack Diamond", ALL_PERMISSIONS);
    this.fb = new FacebookTemplate(this.testUser.getAccessToken());
  }
View Full Code Here

  @Override
  @SuppressWarnings("unchecked"
  protected AccessGrant postForAccessGrant(String accessTokenUrl, MultiValueMap<String, String> parameters) {
    MultiValueMap<String, String> response = getRestTemplate().postForObject(accessTokenUrl, parameters, MultiValueMap.class);
    String expires = response.getFirst("expires");
    return new AccessGrant(response.getFirst("access_token"), null, null, expires != null ? Long.valueOf(expires) : null);
  }
View Full Code Here

      };
    }

    debug("Access token available in signed_request parameter. Creating connection and signing in.");
    OAuth2ConnectionFactory<Facebook> connectionFactory = (OAuth2ConnectionFactory<Facebook>) connectionFactoryLocator.getConnectionFactory(Facebook.class);
    AccessGrant accessGrant = new AccessGrant(accessToken);
    // TODO: Maybe should create via ConnectionData instead?
    Connection<Facebook> connection = connectionFactory.createConnection(accessGrant);
    handleSignIn(connection, request);
    debug("Signed in. Redirecting to post-signin page.");
    return new RedirectView(postSignInUrl, true);
View Full Code Here

    }
    return oauthOperations.fetchRequestToken(null, requestParameters);       
  }

  private String buildOAuth2Url(OAuth2ConnectionFactory<?> connectionFactory, NativeWebRequest request, MultiValueMap<String, String> additionalParameters) {
    OAuth2Operations oauthOperations = connectionFactory.getOAuthOperations();
    String defaultScope = connectionFactory.getScope();
    OAuth2Parameters parameters = getOAuth2Parameters(request, defaultScope, additionalParameters);
    String state = connectionFactory.generateState();
    parameters.add("state", state);
    sessionStrategy.setAttribute(request, OAUTH2_STATE_ATTRIBUTE, state);
    if (useAuthenticateUrl) {
      return oauthOperations.buildAuthenticateUrl(parameters);
    } else {
      return oauthOperations.buildAuthorizeUrl(parameters);
    }
  }
View Full Code Here

TOP

Related Classes of org.springframework.social.oauth2.OAuth2TokenParameterRequestInterceptor

Copyright © 2018 www.massapicom. 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.