o Accounted for refactoring of aether-api

This commit is contained in:
Benjamin Bentmann 2012-09-17 00:05:23 +02:00
parent 03b0269579
commit 2838745156
3 changed files with 36 additions and 20 deletions

View File

@ -74,6 +74,7 @@ import org.codehaus.plexus.component.repository.exception.ComponentLookupExcepti
import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.StringUtils;
import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.repository.AuthenticationContext;
import org.eclipse.aether.repository.AuthenticationSelector; import org.eclipse.aether.repository.AuthenticationSelector;
import org.eclipse.aether.repository.ProxySelector; import org.eclipse.aether.repository.ProxySelector;
import org.eclipse.aether.repository.RemoteRepository; import org.eclipse.aether.repository.RemoteRepository;
@ -583,13 +584,17 @@ public class LegacyRepositorySystem
AuthenticationSelector selector = session.getAuthenticationSelector(); AuthenticationSelector selector = session.getAuthenticationSelector();
if ( selector != null ) if ( selector != null )
{ {
org.eclipse.aether.repository.Authentication auth = RemoteRepository repo = RepositoryUtils.toRepo( repository );
selector.getAuthentication( RepositoryUtils.toRepo( repository ) ); org.eclipse.aether.repository.Authentication auth = selector.getAuthentication( repo );
if ( auth != null ) if ( auth != null )
{ {
Authentication result = new Authentication( auth.getUsername(), auth.getPassword() ); AuthenticationContext authCtx = AuthenticationContext.forRepository( session, repo );
result.setPrivateKey( auth.getPrivateKeyFile() ); Authentication result =
result.setPassphrase( auth.getPassphrase() ); new Authentication( authCtx.get( AuthenticationContext.USERNAME ),
authCtx.get( AuthenticationContext.PASSWORD ) );
result.setPrivateKey( authCtx.get( AuthenticationContext.PRIVATE_KEY_PATH ) );
result.setPassphrase( authCtx.get( AuthenticationContext.PRIVATE_KEY_PASSPHRASE ) );
authCtx.close();
return result; return result;
} }
} }
@ -688,7 +693,8 @@ public class LegacyRepositorySystem
ProxySelector selector = session.getProxySelector(); ProxySelector selector = session.getProxySelector();
if ( selector != null ) if ( selector != null )
{ {
org.eclipse.aether.repository.Proxy proxy = selector.getProxy( RepositoryUtils.toRepo( repository ) ); RemoteRepository repo = RepositoryUtils.toRepo( repository );
org.eclipse.aether.repository.Proxy proxy = selector.getProxy( repo );
if ( proxy != null ) if ( proxy != null )
{ {
Proxy p = new Proxy(); Proxy p = new Proxy();
@ -697,8 +703,12 @@ public class LegacyRepositorySystem
p.setPort( proxy.getPort() ); p.setPort( proxy.getPort() );
if ( proxy.getAuthentication() != null ) if ( proxy.getAuthentication() != null )
{ {
p.setUserName( proxy.getAuthentication().getUsername() ); AuthenticationContext authCtx = AuthenticationContext.forProxy( session, repo );
p.setPassword( proxy.getAuthentication().getPassword() ); p.setUserName( authCtx.get( AuthenticationContext.USERNAME ) );
p.setPassword( authCtx.get( AuthenticationContext.PASSWORD ) );
p.setNtlmDomain( authCtx.get( AuthenticationContext.NTLM_DOMAIN ) );
p.setNtlmHost( authCtx.get( AuthenticationContext.NTLM_WORKSTATION ) );
authCtx.close();
} }
return p; return p;
} }

View File

@ -83,7 +83,6 @@ import org.eclipse.aether.collection.DependencyGraphTransformer;
import org.eclipse.aether.collection.DependencyManager; import org.eclipse.aether.collection.DependencyManager;
import org.eclipse.aether.collection.DependencySelector; import org.eclipse.aether.collection.DependencySelector;
import org.eclipse.aether.collection.DependencyTraverser; import org.eclipse.aether.collection.DependencyTraverser;
import org.eclipse.aether.repository.Authentication;
import org.eclipse.aether.repository.LocalRepository; import org.eclipse.aether.repository.LocalRepository;
import org.eclipse.aether.repository.RepositoryPolicy; import org.eclipse.aether.repository.RepositoryPolicy;
import org.eclipse.aether.repository.WorkspaceReader; import org.eclipse.aether.repository.WorkspaceReader;
@ -99,6 +98,7 @@ import org.eclipse.aether.util.graph.transformer.ConflictMarker;
import org.eclipse.aether.util.graph.transformer.JavaDependencyContextRefiner; import org.eclipse.aether.util.graph.transformer.JavaDependencyContextRefiner;
import org.eclipse.aether.util.graph.transformer.JavaEffectiveScopeCalculator; import org.eclipse.aether.util.graph.transformer.JavaEffectiveScopeCalculator;
import org.eclipse.aether.util.graph.traverser.FatArtifactTraverser; import org.eclipse.aether.util.graph.traverser.FatArtifactTraverser;
import org.eclipse.aether.util.repository.AuthenticationBuilder;
import org.eclipse.aether.util.repository.ChainedWorkspaceReader; import org.eclipse.aether.util.repository.ChainedWorkspaceReader;
import org.eclipse.aether.util.repository.DefaultAuthenticationSelector; import org.eclipse.aether.util.repository.DefaultAuthenticationSelector;
import org.eclipse.aether.util.repository.DefaultMirrorSelector; import org.eclipse.aether.util.repository.DefaultMirrorSelector;
@ -407,19 +407,21 @@ public class DefaultMaven
DefaultProxySelector proxySelector = new DefaultProxySelector(); DefaultProxySelector proxySelector = new DefaultProxySelector();
for ( Proxy proxy : decrypted.getProxies() ) for ( Proxy proxy : decrypted.getProxies() )
{ {
Authentication proxyAuth = new Authentication( proxy.getUsername(), proxy.getPassword() ); AuthenticationBuilder authBuilder = new AuthenticationBuilder();
proxySelector.add( new org.eclipse.aether.repository.Proxy( proxy.getProtocol(), proxy.getHost(), proxy.getPort(), authBuilder.username( proxy.getUsername() ).password( proxy.getPassword() );
proxyAuth ), proxy.getNonProxyHosts() ); proxySelector.add( new org.eclipse.aether.repository.Proxy( proxy.getProtocol(), proxy.getHost(),
proxy.getPort(), authBuilder.build() ),
proxy.getNonProxyHosts() );
} }
session.setProxySelector( proxySelector ); session.setProxySelector( proxySelector );
DefaultAuthenticationSelector authSelector = new DefaultAuthenticationSelector(); DefaultAuthenticationSelector authSelector = new DefaultAuthenticationSelector();
for ( Server server : decrypted.getServers() ) for ( Server server : decrypted.getServers() )
{ {
Authentication auth = AuthenticationBuilder authBuilder = new AuthenticationBuilder();
new Authentication( server.getUsername(), server.getPassword(), server.getPrivateKey(), authBuilder.username( server.getUsername() ).password( server.getPassword() );
server.getPassphrase() ); authBuilder.privateKey( server.getPrivateKey(), server.getPassphrase() );
authSelector.add( server.getId(), auth ); authSelector.add( server.getId(), authBuilder.build() );
if ( server.getConfiguration() != null ) if ( server.getConfiguration() != null )
{ {

View File

@ -44,6 +44,7 @@ import org.eclipse.aether.repository.Authentication;
import org.eclipse.aether.repository.Proxy; import org.eclipse.aether.repository.Proxy;
import org.eclipse.aether.repository.RemoteRepository; import org.eclipse.aether.repository.RemoteRepository;
import org.eclipse.aether.repository.RepositoryPolicy; import org.eclipse.aether.repository.RepositoryPolicy;
import org.eclipse.aether.util.repository.AuthenticationBuilder;
/** /**
* <strong>Warning:</strong> This is an internal utility class that is only public for technical reasons, it is not part * <strong>Warning:</strong> This is an internal utility class that is only public for technical reasons, it is not part
@ -247,8 +248,10 @@ public class RepositoryUtils
Authentication result = null; Authentication result = null;
if ( auth != null ) if ( auth != null )
{ {
result = AuthenticationBuilder authBuilder = new AuthenticationBuilder();
new Authentication( auth.getUsername(), auth.getPassword(), auth.getPrivateKey(), auth.getPassphrase() ); authBuilder.username( auth.getUsername() ).password( auth.getPassword() );
authBuilder.privateKey( auth.getPrivateKey(), auth.getPassphrase() );
result = authBuilder.build();
} }
return result; return result;
} }
@ -258,8 +261,9 @@ public class RepositoryUtils
Proxy result = null; Proxy result = null;
if ( proxy != null ) if ( proxy != null )
{ {
Authentication auth = new Authentication( proxy.getUserName(), proxy.getPassword() ); AuthenticationBuilder authBuilder = new AuthenticationBuilder();
result = new Proxy( proxy.getProtocol(), proxy.getHost(), proxy.getPort(), auth ); authBuilder.username( proxy.getUserName() ).password( proxy.getPassword() );
result = new Proxy( proxy.getProtocol(), proxy.getHost(), proxy.getPort(), authBuilder.build() );
} }
return result; return result;
} }