You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@turbine.apache.org by sg...@apache.org on 2008/07/22 12:09:30 UTC
svn commit: r678700 - in /turbine/fulcrum/trunk/pbe: NOTICE.txt pom.xml
src/site/ src/site/site.xml
src/test/org/apache/fulcrum/pbe/PBEServiceTest.java xdocs/changes.xml
xdocs/configuration.xml xdocs/index.xml
Author: sgoeschl
Date: Tue Jul 22 03:09:30 2008
New Revision: 678700
URL: http://svn.apache.org/viewvc?rev=678700&view=rev
Log:
Adding M2 build and adding some more tests
Added:
turbine/fulcrum/trunk/pbe/NOTICE.txt
turbine/fulcrum/trunk/pbe/pom.xml
turbine/fulcrum/trunk/pbe/src/site/
turbine/fulcrum/trunk/pbe/src/site/site.xml
Modified:
turbine/fulcrum/trunk/pbe/src/test/org/apache/fulcrum/pbe/PBEServiceTest.java
turbine/fulcrum/trunk/pbe/xdocs/changes.xml
turbine/fulcrum/trunk/pbe/xdocs/configuration.xml
turbine/fulcrum/trunk/pbe/xdocs/index.xml
Added: turbine/fulcrum/trunk/pbe/NOTICE.txt
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/pbe/NOTICE.txt?rev=678700&view=auto
==============================================================================
--- turbine/fulcrum/trunk/pbe/NOTICE.txt (added)
+++ turbine/fulcrum/trunk/pbe/NOTICE.txt Tue Jul 22 03:09:30 2008
@@ -0,0 +1,6 @@
+Turbine Fulcrum ServiceManager
+Copyright 2002-2007 The Apache Software Foundation.
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
Added: turbine/fulcrum/trunk/pbe/pom.xml
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/pbe/pom.xml?rev=678700&view=auto
==============================================================================
--- turbine/fulcrum/trunk/pbe/pom.xml (added)
+++ turbine/fulcrum/trunk/pbe/pom.xml Tue Jul 22 03:09:30 2008
@@ -0,0 +1,99 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+-->
+<project
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>fulcrum</groupId>
+ <artifactId>fulcrum-parent</artifactId>
+ <version>1-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>fulcrum-pbe</artifactId>
+ <version>1.0.1-SNAPSHOT</version>
+ <name>Fulcrum PBE</name>
+ <inceptionYear>2008</inceptionYear>
+ <description>Fulcrum PBE Service</description>
+ <url>http://turbine.apache.org/fulcrum/fulcrum-pbe</url>
+
+ <scm>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/turbine/fulcrum/trunk/pbe/</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/turbine/fulcrum/trunk/pbe/</developerConnection>
+ <url>http://svn.apache.org/viewcvs/turbine/fulcrum/trunk/pbe/</url>
+ </scm>
+
+ <distributionManagement>
+ <site>
+ <id>fulcrum.website</id>
+ <name>Fulcrum Website</name>
+ <url>${fulcrum.deployment.protocol}://people.apache.org/www/turbine.apache.org/fulcrum/fulcrum-pbe/</url>
+ </site>
+ </distributionManagement>
+
+ <developers>
+ <developer>
+ <name>Siegfried Goeschl</name>
+ <id>sgoeschl</id>
+ <email>sgoeschl@apache.org</email>
+ <organization></organization>
+ <roles>
+ <role>Java Developer</role>
+ </roles>
+ </developer>
+ </developers>
+
+ <dependencies>
+ <dependency>
+ <groupId>avalon-framework</groupId>
+ <artifactId>avalon-framework-api</artifactId>
+ <version>4.3</version>
+ <exclusions>
+ <exclusion>
+ <groupId>avalon-logkit</groupId>
+ <artifactId>avalon-logkit</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>fulcrum</groupId>
+ <artifactId>fulcrum-yaafi-crypto</artifactId>
+ <version>1.0.6-SNAPSHOT</version>
+ </dependency>
+ <!-- testing dependencies -->
+ <dependency>
+ <groupId>fulcrum</groupId>
+ <artifactId>fulcrum-testcontainer</artifactId>
+ <version>1.0.6-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>fulcrum</groupId>
+ <artifactId>fulcrum-yaafi</artifactId>
+ <version>1.0.6-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <sourceDirectory>${basedir}/src/java</sourceDirectory>
+ <testSourceDirectory>${basedir}/src/test</testSourceDirectory>
+ </build>
+
+</project>
Added: turbine/fulcrum/trunk/pbe/src/site/site.xml
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/pbe/src/site/site.xml?rev=678700&view=auto
==============================================================================
--- turbine/fulcrum/trunk/pbe/src/site/site.xml (added)
+++ turbine/fulcrum/trunk/pbe/src/site/site.xml Tue Jul 22 03:09:30 2008
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+-->
+<project name="Fulcrum PBE Service">
+ <body>
+ <menu name="Overview">
+ <item name="Overview" href="/index.html"/>
+ <item name="Configuration" href="/configuration.html"/>
+ <item name="Technical" href="/technical.html"/>
+ </menu>
+ ${reports}
+ </body>
+</project>
Modified: turbine/fulcrum/trunk/pbe/src/test/org/apache/fulcrum/pbe/PBEServiceTest.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/pbe/src/test/org/apache/fulcrum/pbe/PBEServiceTest.java?rev=678700&r1=678699&r2=678700&view=diff
==============================================================================
--- turbine/fulcrum/trunk/pbe/src/test/org/apache/fulcrum/pbe/PBEServiceTest.java (original)
+++ turbine/fulcrum/trunk/pbe/src/test/org/apache/fulcrum/pbe/PBEServiceTest.java Tue Jul 22 03:09:30 2008
@@ -19,13 +19,11 @@
* under the License.
*/
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
+import java.io.*;
import org.apache.fulcrum.testcontainer.BaseUnitTest;
+import org.apache.fulcrum.jce.crypto.CryptoUtil;
+import org.apache.fulcrum.jce.crypto.StreamUtil;
/**
* PBEServiceTest
@@ -75,32 +73,6 @@
return this.getService().createPassword();
}
- /**
- * Pumps the input stream to the output stream.
- *
- * @param is the source input stream
- * @param os the target output stream
- * @throws IOException the copying failed
- */
- public void copy( InputStream is, OutputStream os )
- throws IOException
- {
- byte[] buf = new byte[1024];
- int n = 0;
- int total = 0;
-
- while ((n = is.read(buf)) > 0)
- {
- os.write(buf, 0, n);
- total += n;
- }
-
- is.close();
-
- os.flush();
- os.close();
- }
-
/////////////////////////////////////////////////////////////////////////
// Start of unit tests
/////////////////////////////////////////////////////////////////////////
@@ -113,6 +85,7 @@
char[] result = this.getService().createPassword();
assertNotNull( result );
assertTrue( result.length > 0 );
+ assertEquals("727a-98b9-93be-4537c", new String(result));
}
/**
@@ -124,20 +97,34 @@
char[] result = this.getService().createPassword(seed);
assertNotNull( result );
assertTrue( result.length > 0 );
+ assertEquals("62cc-bf14-1814-672da", new String(result));
}
/**
* Test encryption and decryption of Strings
*/
- public void testEncryptDecryptString() throws Exception
+ public void testEncryptDecryptStringUsingDefaultPassword() throws Exception
{
- String source = "Nobody knows the toubles I have seen ...";
+ String source = "Nobody knows the troubles I have seen ...";
String cipherText = this.getService().encryptString( source, this.getPassword() );
String plainText = this.getService().decryptString( cipherText, this.getPassword() );
assertEquals( source, plainText );
}
/**
+ * Test encryption and decryption of Strings with
+ * a caller-supplied password
+ */
+ public void testEncryptDecryptStringUsingCustomPassword() throws Exception
+ {
+ char[] myPassword = this.getService().createPassword("mysecret".toCharArray());
+ String source = "Nobody knows the troubles I have seen ...";
+ String cipherText = this.getService().encryptString( source, myPassword );
+ String plainText = this.getService().decryptString( cipherText, myPassword );
+ assertEquals( source, plainText );
+ }
+
+ /**
* Test encryption and decryption of binary data using the default password.
*/
public void testBinaryEncryptDecrypt() throws Exception
@@ -170,7 +157,7 @@
public void testStreamCiphers() throws Exception
{
- String source = "Nobody knows the toubles I have seen ...";
+ String source = "Nobody knows the troubles I have seen ...";
byte[] cipherText = null;
String plainText = null;
char[] password = this.getPassword();
@@ -179,17 +166,30 @@
ByteArrayInputStream bais1 = new ByteArrayInputStream( source.getBytes() );
ByteArrayOutputStream baos1 = new ByteArrayOutputStream();
OutputStream cos = this.getService().getOutputStream( baos1, password );
- this.copy( bais1, cos );
+ StreamUtil.copy( bais1, cos );
cipherText = baos1.toByteArray();
- // decrypt using a CipherinputStream
+ // decrypt using a CipherInputStream
ByteArrayInputStream bais2 = new ByteArrayInputStream( cipherText );
ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
InputStream cis = this.getService().getInputStream( bais2, password );
- this.copy( cis, baos2 );
+ StreamUtil.copy( cis, baos2 );
plainText = new String( baos2.toByteArray() );
// verify the result
assertEquals( source, plainText );
}
+
+ public void testConvinienceEncryption() throws Exception
+ {
+ String plainText = "Nobody knows the troubles I have seen ...";
+
+ this.getService().encrypt(plainText, new File("./target/temp/plain.enc.txt"), "mysecret".toCharArray());
+ this.getService().encrypt(new File("./project.xml"), new File("./target/temp/project.enc.xml"), "mysecret".toCharArray());
+
+ this.getService().decrypt(new File("./target/temp/plain.enc.txt"), new File("./target/temp/plain.dec.txt"), "mysecret".toCharArray());
+ this.getService().decrypt(new File("./target/temp/project.enc.xml"), new File("./target/temp/project.dec.xml"), "mysecret".toCharArray());
+
+
+ }
}
Modified: turbine/fulcrum/trunk/pbe/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/pbe/xdocs/changes.xml?rev=678700&r1=678699&r2=678700&view=diff
==============================================================================
--- turbine/fulcrum/trunk/pbe/xdocs/changes.xml (original)
+++ turbine/fulcrum/trunk/pbe/xdocs/changes.xml Tue Jul 22 03:09:30 2008
@@ -25,7 +25,13 @@
<body>
<release version="1.0.1-dev" date="as in SVN">
- <action dev="sgoeschl" type="fix">
+ <action dev="sgoeschl" type="add">
+ Added more regression tests.
+ </action>
+ <action dev="sgoeschl" type="add">
+ Added a M2 build.
+ </action>
+ <action dev="sgoeschl" type="fix">
Update of fulcrum-yaafi broke the build - fixed it
</action>
</release>
Modified: turbine/fulcrum/trunk/pbe/xdocs/configuration.xml
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/pbe/xdocs/configuration.xml?rev=678700&r1=678699&r2=678700&view=diff
==============================================================================
--- turbine/fulcrum/trunk/pbe/xdocs/configuration.xml (original)
+++ turbine/fulcrum/trunk/pbe/xdocs/configuration.xml Tue Jul 22 03:09:30 2008
@@ -31,8 +31,6 @@
name="org.apache.fulcrum.pbe.PBEService"
shorthand="PBEService"
default-class="org.apache.fulcrum.pbe.PBEServiceImpl"
- early-init="true"
- component-type="merlin"
description="Provides Password Based Encyrption using JCA/JCE"
/>
]]></source>
@@ -52,17 +50,6 @@
<th>Description</th>
</tr>
<tr>
- <td>cryptoAlgorithm</td>
- <td>String</td>
- <td>Y</td>
- <td>
- Defines the JCE provider to be used. Depending
- on your environement you leave it empty to get
- an appropriate implementation automatically or
- use "SunJCE" or "BC"
- </td>
- </tr>
- <tr>
<td>cryptoSalt</td>
<td>String</td>
<td>Y</td>
@@ -94,7 +81,6 @@
<subsection name="Component Configuration Example">
<source><![CDATA[
<PBEService>
- <cryptoAlgorithm>PBEWithMD5AndDES</cryptoAlgorithm>
<cryptoSalt>4463657541544141</cryptoSalt>
<cyrptoCount>20</cyrptoCount>
<cryptoProvider></cryptoProvider>
Modified: turbine/fulcrum/trunk/pbe/xdocs/index.xml
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/pbe/xdocs/index.xml?rev=678700&r1=678699&r2=678700&view=diff
==============================================================================
--- turbine/fulcrum/trunk/pbe/xdocs/index.xml (original)
+++ turbine/fulcrum/trunk/pbe/xdocs/index.xml Tue Jul 22 03:09:30 2008
@@ -19,41 +19,26 @@
-->
<document>
-
<properties>
<title>Fulcrum PBE Service</title>
<author email="siegfried.goeschl@it20one.at">Siegfried Goeschl</author>
</properties>
-
<body>
-
<section name="Overview">
-
<p>
The PBEService (Password Based Encryption Service) supports encryption
- and decryption of resources using JCA (Java Crypto Architecture)
- and JCE (Java Crpyto Extension) providing
+ and decryption of resources using JCA (Java Crypto Architecture) providing
<ul>
<li>method to create more or less secure passwords</li>
<li>creation of cipher streams for transparent encryption/decryption</li>
<li>generic encryption/decryption methods</li>
</ul>
</p>
-
<p>
- The implementation uses PBEWithMD5AndTripleDES and was inspired
+ The implementation uses PBEWithMD5AndDES and was inspired
by Pankaj Kumar and his excellent book
<a href="http://www.j2ee-security.net/">J2EE Security</a>.
</p>
-
-
- <p>
- The implementation depends directly on the YAAFI libraries since
- the actual implementation is found there.
- </p>
-
</section>
-
</body>
-
</document>