diff --git a/maven-wrapper/src/main/java/org/apache/maven/wrapper/DefaultDownloader.java b/maven-wrapper/src/main/java/org/apache/maven/wrapper/DefaultDownloader.java index 2f6478ebfd..57bb24ec1b 100644 --- a/maven-wrapper/src/main/java/org/apache/maven/wrapper/DefaultDownloader.java +++ b/maven-wrapper/src/main/java/org/apache/maven/wrapper/DefaultDownloader.java @@ -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()) {