Package org.apache.oltu.oauth2.ext.dynamicreg.server.request

Examples of org.apache.oltu.oauth2.ext.dynamicreg.server.request.OAuthServerRegistrationRequest


        OAuthClientRequest request = OAuthClientRequest
            .tokenLocation(Common.ACCESS_TOKEN_ENDPOINT)
            .setClientId(Common.CLIENT_ID)
            .buildBodyMessage();

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

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


            .setClientId("unknownid")
            .setClientSecret(Common.CLIENT_SECRET)
            .setRedirectURI(Common.REDIRECT_URL)
            .buildBodyMessage();

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

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

            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);
            String username = resourceResponse.getBody();
            return username;
View Full Code Here

   */
  protected String getServerResponse(String url) throws OAuthException{
    OAuthClient oAuthClient = new OAuthClient(new URLConnectionClient());
    OAuthClientRequest request;
    try {
      request = new OAuthBearerClientRequest(url)
      .setAccessToken(getAccessToken())
      .buildQueryMessage();
    } catch (OAuthSystemException e1) {
      throw new OAuthException("An error occured while authenticating the user");
    }
View Full Code Here

    private String extractUsername(String code) {

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

            OAuthClientRequest accessTokenRequest = OAuthClientRequest
                    .tokenLocation(accessTokenUrl)
                    .setGrantType(GrantType.AUTHORIZATION_CODE)
                    .setClientId(clientId)
                    .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);
            String username = resourceResponse.getBody();
            return username;
View Full Code Here

public class ClientRegistrationTest extends ClientServerOAuthTest {

    @Test
    public void testPushMetadataRegistration() throws Exception {

        OAuthClientRequest request = OAuthClientRegistrationRequest
            .location(CommonExt.REGISTRATION_ENDPOINT, OAuthRegistration.Type.PUSH)
            .setName(CommonExt.APP_NAME)
            .setUrl(CommonExt.APP_URL)
            .setDescription(CommonExt.APP_DESCRIPTION)
            .setIcon(CommonExt.APP_ICON)
View Full Code Here

    }

    @Test
    public void testInvalidType() throws Exception {

        OAuthClientRequest request = OAuthClientRegistrationRequest
            .location(CommonExt.REGISTRATION_ENDPOINT, "unknown_type")
            .setName(CommonExt.APP_NAME)
            .setUrl(CommonExt.APP_URL)
            .setDescription(CommonExt.APP_DESCRIPTION)
            .setIcon(CommonExt.APP_ICON)
View Full Code Here

   * @return The body of the response.
   * @throws OAuthException If an error occurs while making the call.
   */
  protected String getServerResponse(String url) throws OAuthException{
    OAuthClient oAuthClient = new OAuthClient(new URLConnectionClient());
    OAuthClientRequest request;
    try {
      request = new OAuthBearerClientRequest(url)
      .setAccessToken(getAccessToken())
      .buildQueryMessage();
    } catch (OAuthSystemException e1) {
View Full Code Here

   */
  public static void redirectToOAuthProvider(HttpServletRequest req, HttpServletResponse resp, OAuthParams oauthParams) throws OAuthException {
    try {
      AuthenticationRequestBuilder requestBuilder = OAuthClientRequest.authorizationProvider(oauthParams.getProviderType()).setClientId(oauthParams.getClientKey()).setRedirectURI(oauthParams.getRedirectURI()).setResponseType(oauthParams.getResponseType()).setScope(oauthParams.getScope()).setState(oauthParams.getState());
      oauthParams.addAdditionsParams(requestBuilder);
      OAuthClientRequest request = requestBuilder.buildQueryMessage();
      resp.sendRedirect(request.getLocationUri());
    } catch (OAuthSystemException e) {
      // Error building request
      throw new OAuthException(e);
    } catch (IOException e) {
      // Error with sending redirect
View Full Code Here

    String code = req.getParameter("code");
    if (code == null)
      throw new OAuthException("No code provided");

    try {
      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());
View Full Code Here

TOP

Related Classes of org.apache.oltu.oauth2.ext.dynamicreg.server.request.OAuthServerRegistrationRequest

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.