Examples of OutBoundHeaders


Examples of com.sun.jersey.core.header.OutBoundHeaders

      for (Object o : entry.getValue()) {
        target = target.queryParam(entry.getKey(), String.valueOf(o));
      }
    }
    target.addFilter(logger);
    MultivaluedMap<String, Object> headers = new OutBoundHeaders();
    for(Map.Entry<String, List<Object>> h : request.headers().entrySet()) {
      for(Object v : h.getValue()) {
        headers.add(h.getKey(), v);
      }
    }
    if(request.entity() != null && request.entity().getContentType() != null) {
      headers.add("Content-Type", request.entity().getContentType());
    } else {
      headers.add("Content-Type", "application/json");
    }
    try {
      ClientResponse response = null;
      if (request.entity() != null && request.entity().getEntity() != null) {
        response = target.getHeadHandler().handle(new ClientRequestImpl(target.getURI(), request.method().name(), request.entity().getEntity(), headers));
View Full Code Here

Examples of com.sun.jersey.core.header.OutBoundHeaders

    String auth = "Basic ".concat(new String(Base64.encodeBase64(settings.getOauthKey().concat(":")
            .concat(settings.getOauthSecret()).getBytes())));
    Builder builder = client.resource(settings.getAccessTokenEndPoint()).header(AUTHORIZATION, auth)
            .type(MediaType.APPLICATION_FORM_URLENCODED_TYPE);
    OutBoundHeaders headers = getHeadersCopy(builder);
    ClientResponse clientResponse = builder.post(ClientResponse.class, formData);
    String json = IOUtils.toString(clientResponse.getEntityInputStream());
    HashMap map = mapper.readValue(json, HashMap.class);
    settings.setStep("step3");
    settings.setAccessToken((String) map.get("access_token"));
    modelMap.put(SETTINGS, settings);
    modelMap.put(
            "requestInfo",
            "Method: POST".concat(BR).concat("URL: ").concat(settings.getAccessTokenEndPoint()).concat(BR)
                    .concat("Headers: ").concat(headers.toString()).concat(BR).concat("Body: ").concat(formData.toString()));
    addResponseInfo(modelMap, clientResponse);
    modelMap.put("rawResponseInfo", json);
    return "oauth-client";
  }
View Full Code Here

Examples of com.sun.jersey.core.header.OutBoundHeaders

  public String step3(ModelMap modelMap, @ModelAttribute("settings")
  ClientSettings settings, HttpServletRequest request, HttpServletResponse response) throws IOException {
    Builder builder = client.resource(settings.getRequestURL())
            .header(AUTHORIZATION, "bearer ".concat(settings.getAccessToken()))
            .type(MediaType.APPLICATION_FORM_URLENCODED_TYPE);
    OutBoundHeaders headers = getHeadersCopy(builder);
    ClientResponse clientResponse = builder.get(ClientResponse.class);
    String json = IOUtils.toString(clientResponse.getEntityInputStream());
    settings.setStep("step3");
    modelMap.put(SETTINGS, settings);
    modelMap.put("requestInfo", "Method: GET".concat(BR).concat("URL: ").concat(settings.getRequestURL()).concat(BR)
            .concat("Headers: ").concat(headers.toString()));
    addResponseInfo(modelMap, clientResponse);
    modelMap.put("rawResponseInfo", json);
    return "oauth-client";
  }
View Full Code Here

Examples of com.sun.jersey.core.header.OutBoundHeaders

  private OutBoundHeaders getHeadersCopy(Builder builder) {
    Field metaData;
    try {
      metaData = PartialRequestBuilder.class.getDeclaredField("metadata");
      metaData.setAccessible(true);
      return new OutBoundHeaders((OutBoundHeaders) metaData.get(builder));
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

Examples of com.sun.jersey.core.header.OutBoundHeaders

  public void testCanonicalRepresentation_Client_AllFields_Get() throws Exception {

    // Not required for GET but introduced for consistent style
    Providers providers = null;

    OutBoundHeaders headers = new OutBoundHeaders();
    headers.add(HttpHeaders.DATE, "Sat, 01 Jan 2000 12:34:56 GMT");
    headers.add(HttpHeaders.HOST, "www.example.org");
    headers.add(HttpHeaders.USER_AGENT, "curl/7.20.0 (x86_64-pc-linux-gnu) libcurl/7.20.0 OpenSSL/1.0.0a zlib/1.2.3");
    headers.add(HmacUtils.X_HMAC_DATE, "Sat, 01 Jan 2000 12:34:57 GMT");
    headers.add(HmacUtils.X_HMAC_NONCE, "Thohn2Mohd2zugo");

    URI uri = new URI(baseUri + resourcePath + queryParameters);

    ClientRequest clientRequest = new ClientRequestImpl(uri, "get", null, headers);
View Full Code Here

Examples of com.sun.jersey.core.header.OutBoundHeaders

    // Mock Providers
    Providers providers = mock(Providers.class);
    when(providers.getMessageBodyWriter(String.class, String.class,
      new Annotation[0], MediaType.APPLICATION_JSON_TYPE)).thenReturn(messageBodyWriter);

    OutBoundHeaders headers = new OutBoundHeaders();
    headers.add(HttpHeaders.DATE, "Sat, 01 Jan 2000 12:34:56 GMT");
    headers.add(HttpHeaders.HOST, "www.example.org");
    headers.add(HttpHeaders.USER_AGENT, "curl/7.20.0 (x86_64-pc-linux-gnu) libcurl/7.20.0 OpenSSL/1.0.0a zlib/1.2.3");
    headers.add(HmacUtils.X_HMAC_DATE, "Sat, 01 Jan 2000 12:34:57 GMT");
    headers.add(HmacUtils.X_HMAC_NONCE, "Thohn2Mohd2zugo");

    URI uri = new URI(baseUri + resourcePath + queryParameters);

    String entity = "{\"_links\":{\"self\":{\"href\":\"http://example.org/user\"}}}";
View Full Code Here

Examples of com.sun.jersey.core.header.OutBoundHeaders

    private ResponseBuilderImpl(ResponseBuilderImpl that) {
        this.statusType = that.statusType;
        this.entity = that.entity;
        if (that.headers != null) {
            this.headers = new OutBoundHeaders(that.headers);
        } else {
            this.headers = null;
        }
        this.entityType = that.entityType;
    }
View Full Code Here

Examples of com.sun.jersey.core.header.OutBoundHeaders

        return this;
    }

    private OutBoundHeaders getHeaders() {
        if (headers == null)
            headers = new OutBoundHeaders();
        return headers;
    }
View Full Code Here

Examples of com.sun.jersey.core.header.OutBoundHeaders

         */
        protected AJResponseBuilder(AJResponseBuilder<E, ?> that) {
            this.statusType = that.statusType;
            this.entity = that.entity;
            if (that.headers != null) {
                this.headers = new OutBoundHeaders(that.headers);
            } else {
                this.headers = null;
            }
        }
View Full Code Here

Examples of com.sun.jersey.core.header.OutBoundHeaders

         *
         * @return response metadata as a map
         */
        protected OutBoundHeaders getMetadata() {
            if (headers == null)
                headers = new OutBoundHeaders();
            return headers;
        }
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.