mirror of https://github.com/apache/archiva.git
PR: MRM-96
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
This commit is contained in:
parent
4ad366c501
commit
136af3e214
|
@ -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 )
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
|||
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
|
||||
import org.apache.maven.artifact.repository.layout.LegacyRepositoryLayout;
|
||||
import org.apache.maven.repository.proxy.repository.ProxyRepository;
|
||||
import org.apache.maven.wagon.proxy.ProxyInfo;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
|
||||
|
@ -72,6 +73,7 @@ public class ProxyConfigurationTest
|
|||
ProxyRepository repo2 = new ProxyRepository( "repo2", "http://www.ibiblio.org/maven", legacyLayout );
|
||||
repo2.setCacheFailures( false );
|
||||
repo2.setCachePeriod( 3600 );
|
||||
repo2.setProxy( "some.local.proxy", 80, "username", "password" );
|
||||
config.addRepository( repo2 );
|
||||
assertEquals( 2, config.getRepositories().size() );
|
||||
|
||||
|
@ -89,6 +91,13 @@ public class ProxyConfigurationTest
|
|||
assertFalse( repo.isCacheFailures() );
|
||||
assertEquals( 3600, repo.getCachePeriod() );
|
||||
assertEquals( repo2, repo );
|
||||
assertTrue( repo.isProxied() );
|
||||
ProxyInfo proxyInfo = repo.getProxy();
|
||||
assertNotNull( proxyInfo );
|
||||
assertEquals( "some.local.proxy", proxyInfo.getHost() );
|
||||
assertEquals( 80, proxyInfo.getPort() );
|
||||
assertEquals( "username", proxyInfo.getUserName() );
|
||||
assertEquals( "password", proxyInfo.getPassword() );
|
||||
|
||||
try
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue