You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2008/01/23 20:24:11 UTC

svn commit: r614630 - in /geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands: ConnectCommand.groovy StopServerCommand.groovy

Author: jdillon
Date: Wed Jan 23 11:24:08 2008
New Revision: 614630

URL: http://svn.apache.org/viewvc?rev=614630&view=rev
Log:
Add prompting for username and password

Modified:
    geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ConnectCommand.groovy
    geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StopServerCommand.groovy

Modified: geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ConnectCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ConnectCommand.groovy?rev=614630&r1=614629&r2=614630&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ConnectCommand.groovy (original)
+++ geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ConnectCommand.groovy Wed Jan 23 11:24:08 2008
@@ -27,6 +27,8 @@
 import org.apache.geronimo.deployment.plugin.jmx.RemoteDeploymentManager
 import org.apache.geronimo.cli.deployer.ConnectionParamsImpl
 import org.apache.geronimo.kernel.basic.BasicKernel
+import org.apache.geronimo.gshell.command.annotation.Requirement
+import org.apache.geronimo.gshell.console.PromptReader
 import java.util.Collections
 
 /**
@@ -40,21 +42,35 @@
     @Option(name='-s', aliases=['--hostname', '--server'], description='Hostname, default localhost')
     String hostname = 'localhost'
 
-    @Option(name='-p', aliases=['--port'], description='port, default 1099')
+    @Option(name='-p', aliases=['--port'], description='Port, default 1099')
     int port = 1099
 
-    @Option(name='-u', aliases=['--username'], description='username')
-    String username = 'system'
-
-    @Option(name='-w', aliases=['--password'], description='password')
-    String password = 'manager'
+    @Option(name='-u', aliases=['--username'], description='Username')
+    String username
+    
+    @Option(name='-w', aliases=['--password'], description='Password')
+    String password
+    
+    @Requirement
+    PromptReader prompter
 
     protected Object doExecute() throws Exception {
         io.out.println("Connecting to Geronimo server: ${hostname}:${port}")
         
-        //
-        // TODO: If no password given, then prompt for password
-        //
+        // If the username/password was not configured via cli, then prompt the user for the values
+        if (username == null || password == null) {
+            if (username == null) {
+                username = prompter.readLine("Username: ");
+            }
+
+            if (password == null) {
+                password = prompter.readPassword("Password: ");
+            }
+
+            //
+            // TODO: Handle null inputs...
+            //
+        }
         
         def kernel = new BasicKernel("gshell deployer")
         def deploymentManager = new RemoteDeploymentManager(Collections.emptySet());

Modified: geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StopServerCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StopServerCommand.groovy?rev=614630&r1=614629&r2=614630&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StopServerCommand.groovy (original)
+++ geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StopServerCommand.groovy Wed Jan 23 11:24:08 2008
@@ -22,6 +22,8 @@
 import org.apache.geronimo.gshell.clp.Option
 import org.apache.geronimo.gshell.command.annotation.CommandComponent
 import org.apache.geronimo.gshell.command.CommandSupport
+import org.apache.geronimo.gshell.command.annotation.Requirement
+import org.apache.geronimo.gshell.console.PromptReader
 
 /**
  * Stops a running Geronimo server instance.
@@ -39,17 +41,28 @@
     int port = 1099
 
     @Option(name='-u', aliases=['--username'], description='Username')
-    String username = 'system'
-
+    String username
+    
     @Option(name='-w', aliases=['--password'], description='Password')
-    String password = 'manager'
+    String password
     
     protected Object doExecute() throws Exception {
         io.out.println("Stopping Geronimo server: ${hostname}:${port}")
         
-        //
-        // TODO: If no password given, then prompt for password
-        //
+        // If the username/password was not configured via cli, then prompt the user for the values
+        if (username == null || password == null) {
+            if (username == null) {
+                username = prompter.readLine("Username: ");
+            }
+
+            if (password == null) {
+                password = prompter.readPassword("Password: ");
+            }
+
+            //
+            // TODO: Handle null inputs...
+            //
+        }
         
         def server = new ServerProxy(hostname, port, username, password)