Examples of OauthToken


Examples of org.springframework.social.oauth1.OAuthToken

    connectController.setConnectInterceptors(interceptors);
    connectController.afterPropertiesSet();
    MockMvc mockMvc = standaloneSetup(connectController).build();
    assertEquals(0, connectionRepository.findConnections("oauth2Provider").size());   
    mockMvc.perform(get("/connect/oauth1Provider")
            .sessionAttr("oauthToken", new OAuthToken("requestToken", "requestTokenSecret"))
            .param("oauth_token", "requestToken")
            .param("oauth_verifier", "verifier"))
      .andExpect(redirectedUrl("/connect/oauth1Provider"));
    List<Connection<?>> connections = connectionRepository.findConnections("oauth1Provider");
    assertEquals(1, connections.size());
View Full Code Here

Examples of org.springframework.social.oauth1.OAuthToken

    connectionFactoryLocator.addConnectionFactory(connectionFactory);
    StubConnectionRepository connectionRepository = new StubConnectionRepository();
    MockMvc mockMvc = standaloneSetup(new ConnectController(connectionFactoryLocator, connectionRepository)).build();
    assertEquals(0, connectionRepository.findConnections("oauth2Provider").size());   
    mockMvc.perform(get("/connect/oauth1Provider")
            .sessionAttr("oauthToken", new OAuthToken("requestToken", "requestTokenSecret"))
            .param("oauth_token", "requestToken")
            .param("oauth_verifier", "verifier"))
      .andExpect(redirectedUrl("/connect/oauth1Provider"))
      .andExpect(request().sessionAttribute("social_provider_error", notNullValue()));
    assertEquals(0, connectionRepository.findConnections("oauth2Provider").size());   
View Full Code Here

Examples of org.springframework.social.oauth1.OAuthToken

    String verifier = request.getParameter("oauth_verifier");
    if (!StringUtils.hasText(verifier)) {
      // First phase: get a request token
      OAuth1Operations ops = getConnectionFactory().getOAuthOperations();
      String returnToUrl = buildReturnToUrl(request);
      OAuthToken requestToken = ops.fetchRequestToken(returnToUrl, null);
      request.getSession().setAttribute(OAUTH_TOKEN_ATTRIBUTE, requestToken);

      // Redirect to the service provider for authorization
      OAuth1Parameters params;
      if (ops.getVersion() == OAuth1Version.CORE_10) {
        params = new OAuth1Parameters();
        params.setCallbackUrl(returnToUrl);
      } else {
        params = OAuth1Parameters.NONE;
      }     
      throw new SocialAuthenticationRedirectException(ops.buildAuthenticateUrl(requestToken.getValue(), params));
    } else {
      // Second phase: request an access token
      OAuthToken requestToken = extractCachedRequestToken(request);
      if (requestToken == null) {
        logger.warn("requestToken unavailable for oauth_verifier");
        return null;
      }
      OAuthToken accessToken = getConnectionFactory().getOAuthOperations().exchangeForAccessToken(new AuthorizedRequestToken(requestToken, verifier), null);
      // TODO avoid API call if possible (auth using token would be fine)
            Connection<S> connection = getConnectionFactory().createConnection(accessToken);
            return new SocialAuthenticationToken(connection, null);
    }
  }
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.