You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by og...@apache.org on 2009/01/27 04:18:21 UTC

svn commit: r737986 - in /maven/components/branches/maven-2.1.x: maven-core/pom.xml maven-core/src/main/java/org/apache/maven/DefaultMaven.java pom.xml

Author: ogusakov
Date: Tue Jan 27 03:18:20 2009
New Revision: 737986

URL: http://svn.apache.org/viewvc?rev=737986&view=rev
Log:
[MNG-553] added password encryption facility

Modified:
    maven/components/branches/maven-2.1.x/maven-core/pom.xml
    maven/components/branches/maven-2.1.x/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
    maven/components/branches/maven-2.1.x/pom.xml

Modified: maven/components/branches/maven-2.1.x/maven-core/pom.xml
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.1.x/maven-core/pom.xml?rev=737986&r1=737985&r2=737986&view=diff
==============================================================================
--- maven/components/branches/maven-2.1.x/maven-core/pom.xml (original)
+++ maven/components/branches/maven-2.1.x/maven-core/pom.xml Tue Jan 27 03:18:20 2009
@@ -159,6 +159,11 @@
       <groupId>classworlds</groupId>
       <artifactId>classworlds</artifactId>
     </dependency>
+    
+      <dependency>
+        <groupId>org.sonatype.plexus</groupId>
+        <artifactId>plexus-sec-dispatcher</artifactId>
+      </dependency>
   </dependencies>
 
   <build>

Modified: maven/components/branches/maven-2.1.x/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.1.x/maven-core/src/main/java/org/apache/maven/DefaultMaven.java?rev=737986&r1=737985&r2=737986&view=diff
==============================================================================
--- maven/components/branches/maven-2.1.x/maven-core/src/main/java/org/apache/maven/DefaultMaven.java (original)
+++ maven/components/branches/maven-2.1.x/maven-core/src/main/java/org/apache/maven/DefaultMaven.java Tue Jan 27 03:18:20 2009
@@ -20,8 +20,20 @@
  */
 
 
-import org.apache.maven.artifact.manager.WagonManager;
+import java.io.File;
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+import java.util.TimeZone;
+
 import org.apache.maven.artifact.manager.DefaultWagonManager;
+import org.apache.maven.artifact.manager.WagonManager;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.resolver.ArtifactResolutionException;
 import org.apache.maven.artifact.versioning.ArtifactVersion;
@@ -65,18 +77,8 @@
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.dag.CycleDetectedException;
 import org.codehaus.plexus.util.xml.Xpp3Dom;
-
-import java.io.File;
-import java.io.IOException;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-import java.util.TimeZone;
+import org.sonatype.plexus.components.sec.dispatcher.SecDispatcher;
+import org.sonatype.plexus.components.sec.dispatcher.SecDispatcherException;
 
 /**
  * @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
@@ -659,6 +661,19 @@
         try
         {
             Proxy proxy = settings.getActiveProxy();
+            
+            SecDispatcher sd = null;
+            
+            try
+            {
+                sd = (SecDispatcher) container.lookup( SecDispatcher.ROLE );
+            }
+            catch (Exception e)
+            {
+                getLogger().warn( "security features are disabled. Cannot find plexus component "+SecDispatcher.ROLE );
+                
+                line();
+            }
 
             if ( proxy != null )
             {
@@ -666,17 +681,58 @@
                 {
                     throw new SettingsConfigurationException( "Proxy in settings.xml has no host" );
                 }
+                
+                String pass = proxy.getPassword();
+                
+                if( sd != null )
+                    try
+                    {
+                        pass = sd.decrypt( pass, null, null, container );
+                    }
+                    catch ( SecDispatcherException e )
+                    {
+                        throw new SettingsConfigurationException( e.getMessage() );
+                    }
 
-                wagonManager.addProxy( proxy.getProtocol(), proxy.getHost(), proxy.getPort(), proxy.getUsername(),
-                                       proxy.getPassword(), proxy.getNonProxyHosts() );
+                wagonManager.addProxy(   proxy.getProtocol()
+                                       , proxy.getHost()
+                                       , proxy.getPort()
+                                       , proxy.getUsername()
+                                       , pass
+                                       , proxy.getNonProxyHosts()
+                                       );
             }
-
+            
             for ( Iterator i = settings.getServers().iterator(); i.hasNext(); )
             {
                 Server server = (Server) i.next();
+                
+                String passWord = server.getPassword();
+
+                if( sd != null )
+                    try
+                    {
+                        passWord = sd.decrypt( passWord, null, null, container );
+                    }
+                    catch ( SecDispatcherException e )
+                    {
+                        throw new SettingsConfigurationException( e.getMessage() );
+                    }
+                
+                String passPhrase = server.getPassphrase();
+
+                if( sd != null )
+                    try
+                    {
+                        passPhrase = sd.decrypt( passPhrase, null, null, container );
+                    }
+                    catch ( SecDispatcherException e )
+                    {
+                        throw new SettingsConfigurationException( e.getMessage() );
+                    }
 
-                wagonManager.addAuthenticationInfo( server.getId(), server.getUsername(), server.getPassword(),
-                                                    server.getPrivateKey(), server.getPassphrase() );
+                wagonManager.addAuthenticationInfo( server.getId(), server.getUsername(), passWord,
+                                                    server.getPrivateKey(), passPhrase );
 
                 // Remove once Wagon is upgraded to 1.0-beta-5
                 if ( server.getPassword() != null )

Modified: maven/components/branches/maven-2.1.x/pom.xml
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.1.x/pom.xml?rev=737986&r1=737985&r2=737986&view=diff
==============================================================================
--- maven/components/branches/maven-2.1.x/pom.xml (original)
+++ maven/components/branches/maven-2.1.x/pom.xml Tue Jan 27 03:18:20 2009
@@ -397,6 +397,11 @@
         <version>1.5.6</version>
       </dependency>
       <dependency>
+        <groupId>org.sonatype.plexus</groupId>
+        <artifactId>plexus-sec-dispatcher</artifactId>
+        <version>1.0-alpha-1</version>
+      </dependency>
+      <dependency>
         <groupId>org.apache.maven.wagon</groupId>
         <artifactId>wagon-provider-api</artifactId>
         <version>${wagonVersion}</version>



Re: svn commit: r737986 - in /maven/components/branches/maven-2.1.x: maven-core/pom.xml maven-core/src/main/java/org/apache/maven/DefaultMaven.java pom.xml

Posted by Brett Porter <br...@apache.org>.
Hi Oleg,

On 27/01/2009, at 2:18 PM, ogusakov@apache.org wrote:

> +            try
> +            {
> +                sd = (SecDispatcher)  
> container.lookup( SecDispatcher.ROLE );
> +            }
> +            catch (Exception e)
> +            {
> +                getLogger().warn( "security features are disabled.  
> Cannot find plexus component "+SecDispatcher.ROLE );
> +
> +                line();
> +            }

I think you need to add a corresponding container.release( sd ); for  
this guy.

Thanks!

- Brett

--
Brett Porter
brett@apache.org
http://blogs.exist.com/bporter/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org