在HTTP请求头中携带Basic Auth认证的用户名和密码
sftUserConfig.getUserName为Authorization 账号
sftUserConfig.getPassword为Authorization密码
HttpHeaders headers = new HttpHeaders();
headers.set("authorization",
"Basic " +Base64.getEncoder()
.encodeToString("admin:admin".getBytes()));
发起git请求
HttpHeaders headers = new HttpHeaders();
headers.set("authorization",
"Basic " +
Base64.getEncoder()
.encodeToString("admin:admin".getBytes()));
HttpEntity<Map<String, Object>> objectHttpEntity = new HttpEntity<>(null, headers);
ResponseEntity<Object> responseEntity = null;
try {
responseEntity = restTemplate.exchange("xxxxx.168.101/xxx/xxx/xx",HttpMethod.GET,objectHttpEntity,Object.class);
}catch (Exception e){
log.error("远程调用失败");
e.printStackTrace();
}