You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2011/06/24 09:34:30 UTC
svn commit: r1139183 - in
/openejb/trunk/openejb3/examples/datasource-ciphered-password: ./ src/main/
src/test/java/org/superbiz/
src/test/resources/META-INF/org.apache.openejb.resource.jdbc.PasswordCipher/
Author: rmannibucau
Date: Fri Jun 24 07:34:30 2011
New Revision: 1139183
URL: http://svn.apache.org/viewvc?rev=1139183&view=rev
Log:
adding readme for datasource-ciphered-password example
Added:
openejb/trunk/openejb3/examples/datasource-ciphered-password/README.md
openejb/trunk/openejb3/examples/datasource-ciphered-password/src/test/java/org/superbiz/DataSourceCipheredExampleTest.java
- copied, changed from r1139172, openejb/trunk/openejb3/examples/datasource-ciphered-password/src/test/java/org/superbiz/DataSourceCipheredExample.java
Removed:
openejb/trunk/openejb3/examples/datasource-ciphered-password/src/main/
openejb/trunk/openejb3/examples/datasource-ciphered-password/src/test/java/org/superbiz/DataSourceCipheredExample.java
Modified:
openejb/trunk/openejb3/examples/datasource-ciphered-password/src/test/resources/META-INF/org.apache.openejb.resource.jdbc.PasswordCipher/reverse
Added: openejb/trunk/openejb3/examples/datasource-ciphered-password/README.md
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/datasource-ciphered-password/README.md?rev=1139183&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/datasource-ciphered-password/README.md (added)
+++ openejb/trunk/openejb3/examples/datasource-ciphered-password/README.md Fri Jun 24 07:34:30 2011
@@ -0,0 +1,60 @@
+# Datasource Ciphered Password example
+
+This example shows how to use a ciphered password with an OpenEJB datasource.
+
+It shows how to implement its own encryption too.
+
+# Configuration
+
+The configuration is simply a datasource configuration with an additionnal parameter
+"PasswordCipher" to specify the encryption to use.
+
+Example using Static3DES encryption:
+
+ properties.setProperty("ProtectedDatasource", "new://Resource?type=DataSource");
+ properties.setProperty("ProtectedDatasource.JdbcDriver", "org.hsqldb.jdbcDriver");
+ properties.setProperty("ProtectedDatasource.JdbcUrl", "jdbc:hsqldb:mem:protected");
+ properties.setProperty("ProtectedDatasource.UserName", "user");
+ // the plain text password is "YouLLN3v3rFindM3"
+ properties.setProperty("ProtectedDatasource.Password", "fEroTNXjaL5SOTyRQ92x3DNVS/ksbtgs");
+ properties.setProperty("ProtectedDatasource.PasswordCipher", "Static3DES");
+ properties.setProperty("ProtectedDatasource.JtaManaged", "true");
+
+
+# Using its own implementation
+
+The example implement a reverse encryption which simply reverse the password to encrypt/decrypt.
+
+The implementation is done with commons-lang library:
+
+ public static class ReverseEncryption implements PasswordCipher {
+ @Override public char[] encrypt(String plainPassword) {
+ return StringUtils.reverse(plainPassword).toCharArray();
+ }
+
+ @Override public String decrypt(char[] encryptedPassword) {
+ return new String(encrypt(new String(encryptedPassword)));
+ }
+ }
+
+
+To be functional it needs the file META-INF/org.apache.openejb.resource.jdbc.PasswordCipher/reverse.
+
+The file name (reverse) define the encryption name to use for the PasswordCipher parameter.
+
+This file simply contains the implementation class of the encryption.
+
+Then you simply declare this encryption for your datasource:
+
+ properties.setProperty("ProtectedDatasource", "new://Resource?type=DataSource");
+ properties.setProperty("ProtectedDatasource.JdbcDriver", "org.hsqldb.jdbcDriver");
+ properties.setProperty("ProtectedDatasource.JdbcUrl", "jdbc:hsqldb:mem:protected");
+ properties.setProperty("ProtectedDatasource.UserName", USER);
+ properties.setProperty("ProtectedDatasource.Password", "3MdniFr3v3NLLuoY");
+ properties.setProperty("ProtectedDatasource.PasswordCipher", "reverse");
+ properties.setProperty("ProtectedDatasource.JtaManaged", "true");
+
+# Documentation
+
+For more information please see the [OpenEJB documentation](http://openejb.apache.org/3.0/datasource-password-encryption.html)
+
Copied: openejb/trunk/openejb3/examples/datasource-ciphered-password/src/test/java/org/superbiz/DataSourceCipheredExampleTest.java (from r1139172, openejb/trunk/openejb3/examples/datasource-ciphered-password/src/test/java/org/superbiz/DataSourceCipheredExample.java)
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/datasource-ciphered-password/src/test/java/org/superbiz/DataSourceCipheredExampleTest.java?p2=openejb/trunk/openejb3/examples/datasource-ciphered-password/src/test/java/org/superbiz/DataSourceCipheredExampleTest.java&p1=openejb/trunk/openejb3/examples/datasource-ciphered-password/src/test/java/org/superbiz/DataSourceCipheredExample.java&r1=1139172&r2=1139183&rev=1139183&view=diff
==============================================================================
--- openejb/trunk/openejb3/examples/datasource-ciphered-password/src/test/java/org/superbiz/DataSourceCipheredExample.java (original)
+++ openejb/trunk/openejb3/examples/datasource-ciphered-password/src/test/java/org/superbiz/DataSourceCipheredExampleTest.java Fri Jun 24 07:34:30 2011
@@ -10,7 +10,6 @@ import javax.naming.Context;
import javax.sql.DataSource;
import org.apache.commons.lang.StringUtils;
import org.apache.openejb.resource.jdbc.PasswordCipher;
-import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -19,8 +18,8 @@ import static junit.framework.Assert.ass
/**
* @author Romain Manni-Bucau
*/
-public class DataSourceCipheredExample {
- private static final String USER = DataSourceCipheredExample.class.getSimpleName();
+public class DataSourceCipheredExampleTest {
+ private static final String USER = DataSourceCipheredExampleTest.class.getSimpleName();
private static final String PASSWORD = "YouLLN3v3rFindM3";
private static final String DATASOURCE_URL = "jdbc:hsqldb:mem:protected";
Modified: openejb/trunk/openejb3/examples/datasource-ciphered-password/src/test/resources/META-INF/org.apache.openejb.resource.jdbc.PasswordCipher/reverse
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/datasource-ciphered-password/src/test/resources/META-INF/org.apache.openejb.resource.jdbc.PasswordCipher/reverse?rev=1139183&r1=1139182&r2=1139183&view=diff
==============================================================================
--- openejb/trunk/openejb3/examples/datasource-ciphered-password/src/test/resources/META-INF/org.apache.openejb.resource.jdbc.PasswordCipher/reverse (original)
+++ openejb/trunk/openejb3/examples/datasource-ciphered-password/src/test/resources/META-INF/org.apache.openejb.resource.jdbc.PasswordCipher/reverse Fri Jun 24 07:34:30 2011
@@ -1 +1 @@
-org.superbiz.DataSourceCipheredExample$ReverseEncryption
+org.superbiz.DataSourceCipheredExampleTest$ReverseEncryption