use of org.commonjava.util.jhttpc.model.SiteConfigBuilder 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());
} finally {
}
}
use of org.commonjava.util.jhttpc.model.SiteConfigBuilder 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.SiteConfigBuilder in project indy by Commonjava.
the class IndyHttpConfig method getSiteConfigBuilder.
private SiteConfigBuilder getSiteConfigBuilder(Map<String, SiteConfigBuilder> siteConfigBuilderMap, String siteId) {
SiteConfigBuilder builder = siteConfigBuilderMap.get(siteId);
if (builder == null) {
builder = new SiteConfigBuilder(siteId, null);
siteConfigBuilderMap.put(siteId, builder);
}
return builder;
}
use of org.commonjava.util.jhttpc.model.SiteConfigBuilder in project indy by Commonjava.
the class IndyHttpConfig method sectionComplete.
@Override
public void sectionComplete(String name) throws ConfigurationException {
Map<String, SiteConfigBuilder> builderMap = new HashMap<>();
// key: siteId, value: attributes (map)
Map<String, Map<String, Object>> attributesMap = new HashMap<>();
Map<String, String> parametersMap = getConfiguration();
for (Map.Entry<String, String> et : parametersMap.entrySet()) {
String key = et.getKey();
String value = et.getValue();
switch(key) {
case URI:
case USER:
case PROXY_HOST:
case PROXY_PORT:
case PROXY_USER:
case TRUST_TYPE:
case KEY_CERT_PEM:
case KEY_CERT_PEM_PATH:
case SERVER_CERT_PEM:
case SERVER_CERT_PEM_PATH:
case REQUEST_TIMEOUT_SECONDS:
case MAX_CONNECTIONS:
withEntry(getSiteConfigBuilder(builderMap, DEFAULT_SITE), key, value);
break;
case KEY_PASSWORD:
case PASSWORD:
case PROXY_PASSWORD:
withAttribute(getAttributes(attributesMap, DEFAULT_SITE), getAttributeName(key), value);
break;
default:
// Not match? Never mind. These are non-default config entries, e.g., keycloak.key.cert.pem=xxx
int idx = key.indexOf(".");
String siteId = key.substring(0, idx);
String realKey = key.substring(idx + 1);
if (isAttribute(realKey)) {
withAttribute(getAttributes(attributesMap, siteId), getAttributeName(realKey), value);
} else {
withEntry(getSiteConfigBuilder(builderMap, siteId), realKey, value);
}
break;
}
}
for (Map.Entry<String, Map<String, Object>> et : attributesMap.entrySet()) {
SiteConfigBuilder builder = builderMap.get(et.getKey());
if (builder == null) {
throw new ConfigurationException("[http.conf] No site " + et.getKey() + " defined for attributes");
}
builder.withAttributes(et.getValue());
}
for (Map.Entry<String, SiteConfigBuilder> et : builderMap.entrySet()) {
siteConfigMap.put(et.getKey(), et.getValue().build());
}
logger.debug("Section complete, name={}, siteConfigMap={}", name, siteConfigMap);
}
use of org.commonjava.util.jhttpc.model.SiteConfigBuilder 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