geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r963923 - in /geronimo/server/trunk/framework/modules: geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/ geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/ geronimo-shell-base/src/main/java/org/apache/geronimo...
Date Wed, 14 Jul 2010 02:02:42 GMT
Author: gawor
Date: Wed Jul 14 02:02:41 2010
New Revision: 963923

URL: http://svn.apache.org/viewvc?rev=963923&view=rev
Log:
GERONIMO-5421: GoGo command for unlock-keystore plus other related fixes and improvements.
Initial patch from Chi Runhua

Added:
    geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/UnlockKeystoreCommand.java
  (with props)
Modified:
    geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/UnlockKeystoreCommandMetaData.java
    geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/AbstractCommand.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-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandUnlockKeystore.java
    geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/OfflineServerConnection.java
    geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/resources/OSGI-INF/blueprint/shell-deploy.xml

Modified: geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/UnlockKeystoreCommandMetaData.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/UnlockKeystoreCommandMetaData.java?rev=963923&r1=963922&r2=963923&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/UnlockKeystoreCommandMetaData.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/UnlockKeystoreCommandMetaData.java
Wed Jul 14 02:02:41 2010
@@ -26,7 +26,7 @@ public class UnlockKeystoreCommandMetaDa
     public static final CommandMetaData META_DATA = new UnlockKeystoreCommandMetaData();
 
     private UnlockKeystoreCommandMetaData() {
-        super("unlockKeystore", "2. Other Commands", "[keyStoreName][AliasName1][AliasName2]....",
+        super("unlock-keystore", "2. Other Commands", "[keyStoreName][AliasName1][AliasName2]....",
                 "Command to unlock a keystore and its associated private key.\n" +
                 "The usage of javax.net.ssl.keyStorePassword and javax.net.ssl.trustStorePassword
" +
                 "in a command line has been deprecated.\n"+

Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/AbstractCommand.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/AbstractCommand.java?rev=963923&r1=963922&r2=963923&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/AbstractCommand.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/AbstractCommand.java
Wed Jul 14 02:02:41 2010
@@ -30,6 +30,8 @@ import javax.enterprise.deploy.spi.statu
 import javax.enterprise.deploy.spi.status.ProgressObject;
 
 import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.deployment.plugin.jmx.JMXDeploymentManager;
+import org.apache.geronimo.kernel.Kernel;
 
 /**
  * Base class for CLI deployer commands.  Tracks some simple properties and
@@ -46,6 +48,26 @@ public abstract class AbstractCommand im
         return false;
     }
 
+    protected boolean isOffline(ServerConnection connection) {
+        if (connection instanceof OfflineServerConnection) {
+            return ((OfflineServerConnection) connection).isOfflineDeployerStarted();
+        } else {
+            return false;
+        }
+    }
+    
+    protected Kernel getKernel(ServerConnection connection) {
+        Kernel kernel = null;
+        DeploymentManager dm = connection.getDeploymentManager();
+        if (dm instanceof JMXDeploymentManager) {
+            kernel = ((JMXDeploymentManager) dm).getKernel();
+        }
+        if (kernel == null) {
+            throw new NullPointerException("Could not get kernel instance");
+        }
+        return kernel;
+    }
+    
     protected void emit(ConsoleReader out, String message) throws IOException {
         out.printString(DeployUtils.reformat(message, 4, 72));
         out.flushConsole();

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=963923&r1=963922&r2=963923&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 Jul 14 02:02:41 2010
@@ -17,12 +17,9 @@
 
 package org.apache.geronimo.deployment.cli;
 
-import javax.enterprise.deploy.spi.DeploymentManager;
-
 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;
 
@@ -44,10 +41,9 @@ public class CommandEncrypt extends Abst
             }
             
             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();
+            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"});
                 consoleReader.printString(DeployUtils.reformat("Online encryption result:
"+ret, 4, 72));
             } else {

Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandUnlockKeystore.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandUnlockKeystore.java?rev=963923&r1=963922&r2=963923&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandUnlockKeystore.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandUnlockKeystore.java
Wed Jul 14 02:02:41 2010
@@ -24,12 +24,9 @@ import java.util.Iterator;
 import java.util.Properties;
 import java.util.Set;
 
-import javax.enterprise.deploy.spi.DeploymentManager;
-
 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.gbean.AbstractName;
 import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
@@ -54,11 +51,7 @@ public class CommandUnlockKeystore exten
         if (args.length == 0) {
             throw new DeploymentException("Specify the key store name to be unlocked");
         }
-        DeploymentManager dm = connection.getDeploymentManager();
-        Kernel kernel = null;
-        if (dm instanceof RemoteDeploymentManager) {
-            kernel = ((RemoteDeploymentManager) dm).getKernel();
-        }
+        Kernel kernel = getKernel(connection);
         AbstractNameQuery anq = new AbstractNameQuery("org.apache.geronimo.management.geronimo.KeystoreManager");
         Set<AbstractName> it = kernel.listGBeans(anq);
         AbstractName an = (AbstractName) it.iterator().next();

Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/OfflineServerConnection.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/OfflineServerConnection.java?rev=963923&r1=963922&r2=963923&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/OfflineServerConnection.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/OfflineServerConnection.java
Wed Jul 14 02:02:41 2010
@@ -31,6 +31,8 @@ import org.apache.geronimo.kernel.Kernel
  */
 public class OfflineServerConnection extends ServerConnection {
 
+    private final boolean startOfflineDeployer;
+    
     public OfflineServerConnection(Kernel kernel, boolean startDeployer) throws DeploymentException
{
         if (null == kernel) {
             throw new IllegalArgumentException("kernel is required");
@@ -43,8 +45,13 @@ public class OfflineServerConnection ext
         } catch (IOException e) {
             throw new DeploymentException(e);
         }
+        startOfflineDeployer = startDeployer;
     }
 
+    public boolean isOfflineDeployerStarted() {
+        return startOfflineDeployer;
+    }
+    
     protected void startOfflineDeployer(Kernel kernel) throws DeploymentException {
         try {
             OfflineDeployerStarter offlineDeployerStarter = new OfflineDeployerStarter(kernel);

Added: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/UnlockKeystoreCommand.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/UnlockKeystoreCommand.java?rev=963923&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/UnlockKeystoreCommand.java
(added)
+++ geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/UnlockKeystoreCommand.java
Wed Jul 14 02:02:41 2010
@@ -0,0 +1,51 @@
+/*
+ * 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.shell.deploy;
+
+import java.util.List;
+
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+import org.apache.geronimo.cli.deployer.BaseCommandArgs;
+import org.apache.geronimo.deployment.cli.AbstractCommand;
+import org.apache.geronimo.deployment.cli.CommandUnlockKeystore;
+import org.apache.geronimo.deployment.cli.ServerConnection;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Command(scope = "deploy", name = "unlock-keystore", description = "Unlock a keystore")
+public class UnlockKeystoreCommand extends ConnectCommand {
+
+    @Argument(required = true, multiValued = true, description = "keystore name")
+    List<String> keystoreNames;
+
+    @Override
+    protected Object doExecute() throws Exception {
+        ServerConnection connection = connect();
+
+        AbstractCommand command = new CommandUnlockKeystore();
+
+        BaseCommandArgs args = new BaseCommandArgs(keystoreNames.toArray(new String[keystoreNames.size()]));
+
+        command.execute(this, connection, args);
+        return null;
+    }
+}

Propchange: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/UnlockKeystoreCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/UnlockKeystoreCommand.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/UnlockKeystoreCommand.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/resources/OSGI-INF/blueprint/shell-deploy.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/resources/OSGI-INF/blueprint/shell-deploy.xml?rev=963923&r1=963922&r2=963923&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/resources/OSGI-INF/blueprint/shell-deploy.xml
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/resources/OSGI-INF/blueprint/shell-deploy.xml
Wed Jul 14 02:02:41 2010
@@ -93,6 +93,10 @@
             <action class="org.apache.geronimo.shell.deploy.EncryptCommand">
             </action>
         </command>
+        <command name="deploy/unlock-keystore">
+            <action class="org.apache.geronimo.shell.deploy.UnlockKeystoreCommand">
+            </action>
+        </command>
     </command-bundle>
 
 </blueprint>



Mime
View raw message