use of org.apache.maven.settings.Proxy in project maven-plugins by apache.
the class RepositoryUtils method getProxyInfo.
// ----------------------------------------------------------------------
// Private methods
// ----------------------------------------------------------------------
/**
* Convenience method to map a <code>Proxy</code> object from the user system settings to a <code>ProxyInfo</code>
* object.
*
* @return a proxyInfo object instanced or null if no active proxy is define in the settings.xml
*/
private ProxyInfo getProxyInfo() {
if (settings == null || settings.getActiveProxy() == null) {
return null;
}
Proxy settingsProxy = settings.getActiveProxy();
ProxyInfo proxyInfo = new ProxyInfo();
proxyInfo.setHost(settingsProxy.getHost());
proxyInfo.setType(settingsProxy.getProtocol());
proxyInfo.setPort(settingsProxy.getPort());
proxyInfo.setNonProxyHosts(settingsProxy.getNonProxyHosts());
proxyInfo.setUserName(settingsProxy.getUsername());
proxyInfo.setPassword(settingsProxy.getPassword());
return proxyInfo;
}
use of org.apache.maven.settings.Proxy in project karaf by apache.
the class MojoSupport method configureProxyToInlineRepo.
private org.apache.maven.repository.Proxy configureProxyToInlineRepo() {
if (mavenSession != null && mavenSession.getSettings() != null) {
Proxy proxy = mavenSession.getSettings().getActiveProxy();
org.apache.maven.repository.Proxy mavenProxy = new org.apache.maven.repository.Proxy();
if (proxy != null) {
mavenProxy.setProtocol(proxy.getProtocol());
mavenProxy.setHost(proxy.getHost());
mavenProxy.setPort(proxy.getPort());
mavenProxy.setNonProxyHosts(proxy.getNonProxyHosts());
mavenProxy.setUserName(proxy.getUsername());
mavenProxy.setPassword(proxy.getPassword());
return mavenProxy;
} else {
return null;
}
} else {
return null;
}
}
use of org.apache.maven.settings.Proxy in project cuke4duke by cucumber.
the class AbstractJRubyMojo method getProxyArg.
/**
* Detect proxy from settings and convert to arg expected by RubyGems.
*/
protected String getProxyArg() {
Proxy activeProxy = this.settings.getActiveProxy();
if (activeProxy == null) {
return "";
}
String proxyArg = " --http-proxy " + activeProxy.getProtocol() + "://" + activeProxy.getHost() + ":" + activeProxy.getPort();
getLog().debug("Adding proxy from settings.xml: " + proxyArg);
return proxyArg;
}
use of org.apache.maven.settings.Proxy in project spring-boot by spring-projects.
the class MavenSettings method createProxySelector.
private ProxySelector createProxySelector(SettingsDecryptionResult decryptedSettings) {
DefaultProxySelector selector = new DefaultProxySelector();
for (Proxy proxy : decryptedSettings.getProxies()) {
Authentication authentication = new AuthenticationBuilder().addUsername(proxy.getUsername()).addPassword(proxy.getPassword()).build();
selector.add(new org.eclipse.aether.repository.Proxy(proxy.getProtocol(), proxy.getHost(), proxy.getPort(), authentication), proxy.getNonProxyHosts());
}
return selector;
}
use of org.apache.maven.settings.Proxy in project maven-plugins by apache.
the class JavadocUtil method createHttpClient.
/**
* Creates a new {@code HttpClient} instance.
*
* @param settings The settings to use for setting up the client or {@code null}.
* @param url The {@code URL} to use for setting up the client or {@code null}.
*
* @return A new {@code HttpClient} instance.
*
* @see #DEFAULT_TIMEOUT
* @since 2.8
*/
private static HttpClient createHttpClient(Settings settings, URL url) {
DefaultHttpClient httpClient = new DefaultHttpClient(new PoolingClientConnectionManager());
httpClient.getParams().setIntParameter(CoreConnectionPNames.SO_TIMEOUT, DEFAULT_TIMEOUT);
httpClient.getParams().setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, DEFAULT_TIMEOUT);
httpClient.getParams().setBooleanParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS, true);
// Some web servers don't allow the default user-agent sent by httpClient
httpClient.getParams().setParameter(CoreProtocolPNames.USER_AGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
if (settings != null && settings.getActiveProxy() != null) {
Proxy activeProxy = settings.getActiveProxy();
ProxyInfo proxyInfo = new ProxyInfo();
proxyInfo.setNonProxyHosts(activeProxy.getNonProxyHosts());
if (StringUtils.isNotEmpty(activeProxy.getHost()) && (url == null || !ProxyUtils.validateNonProxyHosts(proxyInfo, url.getHost()))) {
HttpHost proxy = new HttpHost(activeProxy.getHost(), activeProxy.getPort());
httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
if (StringUtils.isNotEmpty(activeProxy.getUsername()) && activeProxy.getPassword() != null) {
Credentials credentials = new UsernamePasswordCredentials(activeProxy.getUsername(), activeProxy.getPassword());
httpClient.getCredentialsProvider().setCredentials(AuthScope.ANY, credentials);
}
}
}
return httpClient;
}
Aggregations