use of org.sonatype.aether.repository.Proxy in project zeppelin by apache.
the class AbstractDependencyResolver method setProxy.
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);
}
}
}
use of org.sonatype.aether.repository.Proxy in project sonatype-aether by sonatype.
the class ProxyGetTest method before.
@Override
@Before
public void before() throws Exception {
super.before();
Authentication auth = new Authentication("puser", "password");
Proxy proxy = new Proxy("http", "localhost", provider().getPort(), auth);
repository().setProxy(proxy);
}
use of org.sonatype.aether.repository.Proxy in project sonatype-aether by sonatype.
the class DefaultRemoteRepositoryManagerTest method testProxySelector.
@Test
public void testProxySelector() {
final RemoteRepository repo = newRepo("a", "http://", false, "", "");
final Proxy proxy = new Proxy("http", "host", 2011, null);
session.setProxySelector(new ProxySelector() {
public Proxy getProxy(RemoteRepository repository) {
return proxy;
}
});
session.setMirrorSelector(new MirrorSelector() {
public RemoteRepository getMirror(RemoteRepository repository) {
return null;
}
});
List<RemoteRepository> result = manager.aggregateRepositories(session, Collections.<RemoteRepository>emptyList(), Arrays.asList(repo), true);
assertEquals(1, result.size());
assertEquals("http", result.get(0).getProxy().getType());
assertEquals("host", result.get(0).getProxy().getHost());
assertEquals(2011, result.get(0).getProxy().getPort());
}
use of org.sonatype.aether.repository.Proxy in project sonatype-aether by sonatype.
the class DefaultRemoteRepositoryManagerTest method testMirrorProxy.
@Test
public void testMirrorProxy() {
final RemoteRepository repo = newRepo("a", "http://", false, "", "");
final RemoteRepository mirror = newRepo("a", "http://", false, "", "");
mirror.setProxy(new Proxy("http", "host", 2011, null));
session.setMirrorSelector(new MirrorSelector() {
public RemoteRepository getMirror(RemoteRepository repository) {
return mirror;
}
});
List<RemoteRepository> result = manager.aggregateRepositories(session, Collections.<RemoteRepository>emptyList(), Arrays.asList(repo), true);
assertEquals(1, result.size());
assertEquals("http", result.get(0).getProxy().getType());
assertEquals("host", result.get(0).getProxy().getHost());
assertEquals(2011, result.get(0).getProxy().getPort());
}
use of org.sonatype.aether.repository.Proxy in project sonatype-aether by sonatype.
the class DefaultRemoteRepositoryManager method getRepositoryConnector.
public RepositoryConnector getRepositoryConnector(RepositorySystemSession session, RemoteRepository repository) throws NoRepositoryConnectorException {
if (repository == null) {
throw new IllegalArgumentException("remote repository has not been specified");
}
List<RepositoryConnectorFactory> factories = new ArrayList<RepositoryConnectorFactory>(connectorFactories);
Collections.sort(factories, COMPARATOR);
for (RepositoryConnectorFactory factory : factories) {
try {
RepositoryConnector connector = factory.newInstance(session, repository);
if (logger.isDebugEnabled()) {
StringBuilder buffer = new StringBuilder(256);
buffer.append("Using connector ").append(connector.getClass().getSimpleName());
buffer.append(" with priority ").append(factory.getPriority());
buffer.append(" for ").append(repository.getUrl());
Authentication auth = repository.getAuthentication();
if (auth != null) {
buffer.append(" as ").append(auth.getUsername());
}
Proxy proxy = repository.getProxy();
if (proxy != null) {
buffer.append(" via ").append(proxy.getHost()).append(':').append(proxy.getPort());
auth = proxy.getAuthentication();
if (auth != null) {
buffer.append(" as ").append(auth.getUsername());
}
}
logger.debug(buffer.toString());
}
return connector;
} catch (NoRepositoryConnectorException e) {
// continue and try next factory
}
}
StringBuilder buffer = new StringBuilder(256);
buffer.append("No connector available to access repository ");
buffer.append(repository.getId());
buffer.append(" (").append(repository.getUrl());
buffer.append(") of type ").append(repository.getContentType());
buffer.append(" using the available factories ");
for (ListIterator<RepositoryConnectorFactory> it = factories.listIterator(); it.hasNext(); ) {
RepositoryConnectorFactory factory = it.next();
buffer.append(factory.getClass().getSimpleName());
if (it.hasNext()) {
buffer.append(", ");
}
}
throw new NoRepositoryConnectorException(repository, buffer.toString());
}
Aggregations