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:
Edwin L. Punzalan 2006-03-14 13:10:16 +00:00
parent 020cff7729
commit 62df892f19
5 changed files with 59 additions and 52 deletions

View 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 )

View 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 );

View 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.
*

View 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;
}
/**

View File

@ -61,7 +61,8 @@ 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" );
repo2.setProxied( true );
config.setHttpProxy( "some.local.proxy", 80, "username", "password" );
config.addRepository( repo2 );
assertEquals( 2, config.getRepositories().size() );
@ -83,7 +84,7 @@ public class ProxyConfigurationTest
assertEquals( repo2, repo );
assertTrue( repo.isProxied() );
ProxyInfo proxyInfo = repo.getProxy();
ProxyInfo proxyInfo = config.getHttpProxy();
assertNotNull( proxyInfo );
assertEquals( "some.local.proxy", proxyInfo.getHost() );
assertEquals( 80, proxyInfo.getPort() );