use of org.commonjava.util.jhttpc.model.SiteConfig in project galley by Commonjava.
the class HttpImpl method createClient.
@Override
public CloseableHttpClient createClient(final HttpLocation location) throws GalleyException {
try {
if (location != null) {
locationLookup.register(location);
int maxConnections = LocationUtils.getMaxConnections(location);
SiteConfigBuilder configBuilder = new SiteConfigBuilder(location.getName(), location.getUri());
configBuilder.withAttributes(location.getAttributes()).withKeyCertPem(location.getKeyCertPem()).withServerCertPem(location.getServerCertPem()).withProxyHost(location.getProxyHost()).withProxyPort(location.getProxyPort()).withProxyUser(location.getProxyUser()).withRequestTimeoutSeconds(LocationUtils.getTimeoutSeconds(location)).withUser(location.getUser()).withMaxConnections(maxConnections);
if (location.getTrustType() != null) {
configBuilder.withTrustType(SiteTrustType.getType(location.getTrustType().name()));
}
SiteConfig config = configBuilder.build();
return httpFactory.createClient(config);
} else {
return httpFactory.createClient();
}
} catch (JHttpCException e) {
throw new TransferLocationException(location, "Failed to initialize http client: %s", e, e.getMessage());
}
}
use of org.commonjava.util.jhttpc.model.SiteConfig in project indy by Commonjava.
the class IndySiteConfigLookup method toSiteConfig.
private SiteConfig toSiteConfig(RemoteRepository repository) {
SiteConfigBuilder builder = new SiteConfigBuilder(repository.getName(), repository.getUrl());
logger.debug("Adding server PEM to site config for: {}\n{}", repository.getKey(), repository.getServerCertPem());
builder.withKeyCertPem(repository.getKeyCertPem()).withProxyHost(repository.getProxyHost()).withProxyPort(repository.getProxyPort()).withProxyUser(repository.getProxyUser()).withRequestTimeoutSeconds(repository.getTimeoutSeconds()).withServerCertPem(repository.getServerCertPem()).withTrustType(SiteTrustType.TRUST_SELF_SIGNED).withUser(repository.getUser());
SiteConfig config = builder.build();
logger.debug("Got server PEM in site config:\n{}", config.getServerCertPem());
config.setAttribute(PASSWORD_PREFIX + KEY.name(), repository.getKeyPassword());
config.setAttribute(PASSWORD_PREFIX + USER.name(), repository.getPassword());
config.setAttribute(PASSWORD_PREFIX + PROXY.name(), repository.getProxyPassword());
return config;
}
use of org.commonjava.util.jhttpc.model.SiteConfig in project indy by Commonjava.
the class IndySiteConfigLookupTest method checkHttpConfigLoad.
@Test
public void checkHttpConfigLoad() throws Exception {
File pemFile = testFolder.newFile("keycloak.pem");
final String _URI = "http://site.com";
final String _PROXY_HOST = "http://proxy.com";
final String _PROXY_PORT = "8001";
final String _PEM = "AAAAFFFFFSDADFADSFASDFASDFASDFASDFASDF";
final String _KEY_PASSWORD = "testme";
final String _KEYCLOAK_URI = "http://keycloak.com";
final String _KEYCLOAK_PEM_PATH = pemFile.getAbsolutePath();
IOUtils.write(_PEM, new FileOutputStream(pemFile));
final class TestIndyHttpConfig extends IndyHttpConfig {
@Override
public Map<String, String> getConfiguration() {
Map<String, String> parameters = new HashMap<>();
parameters.put("uri", _URI);
parameters.put("proxy.host", _PROXY_HOST);
parameters.put("proxy.port", _PROXY_PORT);
parameters.put("key.cert.pem", _PEM);
parameters.put("key.password", _KEY_PASSWORD);
parameters.put("keycloak_yourdomain_com.uri", _KEYCLOAK_URI);
parameters.put("keycloak_yourdomain_com.key.cert.pem.path", _KEYCLOAK_PEM_PATH);
return parameters;
}
}
IndyHttpConfig config = new TestIndyHttpConfig();
config.sectionComplete("http");
IndySiteConfigLookup lookup = new IndySiteConfigLookup(null, config);
SiteConfig siteConfig = lookup.lookup(DEFAULT_SITE);
assertThat(siteConfig.getUri(), equalTo(_URI));
assertThat(siteConfig.getProxyHost(), equalTo(_PROXY_HOST));
assertThat(siteConfig.getProxyPort(), equalTo(Integer.parseInt(_PROXY_PORT)));
assertThat(siteConfig.getKeyCertPem(), equalTo(_PEM));
assertThat(siteConfig.getAttribute(PASSWORD_PREFIX + PasswordType.KEY.name()), equalTo(_KEY_PASSWORD));
SiteConfig keycloakConfig = lookup.lookup("keycloak.yourdomain.com");
assertThat(keycloakConfig.getUri(), equalTo(_KEYCLOAK_URI));
assertThat(keycloakConfig.getKeyCertPem(), equalTo(_PEM));
}
use of org.commonjava.util.jhttpc.model.SiteConfig in project indy by Commonjava.
the class HttpSiteConfigTest method run.
@Ignore
@Test
public void run() throws Exception {
String siteId = DEFAULT_SITE;
SiteConfig conf = siteConfigLookup.lookup(siteId);
assertThat(conf.getKeyCertPem(), equalTo(PEM_CONTENT));
}
use of org.commonjava.util.jhttpc.model.SiteConfig in project indy by Commonjava.
the class DownloadDiagBundleTest method createIndyClient.
protected Indy createIndyClient() throws IndyClientException {
SiteConfig config = new SiteConfigBuilder("indy", fixture.getUrl()).withRequestTimeoutSeconds(120).build();
Collection<IndyClientModule> modules = getAdditionalClientModules();
return new Indy(config, new MemoryPasswordManager(), new IndyObjectMapper(getAdditionalMapperModules()), modules.toArray(new IndyClientModule[modules.size()]));
}
Aggregations