diff --git a/pom.xml b/pom.xml index 5a3c24b45d..f630ed2dbe 100644 --- a/pom.xml +++ b/pom.xml @@ -94,14 +94,14 @@ 1.5 3.4.0-SNAPSHOT 1.1.1 - 1.16 + 1.17-SNAPSHOT 1.24 3.2.1 1.16 2.13 2.3 - 1.12 + 1.14-SNAPSHOT 1.5.1 1.5 0.13.1 diff --git a/subsys/groovy/src/test/java/org/commonjava/indy/subsys/template/fixture/TestProvider.java b/subsys/groovy/src/test/java/org/commonjava/indy/subsys/template/fixture/TestProvider.java index 8b2f5bb656..c931eeb7ea 100644 --- a/subsys/groovy/src/test/java/org/commonjava/indy/subsys/template/fixture/TestProvider.java +++ b/subsys/groovy/src/test/java/org/commonjava/indy/subsys/template/fixture/TestProvider.java @@ -21,14 +21,12 @@ import org.commonjava.indy.action.UserLifecycleManager; import org.commonjava.indy.action.fixture.AlternativeUserLifecycleManager; import org.commonjava.indy.content.IndyPathGenerator; -import org.commonjava.indy.data.ArtifactStoreValidateData; import org.commonjava.indy.data.NoOpStoreEventDispatcher; import org.commonjava.indy.data.StoreDataManager; import org.commonjava.indy.data.StoreEventDispatcher; import org.commonjava.indy.data.StoreValidator; import org.commonjava.indy.db.common.inject.Standalone; import org.commonjava.indy.mem.data.MemoryStoreDataManager; -import org.commonjava.indy.model.core.ArtifactStore; import org.commonjava.indy.model.core.io.IndyObjectMapper; import org.commonjava.maven.galley.cache.FileCacheProvider; import org.commonjava.maven.galley.config.TransportManagerConfig; @@ -40,13 +38,12 @@ import org.commonjava.maven.galley.spi.event.FileEventManager; import org.commonjava.maven.galley.spi.nfc.NotFoundCache; import org.commonjava.maven.galley.transport.htcli.conf.GlobalHttpConfiguration; -import org.commonjava.o11yphant.metrics.sli.GoldenSignalsMetricSet; -import org.commonjava.o11yphant.trace.TracerConfiguration; import org.junit.rules.TemporaryFolder; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.inject.Alternative; import javax.enterprise.inject.Default; import javax.enterprise.inject.Produces; import javax.inject.Inject; @@ -190,6 +187,7 @@ public WeftConfig getWeftConfig() } @Produces + @Alternative public GlobalHttpConfiguration getGlobalHttpConfiguration() { return globalHttpConfiguration; diff --git a/subsys/http/src/main/java/org/commonjava/indy/subsys/http/IndyGlobalHttpConfigurationProducer.java b/subsys/http/src/main/java/org/commonjava/indy/subsys/http/IndyGlobalHttpConfigurationProducer.java new file mode 100644 index 0000000000..fea030654d --- /dev/null +++ b/subsys/http/src/main/java/org/commonjava/indy/subsys/http/IndyGlobalHttpConfigurationProducer.java @@ -0,0 +1,93 @@ +package org.commonjava.indy.subsys.http; + +import org.commonjava.indy.subsys.http.conf.IndyHttpConfig; +import org.commonjava.indy.subsys.http.util.IndySiteConfigLookup; +import org.commonjava.maven.galley.transport.htcli.conf.GlobalHttpConfiguration; +import org.commonjava.maven.galley.transport.htcli.conf.ProxyConfig; +import org.commonjava.util.jhttpc.model.SiteConfig; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.inject.Default; +import javax.enterprise.inject.Produces; +import javax.inject.Inject; +import java.util.ArrayList; +import java.util.List; + +import static org.apache.commons.lang3.StringUtils.isNotBlank; +import static org.commonjava.indy.subsys.http.conf.IndyHttpConfig.DEFAULT_SITE; + +@ApplicationScoped +public class IndyGlobalHttpConfigurationProducer +{ + private final Logger logger = LoggerFactory.getLogger( getClass() ); + + @Inject + private IndyHttpConfig config; + + @Inject + private IndySiteConfigLookup siteConfigLookup; + + private GlobalHttpConfiguration globalHttpConfiguration; + + private SiteConfig defaultSiteConfig; + + @Produces + @Default + public GlobalHttpConfiguration getGlobalHttpConfiguration() + { + defaultSiteConfig = siteConfigLookup.lookup( DEFAULT_SITE ); + if ( defaultSiteConfig != null && defaultSiteConfig.getProxyHost() != null ) + { + setUpGlobalHttpConfiguration(); + } + return globalHttpConfiguration; + } + + private void setUpGlobalHttpConfiguration() + { + logger.info( "Setup global http configuration" ); + final String allowTypes = defaultSiteConfig.getProxyAllowHttpJobTypes(); + final List list = new ArrayList<>(); + if ( isNotBlank( allowTypes ) ) + { + String[] toks = allowTypes.split( "," ); + for ( String s : toks ) + { + s = s.trim(); + if ( isNotBlank( s ) ) + { + list.add( s ); + } + } + } + ProxyConfig proxyConfig = new ProxyConfig() + { + @Override + public String getHost() + { + return defaultSiteConfig.getProxyHost(); + } + + @Override + public int getPort() + { + return defaultSiteConfig.getProxyPort(); + } + + @Override + public String getUser() + { + return defaultSiteConfig.getProxyUser(); + } + + @Override + public List getAllowHttpJobTypes() + { + return list; + } + }; + globalHttpConfiguration = new GlobalHttpConfiguration( proxyConfig ); + } +} diff --git a/subsys/http/src/main/java/org/commonjava/indy/subsys/http/conf/IndyHttpConfig.java b/subsys/http/src/main/java/org/commonjava/indy/subsys/http/conf/IndyHttpConfig.java index a078fe9553..c5af5a5a30 100644 --- a/subsys/http/src/main/java/org/commonjava/indy/subsys/http/conf/IndyHttpConfig.java +++ b/subsys/http/src/main/java/org/commonjava/indy/subsys/http/conf/IndyHttpConfig.java @@ -58,6 +58,8 @@ public class IndyHttpConfig public static final String PROXY_USER = "proxy.user"; + public static final String PROXY_ALLOW_HTTP_JOB_TYPES = "proxy.allow.http.job.types"; + public static final String TRUST_TYPE = "trust.type"; public static final String KEY_CERT_PEM = "key.cert.pem"; @@ -102,6 +104,7 @@ public void sectionComplete( String name ) throws ConfigurationException case PROXY_HOST: case PROXY_PORT: case PROXY_USER: + case PROXY_ALLOW_HTTP_JOB_TYPES: case TRUST_TYPE: case KEY_CERT_PEM: case KEY_CERT_PEM_PATH: @@ -221,6 +224,9 @@ private void withEntry( SiteConfigBuilder siteConfigBuilder, String realKey, Str case PROXY_USER: siteConfigBuilder.withProxyUser( value ); break; + case PROXY_ALLOW_HTTP_JOB_TYPES: + siteConfigBuilder.withProxyAllowHttpJobTypes( value ); + break; case TRUST_TYPE: siteConfigBuilder.withTrustType( SiteTrustType.getType( value ) ); break; diff --git a/subsys/http/src/main/resources/default-http.conf b/subsys/http/src/main/resources/default-http.conf index 2ae23ce0eb..4bb0981387 100644 --- a/subsys/http/src/main/resources/default-http.conf +++ b/subsys/http/src/main/resources/default-http.conf @@ -11,7 +11,8 @@ ## Proxy settings #proxy.host=http://myproxy.com -#proxy.port=8001 +#proxy.port=3128 +#proxy.allow.http.job.types=download,existence,listing #proxy.user=proxy-user ## Trust type. Value could be either default or self-signed