mirror of https://github.com/apache/archiva.git
PR: MRM-106
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
This commit is contained in:
parent
020cff7729
commit
62df892f19
|
@ -445,7 +445,14 @@ public class DefaultProxyManager
|
||||||
boolean connected = false;
|
boolean connected = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
wagon.connect( repository, repository.getProxy() );
|
if ( repository.isProxied() )
|
||||||
|
{
|
||||||
|
wagon.connect( repository, config.getHttpProxy() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wagon.connect( repository );
|
||||||
|
}
|
||||||
connected = true;
|
connected = true;
|
||||||
}
|
}
|
||||||
catch ( ConnectionException e )
|
catch ( ConnectionException e )
|
||||||
|
|
|
@ -49,8 +49,11 @@ public class MavenProxyConfigurationReader
|
||||||
{
|
{
|
||||||
HttpRepoConfiguration httpRepo = (HttpRepoConfiguration) repoConfig;
|
HttpRepoConfiguration httpRepo = (HttpRepoConfiguration) repoConfig;
|
||||||
MavenProxyConfiguration httpProxy = httpRepo.getProxy();
|
MavenProxyConfiguration httpProxy = httpRepo.getProxy();
|
||||||
repo.setProxy( httpProxy.getHost(), httpProxy.getPort(), httpProxy.getUsername(),
|
//todo put into the configuration the proxy
|
||||||
httpProxy.getPassword() );
|
if ( httpProxy != null )
|
||||||
|
{
|
||||||
|
repo.setProxied( true );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
repoList.add( repo );
|
repoList.add( repo );
|
||||||
|
|
|
@ -17,7 +17,7 @@ package org.apache.maven.repository.proxy.configuration;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.repository.proxy.repository.ProxyRepository;
|
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.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -34,14 +34,14 @@ public class ProxyConfiguration
|
||||||
{
|
{
|
||||||
public static final String ROLE = ProxyConfiguration.class.getName();
|
public static final String ROLE = ProxyConfiguration.class.getName();
|
||||||
|
|
||||||
private PlexusContainer container;
|
|
||||||
|
|
||||||
private List repositories = new ArrayList();
|
private List repositories = new ArrayList();
|
||||||
|
|
||||||
private String cachePath;
|
private String cachePath;
|
||||||
|
|
||||||
private String layout;
|
private String layout;
|
||||||
|
|
||||||
|
private ProxyInfo httpProxy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to set the location where the proxy should cache the configured repositories
|
* Used to set the location where the proxy should cache the configured repositories
|
||||||
*
|
*
|
||||||
|
@ -62,6 +62,41 @@ public class ProxyConfiguration
|
||||||
return cachePath;
|
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.
|
* Used to add proxied repositories.
|
||||||
*
|
*
|
||||||
|
|
|
@ -18,7 +18,6 @@ package org.apache.maven.repository.proxy.repository;
|
||||||
|
|
||||||
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
|
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
|
||||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
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
|
* 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
|
public class ProxyRepository
|
||||||
extends DefaultArtifactRepository
|
extends DefaultArtifactRepository
|
||||||
{
|
{
|
||||||
// zero does not cache
|
// zero caches forever
|
||||||
private long cachePeriod = 0;
|
private long cachePeriod = 0;
|
||||||
|
|
||||||
private boolean cacheFailures = false;
|
private boolean cacheFailures = false;
|
||||||
|
|
||||||
private boolean hardfail = false;
|
private boolean hardfail = false;
|
||||||
|
|
||||||
private ProxyInfo proxy;
|
private boolean proxied = false;
|
||||||
|
|
||||||
public ProxyRepository( String id, String url, ArtifactRepositoryLayout layout, boolean cacheFailures,
|
public ProxyRepository( String id, String url, ArtifactRepositoryLayout layout, boolean cacheFailures,
|
||||||
long cachePeriod )
|
long cachePeriod )
|
||||||
|
@ -75,50 +74,12 @@ public class ProxyRepository
|
||||||
|
|
||||||
public boolean isProxied()
|
public boolean isProxied()
|
||||||
{
|
{
|
||||||
return ( proxy != null );
|
return proxied;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProxyInfo getProxy()
|
public void setProxied( boolean proxied )
|
||||||
{
|
{
|
||||||
return proxy;
|
this.proxied = proxied;
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -61,7 +61,8 @@ public class ProxyConfigurationTest
|
||||||
ProxyRepository repo2 = new ProxyRepository( "repo2", "http://www.ibiblio.org/maven", legacyLayout );
|
ProxyRepository repo2 = new ProxyRepository( "repo2", "http://www.ibiblio.org/maven", legacyLayout );
|
||||||
repo2.setCacheFailures( false );
|
repo2.setCacheFailures( false );
|
||||||
repo2.setCachePeriod( 3600 );
|
repo2.setCachePeriod( 3600 );
|
||||||
repo2.setProxy( "some.local.proxy", 80, "username", "password" );
|
repo2.setProxied( true );
|
||||||
|
config.setHttpProxy( "some.local.proxy", 80, "username", "password" );
|
||||||
config.addRepository( repo2 );
|
config.addRepository( repo2 );
|
||||||
assertEquals( 2, config.getRepositories().size() );
|
assertEquals( 2, config.getRepositories().size() );
|
||||||
|
|
||||||
|
@ -83,7 +84,7 @@ public class ProxyConfigurationTest
|
||||||
assertEquals( repo2, repo );
|
assertEquals( repo2, repo );
|
||||||
assertTrue( repo.isProxied() );
|
assertTrue( repo.isProxied() );
|
||||||
|
|
||||||
ProxyInfo proxyInfo = repo.getProxy();
|
ProxyInfo proxyInfo = config.getHttpProxy();
|
||||||
assertNotNull( proxyInfo );
|
assertNotNull( proxyInfo );
|
||||||
assertEquals( "some.local.proxy", proxyInfo.getHost() );
|
assertEquals( "some.local.proxy", proxyInfo.getHost() );
|
||||||
assertEquals( 80, proxyInfo.getPort() );
|
assertEquals( 80, proxyInfo.getPort() );
|
||||||
|
|
Loading…
Reference in New Issue