public void setProxy(URL proxyUrl, String proxyUser, String proxyPassword) { Authentication auth = new Authentication(proxyUser, proxyPassword); Proxy proxy = new Proxy(proxyUrl.getProtocol(), proxyUrl.getHost(), proxyUrl.getPort(), auth); synchronized (repos) { for (RemoteRepository repo : repos) { repo.setProxy(proxy); } } }
/** * Sets the port number for the proxy. * * @param port The port number for the proxy. * @return The new proxy, never {@code null}. */ public Proxy setPort( int port ) { if ( this.port == port ) { return this; } return new Proxy( type, host, port, auth ); }
/** * Sets the port number for the proxy. * * @param port The port number for the proxy. * @return The new proxy, never {@code null}. */ public Proxy setPort( int port ) { if ( this.port == port ) { return this; } return new Proxy( type, host, port, auth ); }
/** * Sets the port number for the proxy. * * @param port The port number for the proxy. * @return The new proxy, never {@code null}. */ public Proxy setPort( int port ) { if ( this.port == port ) { return this; } return new Proxy( type, host, port, auth ); }
/** * Sets the type of the proxy. * * @param type The type of the proxy, e.g. "http", may be {@code null}. * @return The new proxy, never {@code null}. */ public Proxy setType( String type ) { if ( this.type.equals( type ) || ( type == null && this.type.length() <= 0 ) ) { return this; } return new Proxy( type, host, port, auth ); }
/** * Sets the type of the proxy. * * @param type The type of the proxy, e.g. "http", may be {@code null}. * @return The new proxy, never {@code null}. */ public Proxy setType( String type ) { if ( this.type.equals( type ) || ( type == null && this.type.length() <= 0 ) ) { return this; } return new Proxy( type, host, port, auth ); }
/** * Sets the host of the proxy. * * @param host The host of the proxy, may be {@code null}. * @return The new proxy, never {@code null}. */ public Proxy setHost( String host ) { if ( this.host.equals( host ) || ( host == null && this.host.length() <= 0 ) ) { return this; } return new Proxy( type, host, port, auth ); }
/** * Sets the type of the proxy. * * @param type The type of the proxy, e.g. "http", may be {@code null}. * @return The new proxy, never {@code null}. */ public Proxy setType( String type ) { if ( this.type.equals( type ) || ( type == null && this.type.length() <= 0 ) ) { return this; } return new Proxy( type, host, port, auth ); }
/** * Sets the host of the proxy. * * @param host The host of the proxy, may be {@code null}. * @return The new proxy, never {@code null}. */ public Proxy setHost( String host ) { if ( this.host.equals( host ) || ( host == null && this.host.length() <= 0 ) ) { return this; } return new Proxy( type, host, port, auth ); }
/** * Sets the host of the proxy. * * @param host The host of the proxy, may be {@code null}. * @return The new proxy, never {@code null}. */ public Proxy setHost( String host ) { if ( this.host.equals( host ) || ( host == null && this.host.length() <= 0 ) ) { return this; } return new Proxy( type, host, port, auth ); }
/** * Sets the authentication to use for the proxy connection. * * @param auth The authentication to use, may be {@code null}. * @return The new proxy, never {@code null}. */ public Proxy setAuthentication( Authentication auth ) { if ( eq( this.auth, auth ) ) { return this; } return new Proxy( type, host, port, auth ); }
/** * Get the Proxy object. * @return The Proxy object. */ public Proxy getProxy() { return new Proxy( this.type, this.host, this.port, this.auth.getAuthentication() ); } }
/** * Sets the authentication to use for the proxy connection. * * @param auth The authentication to use, may be {@code null}. * @return The new proxy, never {@code null}. */ public Proxy setAuthentication( Authentication auth ) { if ( eq( this.auth, auth ) ) { return this; } return new Proxy( type, host, port, auth ); }
/** * Sets the authentication to use for the proxy connection. * * @param auth The authentication to use, may be {@code null}. * @return The new proxy, never {@code null}. */ public Proxy setAuthentication( Authentication auth ) { if ( eq( this.auth, auth ) ) { return this; } return new Proxy( type, host, port, auth ); }
private ProxySelector selectProxies() { DefaultProxySelector proxySelector = new DefaultProxySelector(); Map<String, Map<String, String>> proxies = m_config.getProxySettings(); for (Map<String, String> proxy : proxies.values()) { //The fields are user, pass, host, port, nonProxyHosts, protocol. String nonProxyHosts = proxy.get("nonProxyHosts"); Proxy proxyObj = new Proxy(proxy.get("protocol"), proxy.get("host"), toInt(proxy.get("port")), getAuthentication(proxy) ); proxySelector.add(proxyObj, nonProxyHosts); } return proxySelector; }
@Override public RemoteRepository decorate(RemoteRepository repo) { loadBeesConfig(); if (proxyHost != null && proxyPort!=null) { String proxyType = Proxy.TYPE_HTTP; if (repo.getUrl().startsWith("https")) proxyType = Proxy.TYPE_HTTPS; Proxy proxy = new Proxy(proxyType, proxyHost, Integer.parseInt(proxyPort), null); if (proxyUser != null) { Authentication authentication = new Authentication(proxyUser, proxyPass); proxy.setAuthentication(authentication); } repo.setProxy(proxy); } return repo; }
public static org.sonatype.aether.repository.Proxy convertFromMavenProxy(org.apache.maven.settings.Proxy proxy) { org.sonatype.aether.repository.Proxy result = null; if (proxy != null) { Authentication auth = new Authentication(proxy.getUsername(), proxy.getPassword()); result = new org.sonatype.aether.repository.Proxy(proxy.getProtocol(), proxy.getHost(), proxy.getPort(), auth); } return result; }
static RemoteRepository convertToMavenRepo(final DependencyRepository repo, final Settings settings) { RemoteRepository remoteRepository = new RemoteRepository(repo.getId(), "default", repo.getUrl()); Proxy activeProxy = settings.getActiveProxy(); if (activeProxy != null) { Authentication auth = new Authentication(activeProxy.getUsername(), activeProxy.getPassword()); remoteRepository.setProxy(new org.sonatype.aether.repository.Proxy(activeProxy.getProtocol(), activeProxy .getHost(), activeProxy.getPort(), auth)); } return remoteRepository; }
/** * Returns the default {@link ProxySelector} as configured in the maven settings.xml * * @return */ public static ProxySelector getProxySelector() { DefaultProxySelector selector = new DefaultProxySelector(); Settings settings = getSettings(); for (org.apache.maven.settings.Proxy proxy : settings.getProxies()) { Authentication auth = new Authentication(proxy.getUsername(), proxy.getPassword()); org.sonatype.aether.repository.Proxy p = new Proxy(proxy.getProtocol(), proxy.getHost(), proxy.getPort(), auth); selector.add(p, proxy.getNonProxyHosts()); } return selector; }