Permalink
Browse files

Merge pull request #834 from sonatype/nexus-5214-separate-http-https-…

…proxy

REVIEW: [NEXUS-5214] Make possible to configure separate general (default) HTTP proxies for http and https
  • Loading branch information...
2 parents 850f1ca + 2e05af2 commit 8457c9ccad443f301d9421dc006fa764c618608b @jdillon jdillon committed May 18, 2013
Showing with 2,583 additions and 2,040 deletions.
  1. +4 −3 nexus-client-core/src/main/java/org/sonatype/nexus/client/core/subsystem/ServerConfiguration.java
  2. +15 −5 ...src/main/java/org/sonatype/nexus/client/core/subsystem/config/{HttpProxy.java → RemoteProxy.java}
  3. +10 −7 ...main/java/org/sonatype/nexus/client/internal/rest/jersey/subsystem/JerseyServerConfiguration.java
  4. +26 −22 ...exus/client/internal/rest/jersey/subsystem/config/{JerseyHttpProxy.java → JerseyRemoteProxy.java}
  5. +0 −116 ...est/java/org/sonatype/nexus/client/internal/rest/jersey/subsystem/config/JerseyHttpProxyTest.java
  6. +139 −0 ...t/java/org/sonatype/nexus/client/internal/rest/jersey/subsystem/config/JerseyRemoteProxyTest.java
  7. +4 −2 nexus-configuration-model/pom.xml
  8. +57 −5 nexus-configuration-model/src/main/mdo/nexus.xml
  9. +45 −16 nexus-core/src/main/java/org/sonatype/nexus/apachehttpclient/Hc4ProviderBase.java
  10. +55 −25 ...ype/nexus/apachehttpclient/{NonProxyHostsAwareHttpRoutePlanner.java → NexusHttpRoutePlanner.java}
  11. +0 −285 ...re/src/main/java/org/sonatype/nexus/configuration/application/DefaultGlobalHttpProxySettings.java
  12. +3 −3 nexus-core/src/main/java/org/sonatype/nexus/configuration/application/DefaultNexusConfiguration.java
  13. +271 −0 ...in/java/org/sonatype/nexus/configuration/application/DefaultRemoteProxySettingsConfiguration.java
  14. +9 −8 .../configuration/application/{GlobalHttpProxySettings.java → RemoteProxySettingsConfiguration.java}
  15. +10 −14 ...ts/{GlobalHttpProxySettingsChangedEvent.java → RemoteProxySettingsConfigurationChangedEvent.java}
  16. +6 −6 nexus-core/src/main/java/org/sonatype/nexus/configuration/application/upgrade/Upgrade200to220.java
  17. +115 −0 nexus-core/src/main/java/org/sonatype/nexus/configuration/application/upgrade/Upgrade220to250.java
  18. +20 −12 ...del/{CGlobalHttpProxySettingsCoreConfiguration.java → CRemoteProxySettingsCoreConfiguration.java}
  19. +16 −15 nexus-core/src/main/java/org/sonatype/nexus/configuration/model/DefaultConfigurationHelper.java
  20. +5 −3 ...src/main/java/org/sonatype/nexus/configuration/source/AbstractApplicationConfigurationSource.java
  21. +12 −3 ...ain/java/org/sonatype/nexus/configuration/validator/DefaultApplicationConfigurationValidator.java
  22. +47 −36 nexus-core/src/main/java/org/sonatype/nexus/error/reporting/SetProxyPropertiesInspector.java
  23. +0 −20 nexus-core/src/main/java/org/sonatype/nexus/proxy/repository/AbstractProxyRepository.java
  24. +2 −40 ...s-core/src/main/java/org/sonatype/nexus/proxy/repository/AbstractProxyRepositoryConfigurator.java
  25. +0 −28 nexus-core/src/main/java/org/sonatype/nexus/proxy/repository/DefaultProxySelector.java
  26. +67 −0 nexus-core/src/main/java/org/sonatype/nexus/proxy/repository/DefaultRemoteHttpProxySettings.java
  27. +22 −42 nexus-core/src/main/java/org/sonatype/nexus/proxy/repository/DefaultRemoteProxySettings.java
  28. +0 −26 nexus-core/src/main/java/org/sonatype/nexus/proxy/repository/ProxyRepository.java
  29. +0 −18 nexus-core/src/main/java/org/sonatype/nexus/proxy/repository/ProxySelector.java
  30. +58 −0 nexus-core/src/main/java/org/sonatype/nexus/proxy/repository/RemoteHttpProxySettings.java
  31. +34 −17 nexus-core/src/main/java/org/sonatype/nexus/proxy/repository/RemoteProxySettings.java
  32. +1 −38 nexus-core/src/main/java/org/sonatype/nexus/proxy/storage/remote/DefaultRemoteStorageContext.java
  33. +2 −1 nexus-core/src/main/java/org/sonatype/nexus/proxy/storage/remote/RemoteStorageContext.java
  34. +72 −65 .../src/main/java/org/sonatype/nexus/proxy/storage/remote/commonshttpclient/HttpClientProxyUtil.java
  35. +1 −1 nexus-core/src/test/filtered-resources/META-INF/nexus/nexus.xml
  36. +1 −1 ...sources → filtered-resources}/org/sonatype/nexus/configuration/upgrade/103-1/nexus-103.xml.result
  37. +1 −1 ...sources → filtered-resources}/org/sonatype/nexus/configuration/upgrade/103-2/nexus-103.xml.result
  38. +7 −5 .../{resources → filtered-resources}/org/sonatype/nexus/configuration/upgrade/nexus-001-1.xml.result
  39. +11 −9 .../{resources → filtered-resources}/org/sonatype/nexus/configuration/upgrade/nexus-001-2.xml.result
  40. +7 −5 .../{resources → filtered-resources}/org/sonatype/nexus/configuration/upgrade/nexus-001-3.xml.result
  41. +7 −5 ...st/{resources → filtered-resources}/org/sonatype/nexus/configuration/upgrade/nexus-100.xml.result
  42. +1 −1 ...st/{resources → filtered-resources}/org/sonatype/nexus/configuration/upgrade/nexus-101.xml.result
  43. +1 −1 ...st/{resources → filtered-resources}/org/sonatype/nexus/configuration/upgrade/nexus-104.xml.result
  44. +1 −1 ...st/{resources → filtered-resources}/org/sonatype/nexus/configuration/upgrade/nexus-105.xml.result
  45. +1 −1 ... → filtered-resources}/org/sonatype/nexus/configuration/upgrade/nexus-108-with-mirrors.xml.result
  46. +1 −1 ...st/{resources → filtered-resources}/org/sonatype/nexus/configuration/upgrade/nexus-108.xml.result
  47. +1 −1 ...st/{resources → filtered-resources}/org/sonatype/nexus/configuration/upgrade/nexus-142.xml.result
  48. +1 −1 ...st/{resources → filtered-resources}/org/sonatype/nexus/configuration/upgrade/nexus-143.xml.result
  49. +164 −0 nexus-core/src/test/filtered-resources/org/sonatype/nexus/configuration/upgrade/nexus-220.xml.result
  50. +1 −1 ...sources → filtered-resources}/org/sonatype/nexus/configuration/upgrade/nexus1710/nexus.xml.result
  51. +25 −14 nexus-core/src/test/java/org/sonatype/nexus/configuration/ClearPasswordTest.java
  52. +42 −17 ...ore/src/test/java/org/sonatype/nexus/configuration/application/DefaultNexusConfigurationTest.java
  53. +18 −12 ...tion/{DefaultGlobalHttpProxySettingsTest.java → DefaultRemoteProxySettingsConfigurationTest.java}
  54. +42 −26 ...sonatype/nexus/configuration/application/upgrade/DefaultApplicationConfigurationUpgraderTest.java
  55. +52 −29 nexus-core/src/test/java/org/sonatype/nexus/error/reporting/SetProxyPropertiesInspectorTest.java
  56. +29 −12 nexus-core/src/test/java/org/sonatype/nexus/proxy/NonProxyHostsTest.java
  57. +7 −21 nexus-core/src/test/java/org/sonatype/nexus/proxy/RemoteStorageSettingsInheritanceTest.java
  58. +1 −9 ...re/src/test/java/org/sonatype/nexus/proxy/repository/AbstractProxyRepositoryConfiguratorTest.java
  59. +6 −31 .../test/java/org/sonatype/nexus/proxy/storage/remote/commonshttpclient/HttpClientProxyUtilTest.java
  60. +1 −0 ...-core/src/test/java/org/sonatype/nexus/proxy/storage/remote/httpclient/HttpClientManagerTest.java
  61. +166 −0 nexus-core/src/test/resources/org/sonatype/nexus/configuration/upgrade/nexus-220.xml
  62. +1 −1 nexus-oss-edition/src/main/filtered-resources/META-INF/nexus/nexus.xml
  63. +1 −0 nexus-test/nexus-core-testsuite/src/test/filtered-resources/logback-test.xml
  64. BIN nexus-test/nexus-core-testsuite/src/test/it-resources/trustStore
  65. +320 −0 nexus-test/nexus-core-testsuite/src/test/java/core/webproxy/HttpAndHttpsProxyIT.java
  66. +89 −0 nexus-test/nexus-core-testsuite/src/test/java/core/webproxy/ProxyServerWithHttpsTunneling.java
  67. +0 −18 nexus-test/nexus-test-harness-its/resources/nexus1146/files/pom.xml
  68. +0 −172 nexus-test/nexus-test-harness-its/resources/nexus1146/test-config/nexus.xml
  69. +0 −18 nexus-test/nexus-test-harness-its/resources/nexus1155/files/pom.xml
  70. +0 −176 nexus-test/nexus-test-harness-its/resources/nexus1155/test-config/nexus.xml
  71. +27 −23 ...ness-its/src/test/java/org/sonatype/nexus/integrationtests/nexus1506/Nexus1506NonProxyHostIT.java
  72. +0 −96 ...t/java/org/sonatype/nexus/integrationtests/webproxy/nexus1146/Nexus1146RepositoryOverProxyIT.java
  73. +0 −43 ...e/nexus/integrationtests/webproxy/nexus1155/Nexus1155RepositoryOverProxyWithAuthenticationIT.java
  74. +18 −8 ...in/src/test/java/org/sonatype/nexus/plugins/lvo/strategy/AbstractRemoteDiscoveryStrategyTest.java
  75. +140 −16 plugins/nexus-ui-extjs3-plugin/src/main/resources/static/js/Sonatype/repoServer/ServerEditPanel.js
  76. +22 −20 plugins/nexus-ui-extjs3-plugin/src/main/resources/static/js/Sonatype/repoServer/referenceData.js
  77. +1 −95 plugins/nexus-ui-extjs3-plugin/src/main/resources/static/js/repoServer/RepoEditPanel.js
  78. +45 −24 plugins/restlet1x/nexus-restlet1x-model/src/main/mdo/vos.xml
  79. +95 −21 ...lugin/src/main/java/org/sonatype/nexus/rest/global/AbstractGlobalConfigurationPlexusResource.java
  80. +74 −74 ...tlet1x-plugin/src/main/java/org/sonatype/nexus/rest/global/GlobalConfigurationPlexusResource.java
  81. +0 −35 ...x-plugin/src/main/java/org/sonatype/nexus/rest/repositories/AbstractRepositoryPlexusResource.java
  82. +0 −4 ...let1x-plugin/src/main/java/org/sonatype/nexus/rest/repositories/RepositoryListPlexusResource.java
  83. +0 −26 ...restlet1x-plugin/src/main/java/org/sonatype/nexus/rest/repositories/RepositoryPlexusResource.java
  84. +26 −24 ...1x/nexus-restlet1x-plugin/src/test/java/org/sonatype/nexus/client/model/TestMarshalUnmarchal.java
  85. +0 −59 ...stlet1x-plugin/src/test/java/org/sonatype/nexus/rest/repositories/RepositoryCreateUpdateTest.java
  86. +1 −0 pom.xml
@@ -12,7 +12,7 @@
*/
package org.sonatype.nexus.client.core.subsystem;
-import org.sonatype.nexus.client.core.subsystem.config.HttpProxy;
+import org.sonatype.nexus.client.core.subsystem.config.RemoteProxy;
/**
* Server configuration subsystem.
@@ -23,8 +23,9 @@
{
/**
- * @return Http Proxy configuration segment.
+ * @return Remote Proxy configuration segment.
+ * @since 2.5
*/
- HttpProxy proxySettings();
+ RemoteProxy remoteProxySettings();
}
@@ -12,15 +12,25 @@
*/
package org.sonatype.nexus.client.core.subsystem.config;
-import org.sonatype.nexus.rest.model.RemoteHttpProxySettings;
+import org.sonatype.nexus.rest.model.RemoteProxySettingsDTO;
/**
- * Http Proxy configuration segment.
+ * Remote Proxy configuration segment.
*
- * @since 2.2
+ * @since 2.5
*/
-public interface HttpProxy
- extends OptionalSegment<HttpProxy, RemoteHttpProxySettings>
+public interface RemoteProxy
+ extends Segment<RemoteProxy, RemoteProxySettingsDTO>
{
+ /**
+ * Disables http proxy.
+ */
+ RemoteProxy disableHttpProxy();
+
+ /**
+ * Disables https proxy.
+ */
+ RemoteProxy disableHttpsProxy();
+
}
@@ -14,8 +14,8 @@
import org.sonatype.nexus.client.core.spi.SubsystemSupport;
import org.sonatype.nexus.client.core.subsystem.ServerConfiguration;
-import org.sonatype.nexus.client.core.subsystem.config.HttpProxy;
-import org.sonatype.nexus.client.internal.rest.jersey.subsystem.config.JerseyHttpProxy;
+import org.sonatype.nexus.client.core.subsystem.config.RemoteProxy;
+import org.sonatype.nexus.client.internal.rest.jersey.subsystem.config.JerseyRemoteProxy;
import org.sonatype.nexus.client.rest.jersey.JerseyNexusClient;
/**
@@ -30,21 +30,24 @@
* Http Proxy configuration segment.
* Lazy initialized on first request.
*/
- private HttpProxy httpProxy;
+ private RemoteProxy remoteProxy;
public JerseyServerConfiguration( final JerseyNexusClient nexusClient )
{
super( nexusClient );
}
+ /**
+ * @since 2.5
+ */
@Override
- public HttpProxy proxySettings()
+ public RemoteProxy remoteProxySettings()
{
- if ( httpProxy == null )
+ if ( remoteProxy == null )
{
- httpProxy = new JerseyHttpProxy( getNexusClient() );
+ remoteProxy = new JerseyRemoteProxy( getNexusClient() );
}
- return httpProxy;
+ return remoteProxy;
}
}
@@ -12,51 +12,55 @@
*/
package org.sonatype.nexus.client.internal.rest.jersey.subsystem.config;
-import org.sonatype.nexus.client.core.subsystem.config.HttpProxy;
+import org.sonatype.nexus.client.core.subsystem.config.RemoteProxy;
import org.sonatype.nexus.client.rest.jersey.JerseyNexusClient;
import org.sonatype.nexus.rest.model.GlobalConfigurationResource;
-import org.sonatype.nexus.rest.model.RemoteHttpProxySettings;
+import org.sonatype.nexus.rest.model.RemoteProxySettingsDTO;
-public class JerseyHttpProxy
- extends JerseyOptionalSegmentSupport<HttpProxy, RemoteHttpProxySettings>
- implements HttpProxy
+/**
+ * @since 2.5
+ */
+public class JerseyRemoteProxy
+ extends JerseySegmentSupport<RemoteProxy, RemoteProxySettingsDTO>
+ implements RemoteProxy
{
- public JerseyHttpProxy( final JerseyNexusClient nexusClient )
+ public JerseyRemoteProxy( final JerseyNexusClient nexusClient )
{
super( nexusClient );
}
@Override
- protected void onDisable( final RemoteHttpProxySettings settings )
+ protected RemoteProxySettingsDTO getSettingsFrom( final GlobalConfigurationResource configuration )
{
- settings.setProxyHostname( null );
+ return configuration.getRemoteProxySettings();
}
@Override
- protected RemoteHttpProxySettings getSettingsFrom( final GlobalConfigurationResource configuration )
+ protected void setSettingsIn( final RemoteProxySettingsDTO settings,
+ final GlobalConfigurationResource configuration )
{
- return configuration.getGlobalHttpProxySettings();
+ configuration.setRemoteProxySettings( settings );
}
@Override
- protected void setSettingsIn( final RemoteHttpProxySettings settings,
- final GlobalConfigurationResource configuration )
+ protected RemoteProxySettingsDTO createSettings()
+ {
+ return new RemoteProxySettingsDTO();
+ }
+
+ @Override
+ public RemoteProxy disableHttpProxy()
{
- if ( settings.getProxyHostname() == null )
- {
- configuration.setGlobalHttpProxySettings( null );
- }
- else
- {
- configuration.setGlobalHttpProxySettings( settings );
- }
+ settings().setHttpProxySettings( null );
+ return me();
}
@Override
- protected RemoteHttpProxySettings createSettings()
+ public RemoteProxy disableHttpsProxy()
{
- return new RemoteHttpProxySettings();
+ settings().setHttpsProxySettings( null );
+ return me();
}
}
@@ -1,116 +0,0 @@
-/*
- * Sonatype Nexus (TM) Open Source Version
- * Copyright (c) 2007-2013 Sonatype, Inc.
- * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
- *
- * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
- * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
- * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
- * Eclipse Foundation. All other trademarks are the property of their respective owners.
- */
-package org.sonatype.nexus.client.internal.rest.jersey.subsystem.config;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.hamcrest.Matchers.nullValue;
-import static org.mockito.Mockito.mock;
-
-import org.junit.Test;
-import org.sonatype.nexus.client.core.subsystem.config.HttpProxy;
-import org.sonatype.nexus.client.rest.jersey.JerseyNexusClient;
-import org.sonatype.nexus.rest.model.GlobalConfigurationResource;
-import org.sonatype.nexus.rest.model.RemoteHttpProxySettings;
-import org.sonatype.sisu.litmus.testsupport.TestSupport;
-
-public class JerseyHttpProxyTest
- extends TestSupport
-{
-
- private GlobalConfigurationResource configuration = new GlobalConfigurationResource();
-
- @Test
- public void noSettings()
- {
- final HttpProxy underTest = createJerseyHttpProxy();
- final RemoteHttpProxySettings settings = underTest.settings();
-
- assertThat( settings, is( notNullValue() ) );
-
- settings.setProxyHostname( "bar" );
- underTest.save();
-
- assertThat( configuration.getGlobalHttpProxySettings(), is( notNullValue() ) );
- assertThat( configuration.getGlobalHttpProxySettings().getProxyHostname(), is( "bar" ) );
- }
-
- @Test
- public void existingSettings()
- {
- final RemoteHttpProxySettings configSettings = new RemoteHttpProxySettings();
- configSettings.setProxyHostname( "foo" );
- configuration.setGlobalHttpProxySettings( configSettings );
-
- final HttpProxy underTest = createJerseyHttpProxy();
- final RemoteHttpProxySettings settings = underTest.settings();
-
- assertThat( settings, is( notNullValue() ) );
- assertThat( settings.getProxyHostname(), is( "foo" ) );
-
- settings.setProxyHostname( "bar" );
- underTest.save();
-
- assertThat( configuration.getGlobalHttpProxySettings(), is( notNullValue() ) );
- assertThat( configuration.getGlobalHttpProxySettings().getProxyHostname(), is( "bar" ) );
- }
-
- @Test
- public void reset()
- {
- final HttpProxy underTest = createJerseyHttpProxy();
- final RemoteHttpProxySettings settings = underTest.settings();
-
- assertThat( settings, is( notNullValue() ) );
-
- settings.setProxyHostname( "bar" );
- underTest.refresh();
-
- assertThat( settings.getProxyHostname(), is( nullValue() ) );
- }
-
- @Test
- public void disable()
- {
- final RemoteHttpProxySettings configSettings = new RemoteHttpProxySettings();
- configSettings.setProxyHostname( "foo" );
- configuration.setGlobalHttpProxySettings( configSettings );
-
- final HttpProxy underTest = createJerseyHttpProxy();
-
- underTest.disable();
-
- assertThat( configuration.getGlobalHttpProxySettings(), is( nullValue() ) );
- }
-
- private JerseyHttpProxy createJerseyHttpProxy()
- {
- return new JerseyHttpProxy( mock( JerseyNexusClient.class ) )
- {
- @Override
- GlobalConfigurationResource getConfiguration()
- {
- return configuration;
- }
-
- @Override
- void setConfiguration( final GlobalConfigurationResource configuration )
- {
- // do nothing
- }
-
- };
- }
-
-}
Oops, something went wrong.

0 comments on commit 8457c9c

Please sign in to comment.