Java Code Examples for org.apache.maven.settings.Proxy#isActive()
The following examples show how to use
org.apache.maven.settings.Proxy#isActive() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MojoUtils.java From frontend-maven-plugin with Apache License 2.0 | 6 votes |
static ProxyConfig getProxyConfig(MavenSession mavenSession, SettingsDecrypter decrypter) { if (mavenSession == null || mavenSession.getSettings() == null || mavenSession.getSettings().getProxies() == null || mavenSession.getSettings().getProxies().isEmpty()) { return new ProxyConfig(Collections.<ProxyConfig.Proxy>emptyList()); } else { final List<Proxy> mavenProxies = mavenSession.getSettings().getProxies(); final List<ProxyConfig.Proxy> proxies = new ArrayList<ProxyConfig.Proxy>(mavenProxies.size()); for (Proxy mavenProxy : mavenProxies) { if (mavenProxy.isActive()) { mavenProxy = decryptProxy(mavenProxy, decrypter); proxies.add(new ProxyConfig.Proxy(mavenProxy.getId(), mavenProxy.getProtocol(), mavenProxy.getHost(), mavenProxy.getPort(), mavenProxy.getUsername(), mavenProxy.getPassword(), mavenProxy.getNonProxyHosts())); } } LOGGER.info("Found proxies: {}", proxies); return new ProxyConfig(proxies); } }
Example 2
Source File: MojoUtils.java From wisdom with Apache License 2.0 | 6 votes |
public static ProxyConfig getProxyConfig(MavenSession mavenSession, SettingsDecrypter decrypter) { if (mavenSession == null || mavenSession.getSettings() == null || mavenSession.getSettings().getProxies() == null || mavenSession.getSettings().getProxies().isEmpty()) { return new ProxyConfig(Collections.<ProxyConfig.Proxy>emptyList()); } else { final List<Proxy> mavenProxies = mavenSession.getSettings().getProxies(); final List<ProxyConfig.Proxy> proxies = new ArrayList<>(mavenProxies.size()); for (Proxy mavenProxy : mavenProxies) { if (mavenProxy.isActive()) { mavenProxy = decryptProxy(mavenProxy, decrypter); proxies.add(new ProxyConfig.Proxy(mavenProxy.getId(), mavenProxy.getProtocol(), mavenProxy.getHost(), mavenProxy.getPort(), mavenProxy.getUsername(), mavenProxy.getPassword(), mavenProxy.getNonProxyHosts())); } } return new ProxyConfig(proxies); } }
Example 3
Source File: GatewayAbstractMojo.java From apigee-deploy-maven-plugin with Apache License 2.0 | 5 votes |
/** * Get the proxy configuration from the maven settings * * @param settings the maven settings * @param host the host name of the apigee edge endpoint * * @return proxy or null if none was configured or the host was non-proxied */ protected Proxy getProxy(final Settings settings, final String host) { if (settings == null) { return null; } List<Proxy> proxies = settings.getProxies(); if (proxies == null || proxies.isEmpty()) { return null; } String protocol = "https"; String hostname = host; // check if protocol is present, if not assume https Matcher matcher = URL_PARSE_REGEX.matcher(host); if (matcher.matches()) { protocol = matcher.group(1); hostname = matcher.group(2); } // search active proxy for (Proxy proxy : proxies) { if (proxy.isActive() && protocol.equalsIgnoreCase(proxy.getProtocol()) && !matchNonProxy(proxy, hostname)) { if (settingsDecrypter != null) { return settingsDecrypter.decrypt(new DefaultSettingsDecryptionRequest(proxy)).getProxy(); } else { getLog().warn("Maven did not inject SettingsDecrypter, " + "proxy may contain an encrypted password, which cannot be " + "used to setup the REST client."); return proxy; } } } return null; }