diff options
author | Ade Lee <alee@redhat.com> | 2012-03-22 22:51:56 -0400 |
---|---|---|
committer | Ade Lee <alee@redhat.com> | 2012-03-22 22:58:35 -0400 |
commit | 2b99f63796fb8513c96d04f25dec608d8483763d (patch) | |
tree | 556bc4bdad048816a14de700d019d0eeba0c6858 | |
parent | e168d790c3e797e0dc0f94e3496636a52e935b4f (diff) | |
download | pki-2b99f63796fb8513c96d04f25dec608d8483763d.tar.gz pki-2b99f63796fb8513c96d04f25dec608d8483763d.tar.xz pki-2b99f63796fb8513c96d04f25dec608d8483763d.zip |
Replace URLEncoder.encode with non-deprecated form in pkisilent
Removed some obsolete files.
13 files changed, 330 insertions, 3078 deletions
diff --git a/pki/base/silent/src/CMakeLists.txt b/pki/base/silent/src/CMakeLists.txt index f5ed283fe..a3e6034f8 100644 --- a/pki/base/silent/src/CMakeLists.txt +++ b/pki/base/silent/src/CMakeLists.txt @@ -47,7 +47,6 @@ set(pki-silent_java_SRCS com/netscape/pkisilent/http/CertSelection.java com/netscape/pkisilent/common/Request.java com/netscape/pkisilent/common/CertificateRecord.java - com/netscape/pkisilent/common/CMSInstance.java com/netscape/pkisilent/common/Utilities.java com/netscape/pkisilent/common/ComCrypto.java com/netscape/pkisilent/common/BaseState.java @@ -55,7 +54,6 @@ set(pki-silent_java_SRCS com/netscape/pkisilent/common/CMSConfig.java com/netscape/pkisilent/common/PostQuery.java com/netscape/pkisilent/common/ServerInfo.java - com/netscape/pkisilent/common/AutoInstaller.java com/netscape/pkisilent/common/UserEnroll.java com/netscape/pkisilent/common/ParseXML.java com/netscape/pkisilent/common/CMSProperties.java @@ -64,7 +62,6 @@ set(pki-silent_java_SRCS com/netscape/pkisilent/common/TestClient.java com/netscape/pkisilent/common/CMSTask.java com/netscape/pkisilent/ConfigureOCSP.java - com/netscape/pkisilent/CreateInstance.java com/netscape/pkisilent/ConfigureRA.java com/netscape/pkisilent/ConfigureSubCA.java com/netscape/pkisilent/ConfigureDRM.java diff --git a/pki/base/silent/src/com/netscape/pkisilent/ConfigureCA.java b/pki/base/silent/src/com/netscape/pkisilent/ConfigureCA.java index 4dc77b894..84fe0342f 100644 --- a/pki/base/silent/src/com/netscape/pkisilent/ConfigureCA.java +++ b/pki/base/silent/src/com/netscape/pkisilent/ConfigureCA.java @@ -267,7 +267,7 @@ public class ConfigureCA { // Software Token if (token_name.equalsIgnoreCase("internal")) { query_string = "p=1" + "&op=next" + "&xml=true" + "&choice=" - + URLEncoder.encode("Internal Key Storage Token") + ""; + + URLEncoder.encode("Internal Key Storage Token", "UTF-8") + ""; hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); if (!checkStatus(hr, "updateStatus", SUCCESS, "TokenChoicePanel()")) { return false; @@ -276,8 +276,8 @@ public class ConfigureCA { else { // login to hsm first query_string = "p=2" + "&op=next" + "&xml=true" + "&uTokName=" - + URLEncoder.encode(token_name) + "&__uPasswd=" - + URLEncoder.encode(token_pwd) + ""; + + URLEncoder.encode(token_name, "UTF-8") + "&__uPasswd=" + + URLEncoder.encode(token_pwd, "UTF-8") + ""; hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); if (!checkStatus(hr, "updateStatus", SUCCESS, "TokenChoicePanel()")) { return false; @@ -285,7 +285,7 @@ public class ConfigureCA { // choice with token name now query_string = "p=1" + "&op=next" + "&xml=true" + "&choice=" - + URLEncoder.encode(token_name) + ""; + + URLEncoder.encode(token_name, "UTF-8") + ""; hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); if (!checkStatus(hr, "updateStatus", SUCCESS, "TokenChoicePanel()")) { return false; @@ -306,12 +306,12 @@ public class ConfigureCA { String query_string = null; if (!clone) { - query_string = "sdomainURL=" + URLEncoder.encode(domain_url) - + "&sdomainName=" + URLEncoder.encode(domain_name) + query_string = "sdomainURL=" + URLEncoder.encode(domain_url, "UTF-8") + + "&sdomainName=" + URLEncoder.encode(domain_name, "UTF-8") + "&choice=newdomain" + "&p=3" + "&op=next" + "&xml=true"; } else { domain_url = "https://" + sd_hostname + ":" + sd_admin_port; - query_string = "sdomainURL=" + URLEncoder.encode(domain_url) + query_string = "sdomainURL=" + URLEncoder.encode(domain_url, "UTF-8") + "&sdomainName=" + "&choice=existingdomain" + "&p=3" + "&op=next" + "&xml=true"; } @@ -348,12 +348,12 @@ public class ConfigureCA { String subca_url = "https://" + cs_hostname + ":" + cs_port + "/ca/admin/console/config/wizard" + "?p=5&subsystem=CA"; - String query_string = "url=" + URLEncoder.encode(subca_url); + String query_string = "url=" + URLEncoder.encode(subca_url, "UTF-8"); hr = hc.sslConnect(sd_hostname, sd_admin_port, sd_login_uri, query_string); - String query_string_1 = "uid=" + sd_admin_name + "&pwd=" + URLEncoder.encode(sd_admin_password) + - "&url=" + URLEncoder.encode(subca_url); + String query_string_1 = "uid=" + sd_admin_name + "&pwd=" + URLEncoder.encode(sd_admin_password, "UTF-8") + + "&url=" + URLEncoder.encode(subca_url, "UTF-8"); hr = hc.sslConnect(sd_hostname, sd_admin_port, sd_get_cookie_uri, query_string_1); @@ -397,11 +397,11 @@ public class ConfigureCA { if (!clone) { query_string = "p=5" + "&op=next" + "&xml=true" + "&choice=newsubsystem" + "&subsystemName=" - + URLEncoder.encode(subsystem_name); + + URLEncoder.encode(subsystem_name, "UTF-8"); } else { query_string = "p=5" + "&op=next" + "&xml=true" + "&choice=clonesubsystem" + "&subsystemName=" - + URLEncoder.encode(subsystem_name) + + URLEncoder.encode(subsystem_name, "UTF-8") + "&urls=" + urls + ""; } @@ -433,8 +433,8 @@ public class ConfigureCA { HTTPResponse hr = null; String query_string = "p=7" + "&op=next" + "&xml=true" - + "&__password=" + URLEncoder.encode(clone_p12_passwd) - + "&path=" + URLEncoder.encode(clone_p12_file) + ""; + + "&__password=" + URLEncoder.encode(clone_p12_passwd, "UTF-8") + + "&path=" + URLEncoder.encode(clone_p12_file, "UTF-8") + ""; hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); if (!checkStatus(hr, "updateStatus", SUCCESS, "RestoreKeyCertPanel()")) { @@ -607,16 +607,16 @@ public class ConfigureCA { if (!clone) { query_string = "p=11" + "&op=next" + "&xml=true" + "&subsystem=" - + URLEncoder.encode(ca_subsystem_cert_subject_name) + + URLEncoder.encode(ca_subsystem_cert_subject_name, "UTF-8") + "&ocsp_signing=" - + URLEncoder.encode(ca_ocsp_cert_subject_name) + "&signing=" - + URLEncoder.encode(ca_sign_cert_subject_name) + "&sslserver=" - + URLEncoder.encode(ca_server_cert_subject_name) + "&audit_signing=" - + URLEncoder.encode(ca_audit_signing_cert_subject_name) + "&urls=0" + + URLEncoder.encode(ca_ocsp_cert_subject_name, "UTF-8") + "&signing=" + + URLEncoder.encode(ca_sign_cert_subject_name, "UTF-8") + "&sslserver=" + + URLEncoder.encode(ca_server_cert_subject_name, "UTF-8") + "&audit_signing=" + + URLEncoder.encode(ca_audit_signing_cert_subject_name, "UTF-8") + "&urls=0" + ""; } else { query_string = "p=11" + "&op=next" + "&xml=true" + "&sslserver=" - + URLEncoder.encode(ca_server_cert_subject_name) + "&urls=0" + + URLEncoder.encode(ca_server_cert_subject_name, "UTF-8") + "&urls=0" + ""; } @@ -744,13 +744,13 @@ public class ConfigureCA { HTTPResponse hr = null; String query_string = "p=12" + "&op=next" + "&xml=true" + "&subsystem=" - + URLEncoder.encode(ca_subsystem_cert_cert) + "&subsystem_cc=" - + "&ocsp_signing=" + URLEncoder.encode(ocsp_cert_cert) + + URLEncoder.encode(ca_subsystem_cert_cert, "UTF-8") + "&subsystem_cc=" + + "&ocsp_signing=" + URLEncoder.encode(ocsp_cert_cert, "UTF-8") + "&ocsp_signing_cc=" + "&signing=" - + URLEncoder.encode(ca_cert_cert) + "&signing_cc=" - + "&audit_signing=" + URLEncoder.encode(ca_audit_signing_cert_cert) + + URLEncoder.encode(ca_cert_cert, "UTF-8") + "&signing_cc=" + + "&audit_signing=" + URLEncoder.encode(ca_audit_signing_cert_cert, "UTF-8") + "&audit_signing_cc=" - + "&sslserver=" + URLEncoder.encode(server_cert_cert) + + "&sslserver=" + URLEncoder.encode(server_cert_cert, "UTF-8") + "&sslserver_cc=" + ""; hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); @@ -778,14 +778,14 @@ public class ConfigureCA { String genString = "...certificate be generated internally..."; String query_string = "p=12" + "&op=apply" + "&xml=true" + "&subsystem=" - + URLEncoder.encode(genString) + "&subsystem_cc=" - + "&ocsp_signing=" + URLEncoder.encode(genString) + + URLEncoder.encode(genString, "UTF-8") + "&subsystem_cc=" + + "&ocsp_signing=" + URLEncoder.encode(genString, "UTF-8") + "&ocsp_signing_cc=" + "&signing=" - + URLEncoder.encode(ca_cert_cert) + "&signing_cc=" - + URLEncoder.encode(signing_cc) - + "&audit_signing=" + URLEncoder.encode(genString) + + URLEncoder.encode(ca_cert_cert, "UTF-8") + "&signing_cc=" + + URLEncoder.encode(signing_cc, "UTF-8") + + "&audit_signing=" + URLEncoder.encode(genString, "UTF-8") + "&audit_signing_cc=" - + "&sslserver=" + URLEncoder.encode(genString) + + "&sslserver=" + URLEncoder.encode(genString, "UTF-8") + "&sslserver_cc=" + ""; hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); @@ -866,8 +866,8 @@ public class ConfigureCA { if (save_p12.equalsIgnoreCase("true")) { String query_string = "p=13" + "&op=next" + "&xml=true" - + "&choice=backupkey" + "&__pwd=" + URLEncoder.encode(backup_pwd) - + "&__pwdagain=" + URLEncoder.encode(backup_pwd); + + "&choice=backupkey" + "&__pwd=" + URLEncoder.encode(backup_pwd, "UTF-8") + + "&__pwdagain=" + URLEncoder.encode(backup_pwd, "UTF-8"); hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); if (!checkStatus(hr, "updateStatus", SUCCESS, "BackupPanel()")) { @@ -990,14 +990,14 @@ public class ConfigureCA { String query_string = "p=16" + "&op=next" + "&xml=true" + "&cert_request_type=" + "crmf" + "&uid=" + admin_user - + "&name=" + admin_user + "&__pwd=" + URLEncoder.encode(admin_password) - + "&__admin_password_again=" + URLEncoder.encode(admin_password) + "&profileId=" - + "caAdminCert" + "&email=" + URLEncoder.encode(admin_email) - + "&cert_request=" + URLEncoder.encode(admin_cert_request) - + "&subject=" + URLEncoder.encode(agent_cert_subject) + + "&name=" + admin_user + "&__pwd=" + URLEncoder.encode(admin_password, "UTF-8") + + "&__admin_password_again=" + URLEncoder.encode(admin_password, "UTF-8") + "&profileId=" + + "caAdminCert" + "&email=" + URLEncoder.encode(admin_email, "UTF-8") + + "&cert_request=" + URLEncoder.encode(admin_cert_request, "UTF-8") + + "&subject=" + URLEncoder.encode(agent_cert_subject, "UTF-8") + "&clone=new" + "&import=true" + "&securitydomain=" - + URLEncoder.encode(domain_name) + ""; + + URLEncoder.encode(domain_name, "UTF-8") + ""; hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); if (!checkStatus(hr, "updateStatus", SUCCESS, "AdminCertReqPanel()")) { @@ -1079,7 +1079,7 @@ public class ConfigureCA { ParseXML px = new ParseXML(); String query_string = "p=17" + "&op=next" + "&xml=true" + "&caHost=" - + URLEncoder.encode("/") + "&caPort=" + URLEncoder.encode("/") + + URLEncoder.encode("/", "UTF-8") + "&caPort=" + URLEncoder.encode("/", "UTF-8") + ""; hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); @@ -1381,7 +1381,6 @@ public class ConfigureCA { StringHolder x_backup_fname = new StringHolder(); // separate key size for agent cert - StringHolder x_agent_key_size = new StringHolder(); StringHolder x_agent_key_type = new StringHolder(); StringHolder x_agent_cert_subject = new StringHolder(); diff --git a/pki/base/silent/src/com/netscape/pkisilent/ConfigureDRM.java b/pki/base/silent/src/com/netscape/pkisilent/ConfigureDRM.java index 7d15861d1..d38c92236 100644 --- a/pki/base/silent/src/com/netscape/pkisilent/ConfigureDRM.java +++ b/pki/base/silent/src/com/netscape/pkisilent/ConfigureDRM.java @@ -24,6 +24,7 @@ import java.io.ByteArrayInputStream; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStreamReader; +import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.ArrayList; @@ -224,7 +225,7 @@ public class ConfigureDRM { return st; } - public boolean TokenChoicePanel() { + public boolean TokenChoicePanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); @@ -235,7 +236,7 @@ public class ConfigureDRM { if (token_name.equalsIgnoreCase("internal")) { query_string = "p=1" + "&op=next" + "&xml=true" + "&choice=" + - URLEncoder.encode("Internal Key Storage Token"); + URLEncoder.encode("Internal Key Storage Token", "UTF-8"); hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); // parse xml @@ -246,9 +247,9 @@ public class ConfigureDRM { // login to hsm first query_string = "p=2" + "&op=next" + "&xml=true" + "&uTokName=" + - URLEncoder.encode(token_name) + + URLEncoder.encode(token_name, "UTF-8") + "&__uPasswd=" + - URLEncoder.encode(token_pwd); + URLEncoder.encode(token_pwd, "UTF-8"); hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); // parse xml @@ -259,7 +260,7 @@ public class ConfigureDRM { // choice with token name now query_string = "p=1" + "&op=next" + "&xml=true" + "&choice=" + - URLEncoder.encode(token_name); + URLEncoder.encode(token_name, "UTF-8"); hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); // parse xml @@ -271,7 +272,7 @@ public class ConfigureDRM { return true; } - public boolean DomainPanel() { + public boolean DomainPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); @@ -279,7 +280,7 @@ public class ConfigureDRM { String domain_url = "https://" + sd_hostname + ":" + sd_admin_port; String query_string = "sdomainURL=" + - URLEncoder.encode(domain_url) + + URLEncoder.encode(domain_url, "UTF-8") + "&choice=existingdomain" + "&p=3" + "&op=next" + @@ -312,13 +313,13 @@ public class ConfigureDRM { "/kra/admin/console/config/wizard" + "?p=5&subsystem=KRA"; - String query_string = "url=" + URLEncoder.encode(kra_url); + String query_string = "url=" + URLEncoder.encode(kra_url, "UTF-8"); hr = hc.sslConnect(sd_hostname, sd_admin_port, sd_login_uri, query_string); String query_string_1 = "uid=" + sd_admin_name + - "&pwd=" + URLEncoder.encode(sd_admin_password) + - "&url=" + URLEncoder.encode(kra_url); + "&pwd=" + URLEncoder.encode(sd_admin_password, "UTF-8") + + "&url=" + URLEncoder.encode(kra_url, "UTF-8"); hr = hc.sslConnect(sd_hostname, sd_admin_port, sd_get_cookie_uri, query_string_1); @@ -362,7 +363,7 @@ public class ConfigureDRM { } } - public boolean SubsystemPanel() { + public boolean SubsystemPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); @@ -370,11 +371,11 @@ public class ConfigureDRM { if (!clone) { query_string = "p=5" + "&op=next" + "&xml=true" + "&choice=newsubsystem" + "&subsystemName=" - + URLEncoder.encode(subsystem_name); + + URLEncoder.encode(subsystem_name, "UTF-8"); } else { query_string = "p=5" + "&op=next" + "&xml=true" + "&choice=clonesubsystem" + "&subsystemName=" - + URLEncoder.encode(subsystem_name) + + URLEncoder.encode(subsystem_name, "UTF-8") + "&urls=" + urls; } @@ -394,8 +395,8 @@ public class ConfigureDRM { ParseXML px = new ParseXML(); String query_string = "p=6" + "&op=next" + "&xml=true" - + "&__password=" + URLEncoder.encode(clone_p12_passwd) - + "&path=" + URLEncoder.encode(clone_p12_file) + ""; + + "&__password=" + URLEncoder.encode(clone_p12_passwd, "UTF-8") + + "&path=" + URLEncoder.encode(clone_p12_file, "UTF-8") + ""; hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); @@ -525,7 +526,7 @@ public class ConfigureDRM { return true; } - public boolean CertSubjectPanel() { + public boolean CertSubjectPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); @@ -539,23 +540,23 @@ public class ConfigureDRM { if (!clone) { query_string = "p=9" + "&op=next" + "&xml=true" + "&subsystem=" + - URLEncoder.encode(drm_subsystem_cert_subject_name) + + URLEncoder.encode(drm_subsystem_cert_subject_name, "UTF-8") + "&transport=" + - URLEncoder.encode(drm_transport_cert_subject_name) + + URLEncoder.encode(drm_transport_cert_subject_name, "UTF-8") + "&storage=" + - URLEncoder.encode(drm_storage_cert_subject_name) + + URLEncoder.encode(drm_storage_cert_subject_name, "UTF-8") + "&sslserver=" + - URLEncoder.encode(drm_server_cert_subject_name) + + URLEncoder.encode(drm_server_cert_subject_name, "UTF-8") + "&audit_signing=" + - URLEncoder.encode(drm_audit_signing_cert_subject_name) + + URLEncoder.encode(drm_audit_signing_cert_subject_name, "UTF-8") + "&urls=" + - URLEncoder.encode(domain_url); + URLEncoder.encode(domain_url, "UTF-8"); } else { query_string = "p=9" + "&op=next" + "&xml=true" + "&sslserver=" + - URLEncoder.encode(drm_server_cert_subject_name) + + URLEncoder.encode(drm_server_cert_subject_name, "UTF-8") + "&urls=" + - URLEncoder.encode(domain_url); + URLEncoder.encode(domain_url, "UTF-8"); } hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); @@ -595,26 +596,26 @@ public class ConfigureDRM { return true; } - public boolean CertificatePanel() { + public boolean CertificatePanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); String query_string = "p=10" + "&op=next" + "&xml=true" + "&subsystem=" + - URLEncoder.encode(drm_subsystem_cert_cert) + + URLEncoder.encode(drm_subsystem_cert_cert, "UTF-8") + "&subsystem_cc=" + "&transport=" + - URLEncoder.encode(drm_transport_cert_cert) + + URLEncoder.encode(drm_transport_cert_cert, "UTF-8") + "&transport_cc=" + "&storage=" + - URLEncoder.encode(drm_storage_cert_cert) + + URLEncoder.encode(drm_storage_cert_cert, "UTF-8") + "&storage_cc=" + "&sslserver=" + - URLEncoder.encode(server_cert_cert) + + URLEncoder.encode(server_cert_cert, "UTF-8") + "&sslserver_cc=" + "&audit_signing=" + - URLEncoder.encode(drm_audit_signing_cert_cert) + + URLEncoder.encode(drm_audit_signing_cert_cert, "UTF-8") + "&audit_signing_cc="; hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); @@ -627,15 +628,15 @@ public class ConfigureDRM { return true; } - public boolean BackupPanel() { + public boolean BackupPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); String query_string = "p=11" + "&op=next" + "&xml=true" + "&choice=backupkey" + - "&__pwd=" + URLEncoder.encode(backup_pwd) + - "&__pwdagain=" + URLEncoder.encode(backup_pwd); + "&__pwd=" + URLEncoder.encode(backup_pwd, "UTF-8") + + "&__pwdagain=" + URLEncoder.encode(backup_pwd, "UTF-8"); hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); @@ -706,7 +707,7 @@ public class ConfigureDRM { return true; } - public boolean AdminCertReqPanel() { + public boolean AdminCertReqPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); @@ -736,19 +737,19 @@ public class ConfigureDRM { "&cert_request_type=" + "crmf" + "&uid=" + admin_user + "&name=" + admin_user + - "&__pwd=" + URLEncoder.encode(admin_password) + - "&__admin_password_again=" + URLEncoder.encode(admin_password) + + "&__pwd=" + URLEncoder.encode(admin_password, "UTF-8") + + "&__admin_password_again=" + URLEncoder.encode(admin_password, "UTF-8") + "&profileId=" + "caAdminCert" + "&email=" + - URLEncoder.encode(admin_email) + + URLEncoder.encode(admin_email, "UTF-8") + "&cert_request=" + - URLEncoder.encode(admin_cert_request) + + URLEncoder.encode(admin_cert_request, "UTF-8") + "&subject=" + - URLEncoder.encode(agent_cert_subject) + + URLEncoder.encode(agent_cert_subject, "UTF-8") + "&clone=new" + "&import=true" + "&securitydomain=" + - URLEncoder.encode(domain_name); + URLEncoder.encode(domain_name, "UTF-8"); hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); @@ -800,14 +801,14 @@ public class ConfigureDRM { return true; } - public boolean UpdateDomainPanel() { + public boolean UpdateDomainPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); String query_string = "p=14" + "&op=next" + "&xml=true" + - "&caHost=" + URLEncoder.encode(sd_hostname) + - "&caPort=" + URLEncoder.encode(sd_agent_port); + "&caHost=" + URLEncoder.encode(sd_hostname, "UTF-8") + + "&caPort=" + URLEncoder.encode(sd_agent_port, "UTF-8"); hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); @@ -819,7 +820,7 @@ public class ConfigureDRM { return true; } - public boolean ConfigureDRMInstance() { + public boolean ConfigureDRMInstance() throws UnsupportedEncodingException { // 0. login to cert db ComCrypto cCrypt = new ComCrypto(client_certdb_dir, client_certdb_pwd, @@ -980,7 +981,7 @@ public class ConfigureDRM { } } - public static void main(String args[]) { + public static void main(String args[]) throws UnsupportedEncodingException { ConfigureDRM ca = new ConfigureDRM(); // set variables diff --git a/pki/base/silent/src/com/netscape/pkisilent/ConfigureOCSP.java b/pki/base/silent/src/com/netscape/pkisilent/ConfigureOCSP.java index 149c79dff..53c014b74 100644 --- a/pki/base/silent/src/com/netscape/pkisilent/ConfigureOCSP.java +++ b/pki/base/silent/src/com/netscape/pkisilent/ConfigureOCSP.java @@ -24,6 +24,7 @@ import java.io.ByteArrayInputStream; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStreamReader; +import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.ArrayList; @@ -93,7 +94,6 @@ public class ConfigureOCSP { public static String base_dn = null; public static String db_name = null; public static String secure_conn = null; - public static String clone_start_tls = null; public static String remove_data = null; public static String key_type = null; @@ -206,7 +206,7 @@ public class ConfigureOCSP { return st; } - public boolean TokenChoicePanel() { + public boolean TokenChoicePanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); @@ -216,9 +216,7 @@ public class ConfigureOCSP { // Software Token if (token_name.equalsIgnoreCase("internal")) { query_string = "p=1" + "&op=next" + "&xml=true" + - "&choice=" + - URLEncoder.encode("Internal Key Storage Token") + - ""; + "&choice=" + URLEncoder.encode("Internal Key Storage Token", "UTF-8"); hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); // parse xml bais = new ByteArrayInputStream(hr.getHTML().getBytes()); @@ -230,10 +228,9 @@ public class ConfigureOCSP { // login to hsm first query_string = "p=2" + "&op=next" + "&xml=true" + "&uTokName=" + - URLEncoder.encode(token_name) + + URLEncoder.encode(token_name, "UTF-8") + "&__uPasswd=" + - URLEncoder.encode(token_pwd) + - ""; + URLEncoder.encode(token_pwd, "UTF-8"); hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); // parse xml bais = new ByteArrayInputStream(hr.getHTML().getBytes()); @@ -243,8 +240,7 @@ public class ConfigureOCSP { // choice with token name now query_string = "p=1" + "&op=next" + "&xml=true" + "&choice=" + - URLEncoder.encode(token_name) + - ""; + URLEncoder.encode(token_name, "UTF-8"); hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); // parse xml bais = new ByteArrayInputStream(hr.getHTML().getBytes()); @@ -255,7 +251,7 @@ public class ConfigureOCSP { return true; } - public boolean DomainPanel() { + public boolean DomainPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); @@ -263,7 +259,7 @@ public class ConfigureOCSP { String domain_url = "https://" + sd_hostname + ":" + sd_admin_port; String query_string = "sdomainURL=" + - URLEncoder.encode(domain_url) + + URLEncoder.encode(domain_url, "UTF-8") + "&choice=existingdomain" + "&p=3" + "&op=next" + @@ -294,20 +290,20 @@ public class ConfigureOCSP { } - public boolean SecurityDomainLoginPanel() { + public boolean SecurityDomainLoginPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; String ocsp_url = "https://" + cs_hostname + ":" + cs_port + "/ocsp/admin/console/config/wizard" + "?p=5&subsystem=OCSP"; - String query_string = "url=" + URLEncoder.encode(ocsp_url); + String query_string = "url=" + URLEncoder.encode(ocsp_url, "UTF-8"); hr = hc.sslConnect(sd_hostname, sd_admin_port, sd_login_uri, query_string); String query_string_1 = "uid=" + sd_admin_name + - "&pwd=" + URLEncoder.encode(sd_admin_password) + - "&url=" + URLEncoder.encode(ocsp_url); + "&pwd=" + URLEncoder.encode(sd_admin_password, "UTF-8") + + "&url=" + URLEncoder.encode(ocsp_url, "UTF-8"); hr = hc.sslConnect(sd_hostname, sd_admin_port, sd_get_cookie_uri, query_string_1); @@ -330,23 +326,18 @@ public class ConfigureOCSP { hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string_2); - // parse xml - // bais = new ByteArrayInputStream(hr.getHTML().getBytes()); - // px.parse(bais); - // px.prettyprintxml(); - return true; } - public boolean SubsystemPanel() { + public boolean SubsystemPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); String query_string = "p=5" + "&op=next" + "&xml=true" + "&subsystemName=" + - URLEncoder.encode(subsystem_name) + + URLEncoder.encode(subsystem_name, "UTF-8") + "&choice=newsubsystem"; hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); @@ -358,21 +349,20 @@ public class ConfigureOCSP { return true; } - public boolean LdapConnectionPanel() { + public boolean LdapConnectionPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); String query_string = "p=7" + "&op=next" + "&xml=true" + - "&host=" + URLEncoder.encode(ldap_host) + - "&port=" + URLEncoder.encode(ldap_port) + - "&binddn=" + URLEncoder.encode(bind_dn) + - "&__bindpwd=" + URLEncoder.encode(bind_password) + - "&basedn=" + URLEncoder.encode(base_dn) + - "&database=" + URLEncoder.encode(db_name) + - "&display=" + URLEncoder.encode("$displayStr") + + "&host=" + URLEncoder.encode(ldap_host, "UTF-8") + + "&port=" + URLEncoder.encode(ldap_port, "UTF-8") + + "&binddn=" + URLEncoder.encode(bind_dn, "UTF-8") + + "&__bindpwd=" + URLEncoder.encode(bind_password, "UTF-8") + + "&basedn=" + URLEncoder.encode(base_dn, "UTF-8") + + "&database=" + URLEncoder.encode(db_name, "UTF-8") + + "&display=" + URLEncoder.encode("$displayStr", "UTF-8") + (secure_conn.equals("true") ? "&secureConn=on" : "") + - (clone_start_tls.equals("true") ? "&cloneStartTLS=on" : "") + (remove_data.equals("true") ? "&removeData=true" : ""); hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); @@ -447,7 +437,7 @@ public class ConfigureOCSP { return true; } - public boolean CertSubjectPanel() { + public boolean CertSubjectPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); @@ -459,15 +449,15 @@ public class ConfigureOCSP { String query_string = "p=9" + "&op=next" + "&xml=true" + "&subsystem=" + - URLEncoder.encode(ocsp_subsystem_cert_subject_name) + + URLEncoder.encode(ocsp_subsystem_cert_subject_name, "UTF-8") + "&signing=" + - URLEncoder.encode(ocsp_sign_cert_subject_name) + + URLEncoder.encode(ocsp_sign_cert_subject_name, "UTF-8") + "&sslserver=" + - URLEncoder.encode(ocsp_server_cert_subject_name) + + URLEncoder.encode(ocsp_server_cert_subject_name, "UTF-8") + "&audit_signing=" + - URLEncoder.encode(ocsp_audit_signing_cert_subject_name) + + URLEncoder.encode(ocsp_audit_signing_cert_subject_name, "UTF-8") + "&urls=" + - URLEncoder.encode(domain_url) + + URLEncoder.encode(domain_url, "UTF-8") + ""; hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); @@ -504,25 +494,24 @@ public class ConfigureOCSP { return true; } - public boolean CertificatePanel() { + public boolean CertificatePanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); String query_string = "p=10" + "&op=next" + "&xml=true" + "&subsystem=" + - URLEncoder.encode(ocsp_subsystem_cert_cert) + + URLEncoder.encode(ocsp_subsystem_cert_cert, "UTF-8") + "&subsystem_cc=" + "&signing=" + - URLEncoder.encode(ocsp_signing_cert_cert) + + URLEncoder.encode(ocsp_signing_cert_cert, "UTF-8") + "&signing_cc=" + "&sslserver=" + - URLEncoder.encode(server_cert_cert) + + URLEncoder.encode(server_cert_cert, "UTF-8") + "&sslserver_cc=" + "&audit_signing=" + - URLEncoder.encode(ocsp_audit_signing_cert_cert) + - "&audit_signing_cc=" + - ""; + URLEncoder.encode(ocsp_audit_signing_cert_cert, "UTF-8") + + "&audit_signing_cc="; hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); @@ -537,15 +526,15 @@ public class ConfigureOCSP { return true; } - public boolean BackupPanel() { + public boolean BackupPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); String query_string = "p=11" + "&op=next" + "&xml=true" + "&choice=backupkey" + - "&__pwd=" + URLEncoder.encode(backup_pwd) + - "&__pwdagain=" + URLEncoder.encode(backup_pwd); + "&__pwd=" + URLEncoder.encode(backup_pwd, "UTF-8") + + "&__pwdagain=" + URLEncoder.encode(backup_pwd, "UTF-8"); hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); @@ -605,7 +594,7 @@ public class ConfigureOCSP { return true; } - public boolean AdminCertReqPanel() { + public boolean AdminCertReqPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); @@ -635,20 +624,19 @@ public class ConfigureOCSP { "&cert_request_type=" + "crmf" + "&uid=" + admin_user + "&name=" + admin_user + - "&__pwd=" + URLEncoder.encode(admin_password) + - "&__admin_password_again=" + URLEncoder.encode(admin_password) + + "&__pwd=" + URLEncoder.encode(admin_password, "UTF-8") + + "&__admin_password_again=" + URLEncoder.encode(admin_password, "UTF-8") + "&profileId=" + "caAdminCert" + "&email=" + - URLEncoder.encode(admin_email) + + URLEncoder.encode(admin_email, "UTF-8") + "&cert_request=" + - URLEncoder.encode(admin_cert_request) + + URLEncoder.encode(admin_cert_request, "UTF-8") + "&subject=" + - URLEncoder.encode(agent_cert_subject) + + URLEncoder.encode(agent_cert_subject, "UTF-8") + "&clone=new" + "&import=true" + "&securitydomain=" + - URLEncoder.encode(domain_name) + - ""; + URLEncoder.encode(domain_name, "UTF-8"); hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); @@ -701,15 +689,14 @@ public class ConfigureOCSP { return true; } - public boolean UpdateDomainPanel() { + public boolean UpdateDomainPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); String query_string = "p=14" + "&op=next" + "&xml=true" + - "&caHost=" + URLEncoder.encode(sd_hostname) + - "&caPort=" + URLEncoder.encode(sd_agent_port) + - ""; + "&caHost=" + URLEncoder.encode(sd_hostname, "UTF-8") + + "&caPort=" + URLEncoder.encode(sd_agent_port, "UTF-8"); hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); @@ -721,7 +708,7 @@ public class ConfigureOCSP { return true; } - public boolean ConfigureOCSPInstance() { + public boolean ConfigureOCSPInstance() throws UnsupportedEncodingException { // 0. login to cert db ComCrypto cCrypt = new ComCrypto(client_certdb_dir, client_certdb_pwd, @@ -867,7 +854,7 @@ public class ConfigureOCSP { } } - public static void main(String args[]) { + public static void main(String args[]) throws UnsupportedEncodingException { ConfigureOCSP ca = new ConfigureOCSP(); // set variables @@ -903,7 +890,6 @@ public class ConfigureOCSP { StringHolder x_base_dn = new StringHolder(); StringHolder x_db_name = new StringHolder(); StringHolder x_secure_conn = new StringHolder(); - StringHolder x_clone_start_tls = new StringHolder(); StringHolder x_remove_data = new StringHolder(); // key properties (defaults) @@ -1013,9 +999,6 @@ public class ConfigureOCSP { parser.addOption("-secure_conn %s #use ldaps port (optional, default is false)", x_secure_conn); parser.addOption("-remove_data %s #remove existing data under base_dn (optional, default is false) ", x_remove_data); - parser.addOption( - "-clone_start_tls %s #use startTLS for cloning replication agreement (optional, default is false)", - x_clone_start_tls); // key and algorithm options (default) parser.addOption("-key_type %s #Key type [RSA,ECC] (optional, default is RSA)", x_key_type); @@ -1139,7 +1122,6 @@ public class ConfigureOCSP { db_name = x_db_name.value; secure_conn = set_default(x_secure_conn.value, "false"); remove_data = set_default(x_remove_data.value, "false"); - clone_start_tls = set_default(x_clone_start_tls.value, "false"); key_type = set_default(x_key_type.value, DEFAULT_KEY_TYPE); signing_key_type = set_default(x_signing_key_type.value, key_type); diff --git a/pki/base/silent/src/com/netscape/pkisilent/ConfigureRA.java b/pki/base/silent/src/com/netscape/pkisilent/ConfigureRA.java index 2d109595a..3de70a067 100644 --- a/pki/base/silent/src/com/netscape/pkisilent/ConfigureRA.java +++ b/pki/base/silent/src/com/netscape/pkisilent/ConfigureRA.java @@ -19,6 +19,7 @@ package com.netscape.pkisilent; // --- END COPYRIGHT BLOCK --- import java.io.ByteArrayInputStream; +import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import com.netscape.pkisilent.argparser.ArgParser; @@ -158,7 +159,7 @@ public class ConfigureRA { return st; } - public boolean DomainPanel() { + public boolean DomainPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); @@ -168,7 +169,7 @@ public class ConfigureRA { String query_string = "p=1" + "&choice=existingdomain" + "&sdomainURL=" + - URLEncoder.encode(domain_url) + + URLEncoder.encode(domain_url, "UTF-8") + "&op=next" + "&xml=true"; @@ -191,20 +192,20 @@ public class ConfigureRA { } - public boolean SecurityDomainLoginPanel() { + public boolean SecurityDomainLoginPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; String ra_url = "https://" + cs_hostname + ":" + cs_port + "/ra/admin/console/config/wizard" + "?p=3&subsystem=RA"; - String query_string = "url=" + URLEncoder.encode(ra_url) + ""; + String query_string = "url=" + URLEncoder.encode(ra_url, "UTF-8") + ""; hr = hc.sslConnect(sd_hostname, sd_admin_port, sd_login_uri, query_string); String query_string_1 = "uid=" + sd_admin_name + - "&pwd=" + URLEncoder.encode(sd_admin_password) + - "&url=" + URLEncoder.encode(ra_url) + + "&pwd=" + URLEncoder.encode(sd_admin_password, "UTF-8") + + "&url=" + URLEncoder.encode(ra_url, "UTF-8") + ""; hr = hc.sslConnect(sd_hostname, sd_admin_port, sd_get_cookie_uri, @@ -235,7 +236,7 @@ public class ConfigureRA { } - public boolean SubsystemPanel() { + public boolean SubsystemPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); @@ -244,7 +245,7 @@ public class ConfigureRA { String query_string = "p=3" + "&choice=newsubsystem" + "&subsystemName=" + - URLEncoder.encode(subsystem_name) + + URLEncoder.encode(subsystem_name, "UTF-8") + "&op=next" + "&xml=true"; @@ -290,7 +291,7 @@ public class ConfigureRA { return true; } - public boolean TokenChoicePanel() { + public boolean TokenChoicePanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); @@ -302,7 +303,7 @@ public class ConfigureRA { if (token_name.equalsIgnoreCase("internal")) { query_string = "p=6" + "&choice=" + - URLEncoder.encode("NSS Certificate DB") + + URLEncoder.encode("NSS Certificate DB", "UTF-8") + "&op=next" + "&xml=true"; @@ -317,9 +318,9 @@ public class ConfigureRA { // login to hsm first query_string = "p=7" + "&uTokName=" + - URLEncoder.encode(token_name) + + URLEncoder.encode(token_name, "UTF-8") + "&__uPasswd=" + - URLEncoder.encode(token_pwd) + + URLEncoder.encode(token_pwd, "UTF-8") + "&op=next" + "&xml=true"; @@ -332,7 +333,7 @@ public class ConfigureRA { // choice with token name now query_string = "p=6" + "&choice=" + - URLEncoder.encode(token_name) + + URLEncoder.encode(token_name, "UTF-8") + "&op=next" + "&xml=true"; @@ -375,20 +376,20 @@ public class ConfigureRA { return true; } - public boolean CertSubjectPanel() { + public boolean CertSubjectPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); String query_string = "p=9" + "&sslserver=" + - URLEncoder.encode(ra_server_cert_subject_name) + + URLEncoder.encode(ra_server_cert_subject_name, "UTF-8") + "&sslserver_nick=" + - URLEncoder.encode(ra_server_cert_nickname) + + URLEncoder.encode(ra_server_cert_nickname, "UTF-8") + "&subsystem=" + - URLEncoder.encode(ra_subsystem_cert_subject_name) + + URLEncoder.encode(ra_subsystem_cert_subject_name, "UTF-8") + "&subsystem_nick=" + - URLEncoder.encode(ra_subsystem_cert_nickname) + + URLEncoder.encode(ra_subsystem_cert_nickname, "UTF-8") + "&urls=0" + "&op=next" + "&xml=true"; @@ -426,7 +427,7 @@ public class ConfigureRA { return true; } - public boolean AdminCertReqPanel() { + public boolean AdminCertReqPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); @@ -457,13 +458,13 @@ public class ConfigureRA { String query_string = "p=11" + "&uid=" + admin_user + "&name=" + - URLEncoder.encode("RA Administrator") + + URLEncoder.encode("RA Administrator", "UTF-8") + "&email=" + - URLEncoder.encode(admin_email) + - "&__pwd=" + URLEncoder.encode(admin_password) + - "&__admin_password_again=" + URLEncoder.encode(admin_password) + + URLEncoder.encode(admin_email, "UTF-8") + + "&__pwd=" + URLEncoder.encode(admin_password, "UTF-8") + + "&__admin_password_again=" + URLEncoder.encode(admin_password, "UTF-8") + "&cert_request=" + - URLEncoder.encode(admin_cert_request) + + URLEncoder.encode(admin_cert_request, "UTF-8") + "&display=0" + "&profileId=" + "caAdminCert" + "&cert_request_type=" + "crmf" + @@ -471,11 +472,11 @@ public class ConfigureRA { "&uid=" + admin_user + "&clone=0" + "&securitydomain=" + - URLEncoder.encode(domain_name) + + URLEncoder.encode(domain_name, "UTF-8") + "&subject=" + - URLEncoder.encode(agent_cert_subject) + + URLEncoder.encode(agent_cert_subject, "UTF-8") + "&requestor_name=" + - URLEncoder.encode(requestor_name) + + URLEncoder.encode(requestor_name, "UTF-8") + "&sessionID=" + ra_session_id + "&auth_hostname=" + ca_hostname + "&auth_port=" + ca_ssl_port + @@ -494,7 +495,7 @@ public class ConfigureRA { return true; } - public boolean AdminCertImportPanel() { + public boolean AdminCertImportPanel() throws UnsupportedEncodingException { boolean st = false; HTTPResponse hr = null; ByteArrayInputStream bais = null; @@ -547,7 +548,7 @@ public class ConfigureRA { String query_string_1 = "p=12" + "&serialNumber=" + admin_serial_number + "&caHost=" + - URLEncoder.encode(ca_hostname) + + URLEncoder.encode(ca_hostname, "UTF-8") + "&caPort=" + ca_admin_port + "&op=next" + "&xml=true"; @@ -562,7 +563,7 @@ public class ConfigureRA { return true; } - public boolean ConfigureRAInstance() { + public boolean ConfigureRAInstance() throws UnsupportedEncodingException { // 0. login to cert db ComCrypto cCrypt = new ComCrypto(client_certdb_dir, client_certdb_pwd, @@ -676,7 +677,7 @@ public class ConfigureRA { return true; } - public static void main(String args[]) { + public static void main(String args[]) throws UnsupportedEncodingException { ConfigureRA ca = new ConfigureRA(); // set variables diff --git a/pki/base/silent/src/com/netscape/pkisilent/ConfigureSubCA.java b/pki/base/silent/src/com/netscape/pkisilent/ConfigureSubCA.java index 6dacc9e08..706827c74 100644 --- a/pki/base/silent/src/com/netscape/pkisilent/ConfigureSubCA.java +++ b/pki/base/silent/src/com/netscape/pkisilent/ConfigureSubCA.java @@ -19,6 +19,7 @@ package com.netscape.pkisilent; // --- END COPYRIGHT BLOCK --- import java.io.ByteArrayInputStream; +import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.ArrayList; @@ -86,7 +87,6 @@ public class ConfigureSubCA { public static String base_dn = null; public static String db_name = null; public static String secure_conn = null; - public static String clone_start_tls = null; public static String remove_data = null; public static String key_type = null; @@ -210,8 +210,7 @@ public class ConfigureSubCA { return st; } - public boolean TokenChoicePanel() { - boolean st = false; + public boolean TokenChoicePanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); @@ -223,7 +222,7 @@ public class ConfigureSubCA { if (token_name.equalsIgnoreCase("internal")) { query_string = "p=1" + "&op=next" + "&xml=true" + "&choice=" + - URLEncoder.encode("Internal Key Storage Token") + + URLEncoder.encode("Internal Key Storage Token", "UTF-8") + ""; hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); // parse xml @@ -236,9 +235,9 @@ public class ConfigureSubCA { // login to hsm first query_string = "p=2" + "&op=next" + "&xml=true" + "&uTokName=" + - URLEncoder.encode(token_name) + + URLEncoder.encode(token_name, "UTF-8") + "&__uPasswd=" + - URLEncoder.encode(token_pwd) + + URLEncoder.encode(token_pwd, "UTF-8") + ""; hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); // parse xml @@ -249,7 +248,7 @@ public class ConfigureSubCA { // choice with token name now query_string = "p=1" + "&op=next" + "&xml=true" + "&choice=" + - URLEncoder.encode(token_name) + + URLEncoder.encode(token_name, "UTF-8") + ""; hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); // parse xml @@ -262,8 +261,7 @@ public class ConfigureSubCA { return true; } - public boolean DomainPanel() { - boolean st = false; + public boolean DomainPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); @@ -271,9 +269,9 @@ public class ConfigureSubCA { String domain_url = "https://" + sd_hostname + ":" + sd_admin_port; String query_string = "sdomainURL=" + - URLEncoder.encode(domain_url) + + URLEncoder.encode(domain_url, "UTF-8") + "&sdomainName=" + - URLEncoder.encode(domain_name) + + URLEncoder.encode(domain_name, "UTF-8") + "&choice=existingdomain" + "&p=3" + "&op=next" + @@ -296,18 +294,18 @@ public class ConfigureSubCA { } - public boolean SecurityDomainLoginPanel() { + public boolean SecurityDomainLoginPanel() throws UnsupportedEncodingException { String subca_url = "https://" + cs_hostname + ":" + cs_port + "/ca/admin/console/config/wizard" + "?p=5&subsystem=CA"; - String query_string = "url=" + URLEncoder.encode(subca_url); + String query_string = "url=" + URLEncoder.encode(subca_url, "UTF-8"); HTTPResponse hr = hc.sslConnect(sd_hostname, sd_admin_port, sd_login_uri, query_string); String query_string_1 = "uid=" + sd_admin_name + - "&pwd=" + URLEncoder.encode(sd_admin_password) + - "&url=" + URLEncoder.encode(subca_url); + "&pwd=" + URLEncoder.encode(sd_admin_password, "UTF-8") + + "&url=" + URLEncoder.encode(subca_url, "UTF-8"); hr = hc.sslConnect(sd_hostname, sd_admin_port, sd_get_cookie_uri, query_string_1); @@ -334,13 +332,13 @@ public class ConfigureSubCA { } - public boolean DisplayChainPanel() { + public boolean DisplayChainPanel() throws UnsupportedEncodingException { String query_string = "p=5" + "&op=next" + "&xml=true" + "&choice=newsubsystem" + "&subsystemName=" + - URLEncoder.encode(subsystem_name) + + URLEncoder.encode(subsystem_name, "UTF-8") + "&subsystemName=" + - URLEncoder.encode(subsystem_name) + + URLEncoder.encode(subsystem_name, "UTF-8") + "&urls=0"; hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); // parse xml @@ -352,7 +350,6 @@ public class ConfigureSubCA { } public boolean HierarchyPanel() { - boolean st = false; HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); @@ -371,22 +368,20 @@ public class ConfigureSubCA { } - public boolean LdapConnectionPanel() { - boolean st = false; + public boolean LdapConnectionPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); String query_string = "p=9" + "&op=next" + "&xml=true" + - "&host=" + URLEncoder.encode(ldap_host) + - "&port=" + URLEncoder.encode(ldap_port) + - "&basedn=" + URLEncoder.encode(base_dn) + - "&database=" + URLEncoder.encode(db_name) + - "&binddn=" + URLEncoder.encode(bind_dn) + - "&__bindpwd=" + URLEncoder.encode(bind_password) + - "&display=" + URLEncoder.encode("$displayStr") + + "&host=" + URLEncoder.encode(ldap_host, "UTF-8") + + "&port=" + URLEncoder.encode(ldap_port, "UTF-8") + + "&basedn=" + URLEncoder.encode(base_dn, "UTF-8") + + "&database=" + URLEncoder.encode(db_name, "UTF-8") + + "&binddn=" + URLEncoder.encode(bind_dn, "UTF-8") + + "&__bindpwd=" + URLEncoder.encode(bind_password, "UTF-8") + + "&display=" + URLEncoder.encode("$displayStr", "UTF-8") + (secure_conn.equals("true") ? "&secureConn=on" : "") + - (clone_start_tls.equals("true") ? "&cloneStartTLS=on" : "") + (remove_data.equals("true") ? "&removeData=true" : ""); hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); @@ -400,7 +395,6 @@ public class ConfigureSubCA { } public boolean KeyPanel() { - boolean st = false; HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); @@ -473,8 +467,7 @@ public class ConfigureSubCA { return true; } - public boolean CertSubjectPanel() { - boolean st = false; + public boolean CertSubjectPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); @@ -484,15 +477,15 @@ public class ConfigureSubCA { String query_string = "p=11" + "&op=next" + "&xml=true" + "&signing=" + - URLEncoder.encode(subca_sign_cert_subject_name) + + URLEncoder.encode(subca_sign_cert_subject_name, "UTF-8") + "&ocsp_signing=" + - URLEncoder.encode(subca_ocsp_cert_subject_name) + + URLEncoder.encode(subca_ocsp_cert_subject_name, "UTF-8") + "&sslserver=" + - URLEncoder.encode(subca_server_cert_subject_name) + + URLEncoder.encode(subca_server_cert_subject_name, "UTF-8") + "&subsystem=" + - URLEncoder.encode(subca_subsystem_cert_subject_name) + + URLEncoder.encode(subca_subsystem_cert_subject_name, "UTF-8") + "&audit_signing=" + - URLEncoder.encode(subca_audit_signing_cert_subject_name) + + URLEncoder.encode(subca_audit_signing_cert_subject_name, "UTF-8") + "&urls=0" + ""; @@ -560,26 +553,26 @@ public class ConfigureSubCA { return true; } - public boolean CertificatePanel() { + public boolean CertificatePanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); String query_string = "p=12" + "&op=next" + "&xml=true" + "&signing=" + - URLEncoder.encode(ca_cert_cert) + + URLEncoder.encode(ca_cert_cert, "UTF-8") + "&signing_cc=" + "&ocsp_signing=" + - URLEncoder.encode(ocsp_cert_cert) + + URLEncoder.encode(ocsp_cert_cert, "UTF-8") + "&ocsp_signing_cc=" + "&sslserver=" + - URLEncoder.encode(server_cert_cert) + + URLEncoder.encode(server_cert_cert, "UTF-8") + "&sslserver_cc=" + "&subsystem=" + - URLEncoder.encode(ca_subsystem_cert_cert) + + URLEncoder.encode(ca_subsystem_cert_cert, "UTF-8") + "&subsystem_cc=" + "&audit_signing=" + - URLEncoder.encode(ca_audit_signing_cert_cert) + + URLEncoder.encode(ca_audit_signing_cert_cert, "UTF-8") + "&audit_signing_cc=" + ""; @@ -593,16 +586,15 @@ public class ConfigureSubCA { return true; } - public boolean BackupPanel() { - boolean st = false; + public boolean BackupPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); String query_string = "p=13" + "&op=next" + "&xml=true" + "&choice=backupkey" + - "&__pwd=" + URLEncoder.encode(backup_pwd) + - "&__pwdagain=" + URLEncoder.encode(backup_pwd); + "&__pwd=" + URLEncoder.encode(backup_pwd, "UTF-8") + + "&__pwdagain=" + URLEncoder.encode(backup_pwd, "UTF-8"); hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); @@ -635,7 +627,7 @@ public class ConfigureSubCA { } } - public boolean AdminCertReqPanel() { + public boolean AdminCertReqPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); @@ -663,22 +655,22 @@ public class ConfigureSubCA { String query_string = "p=16" + "&op=next" + "&xml=true" + "&uid=" + admin_user + - "&name=" + URLEncoder.encode(agent_name) + + "&name=" + URLEncoder.encode(agent_name, "UTF-8") + "&email=" + - URLEncoder.encode(admin_email) + - "&__pwd=" + URLEncoder.encode(admin_password) + - "&__admin_password_again=" + URLEncoder.encode(admin_password) + + URLEncoder.encode(admin_email, "UTF-8") + + "&__pwd=" + URLEncoder.encode(admin_password, "UTF-8") + + "&__admin_password_again=" + URLEncoder.encode(admin_password, "UTF-8") + "&cert_request=" + - URLEncoder.encode(admin_cert_request) + - "&display=" + URLEncoder.encode("$displayStr") + + URLEncoder.encode(admin_cert_request, "UTF-8") + + "&display=" + URLEncoder.encode("$displayStr", "UTF-8") + "&profileId=" + "caAdminCert" + "&cert_request_type=" + "crmf" + "&import=true" + "&uid=" + admin_user + "&securitydomain=" + - URLEncoder.encode(domain_name) + + URLEncoder.encode(domain_name, "UTF-8") + "&subject=" + - URLEncoder.encode(agent_cert_subject) + + URLEncoder.encode(agent_cert_subject, "UTF-8") + ""; hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); @@ -732,16 +724,15 @@ public class ConfigureSubCA { return true; } - public boolean UpdateDomainPanel() { - boolean st = false; + public boolean UpdateDomainPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); String query_string = "p=17" + "&serialNumber=" + admin_serial_number + - "&caHost=" + URLEncoder.encode(sd_hostname) + - "&caPort=" + URLEncoder.encode(sd_admin_port) + + "&caHost=" + URLEncoder.encode(sd_hostname, "UTF-8") + + "&caPort=" + URLEncoder.encode(sd_admin_port, "UTF-8") + "&importCert=" + "true" + "&op=next" + "&xml=true" + ""; @@ -764,7 +755,7 @@ public class ConfigureSubCA { return true; } - public boolean ConfigureSubCAInstance() { + public boolean ConfigureSubCAInstance() throws UnsupportedEncodingException { // 0. login to cert db ComCrypto cCrypt = new ComCrypto(client_certdb_dir, client_certdb_pwd, @@ -909,7 +900,7 @@ public class ConfigureSubCA { } } - public static void main(String args[]) { + public static void main(String args[]) throws UnsupportedEncodingException { ConfigureSubCA ca = new ConfigureSubCA(); // set variables @@ -945,7 +936,6 @@ public class ConfigureSubCA { StringHolder x_base_dn = new StringHolder(); StringHolder x_db_name = new StringHolder(); StringHolder x_secure_conn = new StringHolder(); - StringHolder x_clone_start_tls = new StringHolder(); StringHolder x_remove_data = new StringHolder(); // key properties (defaults) @@ -1062,9 +1052,6 @@ public class ConfigureSubCA { parser.addOption("-secure_conn %s #use ldaps port (optional, default is false)", x_secure_conn); parser.addOption("-remove_data %s #remove existing data under base_dn (optional, default is false) ", x_remove_data); - parser.addOption( - "-clone_start_tls %s #use startTLS for cloning replication agreement (optional, default is false)", - x_clone_start_tls); // key and algorithm options (default) parser.addOption("-key_type %s #Key type [RSA,ECC] (optional, default is RSA)", x_key_type); @@ -1198,7 +1185,6 @@ public class ConfigureSubCA { db_name = x_db_name.value; secure_conn = set_default(x_secure_conn.value, "false"); remove_data = set_default(x_remove_data.value, "false"); - clone_start_tls = set_default(x_clone_start_tls.value, "false"); key_type = set_default(x_key_type.value, DEFAULT_KEY_TYPE); signing_key_type = set_default(x_signing_key_type.value, key_type); diff --git a/pki/base/silent/src/com/netscape/pkisilent/ConfigureTKS.java b/pki/base/silent/src/com/netscape/pkisilent/ConfigureTKS.java index 092658b50..760690888 100644 --- a/pki/base/silent/src/com/netscape/pkisilent/ConfigureTKS.java +++ b/pki/base/silent/src/com/netscape/pkisilent/ConfigureTKS.java @@ -24,6 +24,7 @@ import java.io.ByteArrayInputStream; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStreamReader; +import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.ArrayList; @@ -92,7 +93,6 @@ public class ConfigureTKS { public static String base_dn = null; public static String db_name = null; public static String secure_conn = null; - public static String clone_start_tls = null; public static String remove_data = null; public static String key_type = null; @@ -191,8 +191,7 @@ public class ConfigureTKS { return st; } - public boolean TokenChoicePanel() { - boolean st = false; + public boolean TokenChoicePanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); @@ -203,7 +202,7 @@ public class ConfigureTKS { if (token_name.equalsIgnoreCase("internal")) { query_string = "p=1" + "&op=next" + "&xml=true" + "&choice=" + - URLEncoder.encode("Internal Key Storage Token") + + URLEncoder.encode("Internal Key Storage Token", "UTF-8") + ""; hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); // parse xml @@ -216,9 +215,9 @@ public class ConfigureTKS { // login to hsm first query_string = "p=2" + "&op=next" + "&xml=true" + "&uTokName=" + - URLEncoder.encode(token_name) + + URLEncoder.encode(token_name, "UTF-8") + "&__uPasswd=" + - URLEncoder.encode(token_pwd) + + URLEncoder.encode(token_pwd, "UTF-8") + ""; hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); // parse xml @@ -229,7 +228,7 @@ public class ConfigureTKS { // choice with token name now query_string = "p=1" + "&op=next" + "&xml=true" + "&choice=" + - URLEncoder.encode(token_name) + + URLEncoder.encode(token_name, "UTF-8") + ""; hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); // parse xml @@ -241,8 +240,7 @@ public class ConfigureTKS { return true; } - public boolean DomainPanel() { - boolean st = false; + public boolean DomainPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); @@ -250,7 +248,7 @@ public class ConfigureTKS { String domain_url = "https://" + sd_hostname + ":" + sd_admin_port; String query_string = "sdomainURL=" + - URLEncoder.encode(domain_url) + + URLEncoder.encode(domain_url, "UTF-8") + "&choice=existingdomain" + "&p=3" + "&op=next" + @@ -279,18 +277,18 @@ public class ConfigureTKS { } - public boolean SecurityDomainLoginPanel() { + public boolean SecurityDomainLoginPanel() throws UnsupportedEncodingException { String tks_url = "https://" + cs_hostname + ":" + cs_port + "/tks/admin/console/config/wizard" + "?p=5&subsystem=TKS"; - String query_string = "url=" + URLEncoder.encode(tks_url); + String query_string = "url=" + URLEncoder.encode(tks_url, "UTF-8"); HTTPResponse hr = hc.sslConnect(sd_hostname, sd_admin_port, sd_login_uri, query_string); String query_string_1 = "uid=" + sd_admin_name + - "&pwd=" + URLEncoder.encode(sd_admin_password) + - "&url=" + URLEncoder.encode(tks_url); + "&pwd=" + URLEncoder.encode(sd_admin_password, "UTF-8") + + "&url=" + URLEncoder.encode(tks_url, "UTF-8"); hr = hc.sslConnect(sd_hostname, sd_admin_port, sd_get_cookie_uri, query_string_1); @@ -322,15 +320,14 @@ public class ConfigureTKS { } - public boolean SubsystemPanel() { - boolean st = false; + public boolean SubsystemPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); String query_string = "p=5" + "&op=next" + "&xml=true" + "&subsystemName=" + - URLEncoder.encode(subsystem_name) + + URLEncoder.encode(subsystem_name, "UTF-8") + "&choice=newsubsystem"; hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); @@ -342,22 +339,20 @@ public class ConfigureTKS { return true; } - public boolean LdapConnectionPanel() { - boolean st = false; + public boolean LdapConnectionPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); String query_string = "p=7" + "&op=next" + "&xml=true" + - "&host=" + URLEncoder.encode(ldap_host) + - "&port=" + URLEncoder.encode(ldap_port) + - "&binddn=" + URLEncoder.encode(bind_dn) + - "&__bindpwd=" + URLEncoder.encode(bind_password) + - "&basedn=" + URLEncoder.encode(base_dn) + - "&database=" + URLEncoder.encode(db_name) + - "&display=" + URLEncoder.encode("$displayStr") + + "&host=" + URLEncoder.encode(ldap_host, "UTF-8") + + "&port=" + URLEncoder.encode(ldap_port, "UTF-8") + + "&binddn=" + URLEncoder.encode(bind_dn, "UTF-8") + + "&__bindpwd=" + URLEncoder.encode(bind_password, "UTF-8") + + "&basedn=" + URLEncoder.encode(base_dn, "UTF-8") + + "&database=" + URLEncoder.encode(db_name, "UTF-8") + + "&display=" + URLEncoder.encode("$displayStr", "UTF-8") + (secure_conn.equals("true") ? "&secureConn=on" : "") + - (clone_start_tls.equals("true") ? "&cloneStartTLS=on" : "") + (remove_data.equals("true") ? "&removeData=true" : ""); hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); @@ -371,7 +366,6 @@ public class ConfigureTKS { } public boolean KeyPanel() { - boolean st = false; HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); @@ -425,8 +419,7 @@ public class ConfigureTKS { return true; } - public boolean CertSubjectPanel() { - boolean st = false; + public boolean CertSubjectPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); @@ -438,13 +431,13 @@ public class ConfigureTKS { String query_string = "p=9" + "&op=next" + "&xml=true" + "&subsystem=" + - URLEncoder.encode(tks_subsystem_cert_subject_name) + + URLEncoder.encode(tks_subsystem_cert_subject_name, "UTF-8") + "&sslserver=" + - URLEncoder.encode(tks_server_cert_subject_name) + + URLEncoder.encode(tks_server_cert_subject_name, "UTF-8") + "&audit_signing=" + - URLEncoder.encode(tks_audit_signing_cert_subject_name) + + URLEncoder.encode(tks_audit_signing_cert_subject_name, "UTF-8") + "&urls=" + - URLEncoder.encode(domain_url) + + URLEncoder.encode(domain_url, "UTF-8") + ""; hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); @@ -478,20 +471,20 @@ public class ConfigureTKS { return true; } - public boolean CertificatePanel() { + public boolean CertificatePanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); String query_string = "p=10" + "&op=next" + "&xml=true" + "&subsystem=" + - URLEncoder.encode(tks_subsystem_cert_cert) + + URLEncoder.encode(tks_subsystem_cert_cert, "UTF-8") + "&subsystem_cc=" + "&sslserver=" + - URLEncoder.encode(server_cert_cert) + + URLEncoder.encode(server_cert_cert, "UTF-8") + "&sslserver_cc=" + "&audit_signing=" + - URLEncoder.encode(tks_audit_signing_cert_cert) + + URLEncoder.encode(tks_audit_signing_cert_cert, "UTF-8") + "&audit_signing_cc=" + ""; @@ -506,16 +499,15 @@ public class ConfigureTKS { return true; } - public boolean BackupPanel() { - boolean st = false; + public boolean BackupPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); String query_string = "p=11" + "&op=next" + "&xml=true" + "&choice=backupkey" + - "&__pwd=" + URLEncoder.encode(backup_pwd) + - "&__pwdagain=" + URLEncoder.encode(backup_pwd); + "&__pwd=" + URLEncoder.encode(backup_pwd, "UTF-8") + + "&__pwdagain=" + URLEncoder.encode(backup_pwd, "UTF-8"); hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); @@ -547,7 +539,7 @@ public class ConfigureTKS { String line = null; while ((line = br.readLine()) != null) System.out.println("Error: " + line); - int exitVal = proc.waitFor(); + proc.waitFor(); // verify p12 file @@ -573,7 +565,7 @@ public class ConfigureTKS { return true; } - public boolean AdminCertReqPanel() { + public boolean AdminCertReqPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); @@ -603,19 +595,19 @@ public class ConfigureTKS { "&cert_request_type=" + "crmf" + "&uid=" + admin_user + "&name=" + admin_user + - "&__pwd=" + URLEncoder.encode(admin_password) + - "&__admin_password_again=" + URLEncoder.encode(admin_password) + + "&__pwd=" + URLEncoder.encode(admin_password, "UTF-8") + + "&__admin_password_again=" + URLEncoder.encode(admin_password, "UTF-8") + "&profileId=" + "caAdminCert" + "&email=" + - URLEncoder.encode(admin_email) + + URLEncoder.encode(admin_email, "UTF-8") + "&cert_request=" + - URLEncoder.encode(admin_cert_request) + + URLEncoder.encode(admin_cert_request, "UTF-8") + "&subject=" + - URLEncoder.encode(agent_cert_subject) + + URLEncoder.encode(agent_cert_subject, "UTF-8") + "&clone=new" + "&import=true" + "&securitydomain=" + - URLEncoder.encode(domain_name) + + URLEncoder.encode(domain_name, "UTF-8") + ""; hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); @@ -668,15 +660,14 @@ public class ConfigureTKS { return true; } - public boolean UpdateDomainPanel() { - boolean st = false; + public boolean UpdateDomainPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); String query_string = "p=14" + "&op=next" + "&xml=true" + - "&caHost=" + URLEncoder.encode(sd_hostname) + - "&caPort=" + URLEncoder.encode(sd_agent_port) + + "&caHost=" + URLEncoder.encode(sd_hostname, "UTF-8") + + "&caPort=" + URLEncoder.encode(sd_agent_port, "UTF-8") + ""; hr = hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string); @@ -689,7 +680,7 @@ public class ConfigureTKS { return true; } - public boolean ConfigureTKSInstance() { + public boolean ConfigureTKSInstance() throws UnsupportedEncodingException { // 0. login to cert db ComCrypto cCrypt = new ComCrypto(client_certdb_dir, client_certdb_pwd, @@ -836,7 +827,7 @@ public class ConfigureTKS { } } - public static void main(String args[]) { + public static void main(String args[]) throws UnsupportedEncodingException { ConfigureTKS ca = new ConfigureTKS(); // set variables @@ -872,7 +863,6 @@ public class ConfigureTKS { StringHolder x_base_dn = new StringHolder(); StringHolder x_db_name = new StringHolder(); StringHolder x_secure_conn = new StringHolder(); - StringHolder x_clone_start_tls = new StringHolder(); StringHolder x_remove_data = new StringHolder(); // key properties (defaults) @@ -974,9 +964,6 @@ public class ConfigureTKS { parser.addOption("-secure_conn %s #use ldaps port (optional, default is false)", x_secure_conn); parser.addOption("-remove_data %s #remove existing data under base_dn (optional, default is false) ", x_remove_data); - parser.addOption( - "-clone_start_tls %s #use startTLS for cloning replication agreement (optional, default is false)", - x_clone_start_tls); // key and algorithm options (default) parser.addOption("-key_type %s #Key type [RSA,ECC] (optional, default is RSA)", x_key_type); @@ -1085,7 +1072,6 @@ public class ConfigureTKS { db_name = x_db_name.value; secure_conn = set_default(x_secure_conn.value, "false"); remove_data = set_default(x_remove_data.value, "false"); - clone_start_tls = set_default(x_clone_start_tls.value, "false"); key_type = set_default(x_key_type.value, DEFAULT_KEY_TYPE); audit_signing_key_type = set_default(x_audit_signing_key_type.value, key_type); diff --git a/pki/base/silent/src/com/netscape/pkisilent/ConfigureTPS.java b/pki/base/silent/src/com/netscape/pkisilent/ConfigureTPS.java index d4df34a39..366fb57b6 100644 --- a/pki/base/silent/src/com/netscape/pkisilent/ConfigureTPS.java +++ b/pki/base/silent/src/com/netscape/pkisilent/ConfigureTPS.java @@ -19,6 +19,7 @@ package com.netscape.pkisilent; // --- END COPYRIGHT BLOCK --- import java.io.ByteArrayInputStream; +import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import com.netscape.pkisilent.argparser.ArgParser; @@ -193,8 +194,7 @@ public class ConfigureTPS { return st; } - public boolean DomainPanel() { - boolean st = false; + public boolean DomainPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); @@ -204,7 +204,7 @@ public class ConfigureTPS { String query_string = "p=3" + "&choice=existingdomain" + "&sdomainURL=" + - URLEncoder.encode(domain_url) + + URLEncoder.encode(domain_url, "UTF-8") + "&op=next" + "&xml=true"; @@ -227,18 +227,18 @@ public class ConfigureTPS { } - public boolean SecurityDomainLoginPanel() { + public boolean SecurityDomainLoginPanel() throws UnsupportedEncodingException { String tps_url = "https://" + cs_hostname + ":" + cs_port + "/tps/admin/console/config/wizard" + "?p=3&subsystem=TPS"; - String query_string = "url=" + URLEncoder.encode(tps_url) + ""; + String query_string = "url=" + URLEncoder.encode(tps_url, "UTF-8") + ""; HTTPResponse hr = hc.sslConnect(sd_hostname, sd_admin_port, sd_login_uri, query_string); String query_string_1 = "uid=" + sd_admin_name + - "&pwd=" + URLEncoder.encode(sd_admin_password) + - "&url=" + URLEncoder.encode(tps_url) + + "&pwd=" + URLEncoder.encode(sd_admin_password, "UTF-8") + + "&url=" + URLEncoder.encode(tps_url, "UTF-8") + ""; hr = hc.sslConnect(sd_hostname, sd_admin_port, sd_get_cookie_uri, @@ -269,8 +269,7 @@ public class ConfigureTPS { } - public boolean SubsystemPanel() { - boolean st = false; + public boolean SubsystemPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); @@ -279,7 +278,7 @@ public class ConfigureTPS { String query_string = "p=5" + "&choice=newsubsystem" + "&subsystemName=" + - URLEncoder.encode(subsystem_name) + + URLEncoder.encode(subsystem_name, "UTF-8") + "&op=next" + "&xml=true"; @@ -304,8 +303,6 @@ public class ConfigureTPS { px.prettyprintxml(); sleep_time(); - // TKS choice panel - String tks_url = "https://" + tks_hostname + ":" + tks_ssl_port; query_string = "p=7" + "&urls=0" + "&op=next" + @@ -339,20 +336,18 @@ public class ConfigureTPS { return true; } - public boolean LdapAuthConnectionPanel() { - // auth db - boolean st = false; + public boolean LdapAuthConnectionPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); String query_string = "p=9" + "&host=" + - URLEncoder.encode(ldap_auth_host) + + URLEncoder.encode(ldap_auth_host, "UTF-8") + "&port=" + - URLEncoder.encode(ldap_auth_port) + + URLEncoder.encode(ldap_auth_port, "UTF-8") + "&basedn=" + - URLEncoder.encode(ldap_auth_base_dn) + + URLEncoder.encode(ldap_auth_base_dn, "UTF-8") + "&op=next" + "&xml=true"; @@ -366,27 +361,25 @@ public class ConfigureTPS { return true; } - public boolean LdapConnectionPanel() { - boolean st = false; + public boolean LdapConnectionPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); String query_string = "p=10" + "&host=" + - URLEncoder.encode(ldap_host) + + URLEncoder.encode(ldap_host, "UTF-8") + "&port=" + - URLEncoder.encode(ldap_port) + + URLEncoder.encode(ldap_port, "UTF-8") + "&binddn=" + - URLEncoder.encode(bind_dn) + + URLEncoder.encode(bind_dn, "UTF-8") + "&__bindpwd=" + - URLEncoder.encode(bind_password) + + URLEncoder.encode(bind_password, "UTF-8") + "&basedn=" + - URLEncoder.encode(base_dn) + + URLEncoder.encode(base_dn, "UTF-8") + "&database=" + - URLEncoder.encode(db_name) + + URLEncoder.encode(db_name, "UTF-8") + "&display=" + - URLEncoder.encode("") + "&op=next" + "&xml=true"; @@ -400,8 +393,7 @@ public class ConfigureTPS { return true; } - public boolean TokenChoicePanel() { - boolean st = false; + public boolean TokenChoicePanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); @@ -413,7 +405,7 @@ public class ConfigureTPS { if (token_name.equalsIgnoreCase("internal")) { query_string = "p=1" + "&choice=" + - URLEncoder.encode("NSS Certificate DB") + + URLEncoder.encode("NSS Certificate DB", "UTF-8") + "&op=next" + "&xml=true"; @@ -428,9 +420,9 @@ public class ConfigureTPS { // login to hsm first query_string = "p=2" + "&uTokName=" + - URLEncoder.encode(token_name) + + URLEncoder.encode(token_name, "UTF-8") + "&__uPasswd=" + - URLEncoder.encode(token_pwd) + + URLEncoder.encode(token_pwd, "UTF-8") + "&op=next" + "&xml=true"; @@ -443,7 +435,7 @@ public class ConfigureTPS { // choice with token name now query_string = "p=1" + "&choice=" + - URLEncoder.encode(token_name) + + URLEncoder.encode(token_name, "UTF-8") + "&op=next" + "&xml=true"; @@ -489,24 +481,24 @@ public class ConfigureTPS { return true; } - public boolean CertSubjectPanel() { + public boolean CertSubjectPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); String query_string = "p=12" + "&sslserver=" + - URLEncoder.encode(tps_server_cert_subject_name) + + URLEncoder.encode(tps_server_cert_subject_name, "UTF-8") + "&sslserver_nick=" + - URLEncoder.encode(tps_server_cert_nickname) + + URLEncoder.encode(tps_server_cert_nickname, "UTF-8") + "&subsystem=" + - URLEncoder.encode(tps_subsystem_cert_subject_name) + + URLEncoder.encode(tps_subsystem_cert_subject_name, "UTF-8") + "&subsystem_nick=" + - URLEncoder.encode(tps_subsystem_cert_nickname) + + URLEncoder.encode(tps_subsystem_cert_nickname, "UTF-8") + "&audit_signing=" + - URLEncoder.encode(tps_audit_signing_cert_subject_name) + + URLEncoder.encode(tps_audit_signing_cert_subject_name, "UTF-8") + "&audit_signing_nick=" + - URLEncoder.encode(tps_audit_signing_cert_nickname) + + URLEncoder.encode(tps_audit_signing_cert_nickname, "UTF-8") + "&urls=0" + "&op=next" + "&xml=true"; @@ -548,8 +540,7 @@ public class ConfigureTPS { return true; } - public boolean AdminCertReqPanel() { - boolean st = false; + public boolean AdminCertReqPanel() throws UnsupportedEncodingException { HTTPResponse hr = null; ByteArrayInputStream bais = null; ParseXML px = new ParseXML(); @@ -580,13 +571,13 @@ public class ConfigureTPS { String query_string = "p=14" + "&uid=" + admin_user + "&name=" + - URLEncoder.encode("TPS Administrator") + + URLEncoder.encode("TPS Administrator", "UTF-8") + "&email=" + - URLEncoder.encode(admin_email) + - "&__pwd=" + URLEncoder.encode(admin_password) + - "&__admin_password_again=" + URLEncoder.encode(admin_password) + + URLEncoder.encode(admin_email, "UTF-8") + + "&__pwd=" + URLEncoder.encode(admin_password, "UTF-8") + + "&__admin_password_again=" + URLEncoder.encode(admin_password, "UTF-8") + "&cert_request=" + - URLEncoder.encode(admin_cert_request) + + URLEncoder.encode(admin_cert_request, "UTF-8") + "&display=0" + "&profileId=" + "caAdminCert" + "&cert_request_type=" + "crmf" + @@ -594,11 +585,11 @@ public class ConfigureTPS { "&uid=" + admin_user + "&clone=0" + "&securitydomain=" + - URLEncoder.encode(domain_name) + + URLEncoder.encode(domain_name, "UTF-8") + "&subject=" + - URLEncoder.encode(agent_cert_subject) + + URLEncoder.encode(agent_cert_subject, "UTF-8") + "&requestor_name=" + - URLEncoder.encode(requestor_name) + + URLEncoder.encode(requestor_name, "UTF-8") + "&sessionID=" + tps_session_id + "&auth_hostname=" + ca_hostname + "&auth_port=" + ca_ssl_port + @@ -617,7 +608,7 @@ public class ConfigureTPS { return true; } - public boolean AdminCertImportPanel() { + public boolean AdminCertImportPanel() throws UnsupportedEncodingException { boolean st = false; HTTPResponse hr = null; ByteArrayInputStream bais = null; @@ -670,7 +661,7 @@ public class ConfigureTPS { String query_string_1 = "p=15" + "&serialNumber=" + admin_serial_number + "&caHost=" + - URLEncoder.encode(ca_hostname) + + URLEncoder.encode(ca_hostname, "UTF-8") + "&caPort=" + ca_admin_port + "&op=next" + "&xml=true"; @@ -685,7 +676,7 @@ public class ConfigureTPS { return true; } - public boolean ConfigureTPSInstance() { + public boolean ConfigureTPSInstance() throws UnsupportedEncodingException { // 0. login to cert db ComCrypto cCrypt = new ComCrypto(client_certdb_dir, client_certdb_pwd, @@ -807,7 +798,7 @@ public class ConfigureTPS { return true; } - public static void main(String args[]) { + public static void main(String args[]) throws UnsupportedEncodingException { ConfigureTPS ca = new ConfigureTPS(); // set variables diff --git a/pki/base/silent/src/com/netscape/pkisilent/CreateInstance.java b/pki/base/silent/src/com/netscape/pkisilent/CreateInstance.java deleted file mode 100644 index ddc356a07..000000000 --- a/pki/base/silent/src/com/netscape/pkisilent/CreateInstance.java +++ /dev/null @@ -1,111 +0,0 @@ -package com.netscape.pkisilent; - -// --- BEGIN COPYRIGHT BLOCK --- -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; version 2 of the License. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -// -// (C) 2007 Red Hat, Inc. -// All rights reserved. -// --- END COPYRIGHT BLOCK --- - -import java.net.URLEncoder; - -import com.netscape.pkisilent.common.PostQuery; - -public class CreateInstance { - - private static String host; - private static String port; - private static String AdminDN; - private static String AdminDNPW; - private static String serverRoot; - private static String instanceID; - private static String sieurl; - private static String adminDomain; - private static String first_arg; - - public CreateInstance() {// do nothing :) - } - - public void usage() { - System.out.println("Usage : "); - System.out.println(" createinstance -c host"); - System.out.println(" port"); - System.out.println(" AdminDN"); - System.out.println(" AdminDNPW"); - System.out.println(" adminDomain"); - System.out.println(" serverRoot"); - System.out.println(" instanceID"); - System.out.println(" machineName"); - System.out.println(" sieURL"); - System.out.println(" OR "); - System.out.println(" createinstance -h <to print this usage string>"); - - } - - public boolean CreateInstance() { - String startURL = "/cert/Tasks/Operation/Create"; - String myStringUrl = "http://" + host + "." + adminDomain + ":" + port - + startURL; - - System.out.println(myStringUrl); - - String query = "serverRoot=" + URLEncoder.encode(serverRoot); - - query += "&instanceID=" + URLEncoder.encode(instanceID); - query += "&adminDomain=" + URLEncoder.encode(adminDomain); - query += "&sieURL=" + URLEncoder.encode(sieurl); - query += "&adminUID=" + URLEncoder.encode(AdminDN); - query += "&adminPWD=" + URLEncoder.encode(AdminDNPW); - query += "&machineName=" + URLEncoder.encode(host + "." + adminDomain); - - PostQuery sm = new PostQuery(myStringUrl, AdminDN, AdminDNPW, query); - - return (sm.Send()); - - } - - public static void main(String args[]) { - CreateInstance newinstance = new CreateInstance(); - - // set variables - - first_arg = args[0]; - if (args[0].equals("-h")) { - newinstance.usage(); - System.exit(-1); - } else if (args[0].equals("-c")) { - host = args[1]; - port = args[2]; - AdminDN = args[3]; - AdminDNPW = args[4]; - serverRoot = args[5]; - instanceID = args[6]; - sieurl = args[7]; - adminDomain = args[8]; - - } - - boolean st = newinstance.CreateInstance(); - - if (!st) { - System.out.println("ERROR: Certificate System - Instance NOT created"); - System.exit(-1); - } - - System.out.println("Certificate System - Instance created"); - System.exit(0); - - } - -}; diff --git a/pki/base/silent/src/com/netscape/pkisilent/PKISilent.java b/pki/base/silent/src/com/netscape/pkisilent/PKISilent.java index 705280231..f90832481 100644 --- a/pki/base/silent/src/com/netscape/pkisilent/PKISilent.java +++ b/pki/base/silent/src/com/netscape/pkisilent/PKISilent.java @@ -22,7 +22,7 @@ public class PKISilent { static Class<?>[] classes = { ConfigureCA.class, ConfigureDRM.class, ConfigureOCSP.class, ConfigureRA.class, ConfigureSubCA.class, - ConfigureTKS.class, ConfigureTPS.class, CreateInstance.class, }; + ConfigureTKS.class, ConfigureTPS.class, }; public static final void main(String[] args) { HashMap<String, Method> classMap = new HashMap<String, Method>(); diff --git a/pki/base/silent/src/com/netscape/pkisilent/common/AutoInstaller.java b/pki/base/silent/src/com/netscape/pkisilent/common/AutoInstaller.java deleted file mode 100644 index 879278a50..000000000 --- a/pki/base/silent/src/com/netscape/pkisilent/common/AutoInstaller.java +++ /dev/null @@ -1,2266 +0,0 @@ -package com.netscape.pkisilent.common; - -// --- BEGIN COPYRIGHT BLOCK --- -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; version 2 of the License. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -// -// (C) 2007 Red Hat, Inc. -// All rights reserved. -// --- END COPYRIGHT BLOCK --- - -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.net.URLEncoder; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.Properties; - -/** - * CMS Test Framework. - * Use this class to Configure a CA, RA,DRM,OCSP and SubCA subsystem. - * This simulartes the installation wizard functions and helps to configure a CMS subsystem. - */ - -public class AutoInstaller { - - private static Properties props = null; - - // Admin Server and InternalDB varialbes - private String adminDomain, adminID, adminPWD, adminPort, machineName, host, serverID, instanceID, serverRoot, - sieURL, dbConnPort, dbConnHost, dbInstanceName, dbPassword, dbLDAPauthDN, dbmode, ldapServerDB; - - // CMS Subsystem info - - private String certAdminName, certAdminUid, certAdminPWD, kra, subsystems, ca, ra, ocsp, remoteKRA, - wirelessSupport, eeHttpPort, eeHttpsPort, agentHttpsPort, radminHttpsPort, tokenName, tokenPWD, certType, - keyType, keyLength, SingleSignOnPWD, subjectName, aki, isCA, ski, sslCABit, objectSigningCABit, mailCABit, - hashType, caOComponent, certValidityDays, signingCert, tks; - - // CA info - private String caHostname, caPortnum, caTimeout, caEEPort, enpropfile, cdir, tokenpwd, CAadminId, CAadminPwd, - CAcertnickname, caAgentPortnum, cloneInstanceId; - - // Program variables - private int i; - private String configURL, deamonURL, certInstID; - private String inputLine; - private boolean st = false; - - private String postQuery = null; - private String propFileName; - private StringBuffer spage = new StringBuffer(); - // 4.5 server String CERTtokenName="Internal Key Storage Token"; - private String CERTtokenName = "internal"; - - private String certRequestStr = null, ssl_clientcert = "true"; - - private String raSigningCert = null; - private String kraTransportCert = null; - - private boolean subca = false; - - // / Constructors - - public AutoInstaller() { - } - - /** - * Constructor . Takes parameter Server Root . - */ - public AutoInstaller(String sr) { - serverRoot = sr; - } - - // Set InternalDBVInfo - /** - * Set Internal Database Information . Takes parameters internaldatabase hostname, internaldatabase port, - * internaldatabase name, internaldatabase binddn, internaldatabase password - */ - - public void setInternalDBInfo(String dbh, String dbp, String dbname, String dbdn, String dbpswd) { - dbConnPort = dbp; - dbConnHost = dbh; - dbInstanceName = dbname; - dbPassword = dbpswd; - dbLDAPauthDN = dbdn; - dbmode = "local"; - ldapServerDB = "userRoot"; - } - - // Create Password file - private boolean CreatePasswordFile() { - String s = "internal: " + SingleSignOnPWD; - OutputStream f0 = null; - - try { - f0 = new FileOutputStream( - serverRoot + "/" + instanceID + "/config/password.conf"); - - f0.write(s.getBytes()); - f0.close(); - return true; - } catch (Exception e) { - System.out.println("exception " + e.getMessage()); - try { - if (f0 != null) - f0.close(); - } catch (IOException ioe) { - System.out.println("IO Exception: " + ioe.getMessage()); - } - return false; - } - - } - - private boolean BackupConfigFile() { - FileInputStream f1 = null; - OutputStream f2 = null; - try { - f1 = new FileInputStream( - serverRoot + "/" + instanceID + "/config/CS.cfg"); - int size = f1.available(); - byte b[] = new byte[size]; - - if (f1.read(b) != b.length) { - f1.close(); - return false; - } - f2 = new FileOutputStream( - serverRoot + "/" + instanceID + "/config/CS.cfg.org"); - - f2.write(b); - - f1.close(); - f2.close(); - return true; - } catch (Exception e) { - System.out.println("exception " + e.getMessage()); - try { - if (f1 != null) - f1.close(); - } catch (IOException ioe) { - System.out.println("IO Exception: " + ioe.getMessage()); - } - try { - if (f2 != null) - f2.close(); - } catch (IOException ioe) { - System.out.println("IO Exception: " + ioe.getMessage()); - } - return false; - } - - } - - // Get RaSigning Cert - - public String getRASigningCert() { - return raSigningCert; - } - - // Get KRATransportCert - public String getKRATransportCert() { - return kraTransportCert; - } - - // Set Admin Server Info - - /** - * Set Admin Server Information . Takes parameters : hostname, adminserver portnumber , adminId , adminPassword - */ - public void setAdminInfo(String h, String p, String adDN, String id, String adpwd) { - adminDomain = adDN; - adminID = id; - adminPWD = adpwd; - adminPort = p; - host = h; - - } - - // Set CA Server Info - /** - * Set CA server Information . Takes parametrers :CAhostname, CAEEPORT, CAAGENTPORT , CAAdminUID, CAAdminPassword - */ - - public void setCAInfo(String cah, String caeep, String caagp, String caaduid, String caadpwd) { - caHostname = cah; - caPortnum = caagp; - caTimeout = "30"; - caEEPort = caeep; - CAadminId = caaduid; - CAadminPwd = caadpwd; - caAgentPortnum = caagp; - - } - - // Set ClientDB Info; - /** - * Sets Client Database information . Takes paramters : certdbdir, certdbpasswd, certnickanme - */ - - public void setClientDBInfo(String cd, String pwd, String nickname) { - - cdir = cd; - tokenpwd = pwd; - CAcertnickname = nickname; - } - - // Is this Internal or any hardware token and its password; - /** - * Set token info . Takes paramter "Internal" and tokenpasswd - */ - public void setTokenInfo(String t, String tp) { - - tokenName = t; - tokenPWD = tp; - - } - - // Set Subsystem Information for Configuring - - /** - * Takes parameters - sID- ServerID e.x cert1, sRoot- ServerRootK kT- keyType "RSA/DSA" , kL - keylength (1024.2048) - * , cVD- certificate validity dates e.g 365 for 1 year, sdn - subsystems dn, sAdp - subsystem's Admin port, sAgp - - * subsystems's Agentport,seSP- subsystem's ee SSL port , sep- Subsystems ee port. - */ - - public void setSubSystemInfo(String sID, String sRoot, String kT, String kL, String hT, String cVD, String sdn, - String sAdP, String sAgP, String seSP, String seP) { - serverID = sID; - instanceID = "cert-" + sID; - - keyType = kT; - keyLength = kL; - hashType = hT; - certValidityDays = cVD; - - eeHttpPort = seP; - eeHttpsPort = seSP; - agentHttpsPort = sAgP; - radminHttpsPort = sAdP; - subjectName = sdn; - caOComponent = "test"; - } - - // // Configure CMS Subsystems - - /** - * Confiures a CA Subsystem .Takes parameter : adminSubjectDN, adminUID, AdminPasswd, SingleSignonPasswd - */ - public boolean ConfigureCA(String adn, String aduid, String adp, String ssonpwd) { - certAdminName = adn; - certAdminUid = aduid; - certAdminPWD = adp; - SingleSignOnPWD = ssonpwd; - - signingCert = "caSigningCert"; - certType = signingCert; - subsystems = "ca"; - ca = "true"; - kra = "false"; - ra = "false"; - ocsp = "false"; - remoteKRA = "false"; - wirelessSupport = "false"; - aki = "true"; - isCA = "true"; - ski = "true"; - sslCABit = "true"; - objectSigningCABit = "true"; - mailCABit = "true"; - - if (ConfCA()) { - CreatePasswordFile(); - BackupConfigFile(); - return true; - } - - return false; - - } - - public boolean ConfigureTKS(String adn, String aduid, String adp, String ssonpwd) { - - certAdminName = adn; - certAdminUid = aduid; - certAdminPWD = adp; - SingleSignOnPWD = ssonpwd; - signingCert = "raSigningCert"; - certType = signingCert; - subsystems = "tks"; - ra = "false"; - tks = "true"; - kra = "false"; - ca = "false"; - ocsp = "false"; - remoteKRA = "false"; - wirelessSupport = "false"; - aki = "true"; - isCA = "false"; - ski = "true"; - sslCABit = "true"; - objectSigningCABit = "true"; - mailCABit = "true"; - - if (ConfTKS()) { - CreatePasswordFile(); - BackupConfigFile(); - return true; - } - - return false; - - } - - private boolean ConfTKS() { - // Start Configuring - - // Step 1. Start Deamon - - if (!startDeamon()) { - System.out.println( - "Configuring Cert Instance: Unable to start deamon"); - return false; - } - - // Sometimes it takes time to start deamon so wait for few seconds - try { - System.out.println("going to sleep for 10 seconds"); - Thread.sleep(10000); - } catch (InterruptedException ie) { - System.out.println("sleep exection"); - } - - // Step 1a: Initialize Token ( Changed in 6.0)jjj - if (!initializePWD()) { - System.out.println( - "Configuring Cert Instance: error initializing pwd token"); - return false; - } - - // Step 2. Configure Internal DB - if (!configInternalDB()) { - System.out.println( - "Configuring Cert Instance: error configuring internal db"); - return false; - } - - // Step 3. Create Admin Values - if (!createAdminValues()) { - System.out.println( - "Configuring Cert Instance: error configuring admin values "); - return false; - } - - // Step 4. SubSystems - - if (!selectSubSystem()) { - System.out.println( - "Configuring Cert Instance: error selecting subsystems"); - return false; - } - - // Step 5. Network Configuration - if (!networkConfig()) { - System.out.println( - "Configuring Cert Instance: error configuring network ports "); - return false; - } - - // Create a SSL signing cert - Date tmpdate = new Date(); - - certType = "serverCert"; - subjectName = "CN=" + host + "." + adminDomain + ",OU=ssltest" - + tmpdate.getTime() + ",O=SSL,C=US"; - keyLength = "512"; - keyType = "RSA"; - String mtokenPWD = tokenPWD; - - tokenPWD = ""; - ssl_clientcert = "false"; - signingCert = "server"; - - if (!initializeToken()) { - System.out.println( - "Configuring Cert Instance: error initializing token"); - return false; - } - - // Step 8 : keyLenth - if (!keyLength()) { - System.out.println( - "Configuring Cert Instance: error configuring KeyLength"); - return false; - } - - // Step 9 : CheckDN - if (!checkDN()) { - System.out.println( - "Configuring Cert Instance: error checking deamon"); - return false; - } - - // Step 10 : - if (!certRequest(false)) { - System.out.println( - "Configuring Cert Instance: error creating Request"); - return false; - } - - // After creating ssl cert - tokenPWD = mtokenPWD; - - // Step 11 - if (!singleSignON()) { - System.out.println( - "Configuring Cert Instance: error setting up singlesignon"); - return false; - } - - // Step 11 - if (!doMisc()) { - System.out.println( - "Configuring Cert Instance: error setting up miscell"); - return false; - } - - // Step 12 - if (!exitDeamon()) { - System.out.println( - "Configuring Cert Instance: Unable to exit deamon"); - return false; - } - - return true; - } - - /** - * Confiures a RA Subsystem .Takes parameter : adminSubjectDN, adminUID, AdminPasswd, SingleSignonPasswd - */ - - public boolean ConfigureRA(String adn, String aduid, String adp, String ssonpwd) { - certAdminName = adn; - certAdminUid = aduid; - certAdminPWD = adp; - SingleSignOnPWD = ssonpwd; - - signingCert = "raSigningCert"; - certType = signingCert; - subsystems = "ra"; - ra = "true"; - kra = "false"; - ca = "false"; - ocsp = "false"; - remoteKRA = "false"; - wirelessSupport = "false"; - aki = "true"; - isCA = "true"; - ski = "true"; - sslCABit = "true"; - objectSigningCABit = "true"; - mailCABit = "true"; - - if (ConfRA()) { - CreatePasswordFile(); - BackupConfigFile(); - return true; - } - - return false; - - } - - /** - * Confiures a OCSP Subsystem .Takes parameter : adminSubjectDN, adminUID, AdminPasswd, SingleSignonPasswd - */ - - public boolean ConfigureOCSP(String adn, String aduid, String adp, String ssonpwd) { - certAdminName = adn; - certAdminUid = aduid; - certAdminPWD = adp; - SingleSignOnPWD = ssonpwd; - - signingCert = "ocspSigningCert"; - certType = signingCert; - subsystems = "ocsp"; - ocsp = "true"; - kra = "false"; - ra = "false"; - ca = "false"; - remoteKRA = "false"; - wirelessSupport = "false"; - aki = "true"; - isCA = "true"; - ski = "true"; - sslCABit = "true"; - objectSigningCABit = "true"; - mailCABit = "true"; - - if (ConfOCSP()) { - CreatePasswordFile(); - BackupConfigFile(); - return true; - } - - return false; - } - - /** - * Confiures a KRA Subsystem .Takes parameter : adminSubjectDN, adminUID, AdminPasswd, SingleSignonPasswd - */ - - public boolean ConfigureKRA(String adn, String aduid, String adp, String ssonpwd) { - certAdminName = adn; - certAdminUid = aduid; - certAdminPWD = adp; - SingleSignOnPWD = ssonpwd; - - signingCert = "kraTransportCert"; - certType = signingCert; - subsystems = "kra"; - kra = "true"; - ca = "false"; - ra = "false"; - ocsp = "false"; - remoteKRA = "false"; - wirelessSupport = "false"; - aki = "true"; - isCA = "true"; - ski = "true"; - sslCABit = "true"; - objectSigningCABit = "true"; - mailCABit = "true"; - if (ConfKRA()) { - CreatePasswordFile(); - BackupConfigFile(); - return true; - } - - return false; - } - - /** - * Confiures a SubCA Subsystem .Takes parameter : adminSubjectDN, adminUID, AdminPasswd, SingleSignonPasswd - */ - - public boolean ConfigureSubCA(String adn, String aduid, String adp, String ssonpwd) { - certAdminName = adn; - certAdminUid = aduid; - certAdminPWD = adp; - SingleSignOnPWD = ssonpwd; - subca = true; - signingCert = "caSigningCert"; - certType = signingCert; - subsystems = "ca"; - ca = "true"; - kra = "false"; - ra = "false"; - ocsp = "false"; - remoteKRA = "false"; - wirelessSupport = "false"; - aki = "true"; - isCA = "true"; - ski = "true"; - sslCABit = "true"; - objectSigningCABit = "true"; - mailCABit = "true"; - - if (ConfSubCA()) { - CreatePasswordFile(); - BackupConfigFile(); - return true; - } - - return false; - } - - // //////////////////////////////////////////////////////// - - private void getProperties(String filePath) throws Exception { - FileInputStream fis = null; - try { - fis = new FileInputStream(filePath); - - props = new Properties(); - props.load(fis); - System.out.println("Reading Properties file successful"); - } catch (Exception e) { - System.out.println("exception " + e.getMessage()); - } - try { - if (fis != null) - fis.close(); - } catch (IOException ioe) { - System.out.println("IO Exception: " + ioe.getMessage()); - } - } - - private void setPropFile(String fileName) { - propFileName = fileName; - } - - private void setConfigURL() { - configURL = "/" + instanceID + "/Tasks/Operation/config-cert"; - } - - private void setDeamonURL() { - deamonURL = "/" + instanceID + "/Tasks/Operation/start-daemon"; - - } - - private void setPostQueryString(String querystring) { - postQuery = querystring; - } - - private boolean Connect(String myStringUrl) { - // / This functions connects to the URL and POST HTTP Request . - // It compares with NMC_STATUS and return the status. - System.out.println(myStringUrl); - st = false; - - PostQuery sm = new PostQuery(myStringUrl, adminID, adminPWD, postQuery); - boolean st = sm.Send(); - - spage = sm.getPage(); - return st; - } - - private boolean startDeamon() { - // Set StringURL to connect , set the query string and Connect .Get the result - System.out.println("Log Info - configuring Cert Instance : Start Deamon"); - setDeamonURL(); - String myStringUrl = "http://" + host + "." + adminDomain + ":" - + adminPort + deamonURL; - - System.out.println("Log Info -" + myStringUrl); - String query = "instanceID=" + URLEncoder.encode(instanceID); - - query += "&AdminUsername=" + URLEncoder.encode(adminID); - query += "&AdminUserPassword=" + URLEncoder.encode(adminPWD); - - setPostQueryString(query); - return Connect(myStringUrl); - } - - private boolean configInternalDB() { - - System.out.println( - "Log Info - configuring Cert Instance : configureInternalDB"); - setConfigURL(); - String myStringUrl = "http://" + host + ":" + adminPort + configURL; - - System.out.println(myStringUrl); - String query = "serverRoot=" + URLEncoder.encode(serverRoot); - - query += "&instanceID=" + URLEncoder.encode(instanceID); - query += "&adminUID=" + URLEncoder.encode(adminID); - query += "&opType=" + URLEncoder.encode("OP_MODIFY"); - query += "&taskID=" + URLEncoder.encode("createInternalDB"); - query += "&AdminUserPassword=" + URLEncoder.encode(adminPWD); - query += "&host=" + URLEncoder.encode(host); - query += "&internaldb.ldapconn.host=" + URLEncoder.encode(dbConnHost); - query += "&internaldb.ldapconn.port=" + URLEncoder.encode(dbConnPort); - query += "&internaldb.ldapauth.bindDN=" - + URLEncoder.encode(dbLDAPauthDN); - query += "&db.instanceName=" + URLEncoder.encode(dbInstanceName); - query += "&db.password=" + URLEncoder.encode(dbPassword); - query += "&adminDomain=" + URLEncoder.encode(adminDomain); - query += "&db.mode=" + URLEncoder.encode(dbmode); - query += "&ldapServerDB=" + URLEncoder.encode(ldapServerDB); - query += "&cmsSeed=0"; - // logging - setPostQueryString(query); - return Connect(myStringUrl); - - } - - private boolean createAdminValues() { - System.out.println("configuring Cert Instance : configureAdmin"); - setConfigURL(); - String myStringUrl = "http://" + host + ":" + adminPort + configURL; - - System.out.println(myStringUrl); - String query = "serverRoot=" + URLEncoder.encode(serverRoot); - - query += "&"; - query += "instanceID=" + URLEncoder.encode(instanceID); - query += "&AdminUserPassword=" + URLEncoder.encode(adminPWD); - query += "&cert.admin.name=" + URLEncoder.encode(certAdminName); - query += "&cert.admin.uid=" + URLEncoder.encode(certAdminUid); - query += "&cert.admin.passwd=" + URLEncoder.encode(certAdminPWD); - query += "&db.password=" + URLEncoder.encode(dbPassword); - query += "&opType=" + URLEncoder.encode("OP_MODIFY"); - query += "&taskID=" + URLEncoder.encode("setupAdmin"); - query += "&cmsSeed=0"; - setPostQueryString(query); - return Connect(myStringUrl); - - } - - private boolean selectSubSystem() { - System.out.println("configuring Cert Instance : SubSystems"); - setConfigURL(); - String myStringUrl = "http://" + host + ":" + adminPort + configURL; - - System.out.println(myStringUrl); - String query = "serverRoot=" + URLEncoder.encode(serverRoot); - - query += "&"; - query += "instanceID=" + URLEncoder.encode(instanceID); - query += "&AdminUserPassword=" + URLEncoder.encode(adminPWD); - query += "&db.password=" + URLEncoder.encode(dbPassword); - query += "&internaldb.ldapauth.bindDN=" - + URLEncoder.encode(dbLDAPauthDN); - query += "&kra=" + URLEncoder.encode(kra); - query += "&subsystems=" + URLEncoder.encode(subsystems); - query += "&ca=" + URLEncoder.encode(ca); - query += "&ra=" + URLEncoder.encode(ra); - query += "&ocsp=" + URLEncoder.encode(ocsp); - query += "&remoteKRA=" + URLEncoder.encode(remoteKRA); - query += "&wirelessSupport=" + URLEncoder.encode(wirelessSupport); - query += "&opType=" + URLEncoder.encode("OP_MODIFY"); - query += "&taskID=" + URLEncoder.encode("selectSubsystems"); - query += "&cmsSeed=0"; - - if (subsystems.equals("ca")) { - query += "&internaldb.ldapconn.host=" - + URLEncoder.encode(dbConnHost); - query += "&internaldb.ldapconn.port=" - + URLEncoder.encode(dbConnPort); - - } - if (subsystems.equals("ra")) { - query += "&caHostname=" + caHostname; - query += "&caPortnum=" + caPortnum; - query += "&caTimeout=" + caTimeout; - } - if (subsystems.equals("tks")) { - query += "&tks=true"; - } - - setPostQueryString(query); - return Connect(myStringUrl); - - } - - private boolean setSerial(String start, String end) { - System.out.println("configuring Cert Instance : setCASerial"); - setConfigURL(); - String myStringUrl = "http://" + host + ":" + adminPort + configURL; - - System.out.println(myStringUrl); - String query = "serverRoot=" + URLEncoder.encode(serverRoot); - - query += "&"; - query += "instanceID=" + URLEncoder.encode(instanceID); - query += "&db.password=" + URLEncoder.encode(dbPassword); - query += "&caSerialNumber=" + URLEncoder.encode(start); - query += "&caEndSerialNumber=" + URLEncoder.encode(end); - query += "&opType=" + URLEncoder.encode("OP_MODIFY"); - query += "&taskID=" + URLEncoder.encode("setCASerial"); - query += "&cmsSeed=0"; - setPostQueryString(query); - return Connect(myStringUrl); - } - - private boolean setOCSP() { - System.out.println("configuring Cert Instance : setOCSP"); - setConfigURL(); - String myStringUrl = "http://" + host + ":" + adminPort + configURL; - - System.out.println(myStringUrl); - String query = "serverRoot=" + URLEncoder.encode(serverRoot); - - query += "&"; - query += "instanceID=" + URLEncoder.encode(instanceID); - query += "&CAOCSPService=" + URLEncoder.encode("true"); - query += "&opType=" + URLEncoder.encode("OP_MODIFY"); - query += "&taskID=" + URLEncoder.encode("addOCSPService"); - query += "&cmsSeed=0"; - setPostQueryString(query); - return Connect(myStringUrl); - } - - private boolean networkConfig() { - System.out.println("configuring Cert Instance : Network Config"); - setConfigURL(); - String myStringUrl = "http://" + host + ":" + adminPort + configURL; - - System.out.println(myStringUrl); - String query = "AdminUserPassword=" + URLEncoder.encode(adminPWD); - - query += "&"; - query += "instanceID=" + URLEncoder.encode(instanceID); - if (subsystems.equals("kra")) { - query += "&agentGateway.https.port=" - + URLEncoder.encode(agentHttpsPort); - query += "&radm.https.port=" + URLEncoder.encode(radminHttpsPort); - query += "&eePortsEnable=" + URLEncoder.encode("false"); - } else { - query += "&eeGateway.http.port=" + URLEncoder.encode(eeHttpPort); - query += "&eeGateway.https.port=" + URLEncoder.encode(eeHttpsPort); - query += "&agentGateway.https.port=" - + URLEncoder.encode(agentHttpsPort); - query += "&radm.https.port=" + URLEncoder.encode(radminHttpsPort); - query += "&eePortsEnable=" + URLEncoder.encode("true"); - query += "&eeGateway.http.enable=" + URLEncoder.encode("true"); - } - query += "&opType=" + URLEncoder.encode("OP_MODIFY"); - query += "&taskID=" + URLEncoder.encode("configureNetwork"); - query += "&cmsSeed=0"; - setPostQueryString(query); - return Connect(myStringUrl); - - } - - private boolean initializePWD() { - System.out.println("configuring Cert Instance : Initialize token"); - setConfigURL(); - String myStringUrl = "http://" + host + ":" + adminPort + configURL; - - System.out.println(myStringUrl); - String query = "AdminUserPassword=" + URLEncoder.encode(adminPWD); - - query += "&"; - query += "instanceID=" + URLEncoder.encode(instanceID); - query += "&serverRoot=" + URLEncoder.encode(serverRoot); - query += "&tokenName=" + URLEncoder.encode(tokenName); - query += "&tokenPasswd=" + URLEncoder.encode(tokenPWD); - query += "&opType=" + URLEncoder.encode("OP_MODIFY"); - query += "&taskID=" + URLEncoder.encode("initToken"); - query += "&cmsSeed=0"; - setPostQueryString(query); - return Connect(myStringUrl); - - } - - private boolean initializeToken() { - System.out.println("configuring Cert Instance : Initialize token"); - setConfigURL(); - String myStringUrl = "http://" + host + ":" + adminPort + configURL; - - System.out.println(myStringUrl); - String query = "AdminUserPassword=" + URLEncoder.encode(adminPWD); - - query += "&"; - query += "instanceID=" + URLEncoder.encode(instanceID); - query += "&serverRoot=" + URLEncoder.encode(serverRoot); - query += "&tokenName=" + URLEncoder.encode(tokenName); - query += "&tokenPasswd=" + URLEncoder.encode(tokenPWD); - query += "&certType=" + URLEncoder.encode(certType); - query += "&keyType=" + URLEncoder.encode(keyType); - query += "&keyLength=" + URLEncoder.encode(keyLength); - query += "&sopPasswd=" + URLEncoder.encode(SingleSignOnPWD); - query += "&opType=" + URLEncoder.encode("OP_MODIFY"); - query += "&taskID=" + URLEncoder.encode("initToken"); - query += "&cmsSeed=0"; - setPostQueryString(query); - return Connect(myStringUrl); - - } - - private boolean keyLength() { - System.out.println("configuring Cert Instance : Check Key length"); - setConfigURL(); - String myStringUrl = "http://" + host + ":" + adminPort + configURL; - - System.out.println(myStringUrl); - String query = "AdminUserPassword=" + URLEncoder.encode(adminPWD); - - query += "&"; - query += "instanceID=" + URLEncoder.encode(instanceID); - query += "&serverRoot=" + URLEncoder.encode(serverRoot); - query += "&tokenName=" + URLEncoder.encode(tokenName); - query += "&tokenPasswd=" + URLEncoder.encode(tokenPWD); - query += "&certType=" + URLEncoder.encode(certType); - query += "&keyType=" + URLEncoder.encode(keyType); - query += "&keyLength=" + URLEncoder.encode(keyLength); - query += "&sopPasswd=" + URLEncoder.encode(SingleSignOnPWD); - query += "&opType=" + URLEncoder.encode("OP_MODIFY"); - query += "&taskID=" + URLEncoder.encode("checkKeyLength"); - query += "&cmsSeed=0"; - setPostQueryString(query); - return Connect(myStringUrl); - - } - - private boolean checkDN() { - System.out.println("configuring Cert Instance : Check DN"); - setConfigURL(); - String myStringUrl = "http://" + host + ":" + adminPort + configURL; - - System.out.println(myStringUrl); - String query = "AdminUserPassword=" + URLEncoder.encode(adminPWD); - - query += "&"; - query += "instanceID=" + URLEncoder.encode(instanceID); - query += "&certType=" + URLEncoder.encode(certType); - query += "&subjectName=" + URLEncoder.encode(subjectName); - query += "&opType=" + URLEncoder.encode("OP_MODIFY"); - query += "&taskID=" + URLEncoder.encode("checkDN"); - query += "&cmsSeed=0"; - setPostQueryString(query); - return Connect(myStringUrl); - - } - - private String normalize(String s) { - - String val = ""; - - for (int i = 0; i < s.length(); i++) { - if ((s.charAt(i) == '\\') && (s.charAt(i + 1) == 'n')) { - i++; - continue; - } else if ((s.charAt(i) == '\\') && (s.charAt(i + 1) == 'r')) { - i++; - continue; - } else if (s.charAt(i) == '"') { - continue; - } - val += s.charAt(i); - } - return val; - } - - private String pkcs7Convertcert(String s) { - - String val = ""; - - int len = s.length(); - - for (int i = 0; i < len; i = i + 64) { - - if (i + 64 < len) { - val = val + s.substring(i, i + 64) + "\n"; - } else { - val = val + s.substring(i, len); - } - - } - return val; - } - - private boolean certRequest(boolean trustM) { - // This function prepares a Certificate Request. - // Submits it to the CA - // Approves the request. - // And then installs it - - System.out.println("configuring Cert Instance : cert Request"); - setConfigURL(); - String myStringUrl = "http://" + host + ":" + adminPort + configURL; - - System.out.println(myStringUrl); - - String query = "AdminUserPassword=" + URLEncoder.encode(adminPWD); - - query += "&"; - query += "instanceID=" + URLEncoder.encode(instanceID); - query += "&certType=" + URLEncoder.encode(certType); - query += "&subjectName=" + URLEncoder.encode(subjectName); - query += "&keyType=" + URLEncoder.encode(keyType); - query += "&keyLength=" + URLEncoder.encode(keyLength); - query += "&tokenName=" + URLEncoder.encode(CERTtokenName); - - if (subca) { - query += "&sslCABit=true"; - query += "&objectSigningCABit=true"; - query += "&wirelessSupport=false"; - query += "&mailCABit=true"; - query += "&isCA=true"; - query += "&ski=true"; - query += "&aki=true"; - query += "&keyUsage=true"; - query += "&caSigningCertReqFormat=PKCS10"; - } - - if (subsystems.equals("ra")) { - query += "&aki=" + URLEncoder.encode(aki); - query += "&keyUsage=" + URLEncoder.encode("true"); - query += "&signing_cert=" + signingCert; - } - - if (certType.equals("serverCert")) { - query += "&sslServerBit=" + URLEncoder.encode("true"); - query += "&sslClientBit=" + URLEncoder.encode("true"); - query += "&serverCertReqFormat=PKCS10"; - } else { - if (subsystems.equals("ra")) { - query += "&sslClientBit=" + URLEncoder.encode("true"); - query += "&raSigningCertReqFormat=PKCS10"; - } - - if (subsystems.equals("ocsp")) { - query += "&ocspSigningCertReqFormat=PKCS10"; - } - - if (subsystems.equals("kra")) { - // added keyUsage - query += "&keyUsage=" + URLEncoder.encode("true"); - // added URLEncoder - query += "&aki=" + URLEncoder.encode(aki); - query += "&kraTransportCertReqFormat=PKCS10"; - } - } - - query += "&opType=" + URLEncoder.encode("OP_MODIFY"); - query += "&taskID=" + URLEncoder.encode("certRequest"); - query += "&caHostname=" + caHostname; - query += "&caEEPort=" + caEEPort; - query += "&cmsSeed=0"; - - setPostQueryString(query); - if (!Connect(myStringUrl)) { - System.out.println("Error :certRequest"); - return false; - } - - String res = spage.toString(); - - certRequestStr = res.substring( - res.indexOf("certReq: ") + "certReq: ".length(), - res.indexOf("-----END NEW CERTIFICATE REQUEST-----")); - certRequestStr += "-----END NEW CERTIFICATE REQUEST-----"; - - int ReqId = 0; - - UserEnroll e = new UserEnroll(caHostname, caEEPort, subjectName, "test", - "test", null, "test", "test", cdir, tokenpwd, ssl_clientcert, - keyLength, keyType, null, null, signingCert); - - e.setpkcs10Request(certRequestStr); - if (e.Enroll()) { - ReqId = e.getRequestId(); - } else { - System.out.println("Request was not successful"); - return false; - } - - String trm; - - if (trustM) { - trm = "true"; - } else { - trm = "false"; - } - - Request r = new Request(caHostname, caAgentPortnum, CAadminId, - CAadminPwd, CAcertnickname, cdir, tokenpwd, getString(ReqId), - null, null, "approve", "enrollment", "showWaiting", null, trm); - - if (r.ApproveRequests(getString(ReqId)) <= -1) { - System.out.println( - "Error : Agent request approval was not successful"); - return false; - } - - System.out.println("configuring Cert Instance : req Success"); - - // Checking to see if request is approved. - - setConfigURL(); - myStringUrl = "http://" + host + ":" + adminPort + configURL; - System.out.println(myStringUrl); - - query = "AdminUserPassword=" + URLEncoder.encode(adminPWD); - query += "&"; - query += "instanceID=" + URLEncoder.encode(instanceID); - query += "&certType=" + URLEncoder.encode(certType); - - if (certType.equals("serverCert")) { - query += "&serverCertReqID=" + ReqId; - } else { - query += "&raSigningCertReqID=" + ReqId; - } - - query += "&serverRoot=" + URLEncoder.encode(serverRoot); - query += "&caEEPort=" + caEEPort; - query += "&caHostname=" + host; - query += "&caEEType=https"; - query += "&opType=" + URLEncoder.encode("OP_MODIFY"); - query += "&taskID=" + URLEncoder.encode("reqSuccess"); - query += "&cmsSeed=0"; - - setPostQueryString(query); - if (Connect(myStringUrl)) { - - checkRequest cr = new checkRequest(caHostname, caEEPort, cdir, - tokenpwd, getString(ReqId), null, null); - - if (cr.checkRequestStatus()) { - String cert = cr.getpkcs7ChainCert(); - String certtmp = pkcs7Convertcert(cert); - - certtmp = normalize(certtmp); - cert = "-----BEGIN CERTIFICATE-----" + "\n" + certtmp + "\n" - + "-----END CERTIFICATE-----\n"; - - // install cert - System.out.println( - "configuring Cert Instance : install cert :" + cert); - setConfigURL(); - myStringUrl = "http://" + host + ":" + adminPort + configURL; - System.out.println(myStringUrl); - query = "AdminUserPassword=" + URLEncoder.encode(adminPWD); - query += "&"; - query += "instanceID=" + URLEncoder.encode(instanceID); - query += "&certType=" + URLEncoder.encode(certType); - query += "&db.password=" + URLEncoder.encode(dbPassword); - - if (certType.equals("raSigningCert")) { - query += "&nickname=" - + URLEncoder.encode(certType + " " + instanceID); - raSigningCert = "-----BEGIN CERTIFICATE-----" + "\n" - + cr.getCert() + "\n" - + "-----END CERTIFICATE-----\n"; - - } - - if (certType.equals("kraTransportCert")) { - ComCrypto cCrypto = new ComCrypto(); - - kraTransportCert = cCrypto.normalize(cr.getCert()); - } - - if (certType.equals("serverCert")) { - query += "&nickname=" - + URLEncoder.encode("Server-Cert" + " " + instanceID); - } - - if (certType.equals("ocspSigningCert")) { - query += "&nickname=" - + URLEncoder.encode(certType + " " + instanceID); - } - - query += "&pkcs10=" + URLEncoder.encode(cert); - query += "&opType=" + URLEncoder.encode("OP_MODIFY"); - query += "&taskID=" + URLEncoder.encode("installCert"); - query += "&cmsSeed=0"; - - setPostQueryString(query); - return (Connect(myStringUrl)); - } - - } else { - System.out.println("Error: Request is not approved"); - return false; - } - return true; - } - - private String getString(int m) { - Integer x = new Integer(m); - String s = x.toString(); - - return s; - } - - private boolean createCert() { - System.out.println("configuring Cert Instance : Create Cert"); - - // clauclate the validity dates for the cert. - GregorianCalendar begin = new GregorianCalendar(); - GregorianCalendar end = new GregorianCalendar(); - Integer days = new Integer(certValidityDays); - - end.add(GregorianCalendar.DATE, days.intValue()); - - setConfigURL(); - String myStringUrl = "http://" + host + ":" + adminPort + configURL; - - System.out.println(myStringUrl); - - String query = "AdminUserPassword=" + URLEncoder.encode(adminPWD); - - query += "&"; - query += "instanceID=" + URLEncoder.encode(instanceID); - query += "&serverRoot=" + URLEncoder.encode(serverRoot); - query += "&db.password=" + URLEncoder.encode(dbPassword); - query += "&subjectName=" + URLEncoder.encode(subjectName); - query += "&certType=" + URLEncoder.encode(certType); - - query += "&beginYear=" - + URLEncoder.encode(getString(begin.get(GregorianCalendar.YEAR))); - query += "&beginMonth=" - + URLEncoder.encode( - getString(begin.get(GregorianCalendar.MONTH))); - query += "&beginDate=" - + URLEncoder.encode(getString(begin.get(GregorianCalendar.DATE))); - query += "&beginHour=" - + URLEncoder.encode(getString(begin.get(GregorianCalendar.HOUR))); - query += "&beginMin=" - + URLEncoder.encode( - getString(begin.get(GregorianCalendar.MINUTE))); - query += "&beginSec=" - + URLEncoder.encode( - getString(begin.get(GregorianCalendar.SECOND))); - - query += "&afterYear=" - + URLEncoder.encode(getString(end.get(GregorianCalendar.YEAR))); - query += "&afterMonth=" - + URLEncoder.encode(getString(end.get(GregorianCalendar.MONTH))); - query += "&afterDate=" - + URLEncoder.encode(getString(end.get(GregorianCalendar.DATE))); - query += "&afterHour=" - + URLEncoder.encode(getString(end.get(GregorianCalendar.HOUR))); - query += "&afterMin=" - + URLEncoder.encode(getString(end.get(GregorianCalendar.MINUTE))); - query += "&afterSec=" - + URLEncoder.encode(getString(end.get(GregorianCalendar.SECOND))); - - query += "&keyType=" + URLEncoder.encode(keyType); - query += "&keyLength=" + URLEncoder.encode(keyLength); - - query += "&certLen=" + URLEncoder.encode("-1"); - query += "&tokenName=" + URLEncoder.encode(CERTtokenName); - query += "&aki=" + URLEncoder.encode(aki); - query += "&keyUsage=" + URLEncoder.encode("true"); - - if (certType.equals("serverCert")) { - query += "&sslServerBit=" + URLEncoder.encode("true"); - query += "&sslClientBit=" + URLEncoder.encode("true"); - - } else { - query += "&caOComponent=" + URLEncoder.encode(caOComponent); - query += "&caCComponent=" + URLEncoder.encode("us"); - - query += "&isCA=" + URLEncoder.encode(isCA); - query += "&ski=" + URLEncoder.encode(ski); - query += "&tokenPasswd=" + URLEncoder.encode(tokenPWD); - query += "&sslCABit=" + URLEncoder.encode(sslCABit); - query += "&mailCABit=" + URLEncoder.encode(mailCABit); - query += "&objectSigningCABit=" - + URLEncoder.encode(objectSigningCABit); - - } - query += "&hashType=" + URLEncoder.encode(hashType); - - query += "&sopPasswd=" + URLEncoder.encode(SingleSignOnPWD); - query += "&wirelessSupport=" + URLEncoder.encode("false"); - query += "&opType=" + URLEncoder.encode("OP_MODIFY"); - query += "&taskID=" + URLEncoder.encode("createCert"); - query += "&cmsSeed=0"; - setPostQueryString(query); - return Connect(myStringUrl); - - } - - private boolean singleSignON() { - System.out.println("configuring Cert Instance : Single Signon"); - setConfigURL(); - String myStringUrl = "http://" + host + ":" + adminPort + configURL; - - System.out.println(myStringUrl); - String PWTags = "Internal:Internal LDAP Database:singlesignon"; - - String query = "AdminUserPassword=" + URLEncoder.encode(adminPWD); - - query += "&"; - query += "instanceID=" + URLEncoder.encode(instanceID); - query += "&serverRoot=" + URLEncoder.encode(serverRoot); - // query += "&singleSignonPwd=" + URLEncoder.encode(SingleSignOnPWD); - query += "&singleSignonPWTags=" + URLEncoder.encode(PWTags); - query += "&Internal=" + URLEncoder.encode(tokenPWD); - query += "&Internal LDAP Database=" + URLEncoder.encode(dbPassword); - query += "&pwcTokenname=" + URLEncoder.encode("internal"); - - query += "&singlesignon=" + URLEncoder.encode(tokenPWD); - - query += "&opType=" + URLEncoder.encode("OP_MODIFY"); - query += "&taskID=" + URLEncoder.encode("singleSignon"); - query += "&cmsSeed=0"; - setPostQueryString(query); - return Connect(myStringUrl); - - } - - private boolean doMisc() { - System.out.println("configuring Cert Instance : do Miscell"); - setConfigURL(); - String myStringUrl = "http://" + host + ":" + adminPort + configURL; - - System.out.println(myStringUrl); - String PWTags = "Internal:Internal LDAP Database:singlesignon"; - - String query = "AdminUserPassword=" + URLEncoder.encode(adminPWD); - - query += "&"; - query += "instanceID=" + URLEncoder.encode(instanceID); - query += "&serverRoot=" + URLEncoder.encode(serverRoot); - query += "&singleSignonPwd=" + URLEncoder.encode(SingleSignOnPWD); - query += "&singleSignonPWTags=" + URLEncoder.encode(PWTags); - query += "&Internal=" + URLEncoder.encode(tokenPWD); - query += "&Internal LDAP Database=" + URLEncoder.encode(dbPassword); - query += "&singlesignon=" + URLEncoder.encode(tokenPWD); - query += "&deletePasswdConf=false"; - - query += "&opType=" + URLEncoder.encode("OP_MODIFY"); - query += "&taskID=" + URLEncoder.encode("doMiscStuffs"); - query += "&cmsSeed=0"; - setPostQueryString(query); - return Connect(myStringUrl); - } - - private boolean exitDeamon() { - - System.out.println("configuring Cert Instance : Exit Deamon"); - setDeamonURL(); - String myStringUrl = "http://" + host + ":" + adminPort + configURL; - - System.out.println(myStringUrl); - String query = "AdminUserPassword=" + URLEncoder.encode(adminPWD); - - query += "&"; - query += "instanceID=" + URLEncoder.encode(instanceID); - query += "&serverRoot=" + URLEncoder.encode(serverRoot); - query += "&opType=" + URLEncoder.encode("OP_MODIFY"); - query += "&taskID=" + URLEncoder.encode("exit"); - query += "&cmsSeed=0"; - setPostQueryString(query); - return Connect(myStringUrl); - } - - private boolean ConfOCSP() { - - // Step 1. Start Deamon - - if (!startDeamon()) { - System.out.println( - "Configuring Cert Instance: Unable to start deamon"); - return false; - } - - // Sometimes it takes time to start deamon so wait for few seconds - try { - System.out.println("going to sleep for 10 seconds"); - Thread.sleep(10000); - } catch (InterruptedException ie) { - System.out.println("sleep exection"); - } - - // Step 1a: Initialize Token ( Changed in 6.0)jjj - if (!initializePWD()) { - System.out.println( - "Configuring Cert Instance: error initializing pwd token"); - return false; - } - - // Step 2. Configure Internal DB - if (!configInternalDB()) { - System.out.println( - "Configuring Cert Instance: error configuring internal db"); - return false; - } - - // Step 3. Create Admin Values - if (!createAdminValues()) { - System.out.println( - "Configuring Cert Instance: error configuring admin values "); - return false; - } - - // Step 4. SubSystems - - if (!selectSubSystem()) { - System.out.println( - "Configuring Cert Instance: error selecting subsystems"); - return false; - } - - // Step 5. Network Configuration - if (!networkConfig()) { - System.out.println( - "Configuring Cert Instance: error configuring network ports "); - return false; - } - - // Step 6: Initialize Token This has been moved to step 1a - if (!initializeToken()) { - System.out.println( - "Configuring Cert Instance: error initializing token"); - return false; - } - - // Step 7 : keyLenth - if (!keyLength()) { - System.out.println( - "Configuring Cert Instance: error configuring KeyLength"); - return false; - } - - // Step 8 : CheckDN - if (!checkDN()) { - System.out.println( - "Configuring Cert Instance: error checking deamon"); - return false; - } - - // Step 9 : certRequest and Install - if (!certRequest(false)) { - System.out.println("Configuring Cert Instance: error getting cert"); - return false; - } - - // Create a SSL signing cert - Date tmpdate = new Date(); - - certType = "serverCert"; - subjectName = "CN=" + host + "." + adminDomain + ",OU=ssltest" - + tmpdate.getTime() + ",O=SSL,C=US"; - keyLength = "512"; - keyType = "RSA"; - String mtokenPWD = tokenPWD; - - tokenPWD = ""; - ssl_clientcert = "false"; - signingCert = "server"; - - if (!initializeToken()) { - System.out.println( - "Configuring Cert Instance: error initializing token"); - return false; - } - - // Step 8 : keyLenth - if (!keyLength()) { - System.out.println( - "Configuring Cert Instance: error configuring KeyLength"); - return false; - } - - // Step 9 : CheckDN - if (!checkDN()) { - System.out.println( - "Configuring Cert Instance: error checking deamon"); - return false; - } - - // Step 10 : - if (!certRequest(false)) { - System.out.println( - "Configuring Cert Instance: error creating Request"); - return false; - } - - // After creating ssl cert - tokenPWD = mtokenPWD; - - // Step 11 - if (!singleSignON()) { - System.out.println( - "Configuring Cert Instance: error setting up singlesignon"); - return false; - } - - // Step 11 - if (!doMisc()) { - System.out.println( - "Configuring Cert Instance: error setting up miscell"); - return false; - } - - // Step 12 - if (!exitDeamon()) { - System.out.println( - "Configuring Cert Instance: Unable to exit deamon"); - return false; - } - - return true; - - } - - private boolean setupStorageKey() { - System.out.println("configuring Cert Instance : Storage Key"); - setConfigURL(); - String myStringUrl = "http://" + host + ":" + adminPort + configURL; - - System.out.println(myStringUrl); - String query = "AdminUserPassword=" + URLEncoder.encode(adminPWD); - - query += "&"; - query += "instanceID=" + URLEncoder.encode(instanceID); - query += "&serverRoot=" + URLEncoder.encode(serverRoot); - query += "&opType=" + URLEncoder.encode("OP_MODIFY"); - query += "&taskID=" + URLEncoder.encode("storageKey"); - query += "&tokenName=" + URLEncoder.encode("Internal"); - query += "&tokenPasswd=" + URLEncoder.encode(""); - query += "&keyLength=" + URLEncoder.encode("512"); - query += "&cmsSeed=0"; - setPostQueryString(query); - return Connect(myStringUrl); - } - - private boolean ConfRA() { - // Start Configuring - - // Step 1. Start Deamon - - if (!startDeamon()) { - System.out.println( - "Configuring Cert Instance: Unable to start deamon"); - return false; - } - - // Sometimes it takes time to start deamon so wait for few seconds - try { - System.out.println("going to sleep for 10 seconds"); - Thread.sleep(10000); - } catch (InterruptedException ie) { - System.out.println("sleep exection"); - } - - // Step 1a: Initialize Token ( Changed in 6.0)jjj - if (!initializePWD()) { - System.out.println( - "Configuring Cert Instance: error initializing pwd token"); - return false; - } - - // Step 2. Configure Internal DB - if (!configInternalDB()) { - System.out.println( - "Configuring Cert Instance: error configuring internal db"); - return false; - } - - // Step 3. Create Admin Values - if (!createAdminValues()) { - System.out.println( - "Configuring Cert Instance: error configuring admin values "); - return false; - } - - // Step 4. SubSystems - - if (!selectSubSystem()) { - System.out.println( - "Configuring Cert Instance: error selecting subsystems"); - return false; - } - - // Step 5. Network Configuration - if (!networkConfig()) { - System.out.println( - "Configuring Cert Instance: error configuring network ports "); - return false; - } - - // Step 6: Initialize Token This has been moved to step 1a - if (!initializeToken()) { - System.out.println( - "Configuring Cert Instance: error initializing token"); - return false; - } - - // Step 7 : keyLenth - if (!keyLength()) { - System.out.println( - "Configuring Cert Instance: error configuring KeyLength"); - return false; - } - - // Step 8 : CheckDN - if (!checkDN()) { - System.out.println( - "Configuring Cert Instance: error checking deamon"); - return false; - } - - // Step 9 : certRequest and Install i.e approve the request as a trusted manager - if (!certRequest(true)) { - System.out.println("Configuring Cert Instance: error getting cert"); - return false; - } - - // Create a SSL signing cert - Date tmpdate = new Date(); - - certType = "serverCert"; - subjectName = "CN=" + host + "." + adminDomain + ",OU=ssltest" - + tmpdate.getTime() + ",O=SSL,C=US"; - keyLength = "512"; - keyType = "RSA"; - String mtokenPWD = tokenPWD; - - tokenPWD = ""; - ssl_clientcert = "false"; - signingCert = "server"; - - if (!initializeToken()) { - System.out.println( - "Configuring Cert Instance: error initializing token"); - return false; - } - - // Step 8 : keyLenth - if (!keyLength()) { - System.out.println( - "Configuring Cert Instance: error configuring KeyLength"); - return false; - } - - // Step 9 : CheckDN - if (!checkDN()) { - System.out.println( - "Configuring Cert Instance: error checking deamon"); - return false; - } - - // Step 10 : - if (!certRequest(false)) { - System.out.println( - "Configuring Cert Instance: error creating Request"); - return false; - } - - // After creating ssl cert - tokenPWD = mtokenPWD; - - // Step 11 - if (!singleSignON()) { - System.out.println( - "Configuring Cert Instance: error setting up singlesignon"); - return false; - } - - // Step 11 - if (!doMisc()) { - System.out.println( - "Configuring Cert Instance: error setting up miscell"); - return false; - } - - // Step 12 - if (!exitDeamon()) { - System.out.println( - "Configuring Cert Instance: Unable to exit deamon"); - return false; - } - - return true; - } - - private boolean ConfKRA() { - // Start Configuring - - // Step 1. Start Deamon - - if (!startDeamon()) { - System.out.println( - "Configuring Cert Instance: Unable to start deamon"); - return false; - } - - // Sometimes it takes time to start deamon so wait for few seconds - try { - System.out.println("going to sleep for 10 seconds"); - Thread.sleep(10000); - } catch (InterruptedException ie) { - System.out.println("sleep exection"); - } - - // Step 1a: Initialize Token ( Changed in 6.0)jjj - if (!initializePWD()) { - System.out.println( - "Configuring Cert Instance: error initializing pwd token"); - return false; - } - - // Step 2. Configure Internal DB - if (!configInternalDB()) { - System.out.println( - "Configuring Cert Instance: error configuring internal db"); - return false; - } - - // Step 3. Create Admin Values - if (!createAdminValues()) { - System.out.println( - "Configuring Cert Instance: error configuring admin values "); - return false; - } - - // Step 4. SubSystems - - if (!selectSubSystem()) { - System.out.println( - "Configuring Cert Instance: error selecting subsystems"); - return false; - } - - // Step 5. Network Configuration - if (!networkConfig()) { - System.out.println( - "Configuring Cert Instance: error configuring network ports "); - return false; - } - - // Step 6: Initialize Token This has been moved to step 1a - if (!initializeToken()) { - System.out.println( - "Configuring Cert Instance: error initializing token"); - return false; - } - - // Step 7 : keyLenth - if (!keyLength()) { - System.out.println( - "Configuring Cert Instance: error configuring KeyLength"); - return false; - } - - // Step 8 : CheckDN - if (!checkDN()) { - System.out.println( - "Configuring Cert Instance: error checking deamon"); - return false; - } - - // Step 9 : certRequest and Install i.e approve the request as a trusted manager - if (!certRequest(true)) { - System.out.println("Configuring Cert Instance: error getting cert"); - return false; - } - - if (!setupStorageKey()) { - System.out.println( - "Configuring Cert Instance: error configuring storage key"); - return false; - } - - // no need to do this from 7.1 due to new acl based key recovery - /* - if (!setupKRAAgents()) - { System.out.println("Configuring Cert Instance: error configuring storage key"); return false;} - */ - - // Create a SSL signing cert - Date tmpdate = new Date(); - - certType = "serverCert"; - subjectName = "CN=" + host + "." + adminDomain + ",OU=ssltest" - + tmpdate.getTime() + ",O=SSL,C=US"; - keyLength = "512"; - keyType = "RSA"; - String mtokenPWD = tokenPWD; - - tokenPWD = ""; - ssl_clientcert = "false"; - signingCert = "server"; - - if (!initializeToken()) { - System.out.println( - "Configuring Cert Instance: error initializing token"); - return false; - } - - // Step 8 : keyLenth - if (!keyLength()) { - System.out.println( - "Configuring Cert Instance: error configuring KeyLength"); - return false; - } - - // Step 9 : CheckDN - if (!checkDN()) { - System.out.println( - "Configuring Cert Instance: error checking deamon"); - return false; - } - - // Step 10 : - if (!certRequest(false)) { - System.out.println( - "Configuring Cert Instance: error creating Request"); - return false; - } - - // After creating ssl cert - tokenPWD = mtokenPWD; - - // Step 11 - if (!singleSignON()) { - System.out.println( - "Configuring Cert Instance: error setting up singlesignon"); - return false; - } - - // Step 11 - if (!doMisc()) { - System.out.println( - "Configuring Cert Instance: error setting up miscell"); - return false; - } - - // Step 12 - if (!exitDeamon()) { - System.out.println( - "Configuring Cert Instance: Unable to exit deamon"); - return false; - } - - return true; - } - - // /// Sub CA configuration - - private boolean ConfSubCA() { - // Start Configuring - - // Step 1. Start Deamon - - if (!startDeamon()) { - System.out.println( - "Configuring Cert Instance: Unable to start deamon"); - return false; - } - - // Sometimes it takes time to start deamon so wait for few seconds - try { - System.out.println("going to sleep for 10 seconds"); - Thread.sleep(10000); - } catch (InterruptedException ie) { - System.out.println("sleep exection"); - } - - // Step 1a: Initialize Token ( Changed in 6.0)jjj - if (!initializePWD()) { - System.out.println( - "Configuring Cert Instance: error initializing pwd token"); - return false; - } - - // Step 2. Configure Internal DB - if (!configInternalDB()) { - System.out.println( - "Configuring Cert Instance: error configuring internal db"); - return false; - } - - // Step 3. Create Admin Values - if (!createAdminValues()) { - System.out.println( - "Configuring Cert Instance: error configuring admin values "); - return false; - } - - // Step 4. SubSystems - - if (!selectSubSystem()) { - System.out.println( - "Configuring Cert Instance: error selecting subsystems"); - return false; - } - - // Step 5. Network Configuration - if (!networkConfig()) { - System.out.println( - "Configuring Cert Instance: error configuring network ports "); - return false; - } - - // Step 6: Initialize Token This has been moved to step 1a - if (!initializeToken()) { - System.out.println( - "Configuring Cert Instance: error initializing token"); - return false; - } - - // Step 7 : keyLenth - if (!keyLength()) { - System.out.println( - "Configuring Cert Instance: error configuring KeyLength"); - return false; - } - - // Step 8 : CheckDN - if (!checkDN()) { - System.out.println( - "Configuring Cert Instance: error checking deamon"); - return false; - } - - // Step 9 : certRequest and Install i.e approve the request as a trusted manager - if (!certRequest(false)) { - System.out.println("Configuring Cert Instance: error getting cert"); - return false; - } - - // Create a SSL signing cert - Date tmpdate = new Date(); - - certType = "serverCert"; - subjectName = "CN=" + host + "." + adminDomain + ",OU=ssltest" - + tmpdate.getTime() + ",O=SSL,C=US"; - keyLength = "512"; - keyType = "RSA"; - String mtokenPWD = tokenPWD; - - tokenPWD = ""; - ssl_clientcert = "false"; - signingCert = "server"; - - if (!initializeToken()) { - System.out.println( - "Configuring Cert Instance: error initializing token"); - return false; - } - - // Step 8 : keyLenth - if (!keyLength()) { - System.out.println( - "Configuring Cert Instance: error configuring KeyLength"); - return false; - } - - // Step 9 : CheckDN - if (!checkDN()) { - System.out.println( - "Configuring Cert Instance: error checking deamon"); - return false; - } - - // Step 10 : - if (!certRequest(false)) { - System.out.println( - "Configuring Cert Instance: error creating Request"); - return false; - } - - // After creating ssl cert - tokenPWD = mtokenPWD; - - // Step 11 - if (!singleSignON()) { - System.out.println( - "Configuring Cert Instance: error setting up singlesignon"); - return false; - } - - // Step 11 - if (!doMisc()) { - System.out.println( - "Configuring Cert Instance: error setting up miscell"); - return false; - } - - // Step 12 - if (!exitDeamon()) { - System.out.println( - "Configuring Cert Instance: Unable to exit deamon"); - return false; - } - - return true; - } - - // / CA - - // org - private boolean ConfCA() { - // Start Configuring - - // Step 1. Start Deamon - - if (!startDeamon()) { - System.out.println( - "Configuring Cert Instance: Unable to start deamon"); - return false; - } - - // Sometimes it takes time to start deamon so wait for few seconds - try { - System.out.println("going to sleep for 10 seconds"); - Thread.sleep(10000); - } catch (InterruptedException ie) { - System.out.println("sleep exection"); - } - - // Step 1a: Initialize Token ( Changed in 6.0)jjj - if (!initializePWD()) { - System.out.println( - "Configuring Cert Instance: error initializing pwd token"); - return false; - } - - // Step 2. Configure Internal DB - if (!configInternalDB()) { - System.out.println( - "Configuring Cert Instance: error configuring internal db"); - return false; - } - - // Step 3. Create Admin Values - if (!createAdminValues()) { - System.out.println( - "Configuring Cert Instance: error configuring admin values "); - return false; - } - - // Step 4. SubSystems - - if (!selectSubSystem()) { - System.out.println( - "Configuring Cert Instance: error selecting subsystems"); - return false; - } - - // SetSerial Number - if (!setSerial("1", "1000000")) { - System.out.println( - "Configuring Cert Instance: error setting serial number"); - return false; - } - - if (!setOCSP()) { - System.out.println( - "Configuring Cert Instance: error selecting subsystems"); - return false; - } - - // Step 5. Network Configuration - if (!networkConfig()) { - System.out.println( - "Configuring Cert Instance: error configuring network ports "); - return false; - } - - // Step 6. setting up Server Migration - - // if (!serverMigration()) - // { System.out.println("Configuring Cert Instance: error configuring server migration"); return false;} - - // Step 7: Initialize Token - if (!initializeToken()) { - System.out.println( - "Configuring Cert Instance: error initializing token"); - return false; - } - - // Step 8 : keyLenth - if (!keyLength()) { - System.out.println( - "Configuring Cert Instance: error configuring KeyLength"); - return false; - } - - // Step 9 : CheckDN - if (!checkDN()) { - System.out.println( - "Configuring Cert Instance: error checking deamon"); - return false; - } - - // Step 10 : - if (!createCert()) { - System.out.println("Configuring Cert Instance: error creating cert"); - return false; - } - - // Create a SSL signing cert - Date tmpdate = new Date(); - - certType = "serverCert"; - subjectName = "CN=" + host + "." + adminDomain + ",OU=ssltest" - + tmpdate.getTime() + ",O=SSL,C=US"; - keyType = "RSA"; - keyLength = "512"; - String mtokenPWD = tokenPWD; - - tokenPWD = ""; - - if (!initializeToken()) { - System.out.println( - "Configuring Cert Instance: error initializing token"); - return false; - } - - // Step 8 : keyLenth - if (!keyLength()) { - System.out.println( - "Configuring Cert Instance: error configuring KeyLength"); - return false; - } - - // Step 9 : CheckDN - if (!checkDN()) { - System.out.println( - "Configuring Cert Instance: error checking deamon"); - return false; - } - - // Step 10 : - if (!createCert()) { - System.out.println("Configuring Cert Instance: error creating cert"); - return false; - } - - // After creating ssl cert - tokenPWD = mtokenPWD; - - // Step 11 - if (!singleSignON()) { - System.out.println( - "Configuring Cert Instance: error setting up singlesignon"); - return false; - } - - // Step 11 - if (!doMisc()) { - System.out.println( - "Configuring Cert Instance: error setting up miscell"); - return false; - } - - // Step 12 - if (!exitDeamon()) { - System.out.println( - "Configuring Cert Instance: Unable to exit deamon"); - return false; - } - - return true; - } - - // Configure Clone - - public boolean readProperties() { - // Read the properties file and assign values to variables . - try { - getProperties(propFileName); - } catch (Exception e) { - System.out.println( - "exception reading Properties File " + e.getMessage()); - } - - // read all properties - - adminDomain = props.getProperty("inst.admin.domain"); - adminID = props.getProperty("inst.admin.uid"); - adminPWD = props.getProperty("inst.admin.pwd"); - adminPort = props.getProperty("inst.admin.port"); - machineName = props.getProperty("inst.machineName"); - host = props.getProperty("inst.host"); - serverID = props.getProperty("inst.serverIdentifier"); - instanceID = "cert-" + serverID; - serverRoot = props.getProperty("inst.serverRoot"); - // Just for debugging" - sieURL = props.getProperty("inst.sie.url"); - dbConnPort = props.getProperty("inst.dbConnPort"); - dbConnHost = props.getProperty("inst.dbConnHost"); - dbInstanceName = props.getProperty("inst.dbInstanceName"); - dbPassword = props.getProperty("inst.dbPassword"); - dbLDAPauthDN = props.getProperty("inst.ldap.auth.dn"); - dbmode = props.getProperty("inst.dbmode"); - ldapServerDB = props.getProperty("inst.ldapServerDB"); - certAdminName = props.getProperty("inst.cert.admin.name"); - certAdminUid = props.getProperty("inst.cert.admin.uid"); - certAdminPWD = props.getProperty("inst.cert.admin.pwd"); - kra = props.getProperty("inst.subsystem.kra"); - subsystems = props.getProperty("inst.subsystem"); - ca = props.getProperty("inst.subsystem.ca"); - ra = props.getProperty("inst.subsystem.ra"); - ocsp = props.getProperty("inst.subsystem.ocsp"); - remoteKRA = props.getProperty("inst.subsystem.remoteKRA"); - wirelessSupport = props.getProperty("inst.subsystem.wireless"); - eeHttpPort = props.getProperty("inst.ee.http.port"); - eeHttpsPort = props.getProperty("inst.ee.https.port"); - agentHttpsPort = props.getProperty("inst.agent.https.port"); - radminHttpsPort = props.getProperty("inst.admin.https.port"); - tokenName = props.getProperty("inst.tokenName"); - tokenPWD = props.getProperty("inst.token.pwd"); - signingCert = props.getProperty("inst.cert.Type"); - certType = signingCert; - keyType = props.getProperty("inst.key.type"); - keyLength = props.getProperty("inst.key.length"); - SingleSignOnPWD = props.getProperty("inst.singlesignon.pwd"); - subjectName = props.getProperty("inst.ca.dn"); - isCA = props.getProperty("inst.isca"); - aki = props.getProperty("inst.aki"); - ski = props.getProperty("inst.ski"); - sslCABit = props.getProperty("inst.sslCABit"); - objectSigningCABit = props.getProperty("inst.objectSigningCABit"); - mailCABit = props.getProperty("inst.mailCABit"); - hashType = props.getProperty("inst.hash.Type"); - caOComponent = props.getProperty("inst.ca.component"); - certValidityDays = props.getProperty("inst.cert.validity"); - caHostname = props.getProperty("inst.cahostname"); - caPortnum = props.getProperty("inst.caportnum"); - caAgentPortnum = props.getProperty("inst.caASport"); - caTimeout = props.getProperty("inst.catimeout"); - caEEPort = props.getProperty("inst.caEEport"); - cloneInstanceId = props.getProperty("inst.cloneid"); - CAadminId = props.getProperty("inst.caAdminId"); - CAadminPwd = props.getProperty("inst.caAdminPwd"); - CAcertnickname = props.getProperty("inst.caCertnickname"); - enpropfile = props.getProperty("inst.propfile"); - cdir = props.getProperty("inst.certdir"); - tokenpwd = props.getProperty("inst.certtokenpwd"); - - if (subsystems.equals("ca")) { - return ConfCA(); - } - if (subsystems.equals("ra")) { - return ConfRA(); - } - if (subsystems.equals("ocsp")) { - return ConfOCSP(); - } - if (subsystems.equals("kra")) { - return ConfKRA(); - } - if (subsystems.equals("subca")) { - subca = true; - subsystems = "ca"; - return ConfSubCA(); - } - - return true; - } // end of r - - public static void main(String args[]) { - // Exit Status - (-1) for error - // - 1 Configured and server Alive - // - 0 Configured bur could not sart server - - AutoInstaller t = new AutoInstaller(); - - System.out.println(args.length); - t.setPropFile(args[0]); - - if (args.length < 1) { - System.out.println("Usage : PropertiesFilePath"); - System.exit(-1); - } - - System.out.println("configuring Cert Instance : Start"); - - boolean st = t.readProperties(); - - if (st) { - System.out.println("Configuring Cert Instance : Successful"); - System.exit(1); - } else { - - System.out.println("Configuring Cert Instance : Error "); - System.exit(0); - } - } - -} // end of class - diff --git a/pki/base/silent/src/com/netscape/pkisilent/common/CMSInstance.java b/pki/base/silent/src/com/netscape/pkisilent/common/CMSInstance.java deleted file mode 100644 index 1868f17c4..000000000 --- a/pki/base/silent/src/com/netscape/pkisilent/common/CMSInstance.java +++ /dev/null @@ -1,315 +0,0 @@ -package com.netscape.pkisilent.common; - -// --- BEGIN COPYRIGHT BLOCK --- -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; version 2 of the License. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -// -// (C) 2007 Red Hat, Inc. -// All rights reserved. -// --- END COPYRIGHT BLOCK --- - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.net.URLEncoder; - -public class CMSInstance { - - private int i; - private boolean st; - private String host, port, AdminDN, AdminDNPW, serverRoot, instanceID, sieurl, adminDomain, machineName; - - /** - * CMS Test framework . - * This class Creates and Removes a CMS server instance - */ - - /** - * Constructor. Takes parameters hostname, adminserverport, adminDN, adminDNpassword, Dominanname, ServerRoot( full - * path) , instanceID, mnameand sieURL. mname is the fully qualified name of the server ( jupiter2.nscp.aoltw.net) - * sieURL is ("ldap://jupiter2.nscp.aoltw.net:(ConfigLADPPort)/o=NetscapeRoot" - */ - - private String cs_server_root, cs_tps_root, tps_hostname, tps_fqdn, tps_instanceid, tps_ee_port, tps_agent_port, - tps_auth_ldap_host, tps_auth_ldap_port, tps_auth_ldap_suffix, ca_hostname, ca_ee_port, tks_hostname, - tks_agent_port, token_db_hostname, token_db_port, token_db_suffix, token_db_passwd; - - public CMSInstance(String h, String p, String AdDN, String pwd, String domain, String sroot, String insID, - String mname, String sieURL) { - - host = h; - port = p; - AdminDN = AdDN; - AdminDNPW = pwd; - adminDomain = domain; - serverRoot = sroot; - machineName = mname; - instanceID = insID; - sieurl = sieURL; - } - - public CMSInstance(String croot, - String troot, - String th, - String tfqdn, - String tid, - String tep, - String tagp, - String tldaphost, - String tldapport, - String tldapsuffix, - String ch, - String ceep, - String tkh, - String tkagp, - String toh, - String toagp, - String tosuffix, - String topasswd) { - - cs_server_root = croot; - cs_tps_root = troot; - tps_hostname = th; - tps_fqdn = tfqdn; - tps_instanceid = tid; - tps_ee_port = tep; - tps_agent_port = tagp; - tps_auth_ldap_host = tldaphost; - tps_auth_ldap_port = tldapport; - tps_auth_ldap_suffix = tldapsuffix; - ca_hostname = ch; - ca_ee_port = ceep; - tks_hostname = tkh; - tks_agent_port = tkagp; - token_db_hostname = toh; - token_db_port = toagp; - token_db_suffix = tosuffix; - token_db_passwd = topasswd; - - } - - public boolean CreateTPSInstance() throws IOException { - // steps - // 1. create .cfg file - // 2. run create.pl with that .cfg file - - FileOutputStream out = new FileOutputStream( - cs_server_root + "/tps_auto_config.cfg"); - BufferedWriter awriter; - - awriter = new BufferedWriter(new OutputStreamWriter(out, "8859_1")); - awriter.write("CS_SERVER_ROOT=" + cs_server_root); - awriter.newLine(); - awriter.write("CS_TPS_ROOT=" + cs_tps_root); - awriter.newLine(); - awriter.write("TPS_HOSTNAME=" + tps_hostname); - awriter.newLine(); - awriter.write("TPS_FQDN=" + tps_fqdn); - awriter.newLine(); - awriter.write("TPS_INSTANCEID=" + tps_instanceid); - awriter.newLine(); - awriter.write("TPS_EE_PORT=" + tps_ee_port); - awriter.newLine(); - awriter.write("TPS_AGENT_PORT=" + tps_agent_port); - awriter.newLine(); - awriter.write("TPS_AUTH_LDAP_HOST=" + tps_auth_ldap_host); - awriter.newLine(); - awriter.write("TPS_AUTH_LDAP_PORT=" + tps_auth_ldap_port); - awriter.newLine(); - awriter.write("TPS_AUTH_LDAP_SUFFIX=" + tps_auth_ldap_suffix); - awriter.newLine(); - awriter.write("CA_HOSTNAME=" + ca_hostname); - awriter.newLine(); - awriter.write("CA_EE_PORT=" + ca_ee_port); - awriter.newLine(); - awriter.write("TKS_HOSTNAME=" + tks_hostname); - awriter.newLine(); - awriter.write("TKS_AGENT_PORT=" + tks_agent_port); - awriter.newLine(); - awriter.write("TOKEN_DB_HOSTNAME=" + token_db_hostname); - awriter.newLine(); - awriter.write("TOKEN_DB_PORT=" + token_db_port); - awriter.newLine(); - awriter.write("TOKEN_DB_SUFFIX=" + token_db_suffix); - awriter.newLine(); - awriter.write("TOKEN_DB_PASSWD=" + token_db_passwd); - awriter.newLine(); - - awriter.flush(); - out.close(); - - try { - Process p = null; - Runtime r = Runtime.getRuntime(); - // String[] se = {"perl", cs_server_root+"/bin/cert/tps/setup/create.pl" , "-i", cs_server_root+"/tps_auto_config.cfg" }; - String[] se = { - "perl", - "/home/ckannan/cms/src/ns/netkeyra/setup/create.pl", "-i", - cs_server_root + "/tps_auto_config.cfg" }; - - System.out.println(se); - p = r.exec(se); - p.waitFor(); - String line; - - if (p.exitValue() == 0) { - BufferedReader br = new BufferedReader( - new InputStreamReader(p.getInputStream())); - - while ((line = br.readLine()) != null) { - System.out.println(line); - } - } else { - BufferedReader br = new BufferedReader( - new InputStreamReader(p.getErrorStream())); - - while ((line = br.readLine()) != null) { - System.out.println(line); - } - } - } catch (Throwable e) { - System.out.println(e.getMessage()); - e.printStackTrace(); - return false; - } - - return true; - } - - public boolean CreateInstance() { - - String startURL = "/cert/Tasks/Operation/Create"; - String myStringUrl = "http://" + host + "." + adminDomain + ":" + port - + startURL; - - System.out.println(myStringUrl); - - String query = "serverRoot=" + URLEncoder.encode(serverRoot); - - query += "&instanceID=" + URLEncoder.encode(instanceID); - query += "&adminDomain=" + URLEncoder.encode(adminDomain); - query += "&sieURL=" + URLEncoder.encode(sieurl); - query += "&adminUID=" + URLEncoder.encode(AdminDN); - query += "&adminPWD=" + URLEncoder.encode(AdminDNPW); - query += "&machineName=" + URLEncoder.encode(machineName); - - PostQuery sm = new PostQuery(myStringUrl, AdminDN, AdminDNPW, query); - - return (sm.Send()); - - } - - public boolean RemoveInstance() { - - String startURL = "/cert-" + instanceID + "/Tasks/Operation/Remove"; - String myStringUrl = "http://" + host + ":" + port + startURL; - - System.out.println(myStringUrl); - - String query = "serverRoot=" + URLEncoder.encode(serverRoot); - - query += "&instanceID=" + URLEncoder.encode(instanceID); - - PostQuery sm = new PostQuery(myStringUrl, AdminDN, AdminDNPW, query); - - st = sm.Send(); - - if (st) { - System.out.println("Removed the cert instance"); - } else { - System.out.println("Could not remove the cert instance"); - } - - startURL = "/slapd-" + instanceID + "-db" + "/Tasks/Operation/Remove"; - myStringUrl = "http://" + host + ":" + port + startURL; - - System.out.println(myStringUrl); - - query = "serverRoot=" + URLEncoder.encode(serverRoot); - query += "&InstanceName=" + URLEncoder.encode(instanceID + "-db"); - - PostQuery rmdb = new PostQuery(myStringUrl, AdminDN, AdminDNPW, query); - - rmdb.setNMCStatus("NMC_Status: 0"); - return (rmdb.Send()); - - } - - public static void main(String args[]) { - // Exit Status - (-1) for error - - // Exit Status - (-1) for error - // - 0 FAIL - // - 1 PASS - - boolean st; - - System.out.println(args.length); - if (args.length < 10) { - System.out - .println( - "Usage : <task:Create/REmove> host port AdminDN AdminDNPW adminDomain serverRoot instanceID machineName sieURL"); - System.exit(-1); - } - - int task = 0; - - args[0] = args[0].toLowerCase(); - if (args[0].equals("create")) { - task = 0; - } - if (args[0].equals("remove")) { - task = 1; - } - - CMSInstance t = new CMSInstance(args[1], args[2], args[3], args[4], - args[5], args[6], args[7], args[8], args[9]); - - switch (task) { - - case 0: - st = t.CreateInstance(); - if (st) { - System.out.println("server Instance created "); - System.exit(1); - } else { - - System.out.println("Error: Server Instance could not be created"); - System.exit(0); - } - break; - - case 1: - st = t.RemoveInstance(); - if (st) { - System.out.println("Server instance removed"); - System.exit(1); - } else { - - System.out.println("Server instance could not be removed"); - System.exit(0); - } - break; - - default: - System.out.println("Incorrect usage"); - System.exit(-1); - - } // end of switch - }// end of function main - -} // end of class - diff --git a/pki/base/silent/src/com/netscape/pkisilent/common/DirEnroll.java b/pki/base/silent/src/com/netscape/pkisilent/common/DirEnroll.java index 0e47084e7..019b75825 100644 --- a/pki/base/silent/src/com/netscape/pkisilent/common/DirEnroll.java +++ b/pki/base/silent/src/com/netscape/pkisilent/common/DirEnroll.java @@ -23,6 +23,7 @@ import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintStream; +import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.Date; import java.util.GregorianCalendar; @@ -123,7 +124,7 @@ public class DirEnroll extends TestClient { Authenticator = s; } - public boolean enroll_load() { + public boolean enroll_load() throws UnsupportedEncodingException { buildquery(); return (Send()); } @@ -356,7 +357,7 @@ public class DirEnroll extends TestClient { } - private void buildquery() { + private void buildquery() throws UnsupportedEncodingException { StringBuffer queryStrBuf = new StringBuffer(); @@ -374,9 +375,9 @@ public class DirEnroll extends TestClient { queryStrBuf.append("&authenticator=UserDirEnrollment"); queryStrBuf.append("&requestFormat=keygen"); queryStrBuf.append("&uid="); - queryStrBuf.append(URLEncoder.encode(UID)); + queryStrBuf.append(URLEncoder.encode(UID, "UTF-8")); queryStrBuf.append("&pwd="); - queryStrBuf.append(URLEncoder.encode(PWD)); + queryStrBuf.append(URLEncoder.encode(PWD, "UTF-8")); queryStrBuf.append("&email=true"); queryStrBuf.append("&cryptprovider=1"); @@ -386,9 +387,9 @@ public class DirEnroll extends TestClient { queryStrBuf.append("&authenticator=PortalEnrollment"); queryStrBuf.append("&requestFormat=keygen"); queryStrBuf.append("&uid="); - queryStrBuf.append(URLEncoder.encode(UID)); + queryStrBuf.append(URLEncoder.encode(UID, "UTF-8")); queryStrBuf.append("&userPassword="); - queryStrBuf.append(URLEncoder.encode(PWD)); + queryStrBuf.append(URLEncoder.encode(PWD, "UTF-8")); GN = "test"; SN = "test"; CN = "test"; @@ -397,21 +398,21 @@ public class DirEnroll extends TestClient { O = "aol"; L = "MV"; queryStrBuf.append("&givenname="); - queryStrBuf.append(URLEncoder.encode(GN)); + queryStrBuf.append(URLEncoder.encode(GN, "UTF-8")); queryStrBuf.append("&sn="); - queryStrBuf.append(URLEncoder.encode(SN)); + queryStrBuf.append(URLEncoder.encode(SN, "UTF-8")); queryStrBuf.append("&cn="); - queryStrBuf.append(URLEncoder.encode(CN)); + queryStrBuf.append(URLEncoder.encode(CN, "UTF-8")); queryStrBuf.append("&mail="); - queryStrBuf.append(URLEncoder.encode(MAIL)); + queryStrBuf.append(URLEncoder.encode(MAIL, "UTF-8")); queryStrBuf.append("&ou="); - queryStrBuf.append(URLEncoder.encode(OU)); + queryStrBuf.append(URLEncoder.encode(OU, "UTF-8")); queryStrBuf.append("&o="); - queryStrBuf.append(URLEncoder.encode(O)); + queryStrBuf.append(URLEncoder.encode(O, "UTF-8")); queryStrBuf.append("&l="); - queryStrBuf.append(URLEncoder.encode(L)); + queryStrBuf.append(URLEncoder.encode(L, "UTF-8")); queryStrBuf.append("&email=true"); @@ -421,15 +422,15 @@ public class DirEnroll extends TestClient { queryStrBuf.append("&authenticator=NISAuth"); queryStrBuf.append("&requestFormat=keygen"); queryStrBuf.append("&uid="); - queryStrBuf.append(URLEncoder.encode(UID)); + queryStrBuf.append(URLEncoder.encode(UID, "UTF-8")); queryStrBuf.append("&pwd="); - queryStrBuf.append(URLEncoder.encode(PWD)); + queryStrBuf.append(URLEncoder.encode(PWD, "UTF-8")); queryStrBuf.append("&email=true"); } queryStrBuf.append("&pkcs10Request="); - queryStrBuf.append(URLEncoder.encode(pkcs10request)); + queryStrBuf.append(URLEncoder.encode(pkcs10request, "UTF-8")); query = queryStrBuf.toString(); System.out.println(query); |