Examples of OAuthClient


Examples of com.cloudbees.api.oauth.OauthClient

            }
        }
        logger.debug("Expecting scopes: "+Arrays.toString(scopes.toArray()));

        // Create OAuth client
        OauthClient oauthClient = new BeesClient(oauthConfig.getClientId(), oauthConfig.getClientSecret()).getOauthClient();

        //parse Bearer token from Authorization header
        String token = oauthClient.parseAuthorizationHeader(request.getHeaderValue("Authorization"));

        // If not found get it from the access_token parameter
        if(token == null){
            token = request.getQueryParameters().getFirst("access_token");
        }

        if (token == null) {
            logger.error("No OAuth access_token found in the request.");
            throw new AuthException(401, "No OAuth access_token found in the request.");
        }

        OauthToken oauthToken;
        try {
            //Validate scopes
            if(secureAnnotation.validateAllScopes()){
                oauthToken = oauthClient.validateToken(token);
                if(oauthToken != null){
                    for(String scope:scopes){
                        if(!oauthToken.validateScope(scope)){
                            throw new AuthException(401, String.format("Expected scope: %s not found on the token", scope));
                        }
                    }
                }
            }else{
                oauthToken = oauthClient.validateToken(token,scopes.toArray(new String[scopes.size()]));
            }
        } catch (OauthClientException e) {
            logger.error(e.getMessage(),e);
            throw new AuthException(401, "Authentication failed, invalid token");
        }
View Full Code Here

Examples of net.oauth.client.OAuthClient

      params.add(new OAuth.Parameter((String) p.getKey(), (String) p
          .getValue()));
    }
    OAuthAccessor accessor = createOAuthAccessor();
    accessor.tokenSecret = props.getProperty("tokenSecret");
    OAuthClient client = new OAuthClient(
        new HttpClient4(new SingleClient()));
    return client.invoke(accessor, "GET", url, params);
  }
View Full Code Here

Examples of net.oauth.client.OAuthClient

  }

  public void request() throws Exception {
    OAuthAccessor accessor = createOAuthAccessor();
    HttpClient4 httpClient = new HttpClient4(new SingleClient());
    OAuthClient client = new OAuthClient(httpClient);
    client.getRequestToken(accessor);
    props.setProperty("requestToken", accessor.requestToken);
    props.setProperty("tokenSecret", accessor.tokenSecret);
    updateProperties("Last action: added requestToken");
  }
View Full Code Here

Examples of net.oauth.client.OAuthClient

      String accessTokenUrl) {
    OAuthServiceProvider provider =
        new OAuthServiceProvider(requestTokenUrl, authorizeUrl, accessTokenUrl);
    OAuthConsumer consumer = new OAuthConsumer(callbackUrl, consumerKey, consumerSecret, provider);
    OAuthAccessor accessor = new OAuthAccessor(consumer);
    OAuthClient client = new OAuthClient(new OpenSocialHttpClient());
    PersistenceManagerFactory pmf = SingletonPersistenceManagerFactory.get();
    return new OAuthServiceImpl(accessor, client, pmf, userRecordKey);
  }
View Full Code Here

Examples of net.oauth.client.OAuthClient

        OAuthAccessor accessor = consumerDataObj.getAccessor();
        OAuthMessage message = accessor.newRequestMessage("POST", rpcServerUrl, null, bodyStream);
        message.getHeaders().add(
            new SimpleEntry<String, String>(HttpMessage.CONTENT_TYPE, JSON_MIME_TYPE));
        message.getHeaders().add(new SimpleEntry<String, String>("oauth_version", "1.0"));
        OAuthClient client = new OAuthClient(httpFetcher);
        responseStream = client.invoke(message, net.oauth.ParameterStyle.BODY).getBodyAsStream();
      }

      String responseString = HttpFetcher.readInputStream(responseStream);
      if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("Response returned: " + responseString);
View Full Code Here

Examples of net.oauth.client.OAuthClient

   * request token).
   */
  public final void testCheckAuthorizationNoRequestToken() {
    // Setup.
    LoginFormHandler loginForm = mock(LoginFormHandler.class);
    OAuthClient client = mock(OAuthClient.class);
    PersistenceManager pm = mock(PersistenceManager.class);
    PersistenceManagerFactory pmf = mock(PersistenceManagerFactory.class);

    OAuthAccessor accessor = buildAccessor(CONSUMER_KEY, CONSUMER_SECRET,
        REQUEST_TOKEN_URL, AUTHORIZE_URL, CALLBACK_URL, ACCESS_TOKEN_URL);
View Full Code Here

Examples of net.oauth.client.OAuthClient

    if (provider.requestTokenUrl == null) {
      // Used for unregistered oauth
      return new Token("", "");
    }

    OAuthClient httpClient = getOAuthClient();
    OAuthAccessor accessor =
      new OAuthAccessor(getOAuthConsumer(client, provider));

    Set<Map.Entry<String,String>> extraParams = null;
    if (provider.requestTokenParams != null) {
      extraParams = provider.requestTokenParams.entrySet();
    }
    httpClient.getRequestToken(accessor, "GET", extraParams);

    return new Token(accessor.requestToken, accessor.tokenSecret);
  }
View Full Code Here

Examples of net.oauth.client.OAuthClient

    OAuthAccessor accessor =
      new OAuthAccessor(getOAuthConsumer(client, provider));
    accessor.accessToken = requestToken.token;
    accessor.tokenSecret = requestToken.secret;

    OAuthClient httpClient = getOAuthClient();
    OAuthMessage message = httpClient.invoke(accessor, "GET",
        provider.accessTokenUrl, null);

    return new Token(message.getToken(),
        message.getParameter("oauth_token_secret"));
  }
View Full Code Here

Examples of net.oauth.client.OAuthClient

  }

  private static OAuthClient getOAuthClient() {
    if (oAuthClient == null) {
      final HttpClient httpClient = new OpenSocialHttpClient();
      oAuthClient = new OAuthClient(httpClient);
    }

    return oAuthClient;
  }
View Full Code Here

Examples of net.oauth.client.OAuthClient

 
 
  protected OAuthClient createOAuthClient()
  {
   
    OAuthClient authClient = new OAuthClient(new HttpClient4(this.pool));
   
    return authClient;
  }
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.