use of aQute.bnd.connection.settings.ConnectionSettings in project bnd by bndtools.
the class HttpClientProxyTest method assertSocks5Proxy.
@SuppressWarnings("resource")
void assertSocks5Proxy(String password, boolean authenticationCalled) throws MalformedURLException, Exception {
Processor p = new Processor();
p.setProperty("-connectionsettings", "" + false);
HttpClient hc = new HttpClient();
ConnectionSettings cs = new ConnectionSettings(p, hc);
if (socks5Proxy != null) {
ProxyDTO proxy = new ProxyDTO();
proxy.active = true;
proxy.host = "localhost";
proxy.port = socksProxyPort;
proxy.protocol = Type.SOCKS;
if (password != null) {
proxy.username = "proxyuser";
proxy.password = password;
}
hc.addProxyHandler(ConnectionSettings.createProxyHandler(proxy));
}
ServerDTO server = new ServerDTO();
server.id = httpTestServer.getBaseURI().toString();
server.verify = false;
server.trust = Strings.join(httpTestServer.getTrustedCertificateFiles(IO.getFile("generated")));
cs.add(server);
URL url = new URL(httpTestServer.getBaseURI() + "/get-tag/ABCDEFGH");
TaggedData tag = hc.connectTagged(url);
assertNotNull(tag);
assertEquals("ABCDEFGH", tag.getTag());
String s = IO.collect(tag.getInputStream());
assertNotNull(s);
assertTrue(s.trim().startsWith("{"));
// assertTrue(this.authenticationCalled.get() == authenticationCalled);
}
use of aQute.bnd.connection.settings.ConnectionSettings in project bnd by bndtools.
the class HttpClientProxyTest method assertHttpProxy.
@SuppressWarnings("resource")
void assertHttpProxy(String password, boolean authenticationCalled) throws MalformedURLException, Exception {
Processor p = new Processor();
p.setProperty("-connectionsettings", "" + false);
HttpClient hc = new HttpClient();
ConnectionSettings cs = new ConnectionSettings(p, hc);
if (httpProxy != null) {
ProxyDTO proxy = new ProxyDTO();
proxy.active = true;
proxy.host = "localhost";
proxy.port = httpProxyPort;
proxy.protocol = Type.HTTP;
if (password != null) {
proxy.username = "proxyuser";
proxy.password = password;
}
hc.addProxyHandler(ConnectionSettings.createProxyHandler(proxy));
}
ServerDTO server = new ServerDTO();
server.id = httpTestServer.getBaseURI().toString();
server.verify = false;
server.trust = Strings.join(httpTestServer.getTrustedCertificateFiles(IO.getFile("generated")));
cs.add(server);
URL url = new URL(httpTestServer.getBaseURI() + "/get-tag/ABCDEFGH");
TaggedData tag = hc.connectTagged(url);
assertNotNull(tag);
if (tag.getState() != State.OTHER)
assertEquals("ABCDEFGH", tag.getTag());
String s = IO.collect(tag.getInputStream());
assertNotNull(s);
assertTrue(s.trim().startsWith("{"));
assertTrue(this.authenticationCalled.get() == authenticationCalled);
}
use of aQute.bnd.connection.settings.ConnectionSettings in project bnd by bndtools.
the class SettingsParserTest method testMavenEncryptedPassword.
public void testMavenEncryptedPassword() throws Exception {
System.setProperty(ConnectionSettings.M2_SETTINGS_SECURITY_PROPERTY, "testresources/settings-security.xml");
Processor proc = new Processor();
proc.setProperty("-connection-settings", "testresources/server-maven-encrypted-selection.xml");
try (ConnectionSettings cs = new ConnectionSettings(proc, new HttpClient())) {
cs.readSettings();
List<ServerDTO> serverDTOs = cs.getServerDTOs();
assertEquals(1, serverDTOs.size());
ServerDTO s = serverDTOs.get(0);
assertEquals("encrypted-password", s.id);
assertEquals("FOOBAR", s.password);
}
}
use of aQute.bnd.connection.settings.ConnectionSettings in project bnd by bndtools.
the class HttpClientServerTest method assertOk.
@SuppressWarnings("resource")
private void assertOk(String password, boolean verify) throws Exception {
File log = new File(tmp, "log");
Processor p = new Processor();
p.setProperty("-connection-log", log.toURI().getPath());
HttpClient hc = new HttpClient();
hc.setLog(log);
ConnectionSettings cs = new ConnectionSettings(p, hc);
ServerDTO server = new ServerDTO();
server.id = httpServer.getBaseURI().toString();
server.verify = verify;
if (password != null) {
server.username = "user";
server.password = password;
}
server.trust = Strings.join(httpServer.getTrustedCertificateFiles(IO.getFile("generated")));
cs.add(server);
System.out.println(httpServer.getBaseURI());
URL url = password == null ? new URL(httpServer.getBaseURI() + "/get") : new URL(httpServer.getBaseURI() + "/basic-auth/user/good");
TaggedData tag = hc.connectTagged(url);
assertNotNull(tag);
String s = IO.collect(tag.getInputStream());
assertNotNull(s);
assertTrue(s.trim().startsWith("{"));
IO.copy(log, System.out);
}
use of aQute.bnd.connection.settings.ConnectionSettings in project bnd by bndtools.
the class Workspace method setTypeSpecificPlugins.
@Override
protected void setTypeSpecificPlugins(Set<Object> list) {
try {
super.setTypeSpecificPlugins(list);
list.add(this);
list.add(maven);
list.add(settings);
if (!isTrue(getProperty(NOBUILDINCACHE))) {
list.add(new CachedFileRepo());
}
resourceRepositoryImpl = new ResourceRepositoryImpl();
resourceRepositoryImpl.setCache(IO.getFile(getProperty(CACHEDIR, "~/.bnd/caches/shas")));
resourceRepositoryImpl.setExecutor(getExecutor());
resourceRepositoryImpl.setIndexFile(getFile(getBuildDir(), "repo.json"));
resourceRepositoryImpl.setURLConnector(new MultiURLConnectionHandler(this));
customize(resourceRepositoryImpl, null);
list.add(resourceRepositoryImpl);
//
// Exporters
//
list.add(new SubsystemExporter());
try {
HttpClient client = new HttpClient();
client.setOffline(getOffline());
client.setRegistry(this);
try (ConnectionSettings cs = new ConnectionSettings(this, client)) {
cs.readSettings();
}
list.add(client);
} catch (Exception e) {
exception(e, "Failed to load the communication settings");
}
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations