summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAde Lee <alee@redhat.com>2012-10-12 00:40:12 -0400
committerAde Lee <alee@redhat.com>2012-10-12 16:18:10 -0400
commitd6634a7505df8358322b04b8892139195031e5eb (patch)
tree092407bf75fa5ddcf53d540fdf143b0d57265dd9
parent2a43f48bdc5b5584b011c3bce29de70385ef80ed (diff)
downloadpki-d6634a7505df8358322b04b8892139195031e5eb.zip
pki-d6634a7505df8358322b04b8892139195031e5eb.tar.gz
pki-d6634a7505df8358322b04b8892139195031e5eb.tar.xz
Reverted to old interface and httpclient to get installation token.
This is a workaround until we can get the new interface working on IPA clones.
-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 81c9e7f..89233bd 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 44f6089..8db6fc1 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();
}
}