mirror of https://github.com/apache/maven.git
Download using authentication with properties
This commit is contained in:
parent
b9e6795b6c
commit
ed08eabf0e
|
@ -43,6 +43,7 @@ public class DefaultDownloader implements Downloader {
|
|||
this.applicationName = applicationName;
|
||||
this.applicationVersion = applicationVersion;
|
||||
configureProxyAuthentication();
|
||||
configureAuthentication();
|
||||
}
|
||||
|
||||
private void configureProxyAuthentication() {
|
||||
|
@ -50,6 +51,16 @@ public class DefaultDownloader implements Downloader {
|
|||
Authenticator.setDefault(new SystemPropertiesProxyAuthenticator());
|
||||
}
|
||||
}
|
||||
|
||||
private void configureAuthentication() {
|
||||
if (System.getProperty("MVNW_WRAPPER_AUTH_USERNAME") != null && System.getProperty("MVNW_WRAPPER_AUTH_PASSWORD") != null && System.getProperty("http.proxyUser") == null) {
|
||||
Authenticator.setDefault(new Authenticator() {
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
return new PasswordAuthentication(System.getProperty("MVNW_WRAPPER_AUTH_USERNAME"), System.getProperty("MVNW_WRAPPER_AUTH_PASSWORD").toCharArray());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void download(URI address, File destination) throws Exception {
|
||||
if (destination.exists()) {
|
||||
|
|
Loading…
Reference in New Issue