Examples of SocialAuthenticationToken


Examples of org.encuestame.core.security.token.SocialAuthenticationToken

      */
    @Override
    public Authentication authenticate(Authentication authentication)
            throws AuthenticationException {
        if (authentication instanceof SocialAuthenticationToken) {
            SocialAuthenticationToken response = (SocialAuthenticationToken) authentication;
            // handle the various possibilities
                // Lookup user details
                UserDetails userDetails;
                try {
                    userDetails = socialUserService.loadAccountConnection(response.getProfileId(), response.getProvider());
                    //logger.debug("user details "+userDetails);
                } catch (EnMeNoSuchAccountConnectionException e) {
                    throw new BadCredentialsException(e.getMessage());
                }
            Authentication auth = createSuccessAuthentication(response);
View Full Code Here

Examples of org.encuestame.core.security.token.SocialAuthenticationToken

     * @return
     */
    protected Authentication createSuccessAuthentication(SocialAuthenticationToken authentication) {
        //TODO: in the future add more conditionals to block accounts.
        Object user = authentication.getPrincipal();
        final SocialAuthenticationToken result = new SocialAuthenticationToken(user, authentication.getAuthorities());
        result.setProfileId(authentication.getProfileId());
        result.setProvider(authentication.getProvider());
        if (logger.isDebugEnabled()) {
            //logger.debug("createSuccessAuthentication "+result);
        }
        return result;
    }
View Full Code Here

Examples of org.encuestame.core.security.token.SocialAuthenticationToken

                .convertEnMePermission(account.getSecUserPermissions());
        // create user detail based on user account.
        final EnMeSocialUserAccount details = SecurityUtils.convertUserAccountToUserDetails(accountConnection);
        // set the social credentials permission.
        details.setSocialCredentials(true);
        final SocialAuthenticationToken token = new SocialAuthenticationToken(details, authorities);
        token.setProfileId(accountConnection.getSocialProfileId());
        token.setProvider(accountConnection.getAccounType());
        //clear the context.
        SecurityContextHolder.clearContext();
        //set new authentication.
        SecurityContextHolder.getContext().setAuthentication(token);
        if (log.isInfoEnabled()) {
View Full Code Here

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

Examples of org.springframework.social.security.SocialAuthenticationToken

      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

Examples of org.springframework.social.security.SocialAuthenticationToken

    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

Examples of org.springframework.social.security.SocialAuthenticationToken

    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

Examples of org.springframework.social.security.SocialAuthenticationToken

        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.