From 8ff3249f209c81cad21a4f7298b4c685e49e9103 Mon Sep 17 00:00:00 2001
From: Endi Sukma Dewata <edewata@redhat.com>
Date: Fri, 1 Feb 2013 14:31:15 -0500
Subject: [PATCH] Fixed getInstallToken() invocation.

The configuration code has been modified to use the REST interface
to get the installation token and ignore CA cert validation errors.

Ticket #476
---
 base/common/src/com/netscape/certsrv/client/ClientConfig.java       | 6 +++---
 base/common/src/com/netscape/certsrv/client/PKIConnection.java      | 4 ++--
 .../src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java    | 4 +++-
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/base/common/src/com/netscape/certsrv/client/ClientConfig.java b/base/common/src/com/netscape/certsrv/client/ClientConfig.java
index 64eae17eb3b38ab06244445c01484d4382512763..ca17c857548fda4ee8d0b0352032a7c5e43e80d1 100644
--- a/base/common/src/com/netscape/certsrv/client/ClientConfig.java
+++ b/base/common/src/com/netscape/certsrv/client/ClientConfig.java
@@ -48,7 +48,7 @@ public class ClientConfig {
         }
     }
 
-    boolean InstanceCreationMode = false;
+    boolean instanceCreationMode;
 
     URI serverURI;
 
@@ -59,11 +59,11 @@ public class ClientConfig {
 
     @XmlElement(defaultValue="false")
     public boolean getInstanceCreationMode() {
-        return InstanceCreationMode;
+        return instanceCreationMode;
     }
 
     public void setInstanceCreationMode(boolean mode) {
-        this.InstanceCreationMode = mode;
+        this.instanceCreationMode = mode;
     }
 
     @XmlElement(name="ServerURI")
diff --git a/base/common/src/com/netscape/certsrv/client/PKIConnection.java b/base/common/src/com/netscape/certsrv/client/PKIConnection.java
index 4556f1c6a47ea06f840863fb902aa08782adb022..c339f3d67d95b1597b7fc97ceb101db86023b99b 100644
--- a/base/common/src/com/netscape/certsrv/client/PKIConnection.java
+++ b/base/common/src/com/netscape/certsrv/client/PKIConnection.java
@@ -214,7 +214,7 @@ public class PKIConnection {
                     // Ignore the "UNTRUSTED_ISSUER" validity status
                     // during PKI instance creation since we are
                     // utilizing an untrusted temporary CA cert.
-                    if (!config.InstanceCreationMode) {
+                    if (!config.getInstanceCreationMode()) {
                         // Otherwise, issue a WARNING, but allow this process
                         // to continue since we haven't installed a trusted CA
                         // cert for this operation.
@@ -228,7 +228,7 @@ public class PKIConnection {
                     // Ignore the "CA_CERT_INVALID" validity status
                     // during PKI instance creation since we are
                     // utilizing an untrusted temporary CA cert.
-                    if (!config.InstanceCreationMode) {
+                    if (!config.getInstanceCreationMode()) {
                         // Otherwise, set approval false to deny this
                         // certificate so that the connection is terminated.
                         // (Expect an IOException on the outstanding
diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java b/base/common/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java
index a7ec566ce38b02750e140299de9b96a38c38fc89..f8869fc06b728a1942947d6c3acd2977763973c1 100644
--- a/base/common/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java
+++ b/base/common/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java
@@ -314,17 +314,19 @@ public class ConfigurationUtils {
 
     public static String getInstallToken(String sdhost, int sdport, String user, String passwd) throws Exception {
         IConfigStore cs = CMS.getConfigStore();
-        boolean oldtoken = cs.getBoolean("cs.useOldTokenInterface", true);
+        boolean oldtoken = cs.getBoolean("cs.useOldTokenInterface", false);
 
         if (oldtoken) {
             return ConfigurationUtils.getOldToken(sdhost, sdport, user, passwd);
         }
+
         String csType = cs.getString("cs.type");
 
         ClientConfig config = new ClientConfig();
         config.setServerURI("https://" + sdhost + ":" + sdport + "/ca");
         config.setUsername(user);
         config.setPassword(passwd);
+        config.setInstanceCreationMode(true);
 
         PKIConnection connection = new PKIConnection(config);
         AccountClient accountClient = new AccountClient(connection);
-- 
1.7.12.1

