9696import org .apache .maven .shared .invoker .PrintStreamHandler ;
9797import org .apache .maven .shared .utils .io .DirectoryScanner ;
9898import org .apache .maven .shared .utils .io .FileUtils ;
99- import org .apache .maven .wagon .proxy .ProxyInfo ;
100- import org .apache .maven .wagon .proxy .ProxyUtils ;
10199import org .codehaus .plexus .languages .java .version .JavaVersion ;
102100import org .codehaus .plexus .util .cli .CommandLineException ;
103101import org .codehaus .plexus .util .cli .CommandLineUtils ;
@@ -1527,20 +1525,17 @@ private static CloseableHttpClient createHttpClient(Settings settings, URL url)
15271525 // Some web servers don't allow the default user-agent sent by httpClient
15281526 builder .setUserAgent ("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" );
15291527
1530- // Some server reject requests that do not have an Accept header
1528+ // Some servers reject requests that do not have an Accept header
15311529 builder .setDefaultHeaders (Collections .singletonList (new BasicHeader (HttpHeaders .ACCEPT , "*/*" )));
15321530
15331531 if (settings != null && settings .getActiveProxy () != null ) {
15341532 Proxy activeProxy = settings .getActiveProxy ();
1535-
1536- ProxyInfo proxyInfo = new ProxyInfo ();
1537- proxyInfo .setNonProxyHosts (activeProxy .getNonProxyHosts ());
1538-
1533+ String nonProxyHosts = activeProxy .getNonProxyHosts ();
15391534 String activeProxyHost = activeProxy .getHost ();
15401535 if (activeProxyHost != null
15411536 && !activeProxyHost .isEmpty ()
1542- && (url == null || !ProxyUtils . validateNonProxyHosts (proxyInfo , url .getHost ()))) {
1543- HttpHost proxy = new HttpHost (activeProxy . getHost () , activeProxy .getPort ());
1537+ && (url == null || !validateNonProxyHosts (nonProxyHosts , url .getHost ()))) {
1538+ HttpHost proxy = new HttpHost (activeProxyHost , activeProxy .getPort ());
15441539 builder .setProxy (proxy );
15451540
15461541 String activeProxyUsername = activeProxy .getUsername ();
@@ -1559,6 +1554,24 @@ private static CloseableHttpClient createHttpClient(Settings settings, URL url)
15591554 return builder .build ();
15601555 }
15611556
1557+ private static boolean validateNonProxyHosts (String nonProxyHosts , String targetHost ) {
1558+ if (nonProxyHosts == null ) {
1559+ return false ;
1560+ }
1561+ if (targetHost == null ) {
1562+ targetHost = "" ;
1563+ }
1564+ StringTokenizer tokenizer = new StringTokenizer (nonProxyHosts , "|" );
1565+ while (tokenizer .hasMoreTokens ()) {
1566+ String pattern = tokenizer .nextToken ();
1567+ pattern = pattern .replaceAll ("\\ ." , "\\ \\ ." ).replaceAll ("\\ *" , ".*" );
1568+ if (targetHost .matches (pattern )) {
1569+ return true ;
1570+ }
1571+ }
1572+ return false ;
1573+ }
1574+
15621575 static boolean equalsIgnoreCase (String value , String ... strings ) {
15631576 for (String s : strings ) {
15641577 if (s .equalsIgnoreCase (value )) {
0 commit comments