use of org.apache.maven.repository.Proxy in project maven by apache.
the class MavenRepositorySystem method getProxy.
private Proxy getProxy(RepositorySystemSession session, ArtifactRepository repository) {
if (session != null) {
ProxySelector selector = session.getProxySelector();
if (selector != null) {
RemoteRepository repo = RepositoryUtils.toRepo(repository);
org.eclipse.aether.repository.Proxy proxy = selector.getProxy(repo);
if (proxy != null) {
Proxy p = new Proxy();
p.setHost(proxy.getHost());
p.setProtocol(proxy.getType());
p.setPort(proxy.getPort());
if (proxy.getAuthentication() != null) {
repo = new RemoteRepository.Builder(repo).setProxy(proxy).build();
AuthenticationContext authCtx = AuthenticationContext.forProxy(session, repo);
p.setUserName(authCtx.get(AuthenticationContext.USERNAME));
p.setPassword(authCtx.get(AuthenticationContext.PASSWORD));
p.setNtlmDomain(authCtx.get(AuthenticationContext.NTLM_DOMAIN));
p.setNtlmHost(authCtx.get(AuthenticationContext.NTLM_WORKSTATION));
authCtx.close();
}
return p;
}
}
}
return null;
}
use of org.apache.maven.repository.Proxy in project maven by apache.
the class LegacyRepositorySystem method injectProxy.
public void injectProxy(List<ArtifactRepository> repositories, List<org.apache.maven.settings.Proxy> proxies) {
if (repositories != null) {
for (ArtifactRepository repository : repositories) {
org.apache.maven.settings.Proxy proxy = getProxy(repository, proxies);
if (proxy != null) {
SettingsDecryptionRequest request = new DefaultSettingsDecryptionRequest(proxy);
SettingsDecryptionResult result = settingsDecrypter.decrypt(request);
proxy = result.getProxy();
if (logger.isDebugEnabled()) {
for (SettingsProblem problem : result.getProblems()) {
logger.debug(problem.getMessage(), problem.getException());
}
}
Proxy p = new Proxy();
p.setHost(proxy.getHost());
p.setProtocol(proxy.getProtocol());
p.setPort(proxy.getPort());
p.setNonProxyHosts(proxy.getNonProxyHosts());
p.setUserName(proxy.getUsername());
p.setPassword(proxy.getPassword());
repository.setProxy(p);
} else {
repository.setProxy(null);
}
}
}
}
use of org.apache.maven.repository.Proxy in project maven by apache.
the class LegacyRepositorySystem method getProxy.
private Proxy getProxy(RepositorySystemSession session, ArtifactRepository repository) {
if (session != null) {
ProxySelector selector = session.getProxySelector();
if (selector != null) {
RemoteRepository repo = RepositoryUtils.toRepo(repository);
org.eclipse.aether.repository.Proxy proxy = selector.getProxy(repo);
if (proxy != null) {
Proxy p = new Proxy();
p.setHost(proxy.getHost());
p.setProtocol(proxy.getType());
p.setPort(proxy.getPort());
if (proxy.getAuthentication() != null) {
repo = new RemoteRepository.Builder(repo).setProxy(proxy).build();
AuthenticationContext authCtx = AuthenticationContext.forProxy(session, repo);
p.setUserName(authCtx.get(AuthenticationContext.USERNAME));
p.setPassword(authCtx.get(AuthenticationContext.PASSWORD));
p.setNtlmDomain(authCtx.get(AuthenticationContext.NTLM_DOMAIN));
p.setNtlmHost(authCtx.get(AuthenticationContext.NTLM_WORKSTATION));
authCtx.close();
}
return p;
}
}
}
return null;
}
use of org.apache.maven.repository.Proxy in project maven by apache.
the class DefaultUpdateCheckManager method getRepositoryKey.
String getRepositoryKey(ArtifactRepository repository) {
StringBuilder buffer = new StringBuilder(256);
Proxy proxy = repository.getProxy();
if (proxy != null) {
if (proxy.getUserName() != null) {
int hash = (proxy.getUserName() + proxy.getPassword()).hashCode();
buffer.append(hash).append('@');
}
buffer.append(proxy.getHost()).append(':').append(proxy.getPort()).append('>');
}
// consider the username&password because a repo manager might block artifacts depending on authorization
Authentication auth = repository.getAuthentication();
if (auth != null) {
int hash = (auth.getUsername() + auth.getPassword()).hashCode();
buffer.append(hash).append('@');
}
// consider the URL (instead of the id) as this most closely relates to the contents in the repo
buffer.append(repository.getUrl());
return buffer.toString();
}
Aggregations