Search in sources :

Example 1 with Proxy

use of com.github.eirslett.maven.plugins.frontend.lib.ProxyConfig.Proxy in project frontend-maven-plugin by eirslett.

the class DefaultFileDownloader method execute.

private CloseableHttpResponse execute(String requestUrl, String userName, String password) throws IOException {
    CloseableHttpResponse response;
    Proxy proxy = proxyConfig.getProxyForUrl(requestUrl);
    if (proxy != null) {
        LOGGER.info("Downloading via proxy " + proxy.toString());
        return executeViaProxy(proxy, requestUrl);
    } else {
        LOGGER.info("No proxy was configured, downloading directly");
        if (StringUtils.isNotEmpty(userName) && StringUtils.isNotEmpty(password)) {
            LOGGER.info("Using credentials (" + userName + ") from settings.xml");
            // Auth target host
            URL aURL = new URL(requestUrl);
            HttpClientContext localContext = makeLocalContext(aURL);
            CredentialsProvider credentialsProvider = makeCredentialsProvider(aURL.getHost(), aURL.getPort(), userName, password);
            response = buildHttpClient(credentialsProvider).execute(new HttpGet(requestUrl), localContext);
        } else {
            response = buildHttpClient(null).execute(new HttpGet(requestUrl));
        }
    }
    return response;
}
Also used : Proxy(com.github.eirslett.maven.plugins.frontend.lib.ProxyConfig.Proxy) HttpGet(org.apache.http.client.methods.HttpGet) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) HttpClientContext(org.apache.http.client.protocol.HttpClientContext) BasicCredentialsProvider(org.apache.http.impl.client.BasicCredentialsProvider) CredentialsProvider(org.apache.http.client.CredentialsProvider) URL(java.net.URL)

Example 2 with Proxy

use of com.github.eirslett.maven.plugins.frontend.lib.ProxyConfig.Proxy in project frontend-maven-plugin by eirslett.

the class DefaultNpmRunner method buildArguments.

private static List<String> buildArguments(ProxyConfig proxyConfig, String npmRegistryURL) {
    List<String> arguments = new ArrayList<String>();
    if (npmRegistryURL != null && !npmRegistryURL.isEmpty()) {
        arguments.add("--registry=" + npmRegistryURL);
    }
    if (!proxyConfig.isEmpty()) {
        Proxy proxy = null;
        if (npmRegistryURL != null && !npmRegistryURL.isEmpty()) {
            proxy = proxyConfig.getProxyForUrl(npmRegistryURL);
        }
        if (proxy == null) {
            proxy = proxyConfig.getSecureProxy();
        }
        if (proxy == null) {
            proxy = proxyConfig.getInsecureProxy();
        }
        arguments.add("--https-proxy=" + proxy.getUri().toString());
        arguments.add("--proxy=" + proxy.getUri().toString());
    }
    return arguments;
}
Also used : Proxy(com.github.eirslett.maven.plugins.frontend.lib.ProxyConfig.Proxy) ArrayList(java.util.ArrayList)

Example 3 with Proxy

use of com.github.eirslett.maven.plugins.frontend.lib.ProxyConfig.Proxy in project frontend-maven-plugin by eirslett.

the class DefaultYarnRunner method buildArguments.

private static List<String> buildArguments(ProxyConfig proxyConfig, String npmRegistryURL) {
    List<String> arguments = new ArrayList<>();
    if (npmRegistryURL != null && !npmRegistryURL.isEmpty()) {
        arguments.add("--registry=" + npmRegistryURL);
    }
    if (!proxyConfig.isEmpty()) {
        Proxy proxy = null;
        if (npmRegistryURL != null && !npmRegistryURL.isEmpty()) {
            proxy = proxyConfig.getProxyForUrl(npmRegistryURL);
        }
        if (proxy == null) {
            proxy = proxyConfig.getSecureProxy();
        }
        if (proxy == null) {
            proxy = proxyConfig.getInsecureProxy();
        }
        arguments.add("--https-proxy=" + proxy.getUri().toString());
        arguments.add("--proxy=" + proxy.getUri().toString());
    }
    return arguments;
}
Also used : Proxy(com.github.eirslett.maven.plugins.frontend.lib.ProxyConfig.Proxy) ArrayList(java.util.ArrayList)

Aggregations

Proxy (com.github.eirslett.maven.plugins.frontend.lib.ProxyConfig.Proxy)3 ArrayList (java.util.ArrayList)2 URL (java.net.URL)1 CredentialsProvider (org.apache.http.client.CredentialsProvider)1 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)1 HttpGet (org.apache.http.client.methods.HttpGet)1 HttpClientContext (org.apache.http.client.protocol.HttpClientContext)1 BasicCredentialsProvider (org.apache.http.impl.client.BasicCredentialsProvider)1