mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Make CI credentials requirement lenient when building RestTemplate
Fixes gh-18901
This commit is contained in:
parent
891c7120ef
commit
8d3df1b4b8
@ -30,6 +30,7 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.http.RequestEntity;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.client.HttpClientErrorException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@ -53,19 +54,18 @@ public class ArtifactoryService {
|
||||
|
||||
private final RestTemplate restTemplate;
|
||||
|
||||
private final ArtifactoryProperties artifactoryProperties;
|
||||
|
||||
private final BintrayService bintrayService;
|
||||
|
||||
private static final ConsoleLogger console = new ConsoleLogger();
|
||||
|
||||
public ArtifactoryService(RestTemplateBuilder builder, ArtifactoryProperties artifactoryProperties,
|
||||
BintrayService bintrayService) {
|
||||
this.artifactoryProperties = artifactoryProperties;
|
||||
this.bintrayService = bintrayService;
|
||||
String username = artifactoryProperties.getUsername();
|
||||
String password = artifactoryProperties.getPassword();
|
||||
builder = builder.basicAuthentication(username, password);
|
||||
if (StringUtils.hasLength(username)) {
|
||||
builder = builder.basicAuthentication(username, password);
|
||||
}
|
||||
this.restTemplate = builder.build();
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,7 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.RequestEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.client.HttpClientErrorException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@ -65,7 +66,9 @@ public class BintrayService {
|
||||
this.sonatypeService = sonatypeService;
|
||||
String username = bintrayProperties.getUsername();
|
||||
String apiKey = bintrayProperties.getApiKey();
|
||||
builder = builder.basicAuthentication(username, apiKey);
|
||||
if (StringUtils.hasLength(username)) {
|
||||
builder = builder.basicAuthentication(username, apiKey);
|
||||
}
|
||||
this.restTemplate = builder.build();
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.client.HttpClientErrorException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@ -38,15 +39,14 @@ public class SonatypeService {
|
||||
|
||||
private final RestTemplate restTemplate;
|
||||
|
||||
private final SonatypeProperties sonatypeProperties;
|
||||
|
||||
private static final ConsoleLogger console = new ConsoleLogger();
|
||||
|
||||
public SonatypeService(RestTemplateBuilder builder, SonatypeProperties sonatypeProperties) {
|
||||
this.sonatypeProperties = sonatypeProperties;
|
||||
String username = sonatypeProperties.getUserToken();
|
||||
String apiKey = sonatypeProperties.getPasswordToken();
|
||||
builder = builder.basicAuthentication(username, apiKey);
|
||||
String password = sonatypeProperties.getPasswordToken();
|
||||
if (StringUtils.hasLength(username)) {
|
||||
builder = builder.basicAuthentication(username, password);
|
||||
}
|
||||
this.restTemplate = builder.build();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user