You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by rw...@apache.org on 2010/10/13 10:53:32 UTC
svn commit: r1022033 - in /geronimo/server/trunk/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/
modules/geron...
Author: rwonly
Date: Wed Oct 13 08:53:31 2010
New Revision: 1022033
URL: http://svn.apache.org/viewvc?rev=1022033&view=rev
Log:
GERONIMO-5638 Remove the encrypt(String) method from ConfiguredEncryption
Added:
geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/util/EncryptionManagerWrapperGBean.java (with props)
Modified:
geronimo/server/trunk/framework/configs/rmi-naming/src/main/plan/plan.xml
geronimo/server/trunk/framework/modules/geronimo-crypto/src/main/java/org/apache/geronimo/crypto/EncryptionManager.java
geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandEncrypt.java
geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/util/ConfiguredEncryption.java
Modified: geronimo/server/trunk/framework/configs/rmi-naming/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/configs/rmi-naming/src/main/plan/plan.xml?rev=1022033&r1=1022032&r2=1022033&view=diff
==============================================================================
--- geronimo/server/trunk/framework/configs/rmi-naming/src/main/plan/plan.xml (original)
+++ geronimo/server/trunk/framework/configs/rmi-naming/src/main/plan/plan.xml Wed Oct 13 08:53:31 2010
@@ -58,10 +58,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/trunk/framework/modules/geronimo-crypto/src/main/java/org/apache/geronimo/crypto/EncryptionManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-crypto/src/main/java/org/apache/geronimo/crypto/EncryptionManager.java?rev=1022033&r1=1022032&r2=1022033&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-crypto/src/main/java/org/apache/geronimo/crypto/EncryptionManager.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-crypto/src/main/java/org/apache/geronimo/crypto/EncryptionManager.java Wed Oct 13 08:53:31 2010
@@ -49,7 +49,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.
@@ -58,8 +58,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);
}
@@ -74,14 +74,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/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandEncrypt.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandEncrypt.java?rev=1022033&r1=1022032&r2=1022033&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandEncrypt.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandEncrypt.java Wed Oct 13 08:53:31 2010
@@ -44,7 +44,7 @@ public class CommandEncrypt extends Abst
if (!isOffline(connection)) {
// Online encryption
Kernel k = getKernel(connection);
- 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/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/util/ConfiguredEncryption.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/util/ConfiguredEncryption.java?rev=1022033&r1=1022032&r2=1022033&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/util/ConfiguredEncryption.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/util/ConfiguredEncryption.java Wed Oct 13 08:53:31 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/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/util/EncryptionManagerWrapperGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/util/EncryptionManagerWrapperGBean.java?rev=1022033&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/util/EncryptionManagerWrapperGBean.java (added)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/util/EncryptionManagerWrapperGBean.java Wed Oct 13 08:53:31 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/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/util/EncryptionManagerWrapperGBean.java
------------------------------------------------------------------------------
svn:eol-style = native