List of usage examples for org.springframework.http HttpHeaders add
@Override public void add(String headerName, @Nullable String headerValue)
From source file:com.goldengekko.meetr.service.salesforce.SalesforceService.java
protected static HttpEntity getRequestEntity(String accessToken) { HttpHeaders headers = new HttpHeaders(); final String auth = String.format("OAuth %s", accessToken); headers.add("Authorization", auth); LOG.info("Salesforce Authorization: {}", auth); final HttpEntity requestEntity = new HttpEntity(headers); return requestEntity; }
From source file:cn.org.once.cstack.utils.RestUtils.java
@SuppressWarnings("rawtypes") public static String sendPostCommand(String url, String volume) { RestTemplate restTemplate = new RestTemplate(); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); headers.add("Accept", "text/plain"); MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>(); params.add("Binds", volume); @SuppressWarnings("unchecked") HttpEntity request = new HttpEntity(params, headers); ResponseEntity<String> response = restTemplate.postForEntity(url, request, String.class); return response.toString(); }
From source file:com.hatta.consumer.App.java
private static HttpHeaders getHeadersWithClientCredentials() { String plainClientCredentials = "frontend:secret"; String base64ClientCredentials; base64ClientCredentials = new String(Base64.encodeBase64(plainClientCredentials.getBytes())); HttpHeaders headers = getHeaders(); headers.add("Authorization", "Basic " + base64ClientCredentials); return headers; }
From source file:org.dthume.spring.http.client.httpcomponents.HttpComponentsClientHttpResponse.java
private static HttpHeaders toHttpHeaders(final HttpResponse response) { final HttpHeaders headers = new HttpHeaders(); for (final Header header : response.getAllHeaders()) headers.add(header.getName(), header.getValue()); return headers; }
From source file:example.helloworld.CubbyholeAuthenticationTests.java
/** * Write some data to Vault before Vault can be used as {@link VaultPropertySource}. *//*w w w . j av a2s . co m*/ @BeforeClass public static void beforeClass() { VaultOperations vaultOperations = new VaultTestConfiguration().vaultTemplate(); vaultOperations.write("secret/myapp/configuration", Collections.singletonMap("configuration.key", "value")); VaultResponse response = vaultOperations.doWithSession(new RestOperationsCallback<VaultResponse>() { @Override public VaultResponse doWithRestOperations(RestOperations restOperations) { HttpHeaders headers = new HttpHeaders(); headers.add("X-Vault-Wrap-TTL", "10m"); return restOperations.postForObject("auth/token/create", new HttpEntity<Object>(headers), VaultResponse.class); } }); // Response Wrapping requires Vault 0.6.0+ Map<String, String> wrapInfo = response.getWrapInfo(); initialToken = VaultToken.of(wrapInfo.get("token")); }
From source file:io.github.restdocsext.jersey.JerseyResponseConverter.java
/** * Convert {@code MultivaluedMap} headers to {@code HttpHeaders}. * * @param mapHeaders the Jersey map of headers. * @return the converted Spring HTTP Headers. *//*from w w w . ja v a2 s .c o m*/ private static HttpHeaders extractHeaders(MultivaluedMap<String, String> mapHeaders) { HttpHeaders headers = new HttpHeaders(); for (String header : mapHeaders.keySet()) { for (String val : mapHeaders.get(header)) { headers.add(header, val); } } return headers; }
From source file:com.goldengekko.meetr.itest.AuthITest.java
public static HttpHeaders getHttpBasicHeader() { HttpHeaders headers = new HttpHeaders(); headers.set("Authorization", DomainHelper.J_BASIC_ITEST); headers.add("Content-Type", "application/x-www-form-urlencoded"); return headers; }
From source file:io.github.restdocsext.jersey.JerseyRequestConverter.java
/** * Convert {@code MultivaluedMap} headers to {@code HttpHeaders}. * * @param mapHeaders the map of headers. * @return the converted Spring HTTP headers. *///w w w. j a va 2 s .c o m private static HttpHeaders extractHeaders(MultivaluedMap<String, ?> mapHeaders) { final HttpHeaders headers = new HttpHeaders(); for (String header : mapHeaders.keySet()) { for (Object val : mapHeaders.get(header)) { headers.add(header, val.toString()); } } return headers; }
From source file:com.javafxpert.wikibrowser.util.WikiBrowserUtils.java
/** * TODO: Move this to a util class//from ww w . j ava 2 s. c o m * @param username * @param password * @return */ public static HttpHeaders createHeaders(final String username, final String password) { HttpHeaders headers = new HttpHeaders() { { String auth = username + ":" + password; byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(Charset.forName("US-ASCII"))); String authHeader = "Basic " + new String(encodedAuth); set("Authorization", authHeader); } }; headers.add("Content-Type", "application/xml"); headers.add("Accept", "application/xml"); return headers; }
From source file:org.starfishrespect.myconsumption.android.util.CryptoUtils.java
/** * Create header for basic authentication with username and password * @return HttpHeaders with basic authentication */// w w w . ja va 2 s. com public static HttpHeaders createHeaders(final String username, final String password) { HttpHeaders headers = new HttpHeaders() { { String auth = username + ":" + password; byte[] encodedAuth = Base64.encode(auth.getBytes(Charset.forName("US-ASCII")), Base64.NO_WRAP); String authHeader = "Basic " + new String(encodedAuth); //String authHeader = "Basic " + auth; set("Authorization", authHeader); } }; headers.add("Content-Type", "application/json"); headers.add("Accept", "*/*"); return headers; }