96
96
import org .apache .maven .shared .invoker .PrintStreamHandler ;
97
97
import org .apache .maven .shared .utils .io .DirectoryScanner ;
98
98
import org .apache .maven .shared .utils .io .FileUtils ;
99
- import org .apache .maven .wagon .proxy .ProxyInfo ;
100
- import org .apache .maven .wagon .proxy .ProxyUtils ;
101
99
import org .codehaus .plexus .languages .java .version .JavaVersion ;
102
100
import org .codehaus .plexus .util .cli .CommandLineException ;
103
101
import org .codehaus .plexus .util .cli .CommandLineUtils ;
@@ -1527,20 +1525,17 @@ private static CloseableHttpClient createHttpClient(Settings settings, URL url)
1527
1525
// Some web servers don't allow the default user-agent sent by httpClient
1528
1526
builder .setUserAgent ("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" );
1529
1527
1530
- // Some server reject requests that do not have an Accept header
1528
+ // Some servers reject requests that do not have an Accept header
1531
1529
builder .setDefaultHeaders (Collections .singletonList (new BasicHeader (HttpHeaders .ACCEPT , "*/*" )));
1532
1530
1533
1531
if (settings != null && settings .getActiveProxy () != null ) {
1534
1532
Proxy activeProxy = settings .getActiveProxy ();
1535
-
1536
- ProxyInfo proxyInfo = new ProxyInfo ();
1537
- proxyInfo .setNonProxyHosts (activeProxy .getNonProxyHosts ());
1538
-
1533
+ String nonProxyHosts = activeProxy .getNonProxyHosts ();
1539
1534
String activeProxyHost = activeProxy .getHost ();
1540
1535
if (activeProxyHost != null
1541
1536
&& !activeProxyHost .isEmpty ()
1542
- && (url == null || !ProxyUtils . validateNonProxyHosts ( proxyInfo , url .getHost ()))) {
1543
- HttpHost proxy = new HttpHost (activeProxy . getHost () , activeProxy .getPort ());
1537
+ && (url == null || !isNonProxyHost ( nonProxyHosts , url .getHost ()))) {
1538
+ HttpHost proxy = new HttpHost (activeProxyHost , activeProxy .getPort ());
1544
1539
builder .setProxy (proxy );
1545
1540
1546
1541
String activeProxyUsername = activeProxy .getUsername ();
@@ -1559,6 +1554,24 @@ private static CloseableHttpClient createHttpClient(Settings settings, URL url)
1559
1554
return builder .build ();
1560
1555
}
1561
1556
1557
+ private static boolean isNonProxyHost (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
+
1562
1575
static boolean equalsIgnoreCase (String value , String ... strings ) {
1563
1576
for (String s : strings ) {
1564
1577
if (s .equalsIgnoreCase (value )) {
0 commit comments