From 28387451563d45dbc166df3d4b029b63a858c6ac Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Mon, 17 Sep 2012 00:05:23 +0200 Subject: [PATCH] o Accounted for refactoring of aether-api --- .../legacy/LegacyRepositorySystem.java | 26 +++++++++++++------ .../java/org/apache/maven/DefaultMaven.java | 18 +++++++------ .../org/apache/maven/RepositoryUtils.java | 12 ++++++--- 3 files changed, 36 insertions(+), 20 deletions(-) diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java index 366f8ce636..591debc049 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java @@ -74,6 +74,7 @@ import org.codehaus.plexus.component.repository.exception.ComponentLookupExcepti import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.StringUtils; import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.repository.AuthenticationContext; import org.eclipse.aether.repository.AuthenticationSelector; import org.eclipse.aether.repository.ProxySelector; import org.eclipse.aether.repository.RemoteRepository; @@ -583,13 +584,17 @@ public class LegacyRepositorySystem AuthenticationSelector selector = session.getAuthenticationSelector(); if ( selector != null ) { - org.eclipse.aether.repository.Authentication auth = - selector.getAuthentication( RepositoryUtils.toRepo( repository ) ); + RemoteRepository repo = RepositoryUtils.toRepo( repository ); + org.eclipse.aether.repository.Authentication auth = selector.getAuthentication( repo ); if ( auth != null ) { - Authentication result = new Authentication( auth.getUsername(), auth.getPassword() ); - result.setPrivateKey( auth.getPrivateKeyFile() ); - result.setPassphrase( auth.getPassphrase() ); + AuthenticationContext authCtx = AuthenticationContext.forRepository( session, repo ); + Authentication result = + 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; } } @@ -688,7 +693,8 @@ public class LegacyRepositorySystem ProxySelector selector = session.getProxySelector(); 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 ) { Proxy p = new Proxy(); @@ -697,8 +703,12 @@ public class LegacyRepositorySystem p.setPort( proxy.getPort() ); if ( proxy.getAuthentication() != null ) { - p.setUserName( proxy.getAuthentication().getUsername() ); - p.setPassword( proxy.getAuthentication().getPassword() ); + AuthenticationContext authCtx = AuthenticationContext.forProxy( session, repo ); + 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; } diff --git a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java index 28769e73d3..b6f3f491ac 100644 --- a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java +++ b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java @@ -83,7 +83,6 @@ import org.eclipse.aether.collection.DependencyGraphTransformer; import org.eclipse.aether.collection.DependencyManager; import org.eclipse.aether.collection.DependencySelector; import org.eclipse.aether.collection.DependencyTraverser; -import org.eclipse.aether.repository.Authentication; import org.eclipse.aether.repository.LocalRepository; import org.eclipse.aether.repository.RepositoryPolicy; 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.JavaEffectiveScopeCalculator; 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.DefaultAuthenticationSelector; import org.eclipse.aether.util.repository.DefaultMirrorSelector; @@ -407,19 +407,21 @@ public class DefaultMaven DefaultProxySelector proxySelector = new DefaultProxySelector(); for ( Proxy proxy : decrypted.getProxies() ) { - Authentication proxyAuth = new Authentication( proxy.getUsername(), proxy.getPassword() ); - proxySelector.add( new org.eclipse.aether.repository.Proxy( proxy.getProtocol(), proxy.getHost(), proxy.getPort(), - proxyAuth ), proxy.getNonProxyHosts() ); + AuthenticationBuilder authBuilder = new AuthenticationBuilder(); + authBuilder.username( proxy.getUsername() ).password( proxy.getPassword() ); + proxySelector.add( new org.eclipse.aether.repository.Proxy( proxy.getProtocol(), proxy.getHost(), + proxy.getPort(), authBuilder.build() ), + proxy.getNonProxyHosts() ); } session.setProxySelector( proxySelector ); DefaultAuthenticationSelector authSelector = new DefaultAuthenticationSelector(); for ( Server server : decrypted.getServers() ) { - Authentication auth = - new Authentication( server.getUsername(), server.getPassword(), server.getPrivateKey(), - server.getPassphrase() ); - authSelector.add( server.getId(), auth ); + AuthenticationBuilder authBuilder = new AuthenticationBuilder(); + authBuilder.username( server.getUsername() ).password( server.getPassword() ); + authBuilder.privateKey( server.getPrivateKey(), server.getPassphrase() ); + authSelector.add( server.getId(), authBuilder.build() ); if ( server.getConfiguration() != null ) { diff --git a/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java b/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java index 4ad30eab43..f07a377cf7 100644 --- a/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java +++ b/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java @@ -44,6 +44,7 @@ import org.eclipse.aether.repository.Authentication; import org.eclipse.aether.repository.Proxy; import org.eclipse.aether.repository.RemoteRepository; import org.eclipse.aether.repository.RepositoryPolicy; +import org.eclipse.aether.util.repository.AuthenticationBuilder; /** * Warning: 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; if ( auth != null ) { - result = - new Authentication( auth.getUsername(), auth.getPassword(), auth.getPrivateKey(), auth.getPassphrase() ); + AuthenticationBuilder authBuilder = new AuthenticationBuilder(); + authBuilder.username( auth.getUsername() ).password( auth.getPassword() ); + authBuilder.privateKey( auth.getPrivateKey(), auth.getPassphrase() ); + result = authBuilder.build(); } return result; } @@ -258,8 +261,9 @@ public class RepositoryUtils Proxy result = null; if ( proxy != null ) { - Authentication auth = new Authentication( proxy.getUserName(), proxy.getPassword() ); - result = new Proxy( proxy.getProtocol(), proxy.getHost(), proxy.getPort(), auth ); + AuthenticationBuilder authBuilder = new AuthenticationBuilder(); + authBuilder.username( proxy.getUserName() ).password( proxy.getPassword() ); + result = new Proxy( proxy.getProtocol(), proxy.getHost(), proxy.getPort(), authBuilder.build() ); } return result; }