Merge branch '2.1.x'

Closes gh-18906
pull/18918/head
Madhura Bhave 5 years ago
commit 75f210a631

@ -30,6 +30,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.RequestEntity; import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
@ -53,19 +54,18 @@ public class ArtifactoryService {
private final RestTemplate restTemplate; private final RestTemplate restTemplate;
private final ArtifactoryProperties artifactoryProperties;
private final BintrayService bintrayService; private final BintrayService bintrayService;
private static final ConsoleLogger console = new ConsoleLogger(); private static final ConsoleLogger console = new ConsoleLogger();
public ArtifactoryService(RestTemplateBuilder builder, ArtifactoryProperties artifactoryProperties, public ArtifactoryService(RestTemplateBuilder builder, ArtifactoryProperties artifactoryProperties,
BintrayService bintrayService) { BintrayService bintrayService) {
this.artifactoryProperties = artifactoryProperties;
this.bintrayService = bintrayService; this.bintrayService = bintrayService;
String username = artifactoryProperties.getUsername(); String username = artifactoryProperties.getUsername();
String password = artifactoryProperties.getPassword(); String password = artifactoryProperties.getPassword();
builder = builder.basicAuthentication(username, password); if (StringUtils.hasLength(username)) {
builder = builder.basicAuthentication(username, password);
}
this.restTemplate = builder.build(); this.restTemplate = builder.build();
} }

@ -31,6 +31,7 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.RequestEntity; import org.springframework.http.RequestEntity;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
@ -65,7 +66,9 @@ public class BintrayService {
this.sonatypeService = sonatypeService; this.sonatypeService = sonatypeService;
String username = bintrayProperties.getUsername(); String username = bintrayProperties.getUsername();
String apiKey = bintrayProperties.getApiKey(); String apiKey = bintrayProperties.getApiKey();
builder = builder.basicAuthentication(username, apiKey); if (StringUtils.hasLength(username)) {
builder = builder.basicAuthentication(username, apiKey);
}
this.restTemplate = builder.build(); this.restTemplate = builder.build();
} }

@ -23,6 +23,7 @@ import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
@ -38,15 +39,14 @@ public class SonatypeService {
private final RestTemplate restTemplate; private final RestTemplate restTemplate;
private final SonatypeProperties sonatypeProperties;
private static final ConsoleLogger console = new ConsoleLogger(); private static final ConsoleLogger console = new ConsoleLogger();
public SonatypeService(RestTemplateBuilder builder, SonatypeProperties sonatypeProperties) { public SonatypeService(RestTemplateBuilder builder, SonatypeProperties sonatypeProperties) {
this.sonatypeProperties = sonatypeProperties;
String username = sonatypeProperties.getUserToken(); String username = sonatypeProperties.getUserToken();
String apiKey = sonatypeProperties.getPasswordToken(); String password = sonatypeProperties.getPasswordToken();
builder = builder.basicAuthentication(username, apiKey); if (StringUtils.hasLength(username)) {
builder = builder.basicAuthentication(username, password);
}
this.restTemplate = builder.build(); this.restTemplate = builder.build();
} }

Loading…
Cancel
Save