diff options
author | PKI Team <PKI Team@c9f7a03b-bd48-0410-a16d-cbbf54688b0b> | 2008-03-18 22:36:57 +0000 |
---|---|---|
committer | PKI Team <PKI Team@c9f7a03b-bd48-0410-a16d-cbbf54688b0b> | 2008-03-18 22:36:57 +0000 |
commit | d0f2e4efbd3eb0f1d7f5a28e7f97c1fb4ec027bb (patch) | |
tree | 7e7473fae8af5ad7e6cda7eabbef787093fc59a7 /pki/base/silent/src/ra/ConfigureRA.java | |
parent | 273f8d85df5c31293a908185622b378c8f3cf7e8 (diff) | |
download | pki-d0f2e4efbd3eb0f1d7f5a28e7f97c1fb4ec027bb.tar.gz pki-d0f2e4efbd3eb0f1d7f5a28e7f97c1fb4ec027bb.tar.xz pki-d0f2e4efbd3eb0f1d7f5a28e7f97c1fb4ec027bb.zip |
Initial open source version based upon proprietary Red Hat Certificate System (RHCS) 7.3.
git-svn-id: svn+ssh://svn.fedorahosted.org/svn/pki/trunk@2 c9f7a03b-bd48-0410-a16d-cbbf54688b0b
Diffstat (limited to 'pki/base/silent/src/ra/ConfigureRA.java')
-rw-r--r-- | pki/base/silent/src/ra/ConfigureRA.java | 923 |
1 files changed, 923 insertions, 0 deletions
diff --git a/pki/base/silent/src/ra/ConfigureRA.java b/pki/base/silent/src/ra/ConfigureRA.java new file mode 100644 index 000000000..06e4f0883 --- /dev/null +++ b/pki/base/silent/src/ra/ConfigureRA.java @@ -0,0 +1,923 @@ +// --- 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.util.*; +import java.net.*; +import java.io.*; + +import com.netscape.cmsutil.ocsp.*; +import com.netscape.cmsutil.ocsp.Request; + +import org.mozilla.jss.*; +import org.mozilla.jss.pkcs12.*; +import org.mozilla.jss.asn1.*; +import org.mozilla.jss.CryptoManager; +import org.mozilla.jss.pkix.primitive.*; +import org.mozilla.jss.util.*; +import org.mozilla.jss.ssl.*; +import org.mozilla.jss.crypto.*; +import org.mozilla.jss.CertDatabaseException; +import sun.misc.*; +import java.lang.Exception; + +import org.mozilla.jss.pkcs11.*; +import org.mozilla.jss.pkcs11.PK11Token; + +import netscape.security.x509.X509CertImpl; +import netscape.security.x509.X509Key; +import netscape.security.x509.X500Name; + +import com.netscape.osutil.*; + +public class ConfigureRA +{ + + public static Hashtable mUsedPort = new Hashtable(); + + // define global variables + + public static HTTPClient hc = null; + + public static String login_uri = "/ra/admin/console/config/login"; + public static String wizard_uri = "/ra/admin/console/config/wizard"; + public static String domain_uri = "/ra/ee/ca/domain"; + public static String ee_uri = "/ca/ee/ca/getBySerial"; + + public static String sd_login_uri = "/ca/ee/ca/securityDomainLogin"; + public static String sd_get_cookie_uri = "/ca/ee/ca/getCookie"; + public static String pkcs12_uri = "/ra/admin/console/config/savepkcs12"; + + public static String cs_hostname = null; + public static String cs_port = null; + + public static String sd_hostname = null; + public static String sd_ssl_port = null; + public static String sd_admin_name = null; + public static String sd_admin_password = null; + + public static String ca_hostname = null; + public static String ca_port = null; + public static String ca_ssl_port = null; + + public static String client_certdb_dir = null; + public static String client_certdb_pwd = null; + + // Login Panel + public static String pin = null; + + public static String domain_name = null; + + public static String admin_user = null; + public static String admin_email = null; + public static String admin_password = null; + public static String admin_serial_number = null; + public static String agent_name = null; + + public static String key_size = null; + public static String key_type = null; + public static String token_name = null; + public static String token_pwd = null; + + public static String agent_key_size = null; + public static String agent_key_type = null; + public static String agent_cert_subject = null; + + public static String server_cert_name = null; + public static String server_cert_req = null; + public static String server_cert_pp = null; + public static String server_cert_cert = null; + + public static String ra_subsystem_cert_name = null; + public static String ra_subsystem_cert_req = null; + public static String ra_subsystem_cert_pp = null; + public static String ra_subsystem_cert_cert = null; + + // names + public static String ra_subsystem_cert_subject_name = null; + public static String ra_server_cert_subject_name = null; + public static String subsystem_name = null; + + + public ConfigureRA () + { + // do nothing :) + } + + public void sleep_time() + { + try + { + System.out.println("Sleeping for 5 secs.."); + Thread.sleep(5000); + } + catch(Exception e) + { + System.out.println("ERROR: sleep problem"); + } + + } + + public boolean LoginPanel() + { + boolean st = false; + HTTPResponse hr = null; + ByteArrayInputStream bais = null; + ParseXML px = new ParseXML(); + + String query_string = "pin=" + pin + "&xml=true"; + + hr = hc.nonsslConnect(cs_hostname,cs_port,login_uri,query_string); + System.out.println("xml returned: " + hr.getHTML()); + + // parse xml here - nothing to parse + + // no cookie for tps + // get cookie + String temp = hr.getCookieValue("pin"); + + if(temp!=null) + { + int index = temp.indexOf(";"); + hc.j_session_id = temp.substring(0,index); + st = true; + } + + hr = null; + hr = hc.nonsslConnect(cs_hostname,cs_port,wizard_uri, + "p=0&op=next&xml=true"); + + // parse xml here + + bais = new ByteArrayInputStream( + hr.getHTML().getBytes()); + px.parse(bais); + px.prettyprintxml(); + + st = true; + return st; + } + + public boolean DomainPanel() + { + boolean st = false; + HTTPResponse hr = null; + ByteArrayInputStream bais = null; + ParseXML px = new ParseXML(); + + + String domain_url = "https://" + sd_hostname + ":" + sd_ssl_port ; + + String query_string = "sdomainURL=" + + URLEncoder.encode(domain_url) + + "&choice=existingdomain"+ + "&p=1" + + "&op=next" + + "&xml=true"; + + hr = hc.nonsslConnect(cs_hostname,cs_port,wizard_uri,query_string); + + // parse xml + bais = new ByteArrayInputStream(hr.getHTML().getBytes()); + px.parse(bais); + px.prettyprintxml(); + + return true; + + } + + public boolean DisplayChainPanel() + { + boolean st = false; + HTTPResponse hr = null; + ByteArrayInputStream bais = null; + ParseXML px = new ParseXML(); + String query_string = null; + + query_string = "p=2" + "&op=next" + "&xml=true"; + hr = hc.nonsslConnect(cs_hostname,cs_port,wizard_uri,query_string); + + return true; + + } + + public boolean SecurityDomainLoginPanel() + { + boolean st = false; + HTTPResponse hr = null; + ByteArrayInputStream bais = null; + ParseXML px = new ParseXML(); + + + 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); + + hr = hc.sslConnect(sd_hostname,sd_ssl_port,sd_login_uri,query_string); + + String query_string_1 = "uid=" + sd_admin_name + + "&pwd=" + sd_admin_password + + "&url=" + URLEncoder.encode(ra_url) ; + + hr = hc.sslConnect(sd_hostname,sd_ssl_port,sd_get_cookie_uri, + query_string_1); + + // get session id from security domain + sleep_time(); + + String ra_session_id = hr.getContentValue("header.session_id"); + String ra_url_1 = hr.getContentValue("header.url"); + + System.out.println("RA_SESSION_ID=" + ra_session_id ); + System.out.println("RA_URL=" + ra_url_1 ); + + // use session id to connect back to RA + + String query_string_2 = "p=3" + + "&session_id=" + ra_session_id + + "&subsystem=RA" + + "&xml=true" ; + + hr = hc.nonsslConnect(cs_hostname,cs_port,wizard_uri, + query_string_2); + + // parse xml - no parsing + + return true; + + } + + public boolean SubsystemPanel() + { + boolean st = false; + HTTPResponse hr = null; + ByteArrayInputStream bais = null; + ParseXML px = new ParseXML(); + + sleep_time(); + String query_string = "p=3" + "&op=next" + "&xml=true" + + "&subsystemName=" + + URLEncoder.encode(subsystem_name) + + "&choice=newsubsystem" ; + + hr = hc.nonsslConnect(cs_hostname,cs_port,wizard_uri,query_string); + // parse xml + bais = new ByteArrayInputStream(hr.getHTML().getBytes()); + px.parse(bais); + px.prettyprintxml(); + + sleep_time(); + String ca_url = "https://" + ca_hostname + ":" + ca_ssl_port ; + + // CA choice panel + query_string = "p=4" + "&op=next" + "&xml=true" + + "&urls=" + + URLEncoder.encode(ca_url) ; + + hr = hc.nonsslConnect(cs_hostname,cs_port,wizard_uri,query_string); + // parse xml + bais = new ByteArrayInputStream(hr.getHTML().getBytes()); + px.parse(bais); + px.prettyprintxml(); + + return true; + } + + public boolean DBPanel() + { + boolean st = false; + HTTPResponse hr = null; + ByteArrayInputStream bais = null; + ParseXML px = new ParseXML(); + + + // SQL LITE PANEL + + String query_string = "p=5" + "&op=next" + "&xml=true" ; + + hr = hc.nonsslConnect(cs_hostname,cs_port,wizard_uri,query_string); + + // parse xml + bais = new ByteArrayInputStream(hr.getHTML().getBytes()); + px.parse(bais); + px.prettyprintxml(); + + return true; + } + + public boolean TokenChoicePanel() + { + boolean st = false; + HTTPResponse hr = null; + ByteArrayInputStream bais = null; + ParseXML px = new ParseXML(); + + //////////////////////////////////////////////////////// + String query_string = null; + + // Software Token + if(token_name.equalsIgnoreCase("internal")) + { + query_string = "p=6" + "&op=next" + "&xml=true" + + "&choice=" + + URLEncoder.encode("NSS Certificate DB") + + ""; + hr = hc.nonsslConnect(cs_hostname,cs_port,wizard_uri,query_string); + // parse xml + bais = new ByteArrayInputStream(hr.getHTML().getBytes()); + px.parse(bais); + px.prettyprintxml(); + } + // HSM + else + { + // login to hsm first + query_string = "p=7" + "&op=next" + "&xml=true" + + "&uTokName=" + + URLEncoder.encode(token_name) + + "&__uPasswd=" + + URLEncoder.encode(token_pwd) + + ""; + hr = hc.nonsslConnect(cs_hostname,cs_port,wizard_uri,query_string); + // parse xml + bais = new ByteArrayInputStream(hr.getHTML().getBytes()); + px.parse(bais); + px.prettyprintxml(); + + // choice with token name now + query_string = "p=6" + "&op=next" + "&xml=true" + + "&choice=" + + URLEncoder.encode(token_name) + + ""; + hr = hc.nonsslConnect(cs_hostname,cs_port,wizard_uri,query_string); + // parse xml + bais = new ByteArrayInputStream(hr.getHTML().getBytes()); + px.parse(bais); + px.prettyprintxml(); + + } + + + return true; + } + + public boolean KeyPanel() + { + boolean st = false; + HTTPResponse hr = null; + ByteArrayInputStream bais = null; + ParseXML px = new ParseXML(); + ArrayList friendly_list = null; + ArrayList dn_list = null; + + + String query_string = "p=8" + "&op=next" + "&xml=true" + + "&subsystem_custom_size=" + key_size + + "&sslserver_custom_size=" + key_size + + "&custom_size=" + key_size + + "&subsystem_keytype=" + key_type + + "&sslserver_keytype=" + key_type + + "&keytype=" + key_type + + "&subsystem_choice=custom"+ + "&sslserver_choice=custom"+ + "&choice=custom"+ + ""; + + hr = hc.nonsslConnect(cs_hostname,cs_port,wizard_uri,query_string); + + // parse xml + bais = new ByteArrayInputStream(hr.getHTML().getBytes()); + px.parse(bais); + px.prettyprintxml(); + + return true; + } + + public boolean CertSubjectPanel() + { + boolean st = false; + HTTPResponse hr = null; + ByteArrayInputStream bais = null; + ParseXML px = new ParseXML(); + ArrayList req_list = null; + ArrayList cert_list = null; + ArrayList dn_list = null; + ArrayList friendly_list = null; + + String ca_url = "https://" + ca_hostname + ":" + ca_ssl_port ; + + String query_string = "p=9" + "&op=next" + "&xml=true" + + "&subsystem=" + + URLEncoder.encode(ra_subsystem_cert_subject_name) + + "&sslserver=" + + URLEncoder.encode(ra_server_cert_subject_name) + + "&urls=" + + URLEncoder.encode(ca_url) + + ""; + + hr = hc.nonsslConnect(cs_hostname,cs_port,wizard_uri,query_string); + + // parse xml + bais = new ByteArrayInputStream(hr.getHTML().getBytes()); + px.parse(bais); + px.prettyprintxml(); + + // parse the certs if needed + + return true; + } + + public boolean CertificatePanel() + { + boolean st = false; + HTTPResponse hr = null; + ByteArrayInputStream bais = null; + ParseXML px = new ParseXML(); + ArrayList req_list = null; + ArrayList cert_list = null; + ArrayList dn_list = null; + ArrayList pp_list = null; + + + String query_string = "p=10" + "&op=next" + "&xml=true" + + "&subsystem=" + + "&subsystem_cc=" + + "&sslserver=" + + "&sslserver_cc=" + + ""; + + hr = hc.nonsslConnect(cs_hostname,cs_port,wizard_uri,query_string); + + // parse xml + bais = new ByteArrayInputStream(hr.getHTML().getBytes()); + px.parse(bais); + px.prettyprintxml(); + + return true; + } + + public boolean AdminCertReqPanel() + { + boolean st = false; + HTTPResponse hr = null; + ByteArrayInputStream bais = null; + ParseXML px = new ParseXML(); + String admin_cert_request = null; + + // not used + String cert_subject = "CN=" + "ra-" + admin_user; + + ComCrypto cCrypt = new ComCrypto(client_certdb_dir, + client_certdb_pwd, + agent_cert_subject, + agent_key_size, + agent_key_type); + cCrypt.setDebug(true); + cCrypt.setGenerateRequest(true); + cCrypt.setTransportCert(null); + cCrypt.setDualKey(false); + cCrypt.loginDB(); + + String crmf_request = cCrypt.generateCRMFrequest(); + + if(crmf_request == null) + { + System.out.println("ERROR: AdminCertReqPanel() cert req gen failed"); + return false; + } + + admin_cert_request = crmf_request; + + String query_string = "p=11" + "&op=next" + "&xml=true" + + "&cert_request_type=" + "crmf" + + "&uid=" + admin_user + + "&name=" + admin_user + + "&__pwd=" + admin_password + + "&__admin_password_again=" + admin_password + + "&profileId=" + "caAdminCert" + + "&email=" + + URLEncoder.encode(admin_email) + + "&cert_request=" + + URLEncoder.encode(admin_cert_request) + + "&subject=" + agent_cert_subject + + "&clone=0" + + "&import=true" + + "&securitydomain=" + domain_name + + ""; + + hr = hc.nonsslConnect(cs_hostname,cs_port,wizard_uri,query_string); + + // parse xml + bais = new ByteArrayInputStream(hr.getHTML().getBytes()); + px.parse(bais); + px.prettyprintxml(); + + admin_serial_number = px.getvalue("serialNumber"); + + return true; + } + + public boolean AdminCertImportPanel() + { + boolean st = false; + HTTPResponse hr = null; + ByteArrayInputStream bais = null; + ParseXML px = new ParseXML(); + + String query_string = "serialNumber=" + admin_serial_number + + "&importCert=" + "true" + + ""; + + hr = hc.sslConnect(ca_hostname,ca_ssl_port,ee_uri,query_string); + String cert_to_import = null; + + try + { + cert_to_import = + new sun.misc.BASE64Encoder().encode(hr.getResponseData()); + + } + catch (Exception e) + { + System.out.println("ERROR: failed to retrieve cert"); + } + + System.out.println("Imported Cert=" + cert_to_import); + + ComCrypto cCrypt = new ComCrypto(client_certdb_dir, + client_certdb_pwd, + null, + null, + null); + cCrypt.setDebug(true); + cCrypt.setGenerateRequest(true); + cCrypt.loginDB(); + + String start = "-----BEGIN CERTIFICATE-----\r\n" ; + String end = "\r\n-----END CERTIFICATE-----" ; + + st = cCrypt.importCert(start+cert_to_import+end,agent_name); + if(!st) + { + System.out.println("ERROR: AdminCertImportPanel() during cert import"); + return false; + } + + System.out.println("SUCCESS: imported admin user cert"); + return true; + } + + public boolean UpdateDomainPanel() + { + boolean st = false; + HTTPResponse hr = null; + ByteArrayInputStream bais = null; + ParseXML px = new ParseXML(); + + String query_string = "p=12" + "&op=next" + "&xml=true" + + "&caHost=" + URLEncoder.encode(ca_hostname) + + "&caPort=" + URLEncoder.encode(ca_ssl_port) + + ""; + + hr = hc.nonsslConnect(cs_hostname,cs_port,wizard_uri,query_string); + + // parse xml + bais = new ByteArrayInputStream(hr.getHTML().getBytes()); + // px.parse(bais); + // px.prettyprintxml(); + + return true; + } + + public boolean ConfigureRAInstance() + { + // 0. login to cert db + ComCrypto cCrypt = new ComCrypto(client_certdb_dir, + client_certdb_pwd, + null, + null, + null); + cCrypt.setDebug(true); + cCrypt.setGenerateRequest(true); + cCrypt.loginDB(); + + // instantiate http client + hc = new HTTPClient(); + + sleep_time(); + // 1. Login panel + boolean log_st = LoginPanel(); + if(!log_st) + { + System.out.println("ERROR: JSESSIONID not found."); + System.out.println("ERROR: ConfigureRA: LoginPanel() failure"); + return false; + } + + sleep_time(); + // 2. domain panel + boolean dom_st = DomainPanel(); + if(!dom_st) + { + System.out.println("ERROR: ConfigureRA: DomainPanel() failure"); + return false; + } + + sleep_time(); + // 3. display cert chain panel + boolean disp_st = DisplayChainPanel(); + if(!disp_st) + { + System.out.println("ERROR: ConfigureRA: DisplayChainPanel() failure"); + return false; + } + + sleep_time(); + // security domain login panel + boolean disp_sd = SecurityDomainLoginPanel(); + if(!disp_sd) + { + System.out.println("ERROR: ConfigureRA: SecurityDomainLoginPanel() failure"); + return false; + } + + sleep_time(); + // subsystem panel + boolean disp_ss = SubsystemPanel(); + if(!disp_ss) + { + System.out.println("ERROR: ConfigureRA: SubsystemPanel() failure"); + return false; + } + + sleep_time(); + // 7. ldap connection panel + boolean disp_ldap = DBPanel(); + if(!disp_ldap) + { + System.out.println("ERROR: ConfigureRA: DBPanel() failure"); + return false; + } + + sleep_time(); + // 8. Token Choice Panel + boolean disp_token = TokenChoicePanel(); + if(!disp_token) + { + System.out.println("ERROR: ConfigureRA: TokenChoicePanel() failure"); + return false; + } + + sleep_time(); + // 9. Key Panel + boolean disp_key = KeyPanel(); + if(!disp_key) + { + System.out.println("ERROR: ConfigureRA: KeyPanel() failure"); + return false; + } + + sleep_time(); + // 10. Cert Subject Panel + boolean disp_csubj = CertSubjectPanel(); + if(!disp_csubj) + { + System.out.println("ERROR: ConfigureRA: CertSubjectPanel() failure"); + return false; + } + + sleep_time(); + // 11. Certificate Panel + boolean disp_cp = CertificatePanel(); + if(!disp_cp) + { + System.out.println("ERROR: ConfigureRA: CertificatePanel() failure"); + return false; + } + + sleep_time(); + // 13. Admin Cert Req Panel + boolean disp_adm = AdminCertReqPanel(); + if(!disp_adm) + { + System.out.println("ERROR: ConfigureRA: AdminCertReqPanel() failure"); + return false; + } + + sleep_time(); + // 14. Admin Cert import Panel + boolean disp_im = AdminCertImportPanel(); + if(!disp_im) + { + System.out.println("ERROR: ConfigureRA: AdminCertImportPanel() failure"); + return false; + } + + sleep_time(); + // 15. Update Domain Panel + boolean disp_ud = UpdateDomainPanel(); + if(!disp_ud) + { + System.out.println("ERROR: ConfigureRA: UpdateDomainPanel() failure"); + return false; + } + + return true; + } + + public static void main(String args[]) + { + ConfigureRA ca = new ConfigureRA(); + + // set variables + StringHolder x_cs_hostname = new StringHolder(); + StringHolder x_cs_port = new StringHolder(); + + StringHolder x_sd_hostname = new StringHolder(); + StringHolder x_sd_ssl_port = new StringHolder(); + StringHolder x_sd_admin_name = new StringHolder(); + StringHolder x_sd_admin_password = new StringHolder(); + + StringHolder x_ca_hostname = new StringHolder(); + StringHolder x_ca_port = new StringHolder(); + StringHolder x_ca_ssl_port = new StringHolder(); + + StringHolder x_client_certdb_dir = new StringHolder(); + StringHolder x_client_certdb_pwd = new StringHolder(); + StringHolder x_preop_pin = new StringHolder(); + + StringHolder x_domain_name = new StringHolder(); + + StringHolder x_admin_user = new StringHolder(); + StringHolder x_admin_email = new StringHolder(); + StringHolder x_admin_password = new StringHolder(); + + // key size + StringHolder x_token_name = new StringHolder(); + StringHolder x_token_pwd = new StringHolder(); + StringHolder x_key_size = new StringHolder(); + StringHolder x_key_type = new StringHolder(); + + StringHolder x_agent_key_size = new StringHolder(); + StringHolder x_agent_key_type = new StringHolder(); + StringHolder x_agent_cert_subject = new StringHolder(); + + StringHolder x_agent_name = new StringHolder(); + + // ra cert subject name params + StringHolder x_ra_subsystem_cert_subject_name = new StringHolder(); + StringHolder x_ra_server_cert_subject_name = new StringHolder(); + + // subsystemName + StringHolder x_subsystem_name = new StringHolder(); + + + // parse the args + ArgParser parser = new ArgParser("ConfigureRA"); + + parser.addOption ("-cs_hostname %s #CS Hostname", + x_cs_hostname); + parser.addOption ("-cs_port %s #CS SSL port", + x_cs_port); + + parser.addOption ("-sd_hostname %s #Security Domain Hostname", + x_sd_hostname); + parser.addOption ("-sd_ssl_port %s #Security Domain SSL port", + x_sd_ssl_port); + parser.addOption ("-sd_admin_name %s #Security Domain username", + x_sd_admin_name); + parser.addOption ("-sd_admin_password %s #Security Domain password", + x_sd_admin_password); + + parser.addOption ("-ca_hostname %s #CA Hostname", + x_ca_hostname); + parser.addOption ("-ca_port %s #CA non SSL port", + x_ca_port); + parser.addOption ("-ca_ssl_port %s #CA SSL port", + x_ca_ssl_port); + + parser.addOption ("-client_certdb_dir %s #Client CertDB dir", + x_client_certdb_dir); + parser.addOption ("-client_certdb_pwd %s #client certdb password", + x_client_certdb_pwd); + parser.addOption ("-preop_pin %s #pre op pin", + x_preop_pin); + parser.addOption ("-domain_name %s #domain name", + x_domain_name); + parser.addOption ("-admin_user %s #Admin User Name", + x_admin_user); + parser.addOption ("-admin_email %s #Admin email", + x_admin_email); + parser.addOption ("-admin_password %s #Admin password", + x_admin_password); + parser.addOption ("-agent_name %s #Agent Cert Nickname", + x_agent_name); + + parser.addOption ("-token_name %s #HSM/Software Token name", + x_token_name); + parser.addOption ("-token_pwd %s #HSM/Software Token password", + x_token_pwd); + parser.addOption ("-key_size %s #Key Size", + x_key_size); + parser.addOption ("-key_type %s #Key type [rsa,ecc]", + x_key_type); + + parser.addOption ("-agent_key_size %s #Agent Cert Key Size", + x_agent_key_size); + parser.addOption ("-agent_key_type %s #Agent cert Key type [rsa]", + x_agent_key_type); + parser.addOption ("-agent_cert_subject %s #Agent cert Subject", + x_agent_cert_subject); + + parser.addOption ( + "-ra_subsystem_cert_subject_name %s #RA subsystem cert subject name", + x_ra_subsystem_cert_subject_name); + parser.addOption ( + "-ra_server_cert_subject_name %s #RA server cert subject name", + x_ra_server_cert_subject_name); + + parser.addOption ( + "-subsystem_name %s #RA subsystem name", + x_subsystem_name); + + // and then match the arguments + String [] unmatched = null; + unmatched = parser.matchAllArgs (args,0,parser.EXIT_ON_UNMATCHED); + + if(unmatched!=null) + { + System.out.println("ERROR: Argument Mismatch"); + System.exit(-1); + } + + // set variables + cs_hostname = x_cs_hostname.value; + cs_port = x_cs_port.value; + + sd_hostname = x_sd_hostname.value; + sd_ssl_port = x_sd_ssl_port.value; + sd_admin_name = x_sd_admin_name.value; + sd_admin_password = x_sd_admin_password.value; + + ca_hostname = x_ca_hostname.value; + ca_port = x_ca_port.value; + ca_ssl_port = x_ca_ssl_port.value; + + client_certdb_dir = x_client_certdb_dir.value; + client_certdb_pwd = x_client_certdb_pwd.value; + pin = x_preop_pin.value; + domain_name = x_domain_name.value; + + admin_user = x_admin_user.value; + admin_email = x_admin_email.value; + admin_password = x_admin_password.value; + agent_name = x_agent_name.value; + + key_size = x_key_size.value; + key_type = x_key_type.value; + token_name = x_token_name.value; + token_pwd = x_token_pwd.value; + + agent_key_size = x_agent_key_size.value; + agent_key_type = x_agent_key_type.value; + agent_cert_subject = x_agent_cert_subject.value; + + ra_subsystem_cert_subject_name = + x_ra_subsystem_cert_subject_name.value; + ra_server_cert_subject_name = + x_ra_server_cert_subject_name.value ; + + subsystem_name = x_subsystem_name.value ; + + + + boolean st = ca.ConfigureRAInstance(); + + if (!st) + { + System.out.println("ERROR: unable to create RA"); + System.exit(-1); + } + + System.out.println("Certficate System - RA Instance Configured"); + System.exit(0); + + } + +}; |