Package org.springframework.social.security

Examples of org.springframework.social.security.SocialAuthenticationToken


      String verifiedId = (String) token.getPrincipal();
      ConnectionData data = new ConnectionData(connectionFactory.getProviderId(), verifiedId, null, null, null,
          null, null, null, null);

      return new SocialAuthenticationToken(connectionFactory.createConnection(data), obtainAccountData(token));
    } catch (OpenIDConsumerException oice) {
      throw new AuthenticationServiceException("Consumer error", oice);
    }
  }
View Full Code Here


      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);
        return null;
      }
    } else {
View Full Code Here

    request.setSession(session);
    request.addParameter("param", "param_value");
    MockHttpServletResponse response = new MockHttpServletResponse();
   
    try {
      SocialAuthenticationToken token = authSvc.getAuthToken(request, response);
      fail("redirect expected, was token " + token);
    } catch (SocialAuthenticationRedirectException e) {
      // expect redirect to service url including token
      assertEquals(serviceUrl + "?oauth_token=" + oAuthToken.getValue(), e.getRedirectUrl());
    }
   
    // second phase
    request = new MockHttpServletRequest(context, "GET", "/auth/foo");
    request.setServerName(serverName);
    request.setSession(session);
    request.addParameter("oauth_verifier", verifier);
    response = new MockHttpServletResponse();
   
    SocialAuthenticationToken token = authSvc.getAuthToken(request, response);
    assertNotNull(token);
    assertTrue(token.getConnection() instanceof Connection);
    assertFalse(token.isAuthenticated());
  }
View Full Code Here

    request.setSession(session);
    request.addParameter("param", "param_value");
    MockHttpServletResponse response = new MockHttpServletResponse();

    try {
      SocialAuthenticationToken token = authSvc.getAuthToken(request, response);
      fail("redirect expected, was token " + token);
    } catch (SocialAuthenticationRedirectException e) {
      // expect redirect to service url including token
      // assertEquals(serviceUrl + "?oauth_token=" +
      // oAuthToken.getValue(), e.getRedirectUrl());
    }

    // second phase
    request = new MockHttpServletRequest(context, "GET", "/auth/foo");
    request.setServerName(serverName);
    request.setSession(session);
    request.addParameter("code", code);
    response = new MockHttpServletResponse();

    SocialAuthenticationToken token = authSvc.getAuthToken(request, response);
    assertNotNull(token);
    assertTrue(token.getConnection() instanceof Connection);
    assertFalse(token.isAuthenticated());
  }
View Full Code Here

        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

Related Classes of org.springframework.social.security.SocialAuthenticationToken

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.