Package net.oauth.http

Examples of net.oauth.http.HttpMessage


        String url = createOAuthUrlString(
            json, consumerDataObj.getRpcServerUrl(), consumerDataObj.getAccessor());
        if (LOG.isLoggable(Level.FINE)) {
          LOG.fine("JSON request to be sent: " + json);
        }
        HttpMessage request = new HttpMessage("POST", new URL(url), bodyStream);
        request.headers.add(
            new SimpleEntry<String, String>(HttpMessage.CONTENT_TYPE, JSON_MIME_TYPE));
        request.headers.add(new SimpleEntry<String, String>("oauth_version", "1.0"));
        responseStream =
            httpFetcher.execute(request, Collections.<String, Object>emptyMap()).getBody();
View Full Code Here


    final String url = "http://example.org/test?arg=value";
    final Map<String, String> headers = new HashMap<String, String>();

    SecurityTokenScheme authScheme = new SecurityTokenScheme(TOKEN);

    HttpMessage message = authScheme.getHttpMessage(new OrkutProvider(), "GET",
        url, headers, null);
    assertEquals(url + "&st=" + TOKEN, message.url.toString());
  }
View Full Code Here

    final Map<String, String> headers = new HashMap<String, String>();

    SecurityTokenScheme authScheme = new SecurityTokenScheme(TOKEN_NAME,
        TOKEN);

    HttpMessage message = authScheme.getHttpMessage(new OrkutProvider(), "GET",
        url, headers, null);
    assertEquals(url + "?" + TOKEN_NAME + "=" + TOKEN, message.url.toString());
  }
View Full Code Here

    assertEquals("http://api.myspace.com/authorize?oauth_token=OAUTH_TOKEN" +
        "&oauth_callback=http://www.example.org?token=test", authorizationUrl);

    assertEquals(1, httpClient.getNumRequests());

    HttpMessage request = httpClient.getRequest();

    assertEquals(null, request.getBody());
    assertTrue(request.url.toString().startsWith(
        "http://api.myspace.com/request_token"));
    assertTrue(request.url.toString().contains(
        "oauth_consumer_key=consumerKey"));
  }
View Full Code Here

    assertEquals("http://api.myspace.com/authorize?oauth_token=OAUTH_TOKEN" +
        "&oauth_callback=http://www.example.org?token=test", authorizationUrl);

    assertEquals(1, httpClient.getNumRequests());

    HttpMessage request = httpClient.getRequest();

    assertEquals(null, request.getBody());
    assertTrue(request.url.toString().startsWith(
        "http://api.myspace.com/request_token"));
    assertTrue(request.url.toString().contains(
        "oauth_consumer_key=consumerKey"));
    assertTrue(request.url.toString().contains(
View Full Code Here

    List<Map.Entry<String, String>> parameters =
      new ArrayList<Map.Entry<String, String>>();
    parameters.add(new OAuth.Parameter(OAuth.OAUTH_NONCE, "987654321"));
    parameters.add(new OAuth.Parameter(OAuth.OAUTH_TIMESTAMP, "123456789"));

    HttpMessage message = authScheme.getHttpMessage(provider, "GET", url,
        headers, null, parameters);

    assertEquals("http://example.org/test?arg=value" +
        "&oauth_nonce=987654321&oauth_timestamp=123456789" +
        "&oauth_token=ACCESS_TOKEN&oauth_consumer_key=consumerKey&" +
View Full Code Here

    List<Map.Entry<String, String>> parameters =
      new ArrayList<Map.Entry<String, String>>();
    parameters.add(new OAuth.Parameter(OAuth.OAUTH_NONCE, "987654321"));
    parameters.add(new OAuth.Parameter(OAuth.OAUTH_TIMESTAMP, "123456789"));

    HttpMessage message = authScheme.getHttpMessage(provider, "POST", url,
        headers, "{a:\"test\"}".getBytes("UTF-8"), parameters);

    assertEquals("http://example.org/test?arg=value" +
        "&oauth_nonce=987654321&oauth_timestamp=123456789" +
        "&oauth_body_hash=PkyA2Pf44ldLEq%2BZYMo7g6uH3UE%3D&" +
        "oauth_token=ACCESS_TOKEN&oauth_consumer_key=consumerKey&" +
        "oauth_signature_method=HMAC-SHA1&oauth_version=1.0&" +
        "oauth_signature=zdRixuj4wcLHvY6%2BT8u6%2FWGNuZI%3D",
        message.url.toString());
    assertEquals("{a:\"test\"}", new BufferedReader(
        new InputStreamReader(message.getBody())).readLine());
  }
View Full Code Here

      }
      if (!consumerDataObj.isUserAuthenticated()) {
        String url = createOAuthUrlString(
            json, consumerDataObj.getRpcServerUrl(), consumerDataObj.getAccessor());
        LOG.info("JSON request to be sent: " + json);
        HttpMessage request = new HttpMessage("POST", new URL(url), bodyStream);
        request.headers.add(
            new SimpleEntry<String, String>(HttpMessage.CONTENT_TYPE, JSON_MIME_TYPE));
        request.headers.add(new SimpleEntry<String, String>("oauth_version", "1.0"));
        responseStream =
            httpFetcher.execute(request, Collections.<String, Object>emptyMap()).getBody();
View Full Code Here

  public HttpMessage getHttpMessage(Provider provider, String method,
      String url, Map<String, String> headers, byte[] body) throws
      RequestException, IOException {
    url = appendTokenToQueryString(url);

    HttpMessage message = new HttpMessage(method, new URL(url),
        byteArrayToStream(body));
    for (Map.Entry<String, String> header : headers.entrySet()) {
      message.headers.add(header);
    }
View Full Code Here

          requests.values().iterator().next().getContentType());
    } else {
      requestHeaders.put(HttpMessage.CONTENT_TYPE, provider.getContentType());
    }

    HttpMessage message = authScheme.getHttpMessage(provider, "POST",
        buildRpcUrl(requests), requestHeaders, buildRpcPayload(requests));

    HttpResponseMessage responseMessage = httpClient.execute(message);

    logger.finest(buildLogRecord(requests, responseMessage));
View Full Code Here

TOP

Related Classes of net.oauth.http.HttpMessage

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.