/** * @return the first active proxy */ public synchronized Proxy getActiveProxy() { if ( activeProxy == null ) { java.util.List<Proxy> proxies = getProxies(); if ( proxies != null && !proxies.isEmpty() ) { for ( Proxy proxy : proxies ) { if ( proxy.isActive() ) { activeProxy = proxy; break; } } } } return activeProxy; }
/** * Returns the maven proxy. * * @return the maven proxy */ private Proxy getMavenProxy() { if (mavenSettings != null) { final List<Proxy> proxies = mavenSettings.getProxies(); if (proxies != null && !proxies.isEmpty()) { if (mavenSettingsProxyId != null) { for (Proxy proxy : proxies) { if (mavenSettingsProxyId.equalsIgnoreCase(proxy.getId())) { return proxy; } } } else { for (Proxy aProxy : proxies) { if (aProxy.isActive()) { return aProxy; } } } } } return null; }
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); } }
private org.apache.maven.settings.Proxy getProxy( ArtifactRepository repository, List<org.apache.maven.settings.Proxy> proxies ) { if ( proxies != null && repository.getProtocol() != null ) { for ( org.apache.maven.settings.Proxy proxy : proxies ) { if ( proxy.isActive() && repository.getProtocol().equalsIgnoreCase( proxy.getProtocol() ) ) { if ( StringUtils.isNotEmpty( proxy.getNonProxyHosts() ) ) { ProxyInfo pi = new ProxyInfo(); pi.setNonProxyHosts( proxy.getNonProxyHosts() ); org.apache.maven.wagon.repository.Repository repo = new org.apache.maven.wagon.repository.Repository( repository.getId(), repository.getUrl() ); if ( !ProxyUtils.validateNonProxyHosts( pi, repo.getHost() ) ) { return proxy; } } else { return proxy; } } } } return null; }
if ( proxy.isActive() && protocol.equalsIgnoreCase( proxy.getProtocol() ) )
/** * @return the first active proxy */ public synchronized Proxy getActiveProxy() { if ( activeProxy == null ) { java.util.List<Proxy> proxies = getProxies(); if ( proxies != null && !proxies.isEmpty() ) { for ( Proxy proxy : proxies ) { if ( proxy.isActive() ) { activeProxy = proxy; break; } } } } return activeProxy; }
if ( !proxy.isActive() )
if ( !proxy.isActive() )
private Proxy getProxyFromSettings() throws MojoExecutionException { if (settings == null) { return null; } if (proxyId != null) { for (Proxy proxy : settings.getProxies()) { if (proxyId.equals(proxy.getId())) { return proxy; } } throw new MojoExecutionException("Configured proxy with id=" + proxyId + " not found"); } // Get active http/https proxy for (Proxy proxy : settings.getProxies()) { if (proxy.isActive() && ("http".equalsIgnoreCase(proxy.getProtocol()) || "https".equalsIgnoreCase(proxy.getProtocol()))) { return proxy; } } return null; }
public IProxyFactory getProxyFactory(Settings settings) { URI downloadUri = URI.create(downloadPath); final String downloadHost = downloadUri.getHost(); final String downloadProto = downloadUri.getScheme(); if (settings.getProxies() != null) { for (org.apache.maven.settings.Proxy proxy : (List<org.apache.maven.settings.Proxy>) settings.getProxies()) { if (proxy.isActive() && equalsIgnoreCase(proxy.getProtocol(), downloadProto) && !contains(proxy.getNonProxyHosts(), downloadHost)) { return new HttpProxyFactory(proxy.getHost(), proxy.getPort()); } } } return new NoProxyFactory(); }
public IProxyFactory getProxyFactory(Settings settings) { URI downloadUri = URI.create(downloadPath); final String downloadHost = downloadUri.getHost(); final String downloadProto = downloadUri.getScheme(); if (settings.getProxies() != null) { for (org.apache.maven.settings.Proxy proxy : (List<org.apache.maven.settings.Proxy>) settings.getProxies()) { if (proxy.isActive() && equalsIgnoreCase(proxy.getProtocol(), downloadProto) && !contains(proxy.getNonProxyHosts(), downloadHost)) { return new HttpProxyFactory(proxy.getHost(), proxy.getPort()); } } } return new NoProxyFactory(); }
/* default */ static Proxy getProxy(MavenSession mavenSession, SettingsDecrypter decrypter) { if (mavenSession == null || mavenSession.getSettings() == null || mavenSession.getSettings().getProxies() == null || mavenSession.getSettings().getProxies().isEmpty()) { LOGGER.info("Proxy is not specified."); return null; } else { final List<Proxy> mavenProxies = mavenSession.getSettings().getProxies(); for (Proxy proxy : mavenProxies) { if (proxy.isActive()) { proxy = decryptProxy(proxy, decrypter); try (Socket socket = new Socket(proxy.getHost(), proxy.getPort())) { } catch (IOException e) { LOGGER.info(String.format("Proxy: %s:%s is not available", proxy.getHost(), proxy.getPort())); continue; } LOGGER.info(String.format("Found proxy: %s:%s", proxy.getHost(), proxy.getPort())); return proxy; } } LOGGER.info("No active proxies found."); return null; } }
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); } }
@Override public void afterFrameworkStarted(EmbeddedEquinox framework) { MavenSession session = context.getSession(); ProxyServiceFacade proxyService = framework.getServiceFactory().getService(ProxyServiceFacade.class); // make sure there is no old state from previous aborted builds clearProxyConfiguration(proxyService); for (Proxy proxy : session.getSettings().getProxies()) { if (proxy.isActive()) { setProxy(proxyService, proxy); } } }
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); } }
/** * Method updateProxy. * * @param value * @param element * @param counter * @param xmlTag */ protected void updateProxy(Proxy value, String xmlTag, Counter counter, Element element) { Element root = element; Counter innerCount = new Counter(counter.getDepth() + 1); findAndReplaceSimpleElement(innerCount, root, "active", value.isActive() == false ? null : String.valueOf( value.isActive() ), "false"); findAndReplaceSimpleElement(innerCount, root, "protocol", value.getProtocol(), "http"); findAndReplaceSimpleElement(innerCount, root, "username", value.getUsername(), null); findAndReplaceSimpleElement(innerCount, root, "password", value.getPassword(), null); findAndReplaceSimpleElement(innerCount, root, "port", value.getPort() == 8080 ? null : String.valueOf( value.getPort() ), "8080"); findAndReplaceSimpleElement(innerCount, root, "host", value.getHost(), null); findAndReplaceSimpleElement(innerCount, root, "nonProxyHosts", value.getNonProxyHosts(), null); findAndReplaceSimpleElement(innerCount, root, "id", value.getId(), null); } //-- void updateProxy(Proxy, String, Counter, Element)
/** * Method updateProxy * * @param value * @param element * @param counter * @param xmlTag */ protected void updateProxy(Proxy value, String xmlTag, Counter counter, Element element) { Element root = element; Counter innerCount = new Counter(counter.getDepth() + 1); findAndReplaceSimpleElement(innerCount, root, "active", value.isActive() == false ? null : String.valueOf( value.isActive() ), "false"); findAndReplaceSimpleElement(innerCount, root, "protocol", value.getProtocol(), "http"); findAndReplaceSimpleElement(innerCount, root, "username", value.getUsername(), null); findAndReplaceSimpleElement(innerCount, root, "password", value.getPassword(), null); findAndReplaceSimpleElement(innerCount, root, "port", value.getPort() == 8080 ? null : String.valueOf( value.getPort() ), "8080"); findAndReplaceSimpleElement(innerCount, root, "host", value.getHost(), null); findAndReplaceSimpleElement(innerCount, root, "nonProxyHosts", value.getNonProxyHosts(), null); findAndReplaceSimpleElement(innerCount, root, "id", value.getId(), null); } //-- void updateProxy(Proxy, String, Counter, Element)
DefaultProxySelector proxySelector = new DefaultProxySelector(); for (Proxy p : decryptionResult.getProxies()) { if (p.isActive()) {