geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwo...@apache.org
Subject svn commit: r1022007 - in /geronimo/server/branches/2.1/framework: configs/rmi-naming/src/main/plan/ modules/geronimo-crypto/src/main/java/org/apache/geronimo/crypto/ modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/ module...
Date Wed, 13 Oct 2010 06:33:46 GMT
Author: rwonly
Date: Wed Oct 13 06:33:45 2010
New Revision: 1022007

URL: http://svn.apache.org/viewvc?rev=1022007&view=rev
Log:
GERONIMO-5638 Remove the encrypt(String) method from ConfiguredEncryption

Added:
    geronimo/server/branches/2.1/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/util/EncryptionManagerWrapperGBean.java
  (with props)
Modified:
    geronimo/server/branches/2.1/framework/configs/rmi-naming/src/main/plan/plan.xml
    geronimo/server/branches/2.1/framework/modules/geronimo-crypto/src/main/java/org/apache/geronimo/crypto/EncryptionManager.java
    geronimo/server/branches/2.1/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandEncrypt.java
    geronimo/server/branches/2.1/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/util/ConfiguredEncryption.java

Modified: geronimo/server/branches/2.1/framework/configs/rmi-naming/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/configs/rmi-naming/src/main/plan/plan.xml?rev=1022007&r1=1022006&r2=1022007&view=diff
==============================================================================
--- geronimo/server/branches/2.1/framework/configs/rmi-naming/src/main/plan/plan.xml (original)
+++ geronimo/server/branches/2.1/framework/configs/rmi-naming/src/main/plan/plan.xml Wed Oct
13 06:33:45 2010
@@ -62,10 +62,7 @@
         <attribute name="poolName">DefaultThreadPool</attribute>
     </gbean>
     
-    <gbean name="ConfiguredEncryption" class="org.apache.geronimo.system.util.ConfiguredEncryption">
-        <reference name="ServerInfo">
-            <name>ServerInfo</name>
-        </reference>
+    <gbean name="EncryptionManagerWrapper" class="org.apache.geronimo.system.util.EncryptionManagerWrapperGBean">
     </gbean>
 
 </module>

Modified: geronimo/server/branches/2.1/framework/modules/geronimo-crypto/src/main/java/org/apache/geronimo/crypto/EncryptionManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/modules/geronimo-crypto/src/main/java/org/apache/geronimo/crypto/EncryptionManager.java?rev=1022007&r1=1022006&r2=1022007&view=diff
==============================================================================
--- geronimo/server/branches/2.1/framework/modules/geronimo-crypto/src/main/java/org/apache/geronimo/crypto/EncryptionManager.java
(original)
+++ geronimo/server/branches/2.1/framework/modules/geronimo-crypto/src/main/java/org/apache/geronimo/crypto/EncryptionManager.java
Wed Oct 13 06:33:45 2010
@@ -50,7 +50,7 @@ public class EncryptionManager {
         ENCRYPTORS.put("{Standard}", SimpleEncryption.INSTANCE);
     }
 
-    private static String encryptionPrefix = SIMPLE_ENCRYPTION_PREFIX;
+    private static String activeEncryptionPrefix = SIMPLE_ENCRYPTION_PREFIX;
 
     /**
      * Encryption instances should call this to register themselves.
@@ -59,8 +59,8 @@ public class EncryptionManager {
      * @param encryption Encryption instance to do the work.
      */
     public synchronized static void setEncryptionPrefix(String prefix, Encryption encryption)
{
-        if (SIMPLE_ENCRYPTION_PREFIX.equals(encryptionPrefix)) {
-            encryptionPrefix = prefix;
+        if (activeEncryptionPrefix.equals(SIMPLE_ENCRYPTION_PREFIX)) {  //only can be set
once?
+            activeEncryptionPrefix = prefix;
         }
         ENCRYPTORS.put(prefix, encryption);
     }
@@ -75,14 +75,14 @@ public class EncryptionManager {
     public static String encrypt(Serializable source) {
         if (source instanceof String) {
             String sourceString = (String) source;
-            if (sourceString.startsWith(encryptionPrefix)) {
+            if (sourceString.startsWith(activeEncryptionPrefix)) {
                 return (String) source;
             } else if (sourceString.startsWith("{")) {
                 source = decrypt(sourceString);
             }
         }
-        Encryption encryption = ENCRYPTORS.get(encryptionPrefix);
-        return encryptionPrefix + encryption.encrypt(source);
+        Encryption activeEncryption = ENCRYPTORS.get(activeEncryptionPrefix);
+        return activeEncryptionPrefix + activeEncryption.encrypt(source);
     }
 
     /**

Modified: geronimo/server/branches/2.1/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandEncrypt.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandEncrypt.java?rev=1022007&r1=1022006&r2=1022007&view=diff
==============================================================================
--- geronimo/server/branches/2.1/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandEncrypt.java
(original)
+++ geronimo/server/branches/2.1/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandEncrypt.java
Wed Oct 13 06:33:45 2010
@@ -26,7 +26,7 @@ import org.apache.geronimo.common.Deploy
 import org.apache.geronimo.crypto.EncryptionManager;
 import org.apache.geronimo.deployment.plugin.jmx.RemoteDeploymentManager;
 import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.system.util.ConfiguredEncryption;
+import org.apache.geronimo.system.util.EncryptionManagerWrapperGBean;
 
 /**
  * The CLI command to encrypt a given string.
@@ -42,7 +42,7 @@ public class CommandEncrypt extends Abst
             if (dm instanceof RemoteDeploymentManager) {
                 // Online encryption
                 Kernel k = ((RemoteDeploymentManager)dm).getKernel();
-                Object ret = k.invoke(ConfiguredEncryption.class, "encrypt", new Object[]
{commandArgs.getArgs()[0]}, new String[] {"java.lang.String"});
+                Object ret = k.invoke(EncryptionManagerWrapperGBean.class, "encrypt", new
Object[] {commandArgs.getArgs()[0]}, new String[] {"java.io.Serializable"});
                 consoleReader.printString(DeployUtils.reformat("Online encryption result:
"+ret, 4, 72));
             } else {
                 // Offline encryption

Modified: geronimo/server/branches/2.1/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/util/ConfiguredEncryption.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/util/ConfiguredEncryption.java?rev=1022007&r1=1022006&r2=1022007&view=diff
==============================================================================
--- geronimo/server/branches/2.1/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/util/ConfiguredEncryption.java
(original)
+++ geronimo/server/branches/2.1/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/util/ConfiguredEncryption.java
Wed Oct 13 06:33:45 2010
@@ -56,12 +56,7 @@ public class ConfiguredEncryption extend
 
     private final SecretKeySpec spec;
 
-
     public ConfiguredEncryption(String path, ServerInfo serverInfo) throws IOException, ClassNotFoundException
{
-        if (path == null || "".equals(path)) {
-            spec = null;
-            return;
-        }
         File location = serverInfo.resolve(path);
         if (location.exists()) {
             FileInputStream in = new FileInputStream(location);
@@ -104,9 +99,7 @@ public class ConfiguredEncryption extend
     }
 
     public void doStart() throws Exception {
-        if (spec != null) {
-            EncryptionManager.setEncryptionPrefix("{Configured}", this);
-        }
+        EncryptionManager.setEncryptionPrefix("{Configured}", this);
     }
 
     public void doStop() throws Exception {
@@ -119,10 +112,6 @@ public class ConfiguredEncryption extend
         return spec;
     }
     
-    public String encrypt(String text) {
-        return EncryptionManager.encrypt(text);
-    }
-
     public static final GBeanInfo GBEAN_INFO;
 
     static {
@@ -130,7 +119,6 @@ public class ConfiguredEncryption extend
         infoBuilder.addAttribute("path", String.class, true, true);
         infoBuilder.addReference("ServerInfo", ServerInfo.class, "GBean");
         infoBuilder.setConstructor(new String[]{"path", "ServerInfo"});
-        infoBuilder.addOperation("encrypt", new Class[] {String.class}, "java.lang.String");
         GBEAN_INFO = infoBuilder.getBeanInfo();
     }
 

Added: geronimo/server/branches/2.1/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/util/EncryptionManagerWrapperGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/util/EncryptionManagerWrapperGBean.java?rev=1022007&view=auto
==============================================================================
--- geronimo/server/branches/2.1/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/util/EncryptionManagerWrapperGBean.java
(added)
+++ geronimo/server/branches/2.1/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/util/EncryptionManagerWrapperGBean.java
Wed Oct 13 06:33:45 2010
@@ -0,0 +1,33 @@
+package org.apache.geronimo.system.util;
+
+import java.io.Serializable;
+
+import org.apache.geronimo.crypto.EncryptionManager;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+
+
+public class EncryptionManagerWrapperGBean {
+
+    public String encrypt(Serializable source) {
+        return EncryptionManager.encrypt(source);
+    }
+
+    public Serializable decrypt(String source) {
+        return EncryptionManager.decrypt(source);
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(EncryptionManagerWrapperGBean.class,
"GBean");
+        infoBuilder.addOperation("encrypt", new Class[] {Serializable.class}, "java.io.Serializable");
+        infoBuilder.addOperation("decrypt", new Class[] {String.class}, "java.lang.String");
+        GBEAN_INFO = infoBuilder.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+    
+}

Propchange: geronimo/server/branches/2.1/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/util/EncryptionManagerWrapperGBean.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message