[jboss-svn-commits] JBL Code SVN: r5002 - labs/jbossesb/trunk/ESBCore/services/src/org/jboss/soa/esb/internal/core/objectstore

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Jul 10 18:31:18 EDT 2006


Author: estebanschifman
Date: 2006-07-10 18:31:16 -0400 (Mon, 10 Jul 2006)
New Revision: 5002

Modified:
   labs/jbossesb/trunk/ESBCore/services/src/org/jboss/soa/esb/internal/core/objectstore/DaoSnapTable.java
Log:
Obtain encryption class dynamically from the contents of the EsbSysProps.ENCRYPT_FACTORY_CLASS system property

Modified: labs/jbossesb/trunk/ESBCore/services/src/org/jboss/soa/esb/internal/core/objectstore/DaoSnapTable.java
===================================================================
--- labs/jbossesb/trunk/ESBCore/services/src/org/jboss/soa/esb/internal/core/objectstore/DaoSnapTable.java	2006-07-10 22:28:41 UTC (rev 5001)
+++ labs/jbossesb/trunk/ESBCore/services/src/org/jboss/soa/esb/internal/core/objectstore/DaoSnapTable.java	2006-07-10 22:31:16 UTC (rev 5002)
@@ -22,13 +22,16 @@
 
 package org.jboss.soa.esb.internal.core.objectstore;
 
-import org.jboss.soa.esb.util.*;
-import org.jboss.soa.esb.helpers.persist.*;
-import org.jboss.soa.esb.services.crypto.*;
+import java.lang.reflect.Method;
 import java.sql.*;
 import org.apache.log4j.*;
 
+import org.jboss.soa.esb.common.*;
+import org.jboss.soa.esb.util.*;
+import org.jboss.soa.esb.helpers.persist.*;
+import org.jboss.soa.esb.services.*;
 
+
 /**
  * Data access object for all SQL tables that the ROS (Rosetta Object Store)
  * uses as snapshot tables
@@ -217,14 +220,56 @@
       }
     } //________________________________
 
-    private byte[] seeCrypt(byte[] p_ba,long p_l) throws Exception
+    private Iencryption m_oMangler;
+    private static final Object s_oSync = new Integer(0);
+    private Iencryption getMangler() throws Exception
+    	{ return getMangler(null); }
+    private Iencryption getMangler(Object p_oFactParms) throws Exception
+    {	if (null!=m_oMangler)
+    		return m_oMangler;
+    	synchronized(s_oSync)
+    	{	if (null!=m_oMangler) 
+    				return m_oMangler;
+
+    		String sFactoryName = EsbSysProps.getEncryptionFactoryClass();
+    		Class	oFactClass = DefaultEncryptionFactory.class;
+    		if (null!=sFactoryName)
+    			oFactClass = Class.forName(sFactoryName);
+    		Method	oMth  = oFactClass.getMethod("getEncrypter"
+    			,new Class[] {Object.class});
+    		m_oMangler = (Iencryption) oMth.invoke(null,p_oFactParms);
+    	}
+    	
+    	return m_oMangler;
+    } //________________________________
+    
+    /**
+     * Encrypt if you have to or just return your first argument
+     * <p />
+     * You'll probably override this method if you have your own Iencryption implementation
+     * @param p_ba	the byte array to be encrypted (if the store so indicates)
+     * @param p_l   an object for the encrypt method of the Iencryption object
+     * @return      the value to be stored in the column
+     * @throws Exception
+     */
+    
+    protected byte[] seeCrypt(byte[] p_ba,Object p_l) throws Exception
     { if (! m_oST.isEncrypted())    return p_ba;
-      return Mangler.encrypt(p_ba,p_l);
+      return getMangler().encrypt(p_ba,p_l);
     } //________________________________
 
-    private byte[] seeDecrypt(byte[] p_ba,long p_l) throws Exception
+    /**
+     * Decrypt if you have to or just return your first argument
+     * <p />
+     * You'll probably override this method if you have your own Iencryption implementation
+     * @param p_ba	the byte array to be decrypted (if the store so indicates)
+     * @param p_l   an object for the decrypt method of the Iencryption object
+     * @return      the value to be used to construct the XML string
+     * @throws Exception
+     */
+    protected byte[] seeDecrypt(byte[] p_ba,Object p_l) throws Exception
     { if (! m_oST.isEncrypted())  return p_ba;
-      return Mangler.decrypt(p_ba,p_l);
+      return getMangler().decrypt(p_ba,p_l);
     } //________________________________
 
     /**




More information about the jboss-svn-commits mailing list