geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From genspr...@apache.org
Subject svn commit: r916567 - in /geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli: ServerConnection.java StopServer.java
Date Fri, 26 Feb 2010 05:07:18 GMT
Author: genspring
Date: Fri Feb 26 05:07:18 2010
New Revision: 916567

URL: http://svn.apache.org/viewvc?rev=916567&view=rev
Log:
GERONIMO-4896 Commands to a Secure JMX Connector require the SSL keyStorePassword to be specified
on command line, modified based on patch from Ashish.

Modified:
    geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/ServerConnection.java
    geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/StopServer.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=916567&r1=916566&r2=916567&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
Fri Feb 26 05:07:18 2010
@@ -17,9 +17,13 @@
 
 package org.apache.geronimo.deployment.cli;
 
+import java.io.BufferedReader;
+import java.io.DataInputStream;
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.io.PrintWriter;
 import java.io.Serializable;
 import java.util.jar.JarFile;
@@ -31,6 +35,7 @@
 
 import org.apache.geronimo.cli.deployer.ConnectionParams;
 import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.crypto.EncryptionManager;
 import org.apache.geronimo.deployment.cli.DeployUtils.SavedAuthentication;
 import org.apache.geronimo.deployment.plugin.factories.AuthenticationFailedException;
 import org.apache.geronimo.deployment.plugin.jmx.JMXDeploymentManager;
@@ -54,6 +59,9 @@
     private SavedAuthentication auth;
     private boolean logToSysErr;
     private boolean verboseMessages;
+    String KEYSTORE_TRUSTSTORE_PASSWORD_FILE="org.apache.geronimo.keyStoreTrustStorePasswordFile";
+    String DEFAULT_TRUSTSTORE_KEYSTORE_LOCATION="/var/security/keystores/geronimo-default";
+    String GERONIMO_HOME="org.apache.geronimo.home.dir";
 
     public ServerConnection(ConnectionParams params, PrintWriter out, InputStream in, Kernel
kernel, DeploymentFactory geronimoDeploymentFactory) throws DeploymentException {
         this(params, new DefaultUserPasswordHandler(in, out), kernel, geronimoDeploymentFactory);
@@ -149,6 +157,42 @@
             }
         }
 
+        if(secure)
+        {
+            try {
+            FileInputStream fstream= new FileInputStream(System.getProperty(KEYSTORE_TRUSTSTORE_PASSWORD_FILE));
+            DataInputStream in = new DataInputStream(fstream);
+            BufferedReader br = new BufferedReader(new InputStreamReader(in));
+            String strLine;
+            String keyStorePassword=null;
+            String trustStorePassword=null;
+            while ((strLine = br.readLine()) != null)   {
+                if(strLine.startsWith("keyStorePassword"))
+                {
+                    keyStorePassword=(String)EncryptionManager.decrypt(strLine.substring(17));
                   
+                }
+                if(strLine.startsWith("trustStorePassword"))
+                {
+                    trustStorePassword=(String)EncryptionManager.decrypt(strLine.substring(19));;
+                }
+            }
+             
+            String value=System.getProperty("javax.net.ssl.keyStore",System.getProperty(GERONIMO_HOME)+DEFAULT_TRUSTSTORE_KEYSTORE_LOCATION);
+            String value1=System.getProperty("javax.net.ssl.trustStore",System.getProperty(GERONIMO_HOME)+DEFAULT_TRUSTSTORE_KEYSTORE_LOCATION);
+            System.setProperty("javax.net.ssl.keyStore", value);
+            System.setProperty("javax.net.ssl.trustStore", value1);
+            System.setProperty("javax.net.ssl.keyStorePassword",keyStorePassword);
+            System.setProperty("javax.net.ssl.trustStorePassword",trustStorePassword);
+            }
+            catch(NullPointerException e)
+            {
+                throw new NullPointerException("Null value specified for trustStore keyStore
location property org.apache.geronimo.keyStoreTrustStorePasswordFile");
+            }
+            catch(IOException e)
+            {
+                throw new DeploymentException("Unable to set KeyStorePassword and TrustStorePassword",
e);
+            }
+        }
         if (user == null || password == null) {
             try {
                 if (user == null) {

Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/StopServer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/StopServer.java?rev=916567&r1=916566&r2=916567&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/StopServer.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/StopServer.java
Fri Feb 26 05:07:18 2010
@@ -17,7 +17,11 @@
 
 package org.apache.geronimo.deployment.cli;
 
+import java.io.BufferedReader;
+import java.io.DataInputStream;
+import java.io.FileInputStream;
 import java.io.IOException;
+import java.io.InputStreamReader;
 import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.Map;
@@ -30,7 +34,7 @@
 import javax.management.remote.JMXServiceURL;
 import javax.management.remote.rmi.RMIConnectorServer;
 import javax.rmi.ssl.SslRMIClientSocketFactory;
-
+import org.apache.geronimo.crypto.EncryptionManager;
 import org.apache.geronimo.cli.shutdown.ShutdownCLParser;
 import org.apache.geronimo.deployment.cli.DeployUtils.SavedAuthentication;
 import org.apache.geronimo.gbean.GBeanInfo;
@@ -53,6 +57,9 @@
 	private boolean secure;
 
     private final Bundle bundle;
+    String KEYSTORE_TRUSTSTORE_PASSWORD_FILE="org.apache.geronimo.keyStoreTrustStorePasswordFile";
+    String DEFAULT_TRUSTSTORE_KEYSTORE_LOCATION="/var/security/keystores/geronimo-default";
+    String GERONIMO_HOME="org.apache.geronimo.home.dir";
 
     public StopServer(Bundle bundle) {
         this.bundle = bundle;
@@ -76,6 +83,47 @@
 
         secure = parser.isSecure();
         
+        if(secure){
+        
+          try {
+                FileInputStream fstream= new FileInputStream(System.getProperty(KEYSTORE_TRUSTSTORE_PASSWORD_FILE));
+                DataInputStream in = new DataInputStream(fstream);
+                BufferedReader br = new BufferedReader(new InputStreamReader(in));
+                String strLine;
+                String keyStorePassword=null;
+                String trustStorePassword=null;
+                while ((strLine = br.readLine()) != null)   {
+                    if(strLine.startsWith("keyStorePassword"))
+                    {
+                        keyStorePassword=(String)EncryptionManager.decrypt(strLine.substring(17));
                   
+                    }
+                    if(strLine.startsWith("trustStorePassword"))
+                    {
+                        trustStorePassword=(String)EncryptionManager.decrypt(strLine.substring(19));;
+                    }
+                }
+                 
+                String value=System.getProperty("javax.net.ssl.keyStore",System.getProperty(GERONIMO_HOME)+DEFAULT_TRUSTSTORE_KEYSTORE_LOCATION);
+                String value1=System.getProperty("javax.net.ssl.trustStore",System.getProperty(GERONIMO_HOME)+DEFAULT_TRUSTSTORE_KEYSTORE_LOCATION);
+                System.setProperty("javax.net.ssl.keyStore", value);
+                System.setProperty("javax.net.ssl.trustStore", value1);
+                System.setProperty("javax.net.ssl.keyStorePassword",keyStorePassword);
+                System.setProperty("javax.net.ssl.trustStorePassword",trustStorePassword);
+                }
+                
+                catch(NullPointerException e)
+                {
+                throw new NullPointerException("Null value specified for trustStore keyStore
location property org.apache.geronimo.keyStoreTrustStorePasswordFile");
+                }
+                
+                catch(IOException e)
+                {
+                    System.out.println("Unable to set KeyStorePassword and TrustStorePassword");
+                    e.printStackTrace();                    
+                }
+        
+        }
+        
         user = parser.getUser();
         
         password = parser.getPassword();



Mime
View raw message