geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From caij...@apache.org
Subject svn commit: r896316 - in /geronimo/server/branches/2.2/framework: configs/rmi-naming/src/main/plan/ modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/ modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/j...
Date Wed, 06 Jan 2010 03:12:17 GMT
Author: caijunj
Date: Wed Jan  6 03:12:17 2010
New Revision: 896316

URL: http://svn.apache.org/viewvc?rev=896316&view=rev
Log:
GERONIMO-3003 - Encrypt password strings in deployment plans: add a sub command in deploy
command to encrypt a given string for use in deployment plan

Added:
    geronimo/server/branches/2.2/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/EncryptCommandMetaData.java
  (with props)
    geronimo/server/branches/2.2/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandEncrypt.java
  (with props)
Modified:
    geronimo/server/branches/2.2/framework/configs/rmi-naming/src/main/plan/plan.xml
    geronimo/server/branches/2.2/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployerCLParser.java
    geronimo/server/branches/2.2/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/JMXDeploymentManager.java
    geronimo/server/branches/2.2/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployTool.java
    geronimo/server/branches/2.2/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/util/ConfiguredEncryption.java

Modified: geronimo/server/branches/2.2/framework/configs/rmi-naming/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/framework/configs/rmi-naming/src/main/plan/plan.xml?rev=896316&r1=896315&r2=896316&view=diff
==============================================================================
--- geronimo/server/branches/2.2/framework/configs/rmi-naming/src/main/plan/plan.xml (original)
+++ geronimo/server/branches/2.2/framework/configs/rmi-naming/src/main/plan/plan.xml Wed Jan
 6 03:12:17 2010
@@ -61,5 +61,11 @@
         <attribute name="maxPoolSize">500</attribute>
         <attribute name="poolName">DefaultThreadPool</attribute>
     </gbean>
+    
+    <gbean name="ConfiguredEncryption" class="org.apache.geronimo.system.util.ConfiguredEncryption">
+        <reference name="ServerInfo">
+            <name>ServerInfo</name>
+        </reference>
+    </gbean>
 
 </module>

Modified: geronimo/server/branches/2.2/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployerCLParser.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployerCLParser.java?rev=896316&r1=896315&r2=896316&view=diff
==============================================================================
--- geronimo/server/branches/2.2/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployerCLParser.java
(original)
+++ geronimo/server/branches/2.2/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployerCLParser.java
Wed Jan  6 03:12:17 2010
@@ -89,6 +89,7 @@
         commandMetaData.add(InstallPluginCommandMetaData.META_DATA);
         commandMetaData.add(HelpCommandMetaData.META_DATA);
         commandMetaData.add(InstallLibraryCommandMetaData.META_DATA);
+        commandMetaData.add(EncryptCommandMetaData.META_DATA);
 
         addURI();
         addHost();

Added: geronimo/server/branches/2.2/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/EncryptCommandMetaData.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/EncryptCommandMetaData.java?rev=896316&view=auto
==============================================================================
--- geronimo/server/branches/2.2/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/EncryptCommandMetaData.java
(added)
+++ geronimo/server/branches/2.2/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/EncryptCommandMetaData.java
Wed Jan  6 03:12:17 2010
@@ -0,0 +1,36 @@
+/**
+ *  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.
+ */
+package org.apache.geronimo.cli.deployer;
+
+
+/**
+ * @version $Rev: 515007 $ $Date: 2007-03-06 18:26:41 +1100 (Tue, 06 Mar 2007) $
+ */
+public class EncryptCommandMetaData extends BaseCommandMetaData  {
+    public static final CommandMetaData META_DATA = new EncryptCommandMetaData();
+    
+    private EncryptCommandMetaData() {
+        super("encrypt", "2. Other Commands", "",
+                "Encrypt a string for use in deployment plan.\n" +
+                "If you want to use a running server to do the encryption (so that\n" +
+                "you will use the encryption setting of that server, make sure the\n" +
+                "server is running and specify the general options to connect to it.\n" +
+                "If you want to use the common simple encryption, use the --offline\n" +
+                "option. No running server is required in this case.");
+    }
+
+}

Propchange: geronimo/server/branches/2.2/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/EncryptCommandMetaData.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: geronimo/server/branches/2.2/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/JMXDeploymentManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/JMXDeploymentManager.java?rev=896316&r1=896315&r2=896316&view=diff
==============================================================================
--- geronimo/server/branches/2.2/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/JMXDeploymentManager.java
(original)
+++ geronimo/server/branches/2.2/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/JMXDeploymentManager.java
Wed Jan  6 03:12:17 2010
@@ -337,4 +337,8 @@
     public void setInPlace(boolean inPlace) {
         commandContext.setInPlace(inPlace);
     }
+    
+    public Kernel getKernel() {
+        return kernel;
+    }
 }

Added: geronimo/server/branches/2.2/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.2/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandEncrypt.java?rev=896316&view=auto
==============================================================================
--- geronimo/server/branches/2.2/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandEncrypt.java
(added)
+++ geronimo/server/branches/2.2/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandEncrypt.java
Wed Jan  6 03:12:17 2010
@@ -0,0 +1,65 @@
+/**
+ *  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.
+ */
+
+package org.apache.geronimo.deployment.cli;
+
+import javax.enterprise.deploy.spi.DeploymentManager;
+
+import jline.ConsoleReader;
+
+import org.apache.geronimo.cli.deployer.CommandArgs;
+import org.apache.geronimo.common.DeploymentException;
+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;
+
+/**
+ * The CLI command to encrypt a given string.
+ *
+ * @version $Rev: 617588 $ $Date: 2008-02-02 02:20:07 +0800 (Sat, 02 Feb 2008) $
+ */
+public class CommandEncrypt extends AbstractCommand {
+
+    public void execute(ConsoleReader consoleReader, ServerConnection connection, CommandArgs
commandArgs) throws DeploymentException {
+        try {
+            if (commandArgs.getArgs().length == 0) {
+                consoleReader.printString(DeployUtils.reformat("Please enter the string to
be encrypted after the encrypt command.", 4, 72));
+                return;
+            }
+            if (commandArgs.getArgs().length > 1) {
+                consoleReader.printString(DeployUtils.reformat("Too many parameters. Only
the first string will be encrypted.", 4, 72));
+            }
+            
+            consoleReader.printString(DeployUtils.reformat("String to encrypt: "+commandArgs.getArgs()[0],
4, 72));
+            DeploymentManager dm = connection.getDeploymentManager();
+            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"});
+                consoleReader.printString(DeployUtils.reformat("Online encryption result:
"+ret, 4, 72));
+            } else {
+                // Offline encryption
+                Object ret = EncryptionManager.encrypt(commandArgs.getArgs()[0]);
+                consoleReader.printString(DeployUtils.reformat("Offline encryption result:
"+ret, 4, 72));
+            }
+            consoleReader.printNewline();
+        } catch (Exception e) {
+            throw new DeploymentException("Unable to reach the server to do the encryption.",
e);
+        }
+    }
+}

Propchange: geronimo/server/branches/2.2/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandEncrypt.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: geronimo/server/branches/2.2/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployTool.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployTool.java?rev=896316&r1=896315&r2=896316&view=diff
==============================================================================
--- geronimo/server/branches/2.2/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployTool.java
(original)
+++ geronimo/server/branches/2.2/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployTool.java
Wed Jan  6 03:12:17 2010
@@ -32,12 +32,15 @@
 
 import javax.enterprise.deploy.spi.factories.DeploymentFactory;
 
+import jline.ConsoleReader;
+
 import org.apache.geronimo.cli.deployer.CommandArgs;
 import org.apache.geronimo.cli.deployer.CommandFileCommandMetaData;
 import org.apache.geronimo.cli.deployer.CommandMetaData;
 import org.apache.geronimo.cli.deployer.DeployCommandMetaData;
 import org.apache.geronimo.cli.deployer.DeployerCLParser;
 import org.apache.geronimo.cli.deployer.DistributeCommandMetaData;
+import org.apache.geronimo.cli.deployer.EncryptCommandMetaData;
 import org.apache.geronimo.cli.deployer.InstallLibraryCommandMetaData;
 import org.apache.geronimo.cli.deployer.InstallPluginCommandMetaData;
 import org.apache.geronimo.cli.deployer.ListModulesCommandMetaData;
@@ -57,8 +60,6 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import jline.ConsoleReader;
-
 
 /**
  * The main class for the CLI deployer.  Handles chunking the input arguments
@@ -91,6 +92,7 @@
         commands.put(SearchPluginsCommandMetaData.META_DATA, new CommandListConfigurations());
         commands.put(InstallPluginCommandMetaData.META_DATA, new CommandInstallCAR());
         commands.put(InstallLibraryCommandMetaData.META_DATA, new CommandInstallLibrary());
+        commands.put(EncryptCommandMetaData.META_DATA, new CommandEncrypt());
     }
 
     private boolean failed = false;

Modified: geronimo/server/branches/2.2/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/util/ConfiguredEncryption.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/util/ConfiguredEncryption.java?rev=896316&r1=896315&r2=896316&view=diff
==============================================================================
--- geronimo/server/branches/2.2/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/util/ConfiguredEncryption.java
(original)
+++ geronimo/server/branches/2.2/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/util/ConfiguredEncryption.java
Wed Jan  6 03:12:17 2010
@@ -58,6 +58,10 @@
 
 
     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);
@@ -100,7 +104,9 @@
     }
 
     public void doStart() throws Exception {
-        EncryptionManager.setEncryptionPrefix("{Configured}", this);
+        if (spec != null) {
+            EncryptionManager.setEncryptionPrefix("{Configured}", this);
+        }
     }
 
     public void doStop() throws Exception {
@@ -112,6 +118,10 @@
     protected SecretKeySpec getSecretKeySpec() {
         return spec;
     }
+    
+    public String encrypt(String text) {
+        return EncryptionManager.encrypt(text);
+    }
 
     public static final GBeanInfo GBEAN_INFO;
 
@@ -120,6 +130,7 @@
         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();
     }
 



Mime
View raw message