Author: olamy
Date: Thu Jan 24 22:27:47 2013
New Revision: 1438231

URL: http://svn.apache.org/viewvc?rev=1438231&view=rev
Log:
[MANTTASKS-177] artifact:dependencies ignores settings-security.xml and sends 
password hash to repository
Submitted by Ross Mellgren


Added:
    maven/ant-tasks/trunk/src/main/resources/META-INF/
    maven/ant-tasks/trunk/src/main/resources/META-INF/plexus/
    maven/ant-tasks/trunk/src/main/resources/META-INF/plexus/components.xml   
(with props)
Modified:
    maven/ant-tasks/trunk/pom.xml
    
maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java

Modified: maven/ant-tasks/trunk/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/ant-tasks/trunk/pom.xml?rev=1438231&r1=1438230&r2=1438231&view=diff
==============================================================================
--- maven/ant-tasks/trunk/pom.xml (original)
+++ maven/ant-tasks/trunk/pom.xml Thu Jan 24 22:27:47 2013
@@ -135,6 +135,7 @@
   <properties>
     <mavenVersion>2.2.1</mavenVersion>
     <wagonVersion>1.0-beta-6</wagonVersion>
+    <securityDispatcherVersion>1.3</securityDispatcherVersion>
   </properties>
 
   <dependencies>
@@ -220,6 +221,11 @@
       <artifactId>wagon-provider-api</artifactId>
       <version>${wagonVersion}</version>
     </dependency>
+    <dependency>
+      <groupId>org.sonatype.plexus</groupId>
+      <artifactId>plexus-sec-dispatcher</artifactId>
+      <version>${securityDispatcherVersion}</version>
+    </dependency>
   </dependencies>
 
   <build>

Modified: 
maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java
URL: 
http://svn.apache.org/viewvc/maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java?rev=1438231&r1=1438230&r2=1438231&view=diff
==============================================================================
--- 
maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java
 (original)
+++ 
maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java
 Thu Jan 24 22:27:47 2013
@@ -73,6 +73,8 @@ import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.ReaderFactory;
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+import org.sonatype.plexus.components.sec.dispatcher.SecDispatcher;
+import org.sonatype.plexus.components.sec.dispatcher.SecDispatcherException;
 
 /**
  * Base class for artifact tasks.
@@ -436,7 +438,23 @@ public abstract class AbstractArtifactTa
             Server server = getSettings().getServer( repository.getId() );
             if ( server != null )
             {
-                repository.addAuthentication( new Authentication( server ) );
+                Authentication authentication = new Authentication( server );
+                
+                String password = authentication.getPassword();
+                
+                if (password != null) {
+                                       try {
+                                               SecDispatcher 
securityDispatcher = (SecDispatcher) container.lookup(SecDispatcher.ROLE);
+                                               password = 
securityDispatcher.decrypt(password);
+                                               
authentication.setPassword(password);
+                                       } catch (SecDispatcherException e) {
+                                               log(e, Project.MSG_ERR);
+                                       } catch (ComponentLookupException e) {
+                                               log(e, Project.MSG_ERR);
+                                       }
+                }
+                
+                               repository.addAuthentication( authentication );
             }
         }
 
@@ -593,7 +611,7 @@ public abstract class AbstractArtifactTa
             {
                 protocols.add( entry.getKey() );
             }
-            return (String[]) protocols.toArray( new String[protocols.size()] 
);
+            return protocols.toArray( new String[protocols.size()] );
         }
         catch ( ComponentLookupException e )
         {
@@ -682,7 +700,7 @@ public abstract class AbstractArtifactTa
             Object ref = i.next();
             if ( ref instanceof Pom )
             {
-                result.add( (Pom)ref );
+                result.add( ref );
             }
         }
         return result;
@@ -735,7 +753,8 @@ public abstract class AbstractArtifactTa
     }
 
     /** @noinspection RefusedBequest */
-    public void execute()
+    @Override
+       public void execute()
     {
         // Display the version if the log level is verbose
         showVersion();

Added: maven/ant-tasks/trunk/src/main/resources/META-INF/plexus/components.xml
URL: 
http://svn.apache.org/viewvc/maven/ant-tasks/trunk/src/main/resources/META-INF/plexus/components.xml?rev=1438231&view=auto
==============================================================================
--- maven/ant-tasks/trunk/src/main/resources/META-INF/plexus/components.xml 
(added)
+++ maven/ant-tasks/trunk/src/main/resources/META-INF/plexus/components.xml Thu 
Jan 24 22:27:47 2013
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<component-set>
+  <components>
+
+    <component>
+      <role>org.sonatype.plexus.components.sec.dispatcher.SecDispatcher</role>
+      <role-hint>maven</role-hint>
+      
<implementation>org.sonatype.plexus.components.sec.dispatcher.DefaultSecDispatcher</implementation>
+      <description>Maven Security dispatcher</description>
+      <requirements>
+        <requirement>
+          <role>org.sonatype.plexus.components.cipher.PlexusCipher</role>
+          <field-name>_cipher</field-name>
+        </requirement>
+        <requirement>
+          
<role>org.sonatype.plexus.components.sec.dispatcher.PasswordDecryptor</role>
+          <field-name>_decryptors</field-name>
+        </requirement>
+      </requirements>
+      <configuration>
+        <_configuration-file>~/.m2/settings-security.xml</_configuration-file>
+      </configuration>
+    </component>
+  </components>
+</component-set>

Propchange: 
maven/ant-tasks/trunk/src/main/resources/META-INF/plexus/components.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/ant-tasks/trunk/src/main/resources/META-INF/plexus/components.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision


Reply via email to