Here are the examples of the java api org.springframework.http.HttpHeaders.add() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
815 Examples
19
View Source File : ArticleController.java
License : MIT License
Project Creator : wormhole
License : MIT License
Project Creator : wormhole
/**
* 导出markdown格式备份
*
* @param id 文章主键
* @return 返回ResponseEnreplacedy对象
* @throws IOException
*/
@RequestMapping(value = "/export", method = RequestMethod.GET)
@ResponseBody
public ResponseEnreplacedy<byte[]> export(@RequestParam("id") String id) throws IOException {
ArticlePO articlePO = articleService.selectById(id);
String filename = articlePO.getreplacedle() + ".md";
filename = new String(filename.getBytes("UTF-8"), "ISO-8859-1");
InputStream is = new ByteArrayInputStream(articlePO.getArticleMd().getBytes("UTF-8"));
byte[] body = new byte[is.available()];
is.read(body);
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Disposition", "attachment;filename=" + filename);
HttpStatus status = HttpStatus.OK;
ResponseEnreplacedy<byte[]> enreplacedy = new ResponseEnreplacedy<>(body, headers, status);
return enreplacedy;
}
19
View Source File : RestTemplateXhrTransportTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
private ListenableFuture<WebSocketSession> connect(RestOperations restTemplate, ClientHttpResponse... responses) throws Exception {
RestTemplateXhrTransport transport = new RestTemplateXhrTransport(restTemplate);
transport.setTaskExecutor(new SyncTaskExecutor());
SockJsUrlInfo urlInfo = new SockJsUrlInfo(new URI("https://example.com"));
HttpHeaders headers = new HttpHeaders();
headers.add("h-foo", "h-bar");
TransportRequest request = new DefaultTransportRequest(urlInfo, headers, headers, transport, TransportType.XHR, CODEC);
return transport.connect(request, this.webSocketHandler);
}
19
View Source File : HeaderAssertionTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void valueMatcher() {
HttpHeaders headers = new HttpHeaders();
headers.add("foo", "bar");
Headerreplacedertions replacedertions = headerreplacedertions(headers);
replacedertions.value("foo", containsString("a"));
}
19
View Source File : HeaderAssertionTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void valueEqualsWithMultipleValues() {
HttpHeaders headers = new HttpHeaders();
headers.add("foo", "bar");
headers.add("foo", "baz");
Headerreplacedertions replacedertions = headerreplacedertions(headers);
// Success
replacedertions.valueEquals("foo", "bar", "baz");
try {
replacedertions.valueEquals("foo", "bar", "what?!");
fail("Wrong value expected");
} catch (replacedertionError error) {
// expected
}
try {
replacedertions.valueEquals("foo", "bar");
fail("Too few values expected");
} catch (replacedertionError error) {
// expected
}
}
19
View Source File : HeaderAssertionTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void valueEquals() {
HttpHeaders headers = new HttpHeaders();
headers.add("foo", "bar");
Headerreplacedertions replacedertions = headerreplacedertions(headers);
// Success
replacedertions.valueEquals("foo", "bar");
try {
replacedertions.valueEquals("what?!", "bar");
fail("Missing header expected");
} catch (replacedertionError error) {
// expected
}
try {
replacedertions.valueEquals("foo", "what?!");
fail("Wrong value expected");
} catch (replacedertionError error) {
// expected
}
try {
replacedertions.valueEquals("foo", "bar", "what?!");
fail("Wrong # of values expected");
} catch (replacedertionError error) {
// expected
}
}
19
View Source File : GrayHttpTrackInfo.java
License : Apache License 2.0
Project Creator : SpringCloud
License : Apache License 2.0
Project Creator : SpringCloud
public void addHeader(String name, String value) {
headers.add(name.toLowerCase(), value);
}
19
View Source File : InstanceWebClientTest.java
License : Apache License 2.0
Project Creator : SpringCloud
License : Apache License 2.0
Project Creator : SpringCloud
private HttpHeaders createHeaders(String k, String v) {
HttpHeaders headers = new HttpHeaders();
headers.add(k, v);
return headers;
}
19
View Source File : Server.java
License : MIT License
Project Creator : ralscha
License : MIT License
Project Creator : ralscha
@GetMapping("/secret")
public ResponseEnreplacedy<String> secret(@RequestHeader(name = "Authorization", required = false) String authorization) {
System.out.println(authorization);
if (authorization != null && !authorization.isBlank()) {
String decoded = new String(Base64.getDecoder().decode(authorization.substring(6)), StandardCharsets.UTF_8);
if (decoded.equals("user:preplacedword")) {
return new ResponseEnreplacedy<>("the secret message", HttpStatus.OK);
}
}
HttpHeaders headers = new HttpHeaders();
headers.add("WWW-Authenticate", "Basic realm=\"Access to the secret endpoint\"");
return new ResponseEnreplacedy<>(headers, HttpStatus.UNAUTHORIZED);
}
19
View Source File : RestTemplateXhrTransportTests.java
License : MIT License
Project Creator : mindcarver
License : MIT License
Project Creator : mindcarver
private ListenableFuture<WebSocketSession> connect(RestOperations restTemplate, ClientHttpResponse... responses) throws Exception {
RestTemplateXhrTransport transport = new RestTemplateXhrTransport(restTemplate);
transport.setTaskExecutor(new SyncTaskExecutor());
SockJsUrlInfo urlInfo = new SockJsUrlInfo(new URI("http://example.com"));
HttpHeaders headers = new HttpHeaders();
headers.add("h-foo", "h-bar");
TransportRequest request = new DefaultTransportRequest(urlInfo, headers, headers, transport, TransportType.XHR, CODEC);
return transport.connect(request, this.webSocketHandler);
}
19
View Source File : ResponseUtilTest.java
License : Apache License 2.0
Project Creator : jhipster
License : Apache License 2.0
Project Creator : jhipster
@BeforeEach
public void setup() {
optionalYes = Optional.of(42);
optionalNo = Optional.empty();
headers = new HttpHeaders();
headers.add(HEADER_NAME, HEADER_VALUE);
}
19
View Source File : ResponseUtilTest.java
License : Apache License 2.0
Project Creator : jhipster
License : Apache License 2.0
Project Creator : jhipster
@BeforeEach
public void setup() {
monoYes = Mono.just(42);
monoNo = Mono.empty();
headers = new HttpHeaders();
headers.add(HEADER_NAME, HEADER_VALUE);
}
19
View Source File : XzSpider.java
License : Apache License 2.0
Project Creator : huifer
License : Apache License 2.0
Project Creator : huifer
/**
* 请求头信息
*
* @return
*/
private HttpHeaders headers() {
HttpHeaders headers = new HttpHeaders();
headers.add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3");
headers.add("Cache-Control", "max-age=0");
headers.add("Connection", "keep-alive");
headers.add("Cookie", "td_cookie=2522742900; td_cookie=2441244528; csrftoken=nQKAt5cwYT9dsIjBteRKSaNLQZnZynZ3; sessionid=5lx3yvdfwsacv0eaif7rfy6wrvy1x62h; Hm_lvt_7b262f3838ed313bc65b9ec6316c79c4=1571183765,1571185968,1571189278,1571288811; Hm_lpvt_7b262f3838ed313bc65b9ec6316c79c4=1571288811");
headers.add("Host", "www.imxingzhe.com");
headers.add("Upgrade-Insecure-Requests", "1");
headers.add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36");
return headers;
}
19
View Source File : RestActions.java
License : MIT License
Project Creator : hmcts
License : MIT License
Project Creator : hmcts
public RestActions withHeader(String key, String value) {
httpHeaders.add(key, value);
return this;
}
19
View Source File : RestActions.java
License : MIT License
Project Creator : hmcts
License : MIT License
Project Creator : hmcts
public RestActions withAuthorizedUser(String userId) {
httpHeaders.add(USER_ID_HEADER, userId);
return this;
}
19
View Source File : FirebaseJwtTokenDecoderTests.java
License : Apache License 2.0
Project Creator : GoogleCloudPlatform
License : Apache License 2.0
Project Creator : GoogleCloudPlatform
private RestOperations mockRestOperations(Map<String, String> payload) {
HttpHeaders headers = new HttpHeaders();
headers.add(HttpHeaders.CACHE_CONTROL, CacheControl.maxAge(3600L, TimeUnit.SECONDS).getHeaderValue());
ResponseEnreplacedy<Map<String, String>> response = new ResponseEnreplacedy<>(payload, headers, HttpStatus.OK);
return mockRestOperations(response);
}
19
View Source File : DetectorMappingControllerTest.java
License : Apache License 2.0
Project Creator : ExpediaDotCom
License : Apache License 2.0
Project Creator : ExpediaDotCom
@Before
public void setUp() {
this.controllerUnderTest = new DetectorMappingController();
MockitoAnnotations.initMocks(this);
httpHeaders.add("test-header-key", "test-header-value");
val metrics = new NoopMetricsRegistry();
val dispatcher = new NoopDispatcher();
noOpsTracer = new Tracer.Builder(metrics, "testTrace", dispatcher).build();
}
19
View Source File : ContextUtils.java
License : BSD 3-Clause "New" or "Revised" License
Project Creator : dhis2
License : BSD 3-Clause "New" or "Revised" License
Project Creator : dhis2
/**
* Adds basic authentication by adding an Authorization header to the given
* HttpHeaders object.
*
* @param headers the HttpHeaders object.
* @param username the user name.
* @param preplacedword the preplacedword.
*/
public static void setBasicAuth(HttpHeaders headers, String username, String preplacedword) {
headers.add("Authorization", CodecUtils.getBasicAuthString(username, preplacedword));
}
19
View Source File : ResponseEntityBuilder.java
License : Apache License 2.0
Project Creator : authlete
License : Apache License 2.0
Project Creator : authlete
public ResponseEnreplacedyBuilder header(String headerName, String headerValue) {
if (headerName == null) {
return this;
}
mHeaders.add(headerName, headerValue);
return this;
}
19
View Source File : PentahoScheduleReportService.java
License : GNU Lesser General Public License v3.0
Project Creator : ArkCase
License : GNU Lesser General Public License v3.0
Project Creator : ArkCase
private void createCredentialHeaders() {
String plainCreds = reportsConfig.getServerUser() + ":" + reportsConfig.getServerPreplacedword();
byte[] plainCredsBytes = plainCreds.getBytes();
byte[] base64CredsBytes = Base64.encodeBase64(plainCredsBytes);
String base64Creds = new String(base64CredsBytes);
headers = new HttpHeaders();
headers.add("Authorization", "Basic " + base64Creds);
}
19
View Source File : SentinelRuleLocator.java
License : Apache License 2.0
Project Creator : alibaba
License : Apache License 2.0
Project Creator : alibaba
private void addAuthorizationToken(ConfigClientProperties configClientProperties, HttpHeaders httpHeaders, String username, String preplacedword) {
String authorization = configClientProperties.getHeaders().get(AUTHORIZATION);
if (preplacedword != null && authorization != null) {
throw new IllegalStateException("You must set either 'preplacedword' or 'authorization'");
}
if (preplacedword != null) {
byte[] token = Base64Utils.encode((username + ":" + preplacedword).getBytes());
httpHeaders.add("Authorization", "Basic " + new String(token));
} else if (authorization != null) {
httpHeaders.add("Authorization", authorization);
}
}
19
View Source File : RestExceptionHandler.java
License : Apache License 2.0
Project Creator : adorsys
License : Apache License 2.0
Project Creator : adorsys
private HttpHeaders addErrorOriginationHeader(HttpHeaders httpHeaders, ErrorOrigination errorOrigination) {
httpHeaders.add(ERROR_ORIGINATION_HEADER_NAME, errorOrigination.name());
return httpHeaders;
}
19
View Source File : CmsPsuPisControllerTest.java
License : Apache License 2.0
Project Creator : adorsys
License : Apache License 2.0
Project Creator : adorsys
private static HttpHeaders buildInstanceIdHeaders() {
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.add(INSTANCE_ID_HEADER_NAME, INSTANCE_ID);
return httpHeaders;
}
19
View Source File : CmsPsuPisControllerTest.java
License : Apache License 2.0
Project Creator : adorsys
License : Apache License 2.0
Project Creator : adorsys
private static HttpHeaders buildPsuHeaders() {
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.add(PSU_ID_HEADER_NAME, PSU_ID);
httpHeaders.add(PSU_ID_TYPE_HEADER_NAME, PSU_ID_TYPE);
httpHeaders.add(PSU_CORPORATE_ID_HEADER_NAME, PSU_CORPORATE_ID);
httpHeaders.add(PSU_CORPORATE_ID_TYPE_HEADER_NAME, PSU_CORPORATE_ID_TYPE);
return httpHeaders;
}
18
View Source File : UserServiceImpl.java
License : Apache License 2.0
Project Creator : zhengyangyong
License : Apache License 2.0
Project Creator : zhengyangyong
private HttpHeaders generateAuthenticationHeaders(String token) {
HttpHeaders headers = new HttpHeaders();
headers.add(AUTHORIZATION, token);
return headers;
}
18
View Source File : HeaderUtil.java
License : Apache License 2.0
Project Creator : yodamad
License : Apache License 2.0
Project Creator : yodamad
public static HttpHeaders createAlert(String message, String param) {
HttpHeaders headers = new HttpHeaders();
headers.add("X-" + APPLICATION_NAME + "-alert", message);
headers.add("X-" + APPLICATION_NAME + "-params", param);
return headers;
}
18
View Source File : HeaderUtil.java
License : Apache License 2.0
Project Creator : yodamad
License : Apache License 2.0
Project Creator : yodamad
public static HttpHeaders createFailureAlert(String enreplacedyName, String errorKey, String defaultMessage) {
log.error("Enreplacedy processing failed, {}", defaultMessage);
HttpHeaders headers = new HttpHeaders();
headers.add("X-" + APPLICATION_NAME + "-error", "error." + errorKey);
headers.add("X-" + APPLICATION_NAME + "-params", enreplacedyName);
return headers;
}
18
View Source File : HttpRequestTemplate.java
License : Apache License 2.0
Project Creator : yin5980280
License : Apache License 2.0
Project Creator : yin5980280
private HttpHeaders getHeaders() {
HttpHeaders headers = new HttpHeaders();
headers.add(MDCUtils.KEY_MSG_ID, MDCUtils.getOrGenMsgId());
return headers;
}
18
View Source File : HeaderUtil.java
License : Apache License 2.0
Project Creator : xm-online
License : Apache License 2.0
Project Creator : xm-online
public static HttpHeaders createAlert(String message, String param) {
HttpHeaders headers = new HttpHeaders();
headers.add("X-uaaApp-alert", message);
headers.add("X-uaaApp-params", param);
return headers;
}
18
View Source File : HeaderUtil.java
License : Apache License 2.0
Project Creator : xm-online
License : Apache License 2.0
Project Creator : xm-online
public static HttpHeaders createFailureAlert(String enreplacedyName, String errorKey, String defaultMessage) {
log.error("Enreplacedy processing failed, {}", defaultMessage);
HttpHeaders headers = new HttpHeaders();
headers.add("X-uaaApp-error", "error." + errorKey);
headers.add("X-uaaApp-params", enreplacedyName);
return headers;
}
18
View Source File : HeaderUtil.java
License : Apache License 2.0
Project Creator : xm-online
License : Apache License 2.0
Project Creator : xm-online
public static HttpHeaders createFailureAlert(String enreplacedyName, String errorKey, String defaultMessage) {
log.error("Enreplacedy processing failed, {}", defaultMessage);
HttpHeaders headers = new HttpHeaders();
// FIXME @amedvedchuk "X-" for custom headers is deprecated https://tools.ietf.org/html/rfc6648
// See: com.icthh.xm.ms.enreplacedy.web.rest.XmRestApiConstants.XM_HEADER_CONTENT_NAME
headers.add("X-enreplacedyApp-error", "error." + errorKey);
headers.add("X-enreplacedyApp-params", enreplacedyName);
return headers;
}
18
View Source File : HeaderUtil.java
License : Apache License 2.0
Project Creator : xm-online
License : Apache License 2.0
Project Creator : xm-online
public static HttpHeaders createAlert(String message, String param) {
HttpHeaders headers = new HttpHeaders();
// FIXME @amedvedchuk "X-" for custom headers is deprecated https://tools.ietf.org/html/rfc6648
// See: com.icthh.xm.ms.enreplacedy.web.rest.XmRestApiConstants.XM_HEADER_CONTENT_NAME
headers.add("X-enreplacedyApp-alert", message);
headers.add("X-enreplacedyApp-params", param);
return headers;
}
18
View Source File : FilterService.java
License : Apache License 2.0
Project Creator : XiaoMi
License : Apache License 2.0
Project Creator : XiaoMi
public ResponseEnreplacedy<byte[]> downloadFilter(Integer id, SessionAccount account, HttpServletResponse response) throws IOException {
FilterInfoBo filterInfoBo = getFilterInfoBo(id);
if (filterInfoBo == null) {
response.sendError(404, "jar包不存在");
return null;
}
if (account.getRole() != ROLE_ADMIN && !account.getUsername().equals(filterInfoBo.getCreator())) {
response.sendError(401, "您没有该权限");
return null;
}
String fileName = filterInfoBo.getName() + ".jar";
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Disposition", "attachment;filename=" + fileName);
return new ResponseEnreplacedy<>(filterInfoBo.getData(), headers, HttpStatus.OK);
}
18
View Source File : ArticleController.java
License : MIT License
Project Creator : wormhole
License : MIT License
Project Creator : wormhole
/**
* 导出markdown格式备份
*
* @param id 文章主键
* @return ResponseEnreplacedy对象
* @throws IOException
*/
@ApiOperation(value = "导出markdown格式备份文件", response = ResponseEnreplacedy.clreplaced)
@RequestMapping(value = "/export_article", method = RequestMethod.GET)
@ResponseBody
public ResponseEnreplacedy<byte[]> export(@ApiParam(name = "id", value = "文章主键") @RequestParam("id") String id) throws IOException {
Article article = articleService.selectById(id);
String filename = article.getreplacedle() + ".md";
filename = new String(filename.getBytes("UTF-8"), "ISO-8859-1");
InputStream is = new ByteArrayInputStream(article.getArticleMd().getBytes("UTF-8"));
byte[] body = new byte[is.available()];
is.read(body);
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Disposition", "attachment;filename=" + filename);
ResponseEnreplacedy<byte[]> enreplacedy = new ResponseEnreplacedy<>(body, headers, HttpStatus.OK);
return enreplacedy;
}
18
View Source File : CommonUtils.java
License : Apache License 2.0
Project Creator : WeBankFinTech
License : Apache License 2.0
Project Creator : WeBankFinTech
/**
* buildHeaders.
*
* @return
*/
public static HttpHeaders buildHeaders() {
HttpHeaders headers = new HttpHeaders();
MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
headers.setContentType(type);
headers.add("Accept", MediaType.APPLICATION_JSON.toString());
return headers;
}
18
View Source File : HeaderUtil.java
License : Apache License 2.0
Project Creator : viz-centric
License : Apache License 2.0
Project Creator : viz-centric
public static HttpHeaders createFailureAlert(String enreplacedyName, String errorKey, String defaultMessage) {
log.error("Enreplacedy processing failed, {}", defaultMessage);
HttpHeaders headers = new HttpHeaders();
headers.add("X-fbiengineApp-error", defaultMessage);
headers.add("X-fbiengineApp-params", enreplacedyName);
return headers;
}
18
View Source File : HeaderUtil.java
License : Apache License 2.0
Project Creator : viz-centric
License : Apache License 2.0
Project Creator : viz-centric
public static HttpHeaders createAlert(String message, String param) {
HttpHeaders headers = new HttpHeaders();
headers.add("X-fbiengineApp-alert", message);
headers.add("X-fbiengineApp-params", param);
return headers;
}
18
View Source File : DispatcherServletTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
// SPR-12984
@Test
public void noHandlerFoundExceptionMessage() {
HttpHeaders headers = new HttpHeaders();
headers.add("foo", "bar");
NoHandlerFoundException ex = new NoHandlerFoundException("GET", "/foo", headers);
replacedertTrue(!ex.getMessage().contains("bar"));
replacedertTrue(!ex.toString().contains("bar"));
}
18
View Source File : MockHttpServletRequest.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
/**
* Add an HTTP header entry for the given name.
* <p>While this method can take any {@code Object} as a parameter,
* it is recommended to use the following types:
* <ul>
* <li>String or any Object to be converted using {@code toString()}; see {@link #getHeader}.</li>
* <li>String, Number, or Date for date headers; see {@link #getDateHeader}.</li>
* <li>String or Number for integer headers; see {@link #getIntHeader}.</li>
* <li>{@code String[]} or {@code Collection<String>} for multiple values; see {@link #getHeaders}.</li>
* </ul>
* @see #getHeaderNames
* @see #getHeaders
* @see #getHeader
* @see #getDateHeader
*/
public void addHeader(String name, Object value) {
if (HttpHeaders.CONTENT_TYPE.equalsIgnoreCase(name) && !this.headers.containsKey(HttpHeaders.CONTENT_TYPE)) {
setContentType(value.toString());
} else if (HttpHeaders.ACCEPT_LANGUAGE.equalsIgnoreCase(name) && !this.headers.containsKey(HttpHeaders.ACCEPT_LANGUAGE)) {
try {
HttpHeaders headers = new HttpHeaders();
headers.add(HttpHeaders.ACCEPT_LANGUAGE, value.toString());
List<Locale> locales = headers.getAcceptLanguageAsLocales();
this.locales.clear();
this.locales.addAll(locales);
if (this.locales.isEmpty()) {
this.locales.add(Locale.ENGLISH);
}
} catch (IllegalArgumentException ex) {
// Invalid Accept-Language format -> just store plain header
}
doAddHeaderValue(name, value, true);
} else {
doAddHeaderValue(name, value, false);
}
}
18
View Source File : DefaultMultipartMessageReader.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
/**
* Convert the given data buffer into a {@link HttpHeaders} instance. The given string is read
* as US-ASCII, then split along \r\n line boundaries, each line containing a header name and
* value(s).
*/
private static HttpHeaders toHeaders(DataBuffer dataBuffer) {
byte[] bytes = new byte[dataBuffer.readableByteCount()];
dataBuffer.read(bytes);
DataBufferUtils.release(dataBuffer);
String string = new String(bytes, StandardCharsets.US_ASCII);
String[] lines = string.split(HEADER_SEPARATOR);
HttpHeaders result = new HttpHeaders();
for (String line : lines) {
int idx = line.indexOf(':');
if (idx != -1) {
String name = line.substring(0, idx);
String value = line.substring(idx + 1);
while (value.startsWith(" ")) {
value = value.substring(1);
}
String[] tokens = StringUtils.tokenizeToStringArray(value, ",");
for (String token : tokens) {
result.add(name, token);
}
}
}
return result;
}
18
View Source File : OpencpsRestFacade.java
License : GNU Affero General Public License v3.0
Project Creator : VietOpenCPS
License : GNU Affero General Public License v3.0
Project Creator : VietOpenCPS
/**
* Default method for setting the HttpHeaders authorization token
*
* @param httpHeaders
* @param authorizationField
* @return
*/
protected HttpHeaders setHttpHeadersAuthorization(HttpHeaders httpHeaders, String authorizationField) {
httpHeaders.add(HttpHeaders.AUTHORIZATION, authorizationField);
return httpHeaders;
}
18
View Source File : OpencpsRestFacade.java
License : GNU Affero General Public License v3.0
Project Creator : VietOpenCPS
License : GNU Affero General Public License v3.0
Project Creator : VietOpenCPS
protected HttpHeaders setHttpHeadersAuthorization(HttpHeaders httpHeaders, String userName, String preplacedword) {
String authString = userName + StringPool.COLON + preplacedword;
String authStringEnc = new String(Base64.getEncoder().encodeToString(authString.getBytes()));
httpHeaders.add(HttpHeaders.AUTHORIZATION, authStringEnc);
return httpHeaders;
}
18
View Source File : UserJWTController.java
License : MIT License
Project Creator : tillias
License : MIT License
Project Creator : tillias
@PostMapping("/authenticate")
public ResponseEnreplacedy<JWTToken> authorize(@Valid @RequestBody LoginVM loginVM) {
UsernamePreplacedwordAuthenticationToken authenticationToken = new UsernamePreplacedwordAuthenticationToken(loginVM.getUsername(), loginVM.getPreplacedword());
Authentication authentication = authenticationManagerBuilder.getObject().authenticate(authenticationToken);
SecurityContextHolder.getContext().setAuthentication(authentication);
boolean rememberMe = (loginVM.isRememberMe() == null) ? false : loginVM.isRememberMe();
String jwt = tokenProvider.createToken(authentication, rememberMe);
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.add(JWTFilter.AUTHORIZATION_HEADER, "Bearer " + jwt);
return new ResponseEnreplacedy<>(new JWTToken(jwt), httpHeaders, HttpStatus.OK);
}
18
View Source File : LockKeeperVirtualImpl.java
License : Apache License 2.0
Project Creator : telstra
License : Apache License 2.0
Project Creator : telstra
HttpHeaders buildJsonHeaders() {
HttpHeaders headers = new HttpHeaders();
headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
return headers;
}
18
View Source File : RestHelper.java
License : Apache License 2.0
Project Creator : Taskana
License : Apache License 2.0
Project Creator : Taskana
public HttpHeaders getHeadersTeamlead_1() {
HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", AUTHORIZATION_TEAMLEAD_1);
headers.add("Content-Type", "application/json");
return headers;
}
18
View Source File : RestHelper.java
License : Apache License 2.0
Project Creator : Taskana
License : Apache License 2.0
Project Creator : Taskana
public HttpHeaders getHeadersUser_1_2() {
HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", AUTHORIZATION_USER_1_2);
headers.add("Content-Type", "application/json");
return headers;
}
18
View Source File : RestHelper.java
License : Apache License 2.0
Project Creator : Taskana
License : Apache License 2.0
Project Creator : Taskana
public HttpHeaders getHeadersAdmin() {
HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", AUTHORIZATION_ADMIN);
headers.add("Content-Type", "application/hal+json");
return headers;
}
18
View Source File : RestHelper.java
License : Apache License 2.0
Project Creator : Taskana
License : Apache License 2.0
Project Creator : Taskana
public HttpHeaders getHeadersBusinessAdmin() {
HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", AUTHORIZATION_BUSINESSADMIN);
headers.add("Content-Type", "application/hal+json");
return headers;
}
18
View Source File : RestHelper.java
License : Apache License 2.0
Project Creator : Taskana
License : Apache License 2.0
Project Creator : Taskana
public HttpHeaders getHeadersUser_b_1() {
HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", AUTHORIZATION_USER_B_1);
headers.add("Content-Type", "application/json");
return headers;
}
18
View Source File : RestHelper.java
License : Apache License 2.0
Project Creator : Taskana
License : Apache License 2.0
Project Creator : Taskana
public HttpHeaders getHeadersUser_2_1() {
HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", AUTHORIZATION_USER_2_1);
headers.add("Content-Type", "application/json");
return headers;
}
18
View Source File : RestHelper.java
License : Apache License 2.0
Project Creator : Taskana
License : Apache License 2.0
Project Creator : Taskana
public HttpHeaders getHeadersUser_1_1() {
HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", AUTHORIZATION_USER_1_1);
headers.add("Content-Type", "application/json");
return headers;
}
See More Examples