maven-wagon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r355292 - in /maven/wagon/trunk: ./ wagon-openpgp/ wagon-openpgp/src/ wagon-openpgp/src/main/ wagon-openpgp/src/main/java/ wagon-openpgp/src/main/java/org/ wagon-openpgp/src/main/java/org/apache/ wagon-openpgp/src/main/java/org/apache/maven...
Date Fri, 09 Dec 2005 00:20:36 GMT
Author: brett
Date: Thu Dec  8 16:20:31 2005
New Revision: 355292

URL: http://svn.apache.org/viewcvs?rev=355292&view=rev
Log:
open pgp suppoprt for wagon

Added:
    maven/wagon/trunk/wagon-openpgp/   (with props)
    maven/wagon/trunk/wagon-openpgp/pom.xml   (with props)
    maven/wagon/trunk/wagon-openpgp/src/
    maven/wagon/trunk/wagon-openpgp/src/main/
    maven/wagon/trunk/wagon-openpgp/src/main/java/
    maven/wagon/trunk/wagon-openpgp/src/main/java/org/
    maven/wagon/trunk/wagon-openpgp/src/main/java/org/apache/
    maven/wagon/trunk/wagon-openpgp/src/main/java/org/apache/maven/
    maven/wagon/trunk/wagon-openpgp/src/main/java/org/apache/maven/wagon/
    maven/wagon/trunk/wagon-openpgp/src/main/java/org/apache/maven/wagon/openpgp/
    maven/wagon/trunk/wagon-openpgp/src/main/java/org/apache/maven/wagon/openpgp/WagonOpenPgpSignatureVerifierObserver.java
  (with props)
    maven/wagon/trunk/wagon-openpgp/src/main/java/org/apache/maven/wagon/openpgp/WagonOpenPgpSignerObserver.java
  (with props)
    maven/wagon/trunk/wagon-openpgp/src/test/
    maven/wagon/trunk/wagon-openpgp/src/test/java/
    maven/wagon/trunk/wagon-openpgp/src/test/java/org/
    maven/wagon/trunk/wagon-openpgp/src/test/java/org/apache/
    maven/wagon/trunk/wagon-openpgp/src/test/java/org/apache/maven/
    maven/wagon/trunk/wagon-openpgp/src/test/java/org/apache/maven/wagon/
    maven/wagon/trunk/wagon-openpgp/src/test/java/org/apache/maven/wagon/openpgp/
    maven/wagon/trunk/wagon-openpgp/src/test/java/org/apache/maven/wagon/openpgp/WagonOpenPgpObserverTest.java
  (with props)
    maven/wagon/trunk/wagon-openpgp/src/test/resources/
    maven/wagon/trunk/wagon-openpgp/src/test/resources/pubring.gpg
      - copied unchanged from r354611, jakarta/commons/sandbox/openpgp/trunk/src/test/resources/pubring.gpg
    maven/wagon/trunk/wagon-openpgp/src/test/resources/secring.gpg
      - copied unchanged from r354611, jakarta/commons/sandbox/openpgp/trunk/src/test/resources/secring.gpg
    maven/wagon/trunk/wagon-openpgp/src/test/resources/test-input.txt
      - copied unchanged from r354611, jakarta/commons/sandbox/openpgp/trunk/src/test/resources/test-input.txt
    maven/wagon/trunk/wagon-openpgp/src/test/resources/test-signature.bpg
      - copied unchanged from r354747, jakarta/commons/sandbox/openpgp/trunk/src/test/resources/test-signature.bpg
    maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/observers/AbstractTransferListener.java
  (with props)
Modified:
    maven/wagon/trunk/pom.xml

Modified: maven/wagon/trunk/pom.xml
URL: http://svn.apache.org/viewcvs/maven/wagon/trunk/pom.xml?rev=355292&r1=355291&r2=355292&view=diff
==============================================================================
--- maven/wagon/trunk/pom.xml (original)
+++ maven/wagon/trunk/pom.xml Thu Dec  8 16:20:31 2005
@@ -9,7 +9,7 @@
   <issueManagement>
     <system>jira</system>
     <url>http://jira.codehaus.org/browse/WAGON</url>
-  </issueManagement>            
+  </issueManagement>
   <ciManagement>
     <system>wagon-dev@maven.apache.org</system>
     <notifiers>
@@ -93,6 +93,7 @@
     <module>wagon-provider-api</module>
     <module>wagon-provider-test</module>
     <module>wagon-providers</module>
+    <module>wagon-openpgp</module>
   </modules>
   <dependencies>
     <dependency>

Propchange: maven/wagon/trunk/wagon-openpgp/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Dec  8 16:20:31 2005
@@ -0,0 +1,4 @@
+target
+*.iws
+*.ipr
+*.iml

Added: maven/wagon/trunk/wagon-openpgp/pom.xml
URL: http://svn.apache.org/viewcvs/maven/wagon/trunk/wagon-openpgp/pom.xml?rev=355292&view=auto
==============================================================================
--- maven/wagon/trunk/wagon-openpgp/pom.xml (added)
+++ maven/wagon/trunk/wagon-openpgp/pom.xml Thu Dec  8 16:20:31 2005
@@ -0,0 +1,48 @@
+<project>
+  <parent>
+    <artifactId>wagon</artifactId>
+    <groupId>org.apache.maven.wagon</groupId>
+    <version>1.0-alpha-6-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>wagon-openpgp</artifactId>
+  <name>Maven Wagon OpenPGP Integration</name>
+  <version>1.0-alpha-6-SNAPSHOT</version>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.wagon</groupId>
+      <artifactId>wagon-provider-api</artifactId>
+      <version>1.0-alpha-6-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.wagon</groupId>
+      <artifactId>wagon-provider-test</artifactId>
+      <version>1.0-alpha-6-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.wagon</groupId>
+      <artifactId>wagon-file</artifactId>
+      <version>1.0-alpha-6-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-container-default</artifactId>
+      <version>1.0-alpha-8</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-openpgp</artifactId>
+      <version>1.0-SNAPSHOT</version>
+    </dependency>
+  </dependencies>
+  <!-- Until commons-pgp has a release -->
+  <repositories>
+    <repository>
+      <id>apache.snapshots</id>
+      <url>http://cvs.apache.org/maven-snapshot-repository</url>
+    </repository>
+  </repositories>
+</project>

Propchange: maven/wagon/trunk/wagon-openpgp/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/wagon/trunk/wagon-openpgp/pom.xml
------------------------------------------------------------------------------
    svn:executable = *

Propchange: maven/wagon/trunk/wagon-openpgp/pom.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/wagon/trunk/wagon-openpgp/src/main/java/org/apache/maven/wagon/openpgp/WagonOpenPgpSignatureVerifierObserver.java
URL: http://svn.apache.org/viewcvs/maven/wagon/trunk/wagon-openpgp/src/main/java/org/apache/maven/wagon/openpgp/WagonOpenPgpSignatureVerifierObserver.java?rev=355292&view=auto
==============================================================================
--- maven/wagon/trunk/wagon-openpgp/src/main/java/org/apache/maven/wagon/openpgp/WagonOpenPgpSignatureVerifierObserver.java
(added)
+++ maven/wagon/trunk/wagon-openpgp/src/main/java/org/apache/maven/wagon/openpgp/WagonOpenPgpSignatureVerifierObserver.java
Thu Dec  8 16:20:31 2005
@@ -0,0 +1,87 @@
+package org.apache.maven.wagon.openpgp;
+
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.commons.openpgp.BouncyCastleOpenPgpStreamingSignatureVerifier;
+import org.apache.commons.openpgp.KeyRing;
+import org.apache.commons.openpgp.OpenPgpException;
+import org.apache.commons.openpgp.OpenPgpStreamingSignatureVerifier;
+import org.apache.commons.openpgp.SignatureStatus;
+import org.apache.maven.wagon.events.TransferEvent;
+import org.apache.maven.wagon.observers.AbstractTransferListener;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Listener to the upload process that can sign the artifact.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @todo handle non-detached
+ * @todo does this need to handle reset in transferStarted so it can be reused?
+ */
+public class WagonOpenPgpSignatureVerifierObserver
+    extends AbstractTransferListener
+{
+    private final OpenPgpStreamingSignatureVerifier verifier;
+
+    private SignatureStatus status;
+
+    public WagonOpenPgpSignatureVerifierObserver( InputStream inputStream, KeyRing keyRing,
boolean asciiArmored )
+        throws OpenPgpException, IOException
+    {
+        verifier = new BouncyCastleOpenPgpStreamingSignatureVerifier( inputStream, keyRing,
asciiArmored );
+    }
+
+    public void transferInitiated( TransferEvent transferEvent )
+    {
+        this.status = null;
+    }
+
+    public void transferProgress( TransferEvent transferEvent, byte[] buffer, int length
)
+    {
+        try
+        {
+            verifier.update( buffer, 0, length );
+        }
+        catch ( OpenPgpException e )
+        {
+            // TODO: record the error in some way
+        }
+    }
+
+    public void transferCompleted( TransferEvent transferEvent )
+    {
+        try
+        {
+            status = verifier.finish();
+        }
+        catch ( OpenPgpException e )
+        {
+            // TODO: record the error in some way
+        }
+        catch ( IOException e )
+        {
+            // TODO: record the error in some way
+        }
+    }
+
+    public SignatureStatus getStatus()
+    {
+        return status;
+    }
+}

Propchange: maven/wagon/trunk/wagon-openpgp/src/main/java/org/apache/maven/wagon/openpgp/WagonOpenPgpSignatureVerifierObserver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/wagon/trunk/wagon-openpgp/src/main/java/org/apache/maven/wagon/openpgp/WagonOpenPgpSignatureVerifierObserver.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/wagon/trunk/wagon-openpgp/src/main/java/org/apache/maven/wagon/openpgp/WagonOpenPgpSignerObserver.java
URL: http://svn.apache.org/viewcvs/maven/wagon/trunk/wagon-openpgp/src/main/java/org/apache/maven/wagon/openpgp/WagonOpenPgpSignerObserver.java?rev=355292&view=auto
==============================================================================
--- maven/wagon/trunk/wagon-openpgp/src/main/java/org/apache/maven/wagon/openpgp/WagonOpenPgpSignerObserver.java
(added)
+++ maven/wagon/trunk/wagon-openpgp/src/main/java/org/apache/maven/wagon/openpgp/WagonOpenPgpSignerObserver.java
Thu Dec  8 16:20:31 2005
@@ -0,0 +1,85 @@
+package org.apache.maven.wagon.openpgp;
+
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.commons.openpgp.BouncyCastleOpenPgpStreamingSigner;
+import org.apache.commons.openpgp.KeyRing;
+import org.apache.commons.openpgp.OpenPgpException;
+import org.apache.commons.openpgp.OpenPgpStreamingSigner;
+import org.apache.maven.wagon.events.TransferEvent;
+import org.apache.maven.wagon.observers.AbstractTransferListener;
+
+import java.io.IOException;
+
+/**
+ * Listener to the upload process that can sign the artifact.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @todo handle non-detached
+ * @todo does this need to handle reset in transferStarted so it can be reused?
+ */
+public class WagonOpenPgpSignerObserver
+    extends AbstractTransferListener
+{
+    private final OpenPgpStreamingSigner signer;
+
+    private byte[] actualSignature;
+
+    public WagonOpenPgpSignerObserver( String keyId, KeyRing keyRing, boolean asciiArmored
)
+        throws OpenPgpException
+    {
+        signer = new BouncyCastleOpenPgpStreamingSigner( keyId, keyRing, asciiArmored );
+    }
+
+    public void transferInitiated( TransferEvent transferEvent )
+    {
+        this.actualSignature = null;
+    }
+
+    public void transferProgress( TransferEvent transferEvent, byte[] buffer, int length
)
+    {
+        try
+        {
+            signer.update( buffer, 0, length );
+        }
+        catch ( OpenPgpException e )
+        {
+            // TODO: record the error in some way
+        }
+    }
+
+    public void transferCompleted( TransferEvent transferEvent )
+    {
+        try
+        {
+            actualSignature = signer.finish();
+        }
+        catch ( OpenPgpException e )
+        {
+            // TODO: record the error in some way
+        }
+        catch ( IOException e )
+        {
+            // TODO: record the error in some way
+        }
+    }
+
+    public byte[] getActualSignature()
+    {
+        return actualSignature;
+    }
+}

Propchange: maven/wagon/trunk/wagon-openpgp/src/main/java/org/apache/maven/wagon/openpgp/WagonOpenPgpSignerObserver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/wagon/trunk/wagon-openpgp/src/main/java/org/apache/maven/wagon/openpgp/WagonOpenPgpSignerObserver.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/wagon/trunk/wagon-openpgp/src/test/java/org/apache/maven/wagon/openpgp/WagonOpenPgpObserverTest.java
URL: http://svn.apache.org/viewcvs/maven/wagon/trunk/wagon-openpgp/src/test/java/org/apache/maven/wagon/openpgp/WagonOpenPgpObserverTest.java?rev=355292&view=auto
==============================================================================
--- maven/wagon/trunk/wagon-openpgp/src/test/java/org/apache/maven/wagon/openpgp/WagonOpenPgpObserverTest.java
(added)
+++ maven/wagon/trunk/wagon-openpgp/src/test/java/org/apache/maven/wagon/openpgp/WagonOpenPgpObserverTest.java
Thu Dec  8 16:20:31 2005
@@ -0,0 +1,122 @@
+package org.apache.maven.wagon.openpgp;
+
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.commons.openpgp.BouncyCastleKeyRing;
+import org.apache.commons.openpgp.BouncyCastleOpenPgpSignatureVerifier;
+import org.apache.commons.openpgp.KeyRing;
+import org.apache.commons.openpgp.OpenPgpSignatureVerifier;
+import org.apache.commons.openpgp.SignatureStatus;
+import org.apache.maven.wagon.FileTestUtils;
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.repository.Repository;
+import org.codehaus.plexus.PlexusTestCase;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+
+/**
+ * Test the wagon observer for open pgp signatures.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+public class WagonOpenPgpObserverTest
+    extends PlexusTestCase
+{
+    private String keyId = "A7D16BD4";
+
+    private static final String PASSWORD = "cop";
+
+    private KeyRing keyRing;
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        keyRing = new BouncyCastleKeyRing( getClass().getResourceAsStream( "/secring.gpg"
),
+                                           getClass().getResourceAsStream( "/pubring.gpg"
), PASSWORD.toCharArray() );
+    }
+
+    public void testSign()
+        throws Exception
+    {
+        WagonOpenPgpSignerObserver observer = new WagonOpenPgpSignerObserver( keyId, keyRing,
false );
+
+        Wagon wagon = (Wagon) lookup( Wagon.ROLE, "file" );
+
+        wagon.addTransferListener( observer );
+
+        File tempDir = new File( FileTestUtils.getTestOutputDir(), "openpgp-repo" );
+        tempDir.mkdirs();
+        tempDir.deleteOnExit();
+
+        Repository repository = new Repository( "test", tempDir.toURL().toString() );
+
+        wagon.connect( repository );
+
+        // TODO: use streams when available
+        wagon.put( getTestFile( "src/test/resources/test-input.txt" ), "test-input.txt" );
+
+        byte[] signature = observer.getActualSignature();
+
+        wagon.removeTransferListener( observer );
+
+        wagon.disconnect();
+
+        // check signature
+        OpenPgpSignatureVerifier verifier = new BouncyCastleOpenPgpSignatureVerifier();
+        SignatureStatus status = verifier.verifyDetachedSignature( getClass().getResourceAsStream(
"/test-input.txt" ),
+                                                                   new ByteArrayInputStream(
signature ), keyRing,
+                                                                   false );
+
+        assertNotNull( "check we got a status", status );
+        assertTrue( "check it was successful", status.isValid() );
+    }
+
+    public void testVerify()
+        throws Exception
+    {
+        WagonOpenPgpSignatureVerifierObserver observer = new WagonOpenPgpSignatureVerifierObserver(
+            getClass().getResourceAsStream( "/test-signature.bpg" ), keyRing, false );
+
+        Wagon wagon = (Wagon) lookup( Wagon.ROLE, "file" );
+
+        wagon.addTransferListener( observer );
+
+        File tempDir = new File( FileTestUtils.getTestOutputDir(), "openpgp-repo" );
+        tempDir.mkdirs();
+        tempDir.deleteOnExit();
+
+        Repository repository = new Repository( "test", getTestFile( "src/test/resources"
).toURL().toString() );
+
+        wagon.connect( repository );
+
+        // TODO: use streams when available
+        wagon.get( "test-input.txt", new File( tempDir, "test-input.txt" ) );
+
+        SignatureStatus status = observer.getStatus();
+
+        assertNotNull( "check we got a status", status );
+        assertTrue( "check it was successful", status.isValid() );
+
+        wagon.removeTransferListener( observer );
+
+        wagon.disconnect();
+    }
+
+}

Propchange: maven/wagon/trunk/wagon-openpgp/src/test/java/org/apache/maven/wagon/openpgp/WagonOpenPgpObserverTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/wagon/trunk/wagon-openpgp/src/test/java/org/apache/maven/wagon/openpgp/WagonOpenPgpObserverTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/observers/AbstractTransferListener.java
URL: http://svn.apache.org/viewcvs/maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/observers/AbstractTransferListener.java?rev=355292&view=auto
==============================================================================
--- maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/observers/AbstractTransferListener.java
(added)
+++ maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/observers/AbstractTransferListener.java
Thu Dec  8 16:20:31 2005
@@ -0,0 +1,60 @@
+package org.apache.maven.wagon.observers;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.wagon.events.TransferEvent;
+import org.apache.maven.wagon.events.TransferListener;
+
+/**
+ * TransferListeners which computes MD5 checksum on the fly when files are transfered.
+ *
+ * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
+ * @version $Id$
+ */
+public abstract class AbstractTransferListener
+    implements TransferListener
+{
+    public void transferInitiated( TransferEvent transferEvent )
+    {
+    }
+
+    /**
+     * @see org.apache.maven.wagon.events.TransferListener#transferStarted(org.apache.maven.wagon.events.TransferEvent)
+     */
+    public void transferStarted( TransferEvent transferEvent )
+    {
+    }
+
+    /**
+     * @see org.apache.maven.wagon.events.TransferListener#transferProgress(org.apache.maven.wagon.events.TransferEvent,byte[],int)
+     */
+    public void transferProgress( TransferEvent transferEvent, byte[] buffer, int length
)
+    {
+    }
+
+    public void transferCompleted( TransferEvent transferEvent )
+    {
+    }
+
+    public void transferError( TransferEvent transferEvent )
+    {
+    }
+
+    public void debug( String message )
+    {
+    }
+}

Propchange: maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/observers/AbstractTransferListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/observers/AbstractTransferListener.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



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


Mime
View raw message