summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/common/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java22
-rw-r--r--base/util/src/com/netscape/cmsutil/http/HttpMessage.java9
2 files changed, 31 insertions, 0 deletions
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 81c9e7fe3..89233bdc2 100644
--- a/base/common/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java
+++ b/base/common/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java
@@ -315,6 +315,11 @@ public class ConfigurationUtils {
public static String getInstallToken(String sdhost, int sdport, String user, String passwd)
throws EPropertyNotFound, EBaseException, URISyntaxException, IOException {
IConfigStore cs = CMS.getConfigStore();
+ boolean oldtoken = cs.getBoolean("cs.useOldTokenInterface", true);
+
+ if (oldtoken) {
+ return ConfigurationUtils.getOldToken(sdhost, sdport, user, passwd);
+ }
String csType = cs.getString("cs.type");
InstallTokenRequest data = new InstallTokenRequest(user, passwd, csType, CMS.getEEHost(), CMS.getAdminPort());
@@ -356,6 +361,23 @@ public class ConfigurationUtils {
return getContentValue(body, "header.session_id");
}
+ public static String getOldToken(String sdhost, int sdport, String user, String passwd) throws IOException,
+ EPropertyNotFound, EBaseException, URISyntaxException {
+ IConfigStore cs = CMS.getConfigStore();
+
+ String subca_url = "https://" + CMS.getEEHost() + ":"
+ + CMS.getAdminPort() + "/ca/admin/console/config/wizard" +
+ "?p=5&subsystem=" + cs.getString("cs.type");
+
+ String content = "uid=" + URLEncoder.encode(user, "UTF-8") + "&pwd=" + URLEncoder.encode(passwd, "UTF-8") +
+ "&url=" + URLEncoder.encode(subca_url, "UTF-8");
+
+ String response = ConfigurationUtils.getHttpResponse(sdhost, sdport, true,
+ "/ca/admin/ca/getCookie", content, null);
+
+ return getContentValue(response, "header.session_id");
+ }
+
public static String getContentValue(String body, String header) {
StringTokenizer st = new StringTokenizer(body, "\n");
diff --git a/base/util/src/com/netscape/cmsutil/http/HttpMessage.java b/base/util/src/com/netscape/cmsutil/http/HttpMessage.java
index 44f608900..8db6fc11b 100644
--- a/base/util/src/com/netscape/cmsutil/http/HttpMessage.java
+++ b/base/util/src/com/netscape/cmsutil/http/HttpMessage.java
@@ -20,6 +20,7 @@ package com.netscape.cmsutil.http;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.OutputStreamWriter;
+import java.io.StringWriter;
import java.util.Enumeration;
import java.util.Hashtable;
@@ -143,6 +144,14 @@ public class HttpMessage {
}
mContent = new String(cbuf);
+ } else {
+ char[] cbuf = new char[8192];
+ StringWriter sw = new StringWriter();
+ int charsRead;
+ while ((charsRead = reader.read(cbuf)) != -1) {
+ sw.write(cbuf, 0, charsRead);
+ }
+ if (sw.getBuffer().length()>0) mContent = sw.toString();
}
}