]> source.dussan.org Git - archiva.git/commitdiff
PR: MRM-96
authorEdwin L. Punzalan <epunzalan@apache.org>
Fri, 17 Feb 2006 07:19:44 +0000 (07:19 +0000)
committerEdwin L. Punzalan <epunzalan@apache.org>
Fri, 17 Feb 2006 07:19:44 +0000 (07:19 +0000)
Enabled use of proxy and added import of proxy configuration from maven-proxy configuration file.

git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@378453 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/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 bfd670179d67b7fa665deba6b508b599bbebbadb..bd8ceee7d5178715c0310102db66eb0de3ffdfa7 100644 (file)
@@ -287,7 +287,7 @@ public class DefaultProxyManager
             }
             catch ( ResourceDoesNotExistException e )
             {
-                //@todo usage for cacheFailure 
+                //@todo usage for cacheFailure
                 //do nothing, file not found in this repository
             }
             catch ( AuthorizationException e )
@@ -369,7 +369,7 @@ public class DefaultProxyManager
         boolean connected = false;
         try
         {
-            wagon.connect( repository );
+            wagon.connect( repository, repository.getProxy() );
             connected = true;
         }
         catch ( ConnectionException e )
index 6593815977368871154b896cded7e39c3b7642d4..d36fa4961bf1afbee15747ec5cb08fedcbc9725e 100644 (file)
@@ -171,6 +171,14 @@ public class ProxyConfiguration
                 repo.setCacheFailures( repoConfig.getCacheFailures() );
                 repo.setCachePeriod( repoConfig.getCachePeriod() );
 
+                if ( repoConfig instanceof HttpRepoConfiguration )
+                {
+                    HttpRepoConfiguration httpRepo = (HttpRepoConfiguration) repoConfig;
+                    MavenProxyConfiguration httpProxy = httpRepo.getProxy();
+                    repo.setProxy( httpProxy.getHost(), httpProxy.getPort(),
+                                   httpProxy.getUsername(), httpProxy.getPassword() );
+                }
+
                 repoList.add( repo );
             }
         }
index efbe6b3d4eca7fcfe5654c5bc3ee25c0a91c56b8..3cf2e09787a1475dcbfb5478a879490c4ed0e5e8 100644 (file)
@@ -18,6 +18,7 @@ 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
@@ -33,6 +34,8 @@ public class ProxyRepository
 
     private boolean cacheFailures = false;
 
+    private ProxyInfo proxy;
+
     public ProxyRepository( String id, String url, ArtifactRepositoryLayout layout, boolean cacheFailures,
                             long cachePeriod )
     {
@@ -67,4 +70,52 @@ public class ProxyRepository
     {
         this.cacheFailures = cacheFailures;
     }
+
+    public boolean isProxied()
+    {
+        return ( proxy != null );
+    }
+
+    public ProxyInfo getProxy()
+    {
+        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;
+    }
 }
index 08b1f086fbe4f0bd350af0672e353556b149678d..0b6aafa78ecc54a215558864b627fcb4fffe3043 100644 (file)
@@ -21,6 +21,7 @@ import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
 import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;\r
 import org.apache.maven.artifact.repository.layout.LegacyRepositoryLayout;\r
 import org.apache.maven.repository.proxy.repository.ProxyRepository;\r
+import org.apache.maven.wagon.proxy.ProxyInfo;\r
 import org.codehaus.plexus.PlexusTestCase;\r
 import org.codehaus.plexus.util.FileUtils;\r
 \r
@@ -72,6 +73,7 @@ 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
         config.addRepository( repo2 );\r
         assertEquals( 2, config.getRepositories().size() );\r
 \r
@@ -89,6 +91,13 @@ public class ProxyConfigurationTest
         assertFalse( repo.isCacheFailures() );\r
         assertEquals( 3600, repo.getCachePeriod() );\r
         assertEquals( repo2, repo );\r
+        assertTrue( repo.isProxied() );\r
+        ProxyInfo proxyInfo = repo.getProxy();\r
+        assertNotNull( proxyInfo );\r
+        assertEquals( "some.local.proxy", proxyInfo.getHost() );\r
+        assertEquals( 80, proxyInfo.getPort() );\r
+        assertEquals( "username", proxyInfo.getUserName() );\r
+        assertEquals( "password", proxyInfo.getPassword() );\r
 \r
         try\r
         {\r