]> source.dussan.org Git - archiva.git/commitdiff
PR: MRM-106
authorEdwin L. Punzalan <epunzalan@apache.org>
Tue, 14 Mar 2006 13:10:16 +0000 (13:10 +0000)
committerEdwin L. Punzalan <epunzalan@apache.org>
Tue, 14 Mar 2006 13:10:16 +0000 (13:10 +0000)
Allowed only http proxy configuration and setup ProxyRepository if proxied or not

git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@385795 13f79535-47bb-0310-9956-ffa450edef68

maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/DefaultProxyManager.java
maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/MavenProxyConfigurationReader.java
maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/ProxyConfiguration.java
maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/repository/ProxyRepository.java
maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/configuration/ProxyConfigurationTest.java

index cfec8ce463c2fa9b187de29739bd2a635aebfb37..bad33befba265fce91ae9d166baff5287b20ab88 100644 (file)
@@ -445,7 +445,14 @@ public class DefaultProxyManager
         boolean connected = false;
         try
         {
-            wagon.connect( repository, repository.getProxy() );
+            if ( repository.isProxied() )
+            {
+                wagon.connect( repository, config.getHttpProxy() );
+            }
+            else
+            {
+                wagon.connect( repository );
+            }
             connected = true;
         }
         catch ( ConnectionException e )
index 8b9d447bfd070787db72c8a8ae5355ecc8300c6b..d5831bb68125321e5f3e75115e7a04c903f7fa3e 100644 (file)
@@ -49,8 +49,11 @@ public class MavenProxyConfigurationReader
                 {
                     HttpRepoConfiguration httpRepo = (HttpRepoConfiguration) repoConfig;
                     MavenProxyConfiguration httpProxy = httpRepo.getProxy();
-                    repo.setProxy( httpProxy.getHost(), httpProxy.getPort(), httpProxy.getUsername(),
-                                   httpProxy.getPassword() );
+                    //todo put into the configuration the proxy
+                    if ( httpProxy != null )
+                    {
+                        repo.setProxied( true );
+                    }
                 }
 
                 repoList.add( repo );
index 37bc31e6cd104fd7de313a246e2fcef091ea0eae..3ec4e1c2c0285bfe0b2e4a328e7a361ab3657800 100644 (file)
@@ -17,7 +17,7 @@ package org.apache.maven.repository.proxy.configuration;
  */
 
 import org.apache.maven.repository.proxy.repository.ProxyRepository;
-import org.codehaus.plexus.PlexusContainer;
+import org.apache.maven.wagon.proxy.ProxyInfo;
 
 import java.io.File;
 import java.util.ArrayList;
@@ -34,14 +34,14 @@ public class ProxyConfiguration
 {
     public static final String ROLE = ProxyConfiguration.class.getName();
 
-    private PlexusContainer container;
-
     private List repositories = new ArrayList();
 
     private String cachePath;
 
     private String layout;
 
+    private ProxyInfo httpProxy;
+
     /**
      * Used to set the location where the proxy should cache the configured repositories
      *
@@ -62,6 +62,41 @@ public class ProxyConfiguration
         return cachePath;
     }
 
+    public void setHttpProxy( ProxyInfo httpProxy )
+    {
+        this.httpProxy = httpProxy;
+    }
+
+    public void setHttpProxy( String host, int port )
+    {
+        ProxyInfo proxyInfo = new ProxyInfo();
+        proxyInfo.setHost( host );
+        proxyInfo.setPort( port );
+
+        setHttpProxy( proxyInfo );
+    }
+
+    public void setHttpProxy( String host, int port, String username, String password )
+    {
+        setHttpProxy( host, port );
+        httpProxy.setUserName( username );
+        httpProxy.setPassword( password );
+    }
+
+    public void setHttpProxy( String host, int port, String username, String password, String ntlmHost, String ntlmDomain )
+    {
+        setHttpProxy( host, port );
+        httpProxy.setUserName( username );
+        httpProxy.setPassword( password );
+        httpProxy.setNtlmHost( ntlmHost );
+        httpProxy.setNtlmDomain( ntlmDomain );
+    }
+
+    public ProxyInfo getHttpProxy()
+    {
+        return httpProxy;
+    }
+
     /**
      * Used to add proxied repositories.
      *
index 8e5a2e82405a5b85fa3cf87473d972a1f2ecb24d..37fd2110cce1cc35aad99728e265af96d9bdd5e2 100644 (file)
@@ -18,7 +18,6 @@ package org.apache.maven.repository.proxy.repository;
 
 import org.apache.maven.artifact.repository.DefaultArtifactRepository;
 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
-import org.apache.maven.wagon.proxy.ProxyInfo;
 
 /**
  * Class to represent the Proxy repository.  Currently does not provide additional methods from
@@ -29,14 +28,14 @@ import org.apache.maven.wagon.proxy.ProxyInfo;
 public class ProxyRepository
     extends DefaultArtifactRepository
 {
-    // zero does not cache
+    // zero caches forever
     private long cachePeriod = 0;
 
     private boolean cacheFailures = false;
 
     private boolean hardfail = false;
 
-    private ProxyInfo proxy;
+    private boolean proxied = false;
 
     public ProxyRepository( String id, String url, ArtifactRepositoryLayout layout, boolean cacheFailures,
                             long cachePeriod )
@@ -75,50 +74,12 @@ public class ProxyRepository
 
     public boolean isProxied()
     {
-        return ( proxy != null );
+        return proxied;
     }
 
-    public ProxyInfo getProxy()
+    public void setProxied( boolean proxied )
     {
-        return proxy;
-    }
-
-    public void setProxy( String host, int port )
-    {
-        ProxyInfo proxyInfo = new ProxyInfo();
-        proxyInfo.setHost( host );
-        proxyInfo.setPort( port );
-
-        setProxy( proxyInfo );
-    }
-
-    public void setProxy( String host, int port, String username, String password )
-    {
-        ProxyInfo proxyInfo = new ProxyInfo();
-        proxyInfo.setHost( host );
-        proxyInfo.setPort( port );
-        proxyInfo.setUserName( username );
-        proxyInfo.setPassword( password );
-
-        setProxy( proxyInfo );
-    }
-
-    public void setProxy( String host, int port, String username, String password, String ntlmHost, String ntlmDomain )
-    {
-        ProxyInfo proxyInfo = new ProxyInfo();
-        proxyInfo.setHost( host );
-        proxyInfo.setPort( port );
-        proxyInfo.setUserName( username );
-        proxyInfo.setPassword( password );
-        proxyInfo.setNtlmHost( ntlmHost );
-        proxyInfo.setNtlmDomain( ntlmDomain );
-
-        setProxy( proxyInfo );
-    }
-
-    public void setProxy( ProxyInfo proxy )
-    {
-        this.proxy = proxy;
+        this.proxied = proxied;
     }
 
     /**
index dd499ea4fd38c98ed1c19622a0c2b22acc61e552..6fa469369852f3b5051a86bfa7d19df19229077e 100644 (file)
@@ -61,7 +61,8 @@ public class ProxyConfigurationTest
         ProxyRepository repo2 = new ProxyRepository( "repo2", "http://www.ibiblio.org/maven", legacyLayout );\r
         repo2.setCacheFailures( false );\r
         repo2.setCachePeriod( 3600 );\r
-        repo2.setProxy( "some.local.proxy", 80, "username", "password" );\r
+        repo2.setProxied( true );\r
+        config.setHttpProxy( "some.local.proxy", 80, "username", "password" );\r
         config.addRepository( repo2 );\r
         assertEquals( 2, config.getRepositories().size() );\r
 \r
@@ -83,7 +84,7 @@ public class ProxyConfigurationTest
         assertEquals( repo2, repo );\r
         assertTrue( repo.isProxied() );\r
 \r
-        ProxyInfo proxyInfo = repo.getProxy();\r
+        ProxyInfo proxyInfo = config.getHttpProxy();\r
         assertNotNull( proxyInfo );\r
         assertEquals( "some.local.proxy", proxyInfo.getHost() );\r
         assertEquals( 80, proxyInfo.getPort() );\r