Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 72090 invoked from network); 7 Jun 2008 14:10:46 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 7 Jun 2008 14:10:46 -0000 Received: (qmail 24345 invoked by uid 500); 7 Jun 2008 14:10:47 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 24305 invoked by uid 500); 7 Jun 2008 14:10:47 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 24295 invoked by uid 99); 7 Jun 2008 14:10:47 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 07 Jun 2008 07:10:47 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 07 Jun 2008 14:10:05 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 634382388A03; Sat, 7 Jun 2008 07:10:23 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r664341 - /geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/ServerConnection.java Date: Sat, 07 Jun 2008 14:10:23 -0000 To: scm@geronimo.apache.org From: dwoods@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080607141023.634382388A03@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dwoods Date: Sat Jun 7 07:10:22 2008 New Revision: 664341 URL: http://svn.apache.org/viewvc?rev=664341&view=rev Log: GERONIMO-3408 Clean up deployer login code in ServerConnection. Thanks for the patch Ted. Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/ServerConnection.java Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/ServerConnection.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/ServerConnection.java?rev=664341&r1=664340&r2=664341&view=diff ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/ServerConnection.java (original) +++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/ServerConnection.java Sat Jun 7 07:10:22 2008 @@ -91,7 +91,7 @@ startOfflineDeployer(kernel); manager = new LocalDeploymentManager(kernel); } else { - tryToConnect(uri, driver, user, password, true); + tryToConnect(uri, driver, user, password); } if (manager == null) { throw new DeploymentException("Unexpected error; connection failed."); @@ -117,7 +117,7 @@ return auth.uri; } - private void tryToConnect(String argURI, String driver, String user, String password, boolean authPrompt) throws DeploymentException { + private void tryToConnect(String argURI, String driver, String user, String password) throws DeploymentException { DeploymentFactoryManager mgr = DeploymentFactoryManager.getInstance(); if (driver != null) { loadDriver(driver, mgr); @@ -126,7 +126,7 @@ } String useURI = argURI == null ? DEFAULT_URI : argURI; - if (authPrompt && user == null && password == null) { + if (user == null && password == null) { InputStream in; // First check for .geronimo-deployer on class path (e.g. packaged in deployer.jar) in = ServerConnection.class.getResourceAsStream("/.geronimo-deployer"); @@ -177,25 +177,28 @@ } } - if (authPrompt && !useURI.equals(DEFAULT_URI) && user == null && password == null) { - // Non-standard URI, but no authentication information - doAuthPromptAndRetry(useURI, user, password); - return; - } else { // Standard URI with no auth, Non-standard URI with auth, or else this is the 2nd try already + if (user == null || password == null) { try { - manager = mgr.getDeploymentManager(useURI, user, password); - auth = new SavedAuthentication(useURI, user, password == null ? null : password.toCharArray()); - } catch (AuthenticationFailedException e) { // server's there, you just can't talk to it - if (authPrompt) { - doAuthPromptAndRetry(useURI, user, password); - return; - } else { - throw new DeploymentException("Login Failed"); + InputPrompt prompt = new InputPrompt(in, out); + if (user == null) { + user = prompt.getInput("Username: "); } - } catch (DeploymentManagerCreationException e) { - throw new DeploymentException("Unable to connect to server at " + useURI + " -- " + e.getMessage(), e); + if (password == null) { + password = prompt.getPassword("Password: "); + } + } catch (IOException e) { + throw new DeploymentException("Unable to prompt for login", e); } } + try { + manager = mgr.getDeploymentManager(useURI, user, password); + auth = new SavedAuthentication(useURI, user, password == null ? null : password.toCharArray()); + } catch (AuthenticationFailedException e) { + // server's there, you just can't talk to it + throw new DeploymentException("Login Failed"); + } catch (DeploymentManagerCreationException e) { + throw new DeploymentException("Unable to connect to server at " + useURI + " -- " + e.getMessage(), e); + } if (manager instanceof JMXDeploymentManager) { JMXDeploymentManager deploymentManager = (JMXDeploymentManager) manager; @@ -225,21 +228,6 @@ } } - private void doAuthPromptAndRetry(String uri, String user, String password) throws DeploymentException { - try { - InputPrompt prompt = new InputPrompt(in, out); - if (user == null) { - user = prompt.getInput("Username: "); - } - if (password == null) { - password = prompt.getPassword("Password: "); - } - } catch (IOException e) { - throw new DeploymentException("Unable to prompt for login", e); - } - tryToConnect(uri, null, user, password, false); - } - public DeploymentManager getDeploymentManager() { return manager; }