From 7c94a02ef7ed3965c644e2ed27966a9fb0eadb60 Mon Sep 17 00:00:00 2001
From: lutoff <lutoff@localhost>
Date: Fri, 22 Jun 2007 09:06:28 +0000
Subject: [PATCH]     * Add the ability to programmatically call the CLI     * Fix some NullPointerException in trustStore management     * Fix a bug in the certificate nickname handling     * Add unit tests

---
 opends/src/server/org/opends/server/admin/client/cli/DsServiceCliParser.java |   44 +++++++++++++++++++++++++++++++-------------
 1 files changed, 31 insertions(+), 13 deletions(-)

diff --git a/opends/src/server/org/opends/server/admin/client/cli/DsServiceCliParser.java b/opends/src/server/org/opends/server/admin/client/cli/DsServiceCliParser.java
index 11f3ea9..9b165c8 100644
--- a/opends/src/server/org/opends/server/admin/client/cli/DsServiceCliParser.java
+++ b/opends/src/server/org/opends/server/admin/client/cli/DsServiceCliParser.java
@@ -554,17 +554,32 @@
       try
       {
         FileInputStream fos = new FileInputStream(trustStorePathArg.getValue());
-        String trustStorePasswordValue = null;
+        String trustStorePasswordStringValue = null;
+        char[] trustStorePasswordValue = null;
         if (trustStorePasswordArg.isPresent())
         {
-          trustStorePasswordValue = trustStorePasswordArg.getValue();
+          trustStorePasswordStringValue = trustStorePasswordArg.getValue();
         }
         else if (trustStorePasswordFileArg.isPresent())
         {
-          trustStorePasswordValue = trustStorePasswordFileArg.getValue();
+          trustStorePasswordStringValue = trustStorePasswordFileArg.getValue();
         }
+
+        if (trustStorePasswordStringValue !=  null)
+        {
+          trustStorePasswordStringValue = System
+              .getProperty("javax.net.ssl.trustStorePassword");
+        }
+
+
+        if (trustStorePasswordStringValue !=  null)
+        {
+          trustStorePasswordValue = trustStorePasswordStringValue.toCharArray();
+        }
+
         truststore = KeyStore.getInstance(KeyStore.getDefaultType());
-        truststore.load(fos, trustStorePasswordValue.toCharArray());
+        truststore.load(fos, trustStorePasswordValue);
+        fos.close();
       }
       catch (KeyStoreException e)
       {
@@ -596,7 +611,6 @@
       }
     }
     truststoreManager = new ApplicationTrustManager(truststore);
-    truststoreManager.setHost(getHostName());
     return truststoreManager;
   }
 
@@ -661,17 +675,21 @@
         // in a best effor mode.
         LOG.log(Level.WARNING, "Error with the keystore", e);
       }
-    }
-    ApplicationKeyManager akm = new ApplicationKeyManager(keyStore,
-        keyStorePasswordValue.toCharArray());
-    if (certNicknameArg.isPresent())
-    {
-      return new SelectableCertificateKeyManager(akm, certNicknameArg
-          .getValue());
+      ApplicationKeyManager akm = new ApplicationKeyManager(keyStore,
+          keyStorePasswordValue.toCharArray());
+      if (certNicknameArg.isPresent())
+      {
+        return new SelectableCertificateKeyManager(akm, certNicknameArg
+            .getValue());
+      }
+      else
+      {
+        return akm;
+      }
     }
     else
     {
-      return akm;
+      return null;
     }
   }
 

--
Gitblit v1.10.0