use of org.apache.maven.wagon.proxy.ProxyInfo in project maven-plugins by apache.
the class AbstractDeployMojo method getProxy.
/**
* Get proxy information for Maven 3.
*
* @param repository
* @param settingsDecrypter
* @return
*/
private ProxyInfo getProxy(Repository repository, SettingsDecrypter settingsDecrypter) {
String protocol = repository.getProtocol();
String url = repository.getUrl();
getLog().debug("repository protocol " + protocol);
String originalProtocol = protocol;
// so we will check both
if (StringUtils.equalsIgnoreCase("dav", protocol) && url.startsWith("dav:")) {
url = url.substring(4);
if (url.startsWith("http")) {
try {
URL urlSite = new URL(url);
protocol = urlSite.getProtocol();
getLog().debug("found dav protocol so transform to real transport protocol " + protocol);
} catch (MalformedURLException e) {
getLog().warn("fail to build URL with " + url);
}
}
} else {
getLog().debug("getProxy 'protocol': " + protocol);
}
if (mavenSession != null && protocol != null) {
MavenExecutionRequest request = mavenSession.getRequest();
if (request != null) {
List<Proxy> proxies = request.getProxies();
if (proxies != null) {
for (Proxy proxy : proxies) {
if (proxy.isActive() && (protocol.equalsIgnoreCase(proxy.getProtocol()) || originalProtocol.equalsIgnoreCase(proxy.getProtocol()))) {
SettingsDecryptionResult result = settingsDecrypter.decrypt(new DefaultSettingsDecryptionRequest(proxy));
proxy = result.getProxy();
ProxyInfo proxyInfo = new ProxyInfo();
proxyInfo.setHost(proxy.getHost());
// so hackish for wagon the protocol is https for site dav:
// dav:https://dav.codehaus.org/mojo/
// proxy.getProtocol() );
proxyInfo.setType(protocol);
proxyInfo.setPort(proxy.getPort());
proxyInfo.setNonProxyHosts(proxy.getNonProxyHosts());
proxyInfo.setUserName(proxy.getUsername());
proxyInfo.setPassword(proxy.getPassword());
getLog().debug("found proxyInfo " + ("host:port " + proxyInfo.getHost() + ":" + proxyInfo.getPort() + ", " + proxyInfo.getUserName()));
return proxyInfo;
}
}
}
}
}
getLog().debug("getProxy 'protocol': " + protocol + " no ProxyInfo found");
return null;
}
use of org.apache.maven.wagon.proxy.ProxyInfo in project maven-archetype by apache.
the class RemoteCatalogArchetypeDataSource method getProxy.
private ProxyInfo getProxy(String protocol) {
MavenSession session = legacySupport.getSession();
if (session != null && protocol != null) {
MavenExecutionRequest request = session.getRequest();
if (request != null) {
List<Proxy> proxies = request.getProxies();
if (proxies != null) {
for (Proxy proxy : proxies) {
if (proxy.isActive() && protocol.equalsIgnoreCase(proxy.getProtocol())) {
SettingsDecryptionResult result = settingsDecrypter.decrypt(new DefaultSettingsDecryptionRequest(proxy));
proxy = result.getProxy();
ProxyInfo proxyInfo = new ProxyInfo();
proxyInfo.setHost(proxy.getHost());
proxyInfo.setType(proxy.getProtocol());
proxyInfo.setPort(proxy.getPort());
proxyInfo.setNonProxyHosts(proxy.getNonProxyHosts());
proxyInfo.setUserName(proxy.getUsername());
proxyInfo.setPassword(proxy.getPassword());
return proxyInfo;
}
}
}
}
}
return null;
}
Aggregations