Package org.apache.oltu.oauth2.client.response

Examples of org.apache.oltu.oauth2.client.response.OAuthClientResponse


                    .setClientSecret(clientSecret)
                    .setCode(code)
                    .setRedirectURI(redirectUrl)
                    .buildQueryMessage();

            OAuthAccessTokenResponse oAuthResponse = oAuthClient.accessToken(accessTokenRequest, OAuth.HttpMethod.POST);

            String accessToken = oAuthResponse.getAccessToken();
            Long expiresIn = oAuthResponse.getExpiresIn();

            OAuthClientRequest userInfoRequest = new OAuthBearerClientRequest(userInfoUrl)
                    .setAccessToken(accessToken).buildQueryMessage();

            OAuthResourceResponse resourceResponse = oAuthClient.resource(userInfoRequest, OAuth.HttpMethod.GET, OAuthResourceResponse.class);
View Full Code Here


      OAuthClientRequest request = OAuthClientRequest.tokenProvider(oauthParams.getProviderType()).setGrantType(oauthParams.getGrantType()).setClientId(oauthParams.getClientKey()).setClientSecret(oauthParams.getClientSecret()).setRedirectURI(oauthParams.getRedirectURI()).setCode(code).buildBodyMessage();

      OAuthClient oAuthClient = new OAuthClient(new URLConnectionClient());

      // Send request to oauth server
      OAuthAccessTokenResponse oauthAccessTokenResponse = oAuthClient.accessToken(request, oauthParams.getTokenResponseClass());

      OAuthConsumer consumer = oauthParams.getNewOAuthConsumer(oauthAccessTokenResponse);
      return consumer;
    } catch (OAuthSystemException e) {
      // Error building request
View Full Code Here

            .setGrantType(GrantType.PASSWORD)
            .setClientId(Common.CLIENT_ID)
            .buildBodyMessage();

        OAuthClient oAuthClient = new OAuthClient(new URLConnectionClient());
        OAuthClientResponse response = null;

        try {
            oAuthClient.accessToken(request);
            fail("exception expected");
        } catch (OAuthProblemException e) {
View Full Code Here

            .setUsername(Common.USERNAME)
            .setPassword(Common.PASSWORD)
            .buildBodyMessage();

        OAuthClient oAuthClient = new OAuthClient(new URLConnectionClient());
        OAuthClientResponse response = null;

        try {
            oAuthClient.accessToken(request);
            fail("exception expected");
        } catch (OAuthProblemException e) {
View Full Code Here

    }

    @GET
    @Path("/redirect")
    public Response callback(@Context HttpServletRequest request) throws Exception {
        OAuthClientResponse resp = null;
        try {
            OAuthAuthzResponse.oauthCodeAuthzResponse(request);
            fail("exception expected");
        } catch (OAuthProblemException e) {
            assertEquals(OAuthError.CodeResponse.INVALID_REQUEST, e.getError());
View Full Code Here

    @GET
    @Path("/redirect1")
    public Response callback1(@Context HttpServletRequest request) throws Exception {

        OAuthClientResponse resp = null;
        try {
            OAuthAuthzResponse.oauthCodeAuthzResponse(request);
        } catch (OAuthProblemException e) {
            fail("exception not expected");
        }
View Full Code Here

*/
public class OAuthClientResponseFactoryTest {

    @Test
    public void testCreateGitHubTokenResponse() throws Exception {
        OAuthClientResponse gitHubTokenResponse = OAuthClientResponseFactory
            .createGitHubTokenResponse("access_token=123", OAuth.ContentType.URL_ENCODED, 200);
        Assert.assertNotNull(gitHubTokenResponse);
    }
View Full Code Here

        Assert.assertNotNull(gitHubTokenResponse);
    }

    @Test
    public void testCreateJSONTokenResponse() throws Exception {
        OAuthClientResponse jsonTokenResponse = OAuthClientResponseFactory
            .createJSONTokenResponse("{'access_token':'123'}", OAuth.ContentType.JSON, 200);
        Assert.assertNotNull(jsonTokenResponse);
    }
View Full Code Here

            Long expiresIn = oAuthResponse.getExpiresIn();

            OAuthClientRequest userInfoRequest = new OAuthBearerClientRequest(userInfoUrl)
                    .setAccessToken(accessToken).buildQueryMessage();

            OAuthResourceResponse resourceResponse = oAuthClient.resource(userInfoRequest, OAuth.HttpMethod.GET, OAuthResourceResponse.class);
            String username = resourceResponse.getBody();
            return username;
        } catch (Exception e) {
            e.printStackTrace();
            throw new OAuth2AuthenticationException(e);
        }
View Full Code Here

      .setAccessToken(getAccessToken())
      .buildQueryMessage();
    } catch (OAuthSystemException e1) {
      throw new OAuthException("An error occured while authenticating the user");
    }
    OAuthResourceResponse response;
    try {
      response = oAuthClient.resource(request, OAuth.HttpMethod.GET, OAuthResourceResponse.class);
    } catch (OAuthProblemException e) {
      throw new OAuthException("An error occured while authenticating the user");
    } catch (OAuthSystemException e) {
      throw new OAuthException("An error occured while authenticating the user");
    }
    return response.getBody();
  }
View Full Code Here

TOP

Related Classes of org.apache.oltu.oauth2.client.response.OAuthClientResponse

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.