List of usage examples for org.springframework.http HttpHeaders add
@Override public void add(String headerName, @Nullable String headerValue)
From source file:com.springsource.html5expense.security.EndpointTokenServices.java
public OAuth2Authentication loadAuthentication(String accessToken) throws AuthenticationException { // TODO: Probably should catch REST client exceptions and rethrow as AuthenticationException HttpHeaders headers = new HttpHeaders(); headers.add("Authorization", "Bearer " + accessToken); HttpEntity<String> requestEntity = new HttpEntity<String>(headers); ResponseEntity<OAuth2Authentication> response = restTemplate.exchange(oauthAuthenticationUrl, HttpMethod.GET, requestEntity, OAuth2Authentication.class); OAuth2Authentication oauth2Authentication = response.getBody(); return oauth2Authentication; }
From source file:com.biz.report.controller.ItemDashBoardController.java
@ResponseBody @RequestMapping(value = "itemreport/{year}/get", method = RequestMethod.POST, headers = { "Content-type=application/json" }) public ResponseEntity<ReportDataSet> readFTypes(@PathVariable("year") String year, @RequestBody Map data) { logger.info(year);//from w w w.j av a 2s .com logger.info(data); Assert.notNull(data, "Data is null."); Assert.notNull(year, "Year is null."); String items = data.get("items").toString(); String months = data.get("months").toString(); ReportDataSet reportDataSet = itemDashBoardService.getReports(items, months, year); HttpHeaders headers = new HttpHeaders(); headers.add("success", "Success"); return new ResponseEntity<ReportDataSet>(reportDataSet, headers, HttpStatus.OK); }
From source file:cz.muni.fi.mushroomhunter.restclient.AllLocationSwingWorker.java
@Override protected List<LocationDto> doInBackground() throws Exception { String plainCreds = RestClient.USER_NAME + ":" + RestClient.PASSWORD; byte[] plainCredsBytes = plainCreds.getBytes(); byte[] base64CredsBytes = Base64.encodeBase64(plainCredsBytes); String base64Creds = new String(base64CredsBytes); HttpHeaders headers = new HttpHeaders(); headers.add("Authorization", "Basic " + base64Creds); HttpEntity<String> request = new HttpEntity<>(headers); RestTemplate restTemplate = new RestTemplate(); ResponseEntity<LocationDto[]> responseEntity = restTemplate.exchange( RestClient.SERVER_URL + "pa165/rest/location/", HttpMethod.GET, request, LocationDto[].class); LocationDto[] locationDtoArray = responseEntity.getBody(); List<LocationDto> locationDtoList = new ArrayList<>(); locationDtoList.addAll(Arrays.asList(locationDtoArray)); return locationDtoList; }
From source file:com.github.ljtfreitas.restify.http.spring.client.request.RequestEntityConverter.java
private HttpHeaders headersOf(Headers headers) { HttpHeaders httpHeaders = new HttpHeaders(); headers.all().forEach(h -> httpHeaders.add(h.name(), h.value())); return httpHeaders; }
From source file:com.neu.controller.APIController.java
@RequestMapping(value = "/apicall.htm", method = RequestMethod.POST, headers = "Accept=*/*", produces = "application/json") @ResponseStatus(HttpStatus.OK)/* ww w .j a v a 2 s .c o m*/ public @ResponseBody String searchresult(HttpServletRequest request) throws Exception { Map pmap = request.getParameterMap(); System.out.println("in drugsearch controller"); String action = request.getParameter("action"); String urlRestWebService = "https://ussouthcentral.services.azureml.net/workspaces/168eb4a3d72e4b078160213fcdaa4333/services/ee080088b48141e0af10c9913067689d/execute?api-version=2.0&details=true"; HttpHeaders headers = new HttpHeaders(); headers.add("Authorization", "Bearer AJacooh+WG4WeJTntLNn/E3A3E4yQELYY8S6/2sbpcsBvNFSCabuopvuiqlnrd47a0qBf4Coj1LMcEhBUm0Ujw=="); headers.add("Content-Length", "100000"); headers.add("Content-Type", "application/json"); String requestJson = "{'Inputs': {'input1': {'ColumnNames': [ 'drugname','route','dose_amt','dose_unit','dose_form', 'dose_freq','mfr_sndr','pt'],'Values':[['" + pmap.get("drugname") + "','" + pmap.get("reactionlist") + "','" + pmap.get("doseform") + "','" + pmap.get("doseunit") + "','" + pmap.get("dosefreq") + "','" + pmap.get("mfndetails") + "','" + pmap.get("route") + "','" + pmap.get("doseamt") + "']]}},'GlobalParameters': {}}"; HttpEntity<String> entity = new HttpEntity<String>(requestJson, headers); System.out.println("entity" + entity); RestTemplate restTemplate = new RestTemplate(); String restData = restTemplate.postForObject(urlRestWebService, entity, String.class); ObjectMapper mapper = new ObjectMapper(); mapper.enable(SerializationConfig.Feature.INDENT_OUTPUT); mapper.writeValue(System.out, restData); // Drugs drug=new Drugs("AZ","sn"); return mapper.writeValueAsString(restData); }
From source file:org.esupportail.papercut.web.PayBoxCallbackController.java
/** * Manage callback response from paybox - url like : * /* w w w. j av a 2 s .c o m*/ * /payboxcallback?montant=200&reference=bonamvin@univrouen@200-2013-08-23-17-08-18-394&auto=XXXXXX&erreur=00000&idtrans=3608021&signature=CPqq18Un24NL0llB3E3G9kbKI4ztlkoL%2BSRTnMMrWlPBTVNTsn%2B%2FxA0YMSQOGGnU0wm45HYh%2F2RHoZGG3THzj7xKSY6upNJcnKrfFmzfTgA5FTFA3dyM27RgKmLcCeH48FRNoZPjVsKk0G2npvaP%2FY5pkSvn%2BQUl34DkmJkTejs%3D * * @param uiModel * @return empty page */ @RequestMapping("/payboxcallback") @ResponseBody public ResponseEntity<String> index(@RequestParam String montant, @RequestParam String reference, @RequestParam(required = false) String auto, @RequestParam String erreur, @RequestParam String idtrans, @RequestParam String signature, HttpServletRequest request) { String paperCutContext = reference.split("@")[1]; String ip = request.getRemoteAddr(); String queryString = request.getQueryString(); if (esupPaperCutServices.get(paperCutContext).payboxCallback(montant, reference, auto, erreur, idtrans, signature, queryString, ip, null)) { HttpHeaders headers = new HttpHeaders(); headers.add("Content-Type", "text/html; charset=utf-8"); return new ResponseEntity<String>("", headers, HttpStatus.OK); } else { HttpHeaders headers = new HttpHeaders(); headers.add("Content-Type", "text/html; charset=utf-8"); return new ResponseEntity<String>("", headers, HttpStatus.FORBIDDEN); } }
From source file:org.openlmis.fulfillment.service.AuthService.java
/** * Retrieves access token from the auth service. * * @return token.//from w w w .ja v a2 s . com */ @Cacheable("token") public String obtainAccessToken() { String plainCreds = clientId + ":" + clientSecret; byte[] plainCredsBytes = plainCreds.getBytes(); byte[] base64CredsBytes = Base64.encodeBase64(plainCredsBytes); String base64Creds = new String(base64CredsBytes); HttpHeaders headers = new HttpHeaders(); headers.add("Authorization", "Basic " + base64Creds); HttpEntity<String> request = new HttpEntity<>(headers); RequestParameters params = RequestParameters.init().set("grant_type", "client_credentials"); ResponseEntity<?> response = restTemplate.exchange(createUri(authorizationUrl, params), HttpMethod.POST, request, Object.class); return ((Map<String, String>) response.getBody()).get(ACCESS_TOKEN); }
From source file:com.biz.report.controller.ReportController.java
@RequestMapping(value = "/type-name") public ResponseEntity<List<String>> selectTag() { List<String> list = reportService.getTypes(); HttpHeaders headers = new HttpHeaders(); headers.add("success", "Success"); return new ResponseEntity<List<String>>(list, headers, HttpStatus.OK); }
From source file:com.biz.report.controller.ReportController.java
@RequestMapping(value = "/years") public ResponseEntity<List<String>> readYears() { List<String> list = reportService.readYears(); HttpHeaders headers = new HttpHeaders(); headers.add("success", "Success"); return new ResponseEntity<List<String>>(list, headers, HttpStatus.OK); }
From source file:org.zalando.github.spring.pagination.PaginationTest.java
protected HttpHeaders buildHeaders(String headerValue) { HttpHeaders headers = new HttpHeaders(); headers.add("Link", headerValue); return headers; }