geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ammul...@apache.org
Subject svn commit: r397641 - /geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/ServerConnection.java
Date Thu, 27 Apr 2006 21:19:26 GMT
Author: ammulder
Date: Thu Apr 27 14:19:23 2006
New Revision: 397641

URL: http://svn.apache.org/viewcvs?rev=397641&view=rev
Log:
Check the classpath before the home directory when looking for saved
  deployment auth info.  This lets you package .geronimo-deployer into
  the deployer.jar and thereby kind of disable security.  GERONIMO-1927

Modified:
    geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/ServerConnection.java

Modified: geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/ServerConnection.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/ServerConnection.java?rev=397641&r1=397640&r2=397641&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/ServerConnection.java
(original)
+++ geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/ServerConnection.java
Thu Apr 27 14:19:23 2006
@@ -25,6 +25,7 @@
 import java.io.InputStream;
 import java.io.PrintWriter;
 import java.io.Serializable;
+import java.io.FileNotFoundException;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -213,13 +214,22 @@
         String useURI = argURI == null ? DEFAULT_URI : argURI;
 
         if(authPrompt && user == null && password == null) {
-            File authFile = new File(System.getProperty("user.home"), ".geronimo-deployer");
-            if(authFile.exists() && authFile.canRead()) {
+            InputStream in;
+            // First check for .geronimo-deployer on class path (e.g. packaged in deployer.jar)
+            in = ServerConnection.class.getResourceAsStream("/.geronimo-deployer");
+            // If not there, check in home directory
+            if(in == null) {
+                File authFile = new File(System.getProperty("user.home"), ".geronimo-deployer");
+                if(authFile.exists() && authFile.canRead()) {
+                    try {
+                        in = new BufferedInputStream(new FileInputStream(authFile));
+                    } catch (FileNotFoundException e) {}
+                }
+            }
+            if(in != null) {
                 try {
                     Properties props = new Properties();
-                    InputStream in = new BufferedInputStream(new FileInputStream(authFile));
                     props.load(in);
-                    in.close();
                     String encryped = props.getProperty("login."+useURI);
                     if(encryped != null) {
                         if(encryped.startsWith("{Standard}")) {
@@ -238,6 +248,8 @@
                     }
                 } catch (IOException e) {
                     System.out.println(DeployUtils.reformat("Unable to read authentication
from saved login file: "+e.getMessage(), 4, 72));
+                } finally {
+                    try {in.close();}catch(IOException e) {}
                 }
             }
         }



Mime
View raw message