Package oauth.signpost

Examples of oauth.signpost.OAuthConsumer


     * @param token the token obtained from a previous call
     * @param secret your application secret
     * @return a Response object holding either the result in case of a success or the error
     */
    public Response retrieveAccessToken(String token, String secret) {
         OAuthConsumer consumer = new DefaultOAuthConsumer(info.consumerKey, info.consumerSecret);
        consumer.setTokenWithSecret(token, secret);
        String verifier = Params.current().get("oauth_verifier");
        try {
            provider.retrieveAccessToken(consumer, verifier);
        } catch (OAuthException e) {
            return Response.error(new Error(e));
        }
        return Response.success(consumer.getToken(), consumer.getTokenSecret());
    }
View Full Code Here


     *
     * @param callbackURL the URL where the provider should redirect to
     * @return a Response object holding either the result in case of a success or the error
     */
    public Response retrieveRequestToken(String callbackURL) {
        OAuthConsumer consumer = new DefaultOAuthConsumer(info.consumerKey, info.consumerSecret);
        try {
            provider.retrieveRequestToken(consumer, callbackURL);
        } catch (OAuthException e) {
            return Response.error(new Error(e));
        }
        return Response.success(consumer.getToken(), consumer.getTokenSecret());
    }
View Full Code Here

     * @param token  the token obtained from a previous call
     * @param secret your application secret
     * @return a Response object holding either the result in case of a success or the error
     */
    public Response retrieveAccessToken(String token, String secret) {
        OAuthConsumer consumer = new DefaultOAuthConsumer(info.consumerKey, info.consumerSecret);
        consumer.setTokenWithSecret(token, secret);
        String verifier = Params.current().get("oauth_verifier");
        try {
            provider.retrieveAccessToken(consumer, verifier);
        } catch (OAuthException e) {
            return Response.error(new Error(e));
        }
        return Response.success(consumer.getToken(), consumer.getTokenSecret());
    }
View Full Code Here

                for (String key : this.headers.keySet()) {
                    connection.setRequestProperty(key, headers.get(key));
                }
                checkFileBody(connection);
                if (this.oauthToken != null && this.oauthSecret != null) {
                    OAuthConsumer consumer = new DefaultOAuthConsumer(oauthInfo.consumerKey, oauthInfo.consumerSecret);
                    consumer.setTokenWithSecret(oauthToken, oauthSecret);
                    consumer.sign(connection);
                }
                return connection;
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
View Full Code Here

    }
  }

  public ContentExchange stream(ContentExchange ex, Symbol... symbols) throws ModelException
  {
    OAuthConsumer consumer = new JettyOAuthConsumer(ForemanConstants.API_KEY.toString(), ForemanConstants.API_SECRET.toString());
    consumer.setTokenWithSecret(ForemanConstants.ACCESS_TOKEN.toString(), ForemanConstants.ACCESS_TOKEN_SECRET.toString());

    ex.setMethod(Verb.GET.name());
    ex.setURL(APICall.getStreamingQuote(ResponseFormat.XML) + getParameters(symbols));

    // sign the request
    try
    {
      consumer.sign(ex);
      client.send(ex);
    }
    catch (IOException | OAuthMessageSignerException | OAuthExpectationFailedException | OAuthCommunicationException e)
    {
      throw new ModelException("Sent Exchange to Client", e);
View Full Code Here

    @Override
    protected void finish() {}

    protected void sign(HttpURLConnection con) throws OAuthException{
        OAuthConsumer consumer = oauthParameters.buildConsumer();
        consumer.setTokenWithSecret(token.getKey(), token.getSecret());
        consumer.sign(con);
    }
View Full Code Here

     */
    protected void addOAuthAuthorizationHeader(HttpURLConnection connection) throws OsmTransferException {
        if (oauthParameters == null) {
            oauthParameters = OAuthParameters.createFromPreferences(Main.pref);
        }
        OAuthConsumer consumer = oauthParameters.buildConsumer();
        OAuthAccessTokenHolder holder = OAuthAccessTokenHolder.getInstance();
        if (! holder.containsAccessToken())
            throw new MissingOAuthAccessTokenException();
        consumer.setTokenWithSecret(holder.getAccessTokenKey(), holder.getAccessTokenSecret());
        try {
            consumer.sign(connection);
        } catch(OAuthException e) {
            throw new OsmTransferException(tr("Failed to sign a HTTP connection with an OAuth Authentication header"), e);
        }
    }
View Full Code Here

  }

  private byte[] doRequest(HttpRequestBase request, TokenHolder tokenHolder, HttpParameters oauthParams) {
    CloseableHttpResponse response = null;
    try {
      OAuthConsumer consumer = tokenHolder.createConsumer();
      consumer.setAdditionalParameters(oauthParams);
      consumer.sign(request);
      response = client.execute(request);
      int statusCode = response.getStatusLine().getStatusCode();
      HttpEntity entity = response.getEntity();
      byte[] content = entity != null ? readBytes(entity.getContent()) : new byte[0];
      switch (statusCode) {
View Full Code Here

  }

  private byte[] doRequest(HttpRequestBase request, TokenHolder tokenHolder, HttpParameters oauthParams) {
    CloseableHttpResponse response = null;
    try {
      OAuthConsumer consumer = tokenHolder.createConsumer();
      consumer.setAdditionalParameters(oauthParams);
      consumer.sign(request);
      response = client.execute(request);
      int statusCode = response.getStatusLine().getStatusCode();
      HttpEntity entity = response.getEntity();
      byte[] content = entity != null ? readBytes(entity.getContent()) : new byte[0];
      switch (statusCode) {
View Full Code Here

      this.clientServiceRegistration.unregister();
    }
  }

  private OAuthConsumer createConsumer() {
    OAuthConsumer consumer = new DefaultOAuthConsumer(this.consumerKey,
        this.consumerSecret);
    consumer.setSigningStrategy(new AuthorizationHeaderSigningStrategy());
    consumer.setMessageSigner(new HmacSha1MessageSigner());
    return consumer;
  }
View Full Code Here

TOP

Related Classes of oauth.signpost.OAuthConsumer

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.