PageRenderTime 45ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 1ms

/pki-core-9.0.21/base/silent/src/common/AutoInstaller.java

#
Java | 2461 lines | 1797 code | 432 blank | 232 comment | 181 complexity | 40377d981c0c94c94baf17b1ad5270a5 MD5 | raw file
Possible License(s): GPL-2.0

Large files files are truncated, but you can click here to view the full file

  1. // --- BEGIN COPYRIGHT BLOCK ---
  2. // This program is free software; you can redistribute it and/or modify
  3. // it under the terms of the GNU General Public License as published by
  4. // the Free Software Foundation; version 2 of the License.
  5. //
  6. // This program is distributed in the hope that it will be useful,
  7. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. // GNU General Public License for more details.
  10. //
  11. // You should have received a copy of the GNU General Public License along
  12. // with this program; if not, write to the Free Software Foundation, Inc.,
  13. // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  14. //
  15. // (C) 2007 Red Hat, Inc.
  16. // All rights reserved.
  17. // --- END COPYRIGHT BLOCK ---
  18. import java.net.*;
  19. import java.io.*;
  20. import java.util.*;
  21. /**
  22. * CMS Test Framework.
  23. * Use this class to Configure a CA, RA,DRM,OCSP and SubCA subsystem.
  24. * This simulartes the installation wizard functions and helps to configure a CMS subsystem.
  25. */
  26. public class AutoInstaller {
  27. private static Properties props = null;
  28. // Admin Server and InternalDB varialbes
  29. private String adminDomain, adminID, adminPWD, adminPort, machineName, host, serverID, instanceID, serverRoot, sieURL, dbConnPort, dbConnHost, dbInstanceName, dbPassword, dbLDAPauthDN, dbmode, ldapServerDB;
  30. // CMS Subsystem info
  31. 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;
  32. // CA info
  33. private String caHostname, caPortnum, caTimeout, caEEPort, enpropfile, cdir, tokenpwd, CAadminId, CAadminPwd, CAcertnickname, caAgentPortnum, cloneInstanceId;
  34. // Program variables
  35. private int i;
  36. private String configURL, deamonURL, certInstID;
  37. private String inputLine;
  38. private boolean st = false;
  39. private String postQuery = null;
  40. private String propFileName;
  41. private StringBuffer spage = new StringBuffer();
  42. // 4.5 server String CERTtokenName="Internal Key Storage Token";
  43. private String CERTtokenName = "internal";
  44. private String certRequestStr = null, ssl_clientcert = "true";
  45. private String raSigningCert = null;
  46. private String kraTransportCert = null;
  47. private boolean subca = false;
  48. // / Constructors
  49. public AutoInstaller() {}
  50. /**
  51. * Constructor . Takes parameter Server Root .
  52. */
  53. public AutoInstaller(String sr) {
  54. serverRoot = sr;
  55. }
  56. // Set InternalDBVInfo
  57. /**
  58. * Set Internal Database Information . Takes parameters internaldatabase hostname, internaldatabase port, internaldatabase name, internaldatabase binddn, internaldatabase password
  59. */
  60. public void setInternalDBInfo(String dbh, String dbp, String dbname, String dbdn, String dbpswd) {
  61. dbConnPort = dbp;
  62. dbConnHost = dbh;
  63. dbInstanceName = dbname;
  64. dbPassword = dbpswd;
  65. dbLDAPauthDN = dbdn;
  66. dbmode = "local";
  67. ldapServerDB = "userRoot";
  68. }
  69. // Create Password file
  70. private boolean CreatePasswordFile() {
  71. String s = "internal: " + SingleSignOnPWD;
  72. OutputStream f0 = null;
  73. try {
  74. f0 = new FileOutputStream(
  75. serverRoot + "/" + instanceID + "/config/password.conf");
  76. f0.write(s.getBytes());
  77. f0.close();
  78. return true;
  79. } catch (Exception e) {
  80. System.out.println("exception " + e.getMessage());
  81. try {
  82. if (f0 != null) f0.close();
  83. } catch (IOException ioe) {
  84. System.out.println("IO Exception: " + ioe.getMessage());
  85. }
  86. return false;
  87. }
  88. }
  89. private boolean BackupConfigFile() {
  90. FileInputStream f1 = null;
  91. OutputStream f2 = null;
  92. try {
  93. f1 = new FileInputStream(
  94. serverRoot + "/" + instanceID + "/config/CS.cfg");
  95. int size = f1.available();
  96. byte b[] = new byte[size];
  97. if (f1.read(b) != b.length) {
  98. f1.close();
  99. return false;
  100. }
  101. f2 = new FileOutputStream(
  102. serverRoot + "/" + instanceID + "/config/CS.cfg.org");
  103. f2.write(b);
  104. f1.close();
  105. f2.close();
  106. return true;
  107. } catch (Exception e) {
  108. System.out.println("exception " + e.getMessage());
  109. try {
  110. if (f1 != null) f1.close();
  111. } catch (IOException ioe) {
  112. System.out.println("IO Exception: " + ioe.getMessage());
  113. }
  114. try {
  115. if (f2 != null) f2.close();
  116. } catch (IOException ioe) {
  117. System.out.println("IO Exception: " + ioe.getMessage());
  118. }
  119. return false;
  120. }
  121. }
  122. // Get RaSigning Cert
  123. public String getRASigningCert() {
  124. return raSigningCert;
  125. }
  126. // Get KRATransportCert
  127. public String getKRATransportCert() {
  128. return kraTransportCert;
  129. }
  130. // Set Admin Server Info
  131. /**
  132. * Set Admin Server Information . Takes parameters : hostname, adminserver portnumber , adminId , adminPassword
  133. */
  134. public void setAdminInfo(String h, String p, String adDN, String id, String adpwd) {
  135. adminDomain = adDN;
  136. adminID = id;
  137. adminPWD = adpwd;
  138. adminPort = p;
  139. host = h;
  140. }
  141. // Set CA Server Info
  142. /**
  143. * Set CA server Information . Takes parametrers :CAhostname, CAEEPORT, CAAGENTPORT , CAAdminUID, CAAdminPassword
  144. */
  145. public void setCAInfo(String cah, String caeep, String caagp, String caaduid, String caadpwd) {
  146. caHostname = cah;
  147. caPortnum = caagp;
  148. caTimeout = "30";
  149. caEEPort = caeep;
  150. CAadminId = caaduid;
  151. CAadminPwd = caadpwd;
  152. caAgentPortnum = caagp;
  153. }
  154. // Set ClientDB Info;
  155. /**
  156. * Sets Client Database information . Takes paramters : certdbdir, certdbpasswd, certnickanme
  157. */
  158. public void setClientDBInfo(String cd, String pwd, String nickname) {
  159. cdir = cd;
  160. tokenpwd = pwd;
  161. CAcertnickname = nickname;
  162. }
  163. // Is this Internal or any hardware token and its password;
  164. /**
  165. * Set token info . Takes paramter "Internal" and tokenpasswd
  166. */
  167. public void setTokenInfo(String t, String tp) {
  168. tokenName = t;
  169. tokenPWD = tp;
  170. }
  171. // Set Subsystem Information for Configuring
  172. /**
  173. * 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.
  174. */
  175. 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) {
  176. serverID = sID;
  177. instanceID = "cert-" + sID;
  178. keyType = kT;
  179. keyLength = kL;
  180. hashType = hT;
  181. certValidityDays = cVD;
  182. eeHttpPort = seP;
  183. eeHttpsPort = seSP;
  184. agentHttpsPort = sAgP;
  185. radminHttpsPort = sAdP;
  186. subjectName = sdn;
  187. caOComponent = "test";
  188. }
  189. // // Configure CMS Subsystems
  190. /**
  191. * Confiures a CA Subsystem .Takes parameter : adminSubjectDN, adminUID, AdminPasswd, SingleSignonPasswd
  192. */
  193. public boolean ConfigureCA(String adn, String aduid, String adp, String ssonpwd) {
  194. certAdminName = adn;
  195. certAdminUid = aduid;
  196. certAdminPWD = adp;
  197. SingleSignOnPWD = ssonpwd;
  198. signingCert = "caSigningCert";
  199. certType = signingCert;
  200. subsystems = "ca";
  201. ca = "true";
  202. kra = "false";
  203. ra = "false";
  204. ocsp = "false";
  205. remoteKRA = "false";
  206. wirelessSupport = "false";
  207. aki = "true";
  208. isCA = "true";
  209. ski = "true";
  210. sslCABit = "true";
  211. objectSigningCABit = "true";
  212. mailCABit = "true";
  213. if (ConfCA()) {
  214. CreatePasswordFile();
  215. BackupConfigFile();
  216. return true;
  217. }
  218. return false;
  219. }
  220. public boolean ConfigureTKS(String adn, String aduid, String adp, String ssonpwd) {
  221. certAdminName = adn;
  222. certAdminUid = aduid;
  223. certAdminPWD = adp;
  224. SingleSignOnPWD = ssonpwd;
  225. signingCert = "raSigningCert";
  226. certType = signingCert;
  227. subsystems = "tks";
  228. ra = "false";
  229. tks = "true";
  230. kra = "false";
  231. ca = "false";
  232. ocsp = "false";
  233. remoteKRA = "false";
  234. wirelessSupport = "false";
  235. aki = "true";
  236. isCA = "false";
  237. ski = "true";
  238. sslCABit = "true";
  239. objectSigningCABit = "true";
  240. mailCABit = "true";
  241. if (ConfTKS()) {
  242. CreatePasswordFile();
  243. BackupConfigFile();
  244. return true;
  245. }
  246. return false;
  247. }
  248. private boolean ConfTKS() {
  249. // Start Configuring
  250. // Step 1. Start Deamon
  251. if (!startDeamon()) {
  252. System.out.println(
  253. "Configuring Cert Instance: Unable to start deamon");
  254. return false;
  255. }
  256. // Sometimes it takes time to start deamon so wait for few seconds
  257. try {
  258. System.out.println("going to sleep for 10 seconds");
  259. Thread.sleep(10000);
  260. } catch (InterruptedException ie) {
  261. System.out.println("sleep exection");
  262. }
  263. // Step 1a: Initialize Token ( Changed in 6.0)jjj
  264. if (!initializePWD()) {
  265. System.out.println(
  266. "Configuring Cert Instance: error initializing pwd token");
  267. return false;
  268. }
  269. // Step 2. Configure Internal DB
  270. if (!configInternalDB()) {
  271. System.out.println(
  272. "Configuring Cert Instance: error configuring internal db");
  273. return false;
  274. }
  275. // Step 3. Create Admin Values
  276. if (!createAdminValues()) {
  277. System.out.println(
  278. "Configuring Cert Instance: error configuring admin values ");
  279. return false;
  280. }
  281. // Step 4. SubSystems
  282. if (!selectSubSystem()) {
  283. System.out.println(
  284. "Configuring Cert Instance: error selecting subsystems");
  285. return false;
  286. }
  287. // Step 5. Network Configuration
  288. if (!networkConfig()) {
  289. System.out.println(
  290. "Configuring Cert Instance: error configuring network ports ");
  291. return false;
  292. }
  293. // Create a SSL signing cert
  294. Date tmpdate = new Date();
  295. certType = "serverCert";
  296. subjectName = "CN=" + host + "." + adminDomain + ",OU=ssltest"
  297. + tmpdate.getTime() + ",O=SSL,C=US";
  298. keyLength = "512";
  299. keyType = "RSA";
  300. String mtokenPWD = tokenPWD;
  301. tokenPWD = "";
  302. ssl_clientcert = "false";
  303. signingCert = "server";
  304. if (!initializeToken()) {
  305. System.out.println(
  306. "Configuring Cert Instance: error initializing token");
  307. return false;
  308. }
  309. // Step 8 : keyLenth
  310. if (!keyLength()) {
  311. System.out.println(
  312. "Configuring Cert Instance: error configuring KeyLength");
  313. return false;
  314. }
  315. // Step 9 : CheckDN
  316. if (!checkDN()) {
  317. System.out.println(
  318. "Configuring Cert Instance: error checking deamon");
  319. return false;
  320. }
  321. // Step 10 :
  322. if (!certRequest(false)) {
  323. System.out.println(
  324. "Configuring Cert Instance: error creating Request");
  325. return false;
  326. }
  327. // After creating ssl cert
  328. tokenPWD = mtokenPWD;
  329. // Step 11
  330. if (!singleSignON()) {
  331. System.out.println(
  332. "Configuring Cert Instance: error setting up singlesignon");
  333. return false;
  334. }
  335. // Step 11
  336. if (!doMisc()) {
  337. System.out.println(
  338. "Configuring Cert Instance: error setting up miscell");
  339. return false;
  340. }
  341. // Step 12
  342. if (!exitDeamon()) {
  343. System.out.println(
  344. "Configuring Cert Instance: Unable to exit deamon");
  345. return false;
  346. }
  347. return true;
  348. }
  349. /**
  350. * Confiures a RA Subsystem .Takes parameter : adminSubjectDN, adminUID, AdminPasswd, SingleSignonPasswd
  351. */
  352. public boolean ConfigureRA(String adn, String aduid, String adp, String ssonpwd) {
  353. certAdminName = adn;
  354. certAdminUid = aduid;
  355. certAdminPWD = adp;
  356. SingleSignOnPWD = ssonpwd;
  357. signingCert = "raSigningCert";
  358. certType = signingCert;
  359. subsystems = "ra";
  360. ra = "true";
  361. kra = "false";
  362. ca = "false";
  363. ocsp = "false";
  364. remoteKRA = "false";
  365. wirelessSupport = "false";
  366. aki = "true";
  367. isCA = "true";
  368. ski = "true";
  369. sslCABit = "true";
  370. objectSigningCABit = "true";
  371. mailCABit = "true";
  372. if (ConfRA()) {
  373. CreatePasswordFile();
  374. BackupConfigFile();
  375. return true;
  376. }
  377. return false;
  378. }
  379. /**
  380. * Confiures a OCSP Subsystem .Takes parameter : adminSubjectDN, adminUID, AdminPasswd, SingleSignonPasswd
  381. */
  382. public boolean ConfigureOCSP(String adn, String aduid, String adp, String ssonpwd) {
  383. certAdminName = adn;
  384. certAdminUid = aduid;
  385. certAdminPWD = adp;
  386. SingleSignOnPWD = ssonpwd;
  387. signingCert = "ocspSigningCert";
  388. certType = signingCert;
  389. subsystems = "ocsp";
  390. ocsp = "true";
  391. kra = "false";
  392. ra = "false";
  393. ca = "false";
  394. remoteKRA = "false";
  395. wirelessSupport = "false";
  396. aki = "true";
  397. isCA = "true";
  398. ski = "true";
  399. sslCABit = "true";
  400. objectSigningCABit = "true";
  401. mailCABit = "true";
  402. if (ConfOCSP()) {
  403. CreatePasswordFile();
  404. BackupConfigFile();
  405. return true;
  406. }
  407. return false;
  408. }
  409. /**
  410. * Confiures a KRA Subsystem .Takes parameter : adminSubjectDN, adminUID, AdminPasswd, SingleSignonPasswd
  411. */
  412. public boolean ConfigureKRA(String adn, String aduid, String adp, String ssonpwd) {
  413. certAdminName = adn;
  414. certAdminUid = aduid;
  415. certAdminPWD = adp;
  416. SingleSignOnPWD = ssonpwd;
  417. signingCert = "kraTransportCert";
  418. certType = signingCert;
  419. subsystems = "kra";
  420. kra = "true";
  421. ca = "false";
  422. ra = "false";
  423. ocsp = "false";
  424. remoteKRA = "false";
  425. wirelessSupport = "false";
  426. aki = "true";
  427. isCA = "true";
  428. ski = "true";
  429. sslCABit = "true";
  430. objectSigningCABit = "true";
  431. mailCABit = "true";
  432. if (ConfKRA()) {
  433. CreatePasswordFile();
  434. BackupConfigFile();
  435. return true;
  436. }
  437. return false;
  438. }
  439. /**
  440. * Confiures a SubCA Subsystem .Takes parameter : adminSubjectDN, adminUID, AdminPasswd, SingleSignonPasswd
  441. */
  442. public boolean ConfigureSubCA(String adn, String aduid, String adp, String ssonpwd) {
  443. certAdminName = adn;
  444. certAdminUid = aduid;
  445. certAdminPWD = adp;
  446. SingleSignOnPWD = ssonpwd;
  447. subca = true;
  448. signingCert = "caSigningCert";
  449. certType = signingCert;
  450. subsystems = "ca";
  451. ca = "true";
  452. kra = "false";
  453. ra = "false";
  454. ocsp = "false";
  455. remoteKRA = "false";
  456. wirelessSupport = "false";
  457. aki = "true";
  458. isCA = "true";
  459. ski = "true";
  460. sslCABit = "true";
  461. objectSigningCABit = "true";
  462. mailCABit = "true";
  463. if (ConfSubCA()) {
  464. CreatePasswordFile();
  465. BackupConfigFile();
  466. return true;
  467. }
  468. return false;
  469. }
  470. // ////////////////////////////////////////////////////////
  471. private void getProperties(String filePath) throws Exception {
  472. FileInputStream fis = null;
  473. try {
  474. fis = new FileInputStream(filePath);
  475. props = new Properties();
  476. props.load(fis);
  477. System.out.println("Reading Properties file successful");
  478. } catch (Exception e) {
  479. System.out.println("exception " + e.getMessage());
  480. }
  481. try {
  482. if (fis != null) fis.close();
  483. } catch (IOException ioe) {
  484. System.out.println("IO Exception: " + ioe.getMessage());
  485. }
  486. }
  487. private void setPropFile(String fileName) {
  488. propFileName = fileName;
  489. }
  490. private void setConfigURL() {
  491. configURL = "/" + instanceID + "/Tasks/Operation/config-cert";
  492. }
  493. private void setDeamonURL() {
  494. deamonURL = "/" + instanceID + "/Tasks/Operation/start-daemon";
  495. }
  496. private void setPostQueryString(String querystring) {
  497. postQuery = querystring;
  498. }
  499. private boolean Connect(String myStringUrl) {
  500. // / This functions connects to the URL and POST HTTP Request .
  501. // It compares with NMC_STATUS and return the status.
  502. System.out.println(myStringUrl);
  503. st = false;
  504. PostQuery sm = new PostQuery(myStringUrl, adminID, adminPWD, postQuery);
  505. boolean st = sm.Send();
  506. spage = sm.getPage();
  507. return st;
  508. }
  509. private boolean startDeamon() {
  510. // Set StringURL to connect , set the query string and Connect .Get the result
  511. System.out.println("Log Info - configuring Cert Instance : Start Deamon");
  512. setDeamonURL();
  513. String myStringUrl = "http://" + host + "." + adminDomain + ":"
  514. + adminPort + deamonURL;
  515. System.out.println("Log Info -" + myStringUrl);
  516. String query = "instanceID=" + URLEncoder.encode(instanceID);
  517. query += "&AdminUsername=" + URLEncoder.encode(adminID);
  518. query += "&AdminUserPassword=" + URLEncoder.encode(adminPWD);
  519. setPostQueryString(query);
  520. return Connect(myStringUrl);
  521. }
  522. private boolean configInternalDB() {
  523. System.out.println(
  524. "Log Info - configuring Cert Instance : configureInternalDB");
  525. setConfigURL();
  526. String myStringUrl = "http://" + host + ":" + adminPort + configURL;
  527. System.out.println(myStringUrl);
  528. String query = "serverRoot=" + URLEncoder.encode(serverRoot);
  529. query += "&instanceID=" + URLEncoder.encode(instanceID);
  530. query += "&adminUID=" + URLEncoder.encode(adminID);
  531. query += "&opType=" + URLEncoder.encode("OP_MODIFY");
  532. query += "&taskID=" + URLEncoder.encode("createInternalDB");
  533. query += "&AdminUserPassword=" + URLEncoder.encode(adminPWD);
  534. query += "&host=" + URLEncoder.encode(host);
  535. query += "&internaldb.ldapconn.host=" + URLEncoder.encode(dbConnHost);
  536. query += "&internaldb.ldapconn.port=" + URLEncoder.encode(dbConnPort);
  537. query += "&internaldb.ldapauth.bindDN="
  538. + URLEncoder.encode(dbLDAPauthDN);
  539. query += "&db.instanceName=" + URLEncoder.encode(dbInstanceName);
  540. query += "&db.password=" + URLEncoder.encode(dbPassword);
  541. query += "&adminDomain=" + URLEncoder.encode(adminDomain);
  542. query += "&db.mode=" + URLEncoder.encode(dbmode);
  543. query += "&ldapServerDB=" + URLEncoder.encode(ldapServerDB);
  544. query += "&cmsSeed=0";
  545. // logging
  546. setPostQueryString(query);
  547. return Connect(myStringUrl);
  548. }
  549. private boolean createAdminValues() {
  550. System.out.println("configuring Cert Instance : configureAdmin");
  551. setConfigURL();
  552. String myStringUrl = "http://" + host + ":" + adminPort + configURL;
  553. System.out.println(myStringUrl);
  554. String query = "serverRoot=" + URLEncoder.encode(serverRoot);
  555. query += "&";
  556. query += "instanceID=" + URLEncoder.encode(instanceID);
  557. query += "&AdminUserPassword=" + URLEncoder.encode(adminPWD);
  558. query += "&cert.admin.name=" + URLEncoder.encode(certAdminName);
  559. query += "&cert.admin.uid=" + URLEncoder.encode(certAdminUid);
  560. query += "&cert.admin.passwd=" + URLEncoder.encode(certAdminPWD);
  561. query += "&db.password=" + URLEncoder.encode(dbPassword);
  562. query += "&opType=" + URLEncoder.encode("OP_MODIFY");
  563. query += "&taskID=" + URLEncoder.encode("setupAdmin");
  564. query += "&cmsSeed=0";
  565. setPostQueryString(query);
  566. return Connect(myStringUrl);
  567. }
  568. private boolean selectSubSystem() {
  569. System.out.println("configuring Cert Instance : SubSystems");
  570. setConfigURL();
  571. String myStringUrl = "http://" + host + ":" + adminPort + configURL;
  572. System.out.println(myStringUrl);
  573. String query = "serverRoot=" + URLEncoder.encode(serverRoot);
  574. query += "&";
  575. query += "instanceID=" + URLEncoder.encode(instanceID);
  576. query += "&AdminUserPassword=" + URLEncoder.encode(adminPWD);
  577. query += "&db.password=" + URLEncoder.encode(dbPassword);
  578. query += "&internaldb.ldapauth.bindDN="
  579. + URLEncoder.encode(dbLDAPauthDN);
  580. query += "&kra=" + URLEncoder.encode(kra);
  581. query += "&subsystems=" + URLEncoder.encode(subsystems);
  582. query += "&ca=" + URLEncoder.encode(ca);
  583. query += "&ra=" + URLEncoder.encode(ra);
  584. query += "&ocsp=" + URLEncoder.encode(ocsp);
  585. query += "&remoteKRA=" + URLEncoder.encode(remoteKRA);
  586. query += "&wirelessSupport=" + URLEncoder.encode(wirelessSupport);
  587. query += "&opType=" + URLEncoder.encode("OP_MODIFY");
  588. query += "&taskID=" + URLEncoder.encode("selectSubsystems");
  589. query += "&cmsSeed=0";
  590. if (subsystems.equals("ca")) {
  591. query += "&internaldb.ldapconn.host="
  592. + URLEncoder.encode(dbConnHost);
  593. query += "&internaldb.ldapconn.port="
  594. + URLEncoder.encode(dbConnPort);
  595. }
  596. if (subsystems.equals("ra")) {
  597. query += "&caHostname=" + caHostname;
  598. query += "&caPortnum=" + caPortnum;
  599. query += "&caTimeout=" + caTimeout;
  600. }
  601. if (subsystems.equals("tks")) {
  602. query += "&tks=true";
  603. }
  604. setPostQueryString(query);
  605. return Connect(myStringUrl);
  606. }
  607. private boolean taskCloneMaster() {
  608. System.out.println("configuring Cert Instance : taskCloneMaster");
  609. setConfigURL();
  610. String myStringUrl = "http://" + host + ":" + adminPort + configURL;
  611. System.out.println(myStringUrl);
  612. String query = "serverRoot=" + URLEncoder.encode(serverRoot);
  613. query += "&";
  614. query += "&claPortnumEE=" + URLEncoder.encode(caEEPort);
  615. query += "&claPortnum=" + URLEncoder.encode(caAgentPortnum);
  616. query += "&claHostname=" + URLEncoder.encode(caHostname);
  617. query += "&ra=false";
  618. query += "&ca=true";
  619. query += "&kra=false";
  620. query += "&subsystems=ca";
  621. query += "&cloning=true";
  622. query += "&cloningInstance=" + URLEncoder.encode(cloneInstanceId);
  623. query += "&claTimeout=" + URLEncoder.encode("60");
  624. query += "&internaldb.ldapauth.bindDN="
  625. + URLEncoder.encode(dbLDAPauthDN);
  626. query += "&AdminUserPassword=" + URLEncoder.encode(adminPWD);
  627. query += "&db.password=" + URLEncoder.encode(dbPassword);
  628. query += "&instanceID=" + URLEncoder.encode(instanceID);
  629. query += "&opType=" + URLEncoder.encode("OP_MODIFY");
  630. query += "&taskID=" + URLEncoder.encode("taskCloneMaster");
  631. query += "&cmsSeed=0";
  632. setPostQueryString(query);
  633. return Connect(myStringUrl);
  634. }
  635. private boolean taskCloning() {
  636. System.out.println("configuring Cert Instance : taskCloning");
  637. setConfigURL();
  638. String myStringUrl = "http://" + host + ":" + adminPort + configURL;
  639. System.out.println(myStringUrl);
  640. String query = "serverRoot=" + URLEncoder.encode(serverRoot);
  641. query += "&";
  642. query += "&cloneTokenPasswd=" + URLEncoder.encode(dbPassword);
  643. query += "&cloneTokenName=" + URLEncoder.encode("internal");
  644. query += "&cloningInstance=" + URLEncoder.encode(cloneInstanceId);
  645. query += "&cloneSameMachine=true";
  646. query += "&AdminUserPassword=" + URLEncoder.encode(adminPWD);
  647. query += "&certType=" + URLEncoder.encode(certType);
  648. query += "&instanceID=" + URLEncoder.encode(instanceID);
  649. query += "&opType=" + URLEncoder.encode("OP_MODIFY");
  650. query += "&taskID=" + URLEncoder.encode("taskCloning");
  651. query += "&cmsSeed=0";
  652. setPostQueryString(query);
  653. return Connect(myStringUrl);
  654. }
  655. private boolean setSerial(String start, String end) {
  656. System.out.println("configuring Cert Instance : setCASerial");
  657. setConfigURL();
  658. String myStringUrl = "http://" + host + ":" + adminPort + configURL;
  659. System.out.println(myStringUrl);
  660. String query = "serverRoot=" + URLEncoder.encode(serverRoot);
  661. query += "&";
  662. query += "instanceID=" + URLEncoder.encode(instanceID);
  663. query += "&db.password=" + URLEncoder.encode(dbPassword);
  664. query += "&caSerialNumber=" + URLEncoder.encode(start);
  665. query += "&caEndSerialNumber=" + URLEncoder.encode(end);
  666. query += "&opType=" + URLEncoder.encode("OP_MODIFY");
  667. query += "&taskID=" + URLEncoder.encode("setCASerial");
  668. query += "&cmsSeed=0";
  669. setPostQueryString(query);
  670. return Connect(myStringUrl);
  671. }
  672. private boolean setOCSP() {
  673. System.out.println("configuring Cert Instance : setOCSP");
  674. setConfigURL();
  675. String myStringUrl = "http://" + host + ":" + adminPort + configURL;
  676. System.out.println(myStringUrl);
  677. String query = "serverRoot=" + URLEncoder.encode(serverRoot);
  678. query += "&";
  679. query += "instanceID=" + URLEncoder.encode(instanceID);
  680. query += "&CAOCSPService=" + URLEncoder.encode("true");
  681. query += "&opType=" + URLEncoder.encode("OP_MODIFY");
  682. query += "&taskID=" + URLEncoder.encode("addOCSPService");
  683. query += "&cmsSeed=0";
  684. setPostQueryString(query);
  685. return Connect(myStringUrl);
  686. }
  687. private boolean networkConfig() {
  688. System.out.println("configuring Cert Instance : Network Config");
  689. setConfigURL();
  690. String myStringUrl = "http://" + host + ":" + adminPort + configURL;
  691. System.out.println(myStringUrl);
  692. String query = "AdminUserPassword=" + URLEncoder.encode(adminPWD);
  693. query += "&";
  694. query += "instanceID=" + URLEncoder.encode(instanceID);
  695. if (subsystems.equals("kra")) {
  696. query += "&agentGateway.https.port="
  697. + URLEncoder.encode(agentHttpsPort);
  698. query += "&radm.https.port=" + URLEncoder.encode(radminHttpsPort);
  699. query += "&eePortsEnable=" + URLEncoder.encode("false");
  700. } else {
  701. query += "&eeGateway.http.port=" + URLEncoder.encode(eeHttpPort);
  702. query += "&eeGateway.https.port=" + URLEncoder.encode(eeHttpsPort);
  703. query += "&agentGateway.https.port="
  704. + URLEncoder.encode(agentHttpsPort);
  705. query += "&radm.https.port=" + URLEncoder.encode(radminHttpsPort);
  706. query += "&eePortsEnable=" + URLEncoder.encode("true");
  707. query += "&eeGateway.http.enable=" + URLEncoder.encode("true");
  708. }
  709. query += "&opType=" + URLEncoder.encode("OP_MODIFY");
  710. query += "&taskID=" + URLEncoder.encode("configureNetwork");
  711. query += "&cmsSeed=0";
  712. setPostQueryString(query);
  713. return Connect(myStringUrl);
  714. }
  715. private boolean serverMigration() {
  716. System.out.println("configuring Cert Instance : Server migration");
  717. setConfigURL();
  718. String myStringUrl = "http://" + host + ":" + adminPort + configURL;
  719. System.out.println(myStringUrl);
  720. String query = "AdminUserPassword=" + URLEncoder.encode(adminPWD);
  721. query += "&";
  722. query += "instanceID=" + URLEncoder.encode(instanceID);
  723. query += "&migrationEnable=" + URLEncoder.encode("false");
  724. query += "&opType=" + URLEncoder.encode("OP_MODIFY");
  725. query += "&taskID=" + URLEncoder.encode("migration");
  726. query += "&cmsSeed=0";
  727. setPostQueryString(query);
  728. return Connect(myStringUrl);
  729. }
  730. private boolean initializePWD() {
  731. System.out.println("configuring Cert Instance : Initialize token");
  732. setConfigURL();
  733. String myStringUrl = "http://" + host + ":" + adminPort + configURL;
  734. System.out.println(myStringUrl);
  735. String query = "AdminUserPassword=" + URLEncoder.encode(adminPWD);
  736. query += "&";
  737. query += "instanceID=" + URLEncoder.encode(instanceID);
  738. query += "&serverRoot=" + URLEncoder.encode(serverRoot);
  739. query += "&tokenName=" + URLEncoder.encode(tokenName);
  740. query += "&tokenPasswd=" + URLEncoder.encode(tokenPWD);
  741. query += "&opType=" + URLEncoder.encode("OP_MODIFY");
  742. query += "&taskID=" + URLEncoder.encode("initToken");
  743. query += "&cmsSeed=0";
  744. setPostQueryString(query);
  745. return Connect(myStringUrl);
  746. }
  747. private boolean initializeToken() {
  748. System.out.println("configuring Cert Instance : Initialize token");
  749. setConfigURL();
  750. String myStringUrl = "http://" + host + ":" + adminPort + configURL;
  751. System.out.println(myStringUrl);
  752. String query = "AdminUserPassword=" + URLEncoder.encode(adminPWD);
  753. query += "&";
  754. query += "instanceID=" + URLEncoder.encode(instanceID);
  755. query += "&serverRoot=" + URLEncoder.encode(serverRoot);
  756. query += "&tokenName=" + URLEncoder.encode(tokenName);
  757. query += "&tokenPasswd=" + URLEncoder.encode(tokenPWD);
  758. query += "&certType=" + URLEncoder.encode(certType);
  759. query += "&keyType=" + URLEncoder.encode(keyType);
  760. query += "&keyLength=" + URLEncoder.encode(keyLength);
  761. query += "&sopPasswd=" + URLEncoder.encode(SingleSignOnPWD);
  762. query += "&opType=" + URLEncoder.encode("OP_MODIFY");
  763. query += "&taskID=" + URLEncoder.encode("initToken");
  764. query += "&cmsSeed=0";
  765. setPostQueryString(query);
  766. return Connect(myStringUrl);
  767. }
  768. private boolean keyLength() {
  769. System.out.println("configuring Cert Instance : Check Key length");
  770. setConfigURL();
  771. String myStringUrl = "http://" + host + ":" + adminPort + configURL;
  772. System.out.println(myStringUrl);
  773. String query = "AdminUserPassword=" + URLEncoder.encode(adminPWD);
  774. query += "&";
  775. query += "instanceID=" + URLEncoder.encode(instanceID);
  776. query += "&serverRoot=" + URLEncoder.encode(serverRoot);
  777. query += "&tokenName=" + URLEncoder.encode(tokenName);
  778. query += "&tokenPasswd=" + URLEncoder.encode(tokenPWD);
  779. query += "&certType=" + URLEncoder.encode(certType);
  780. query += "&keyType=" + URLEncoder.encode(keyType);
  781. query += "&keyLength=" + URLEncoder.encode(keyLength);
  782. query += "&sopPasswd=" + URLEncoder.encode(SingleSignOnPWD);
  783. query += "&opType=" + URLEncoder.encode("OP_MODIFY");
  784. query += "&taskID=" + URLEncoder.encode("checkKeyLength");
  785. query += "&cmsSeed=0";
  786. setPostQueryString(query);
  787. return Connect(myStringUrl);
  788. }
  789. private boolean checkDN() {
  790. System.out.println("configuring Cert Instance : Check DN");
  791. setConfigURL();
  792. String myStringUrl = "http://" + host + ":" + adminPort + configURL;
  793. System.out.println(myStringUrl);
  794. String query = "AdminUserPassword=" + URLEncoder.encode(adminPWD);
  795. query += "&";
  796. query += "instanceID=" + URLEncoder.encode(instanceID);
  797. query += "&certType=" + URLEncoder.encode(certType);
  798. query += "&subjectName=" + URLEncoder.encode(subjectName);
  799. query += "&opType=" + URLEncoder.encode("OP_MODIFY");
  800. query += "&taskID=" + URLEncoder.encode("checkDN");
  801. query += "&cmsSeed=0";
  802. setPostQueryString(query);
  803. return Connect(myStringUrl);
  804. }
  805. private String normalize(String s) {
  806. String val = "";
  807. for (int i = 0; i < s.length(); i++) {
  808. if ((s.charAt(i) == '\\') && (s.charAt(i + 1) == 'n')) {
  809. i++;
  810. continue;
  811. } else if ((s.charAt(i) == '\\') && (s.charAt(i + 1) == 'r')) {
  812. i++;
  813. continue;
  814. } else if (s.charAt(i) == '"') {
  815. continue;
  816. }
  817. val += s.charAt(i);
  818. }
  819. return val;
  820. }
  821. private String pkcs7Convertcert(String s) {
  822. String val = "";
  823. int len = s.length();
  824. for (int i = 0; i < len; i = i + 64) {
  825. if (i + 64 < len) {
  826. val = val + s.substring(i, i + 64) + "\n";
  827. } else {
  828. val = val + s.substring(i, len);
  829. }
  830. }
  831. return val;
  832. }
  833. private boolean certRequest(boolean trustM) {
  834. // This function prepares a Certificate Request.
  835. // Submits it to the CA
  836. // Approves the request.
  837. // And then installs it
  838. System.out.println("configuring Cert Instance : cert Request");
  839. setConfigURL();
  840. String myStringUrl = "http://" + host + ":" + adminPort + configURL;
  841. System.out.println(myStringUrl);
  842. String query = "AdminUserPassword=" + URLEncoder.encode(adminPWD);
  843. query += "&";
  844. query += "instanceID=" + URLEncoder.encode(instanceID);
  845. query += "&certType=" + URLEncoder.encode(certType);
  846. query += "&subjectName=" + URLEncoder.encode(subjectName);
  847. query += "&keyType=" + URLEncoder.encode(keyType);
  848. query += "&keyLength=" + URLEncoder.encode(keyLength);
  849. query += "&tokenName=" + URLEncoder.encode(CERTtokenName);
  850. if (subca) {
  851. query += "&sslCABit=true";
  852. query += "&objectSigningCABit=true";
  853. query += "&wirelessSupport=false";
  854. query += "&mailCABit=true";
  855. query += "&isCA=true";
  856. query += "&ski=true";
  857. query += "&aki=true";
  858. query += "&keyUsage=true";
  859. query += "&caSigningCertReqFormat=PKCS10";
  860. }
  861. if (subsystems.equals("ra")) {
  862. query += "&aki=" + URLEncoder.encode(aki);
  863. query += "&keyUsage=" + URLEncoder.encode("true");
  864. query += "&signing_cert=" + signingCert;
  865. }
  866. if (certType.equals("serverCert")) {
  867. query += "&sslServerBit=" + URLEncoder.encode("true");
  868. query += "&sslClientBit=" + URLEncoder.encode("true");
  869. query += "&serverCertReqFormat=PKCS10";
  870. } else {
  871. if (subsystems.equals("ra")) {
  872. query += "&sslClientBit=" + URLEncoder.encode("true");
  873. query += "&raSigningCertReqFormat=PKCS10";
  874. }
  875. if (subsystems.equals("ocsp")) {
  876. query += "&ocspSigningCertReqFormat=PKCS10";
  877. }
  878. if (subsystems.equals("kra")) {
  879. // added keyUsage
  880. query += "&keyUsage=" + URLEncoder.encode("true");
  881. // added URLEncoder
  882. query += "&aki=" + URLEncoder.encode(aki);
  883. query += "&kraTransportCertReqFormat=PKCS10";
  884. }
  885. }
  886. query += "&opType=" + URLEncoder.encode("OP_MODIFY");
  887. query += "&taskID=" + URLEncoder.encode("certRequest");
  888. query += "&caHostname=" + caHostname;
  889. query += "&caEEPort=" + caEEPort;
  890. query += "&cmsSeed=0";
  891. setPostQueryString(query);
  892. if (!Connect(myStringUrl)) {
  893. System.out.println("Error :certRequest");
  894. return false;
  895. }
  896. String res = spage.toString();
  897. certRequestStr = res.substring(
  898. res.indexOf("certReq: ") + "certReq: ".length(),
  899. res.indexOf("-----END NEW CERTIFICATE REQUEST-----"));
  900. certRequestStr += "-----END NEW CERTIFICATE REQUEST-----";
  901. int ReqId = 0;
  902. UserEnroll e = new UserEnroll(caHostname, caEEPort, subjectName, "test",
  903. "test", null, "test", "test", cdir, tokenpwd, ssl_clientcert,
  904. keyLength, keyType, null, null, signingCert);
  905. e.setpkcs10Request(certRequestStr);
  906. if (e.Enroll()) {
  907. ReqId = e.getRequestId();
  908. } else {
  909. System.out.println("Request was not successful");
  910. return false;
  911. }
  912. String trm;
  913. if (trustM) {
  914. trm = "true";
  915. } else {
  916. trm = "false";
  917. }
  918. Request r = new Request(caHostname, caAgentPortnum, CAadminId,
  919. CAadminPwd, CAcertnickname, cdir, tokenpwd, getString(ReqId),
  920. null, null, "approve", "enrollment", "showWaiting", null, trm);
  921. if (r.ApproveRequests(getString(ReqId)) <= -1) {
  922. System.out.println(
  923. "Error : Agent request approval was not successful");
  924. return false;
  925. }
  926. System.out.println("configuring Cert Instance : req Success");
  927. // Checking to see if request is approved.
  928. setConfigURL();
  929. myStringUrl = "http://" + host + ":" + adminPort + configURL;
  930. System.out.println(myStringUrl);
  931. query = "AdminUserPassword=" + URLEncoder.encode(adminPWD);
  932. query += "&";
  933. query += "instanceID=" + URLEncoder.encode(instanceID);
  934. query += "&certType=" + URLEncoder.encode(certType);
  935. if (certType.equals("serverCert")) {
  936. query += "&serverCertReqID=" + ReqId;
  937. } else {
  938. query += "&raSigningCertReqID=" + ReqId;
  939. }
  940. query += "&serverRoot=" + URLEncoder.encode(serverRoot);
  941. query += "&caEEPort=" + caEEPort;
  942. query += "&caHostname=" + host;
  943. query += "&caEEType=https";
  944. query += "&opType=" + URLEncoder.encode("OP_MODIFY");
  945. query += "&taskID=" + URLEncoder.encode("reqSuccess");
  946. query += "&cmsSeed=0";
  947. setPostQueryString(query);
  948. if (Connect(myStringUrl)) {
  949. checkRequest cr = new checkRequest(caHostname, caEEPort, cdir,
  950. tokenpwd, getString(ReqId), null, null);
  951. if (cr.checkRequestStatus()) {
  952. String cert = cr.getpkcs7ChainCert();
  953. String certtmp = pkcs7Convertcert(cert);
  954. certtmp = normalize(certtmp);
  955. cert = "-----BEGIN CERTIFICATE-----" + "\n" + certtmp + "\n"
  956. + "-----END CERTIFICATE-----\n";
  957. // install cert
  958. System.out.println(
  959. "configuring Cert Instance : install cert :" + cert);
  960. setConfigURL();
  961. myStringUrl = "http://" + host + ":" + adminPort + configURL;
  962. System.out.println(myStringUrl);
  963. query = "AdminUserPassword=" + URLEncoder.encode(adminPWD);
  964. query += "&";
  965. query += "instanceID=" + URLEncoder.encode(instanceID);
  966. query += "&certType=" + URLEncoder.encode(certType);
  967. query += "&db.password=" + URLEncoder.encode(dbPassword);
  968. if (certType.equals("raSigningCert")) {
  969. query += "&nickname="
  970. + URLEncoder.encode(certType + " " + instanceID);
  971. raSigningCert = "-----BEGIN CERTIFICATE-----" + "\n"
  972. + cr.getCert() + "\n"
  973. + "-----END CERTIFICATE-----\n";
  974. }
  975. if (certType.equals("kraTransportCert")) {
  976. ComCrypto cCrypto = new ComCrypto();
  977. kraTransportCert = cCrypto.normalize(cr.getCert());
  978. }
  979. if (certType.equals("serverCert")) {
  980. query += "&nickname="
  981. + URLEncoder.encode("Server-Cert" + " " + instanceID);
  982. }
  983. if (certType.equals("ocspSigningCert")) {
  984. query += "&nickname="
  985. + URLEncoder.encode(certType + " " + instanceID);
  986. }
  987. query += "&pkcs10=" + URLEncoder.encode(cert);
  988. query += "&opType=" + URLEncoder.encode("OP_MODIFY");
  989. query += "&taskID=" + URLEncoder.encode("installCert");
  990. query += "&cmsSeed=0";
  991. setPostQueryString(query);
  992. return(Connect(myStringUrl));
  993. }
  994. } else {
  995. System.out.println("Error: Request is not approved");
  996. return false;
  997. }
  998. return true;
  999. }
  1000. private String getString(int m) {
  1001. Integer x = new Integer(m);
  1002. String s = x.toString();
  1003. return s;
  1004. }
  1005. private boolean createCert() {
  1006. System.out.println("configuring Cert Instance : Create Cert");
  1007. // clauclate the validity dates for the cert.
  1008. GregorianCalendar begin = new GregorianCalendar();
  1009. GregorianCalendar end = new GregorianCalendar();
  1010. Integer days = new Integer(certValidityDays);
  1011. end.add(GregorianCalendar.DATE, days.intValue());
  1012. setConfigURL();
  1013. String myStringUrl = "http://" + host + ":" + adminPort + configURL;
  1014. System.out.println(myStringUrl);
  1015. String query = "AdminUserPassword=" + URLEncoder.encode(adminPWD);
  1016. query += "&";
  1017. query += "instanceID=" + URLEncoder.encode(instanceID);
  1018. query += "&serverRoot=" + URLEncoder.encode(serverRoot);
  1019. query += "&db.password=" + URLEncoder.encode(dbPassword);
  1020. query += "&subjectName=" + URLEncoder.encode(subjectName);
  1021. query += "&certType=" + URLEncoder.encode(certType);
  1022. query += "&beginYear="
  1023. + URLEncoder.encode(getString(begin.get(GregorianCalendar.YEAR)));
  1024. query += "&beginMonth="
  1025. + URLEncoder.encode(
  1026. getString(begin.get(GregorianCalendar.MONTH)));
  1027. query += "&beginDate="
  1028. + URLEncoder.encode(getString(begin.get(GregorianCalendar.DATE)));
  1029. query += "&beginHour="
  1030. + URLEncoder.encode(getString(begin.get(GregorianCalendar.HOUR)));
  1031. query += "&beginMin="
  1032. + URLEncoder.encode(
  1033. getString(begin.get(GregorianCalendar.MINUTE)));
  1034. query += "&beginSec="
  1035. + URLEncoder.encode(
  1036. getString(begin.get(GregorianCalendar.SECOND)));
  1037. query += "&afterYear="
  1038. + URLEncoder.encode(getString(end.get(GregorianCalendar.YEAR)));
  1039. query += "&afterMonth="
  1040. + URLEncoder.encode(getString(end.get(GregorianCalendar.MONTH)));
  1041. query += "&afterDate="
  1042. + URLEncoder.encode(getString(end.get(GregorianCalendar.DATE)));
  1043. query += "&afterHour="
  1044. + URLEncoder.encode(getString(end.get(GregorianCalendar.HOUR)));
  1045. query += "&afterMin="
  1046. + URLEncoder.encode(getString(end.get(GregorianCalendar.MINUTE)));
  1047. query += "&afterSec="
  1048. + URLEncoder.encode(getString(end.get(GregorianCalendar.SECOND)));
  1049. query += "&keyType=" + URLEncoder.encode(keyType);
  1050. query += "&keyLength=" + URLEncoder.encode(keyLength);
  1051. query += "&certLen=" + URLEncoder.encode("-1");
  1052. query += "&tokenName=" + URLEncoder.encode(CERTtokenName);
  1053. query += "&aki=" + URLEncoder.encode(aki);
  1054. query += "&keyUsage=" + URLEncoder.encode("true");
  1055. if (certType.equals("serverCert")) {
  1056. query += "&sslServerBit=" + URLEncoder.encode("true");
  1057. query += "&sslClientBit=" + URLEncoder.encode("true");
  1058. } else {
  1059. query += "&caOComponent=" + URLEncoder.encode(caOComponent);
  1060. query += "&caCComponent=" + URLEncoder.encode("us");
  1061. query += "&isCA=" + URLEncoder.encode(isCA);
  1062. query += "&ski=" + URLEncoder.encode(ski);
  1063. query += "&tokenPasswd=" + URLEncoder.encode(tokenPWD);
  1064. query += "&sslCABit=" + URLEncoder.encode(sslCABit);
  1065. query += "&mailCABit=" + URLEncoder.encode(mailCABit);
  1066. query += "&objectSigningCABit="
  1067. + URLEncoder.encode(objectSigningCABit);
  1068. }
  1069. query += "&hashType=" + URLEncoder.encode(hashType);
  1070. query += "&sopPasswd=" + URLEncoder.encode(SingleSignOnPWD);
  1071. query += "&wirelessSupport=" + URLEncoder.encode("false");
  1072. query += "&opType=" + URLEncoder.encode("OP_MODIFY");
  1073. query += "&taskID=" + URLEncoder.encode("createCert");
  1074. query += "&cmsSeed=0";
  1075. setPostQueryString(query);
  1076. return Connect(myStringUrl);
  1077. }
  1078. private boolean singleSignON() {
  1079. System.out.println("configuring Cert Instance : Single Signon");
  1080. setConfigURL();
  1081. String myStringUrl = "http://" + host + ":" + adminPort + configURL;
  1082. System.out.println(myStringUrl);
  1083. String PWTags = "Internal:Internal LDAP Database:singlesignon";
  1084. String query = "AdminUserPassword=" + URLEncoder.encode(adminPWD);
  1085. query += "&";
  1086. query += "instanceID=" + URLEncoder.encode(instanceID);
  1087. query += "&serverRoot=" + URLEncoder.encode(serverRoot);
  1088. // query += "&singleSignonPwd=" + URLEncoder.encode(SingleSignOnPWD);
  1089. query += "&singleSignonPWTags=" + URLEncoder.encode(PWTags);
  1090. query += "&Internal=" + URLEncoder.encode(tokenPWD);
  1091. query += "&Internal LDAP Database=" + URLEncoder.encode(dbPassword);
  1092. query += "&pwcTokenname=" + URLEncoder.encode("internal");
  1093. query += "&singlesignon=" + URLEncoder.encode(tokenPWD);
  1094. query += "&opType=" + URLEncoder.encode("OP_MODIFY");
  1095. query += "&taskID=" + URLEncoder.encode("singleSignon");
  1096. query += "&cmsSeed=0";
  1097. setPostQueryString(query);
  1098. return Connect(myStringUrl);
  1099. }
  1100. private boolean doMisc() {
  1101. System.out.println("configuring Cert Instance : do Miscell");
  1102. setConfigURL();
  1103. String myStringUrl = "http://" + host + ":" + adminPort + configURL;
  1104. System.out.println(myStringUrl);
  1105. String PWTags = "Internal:Internal LDAP Database:singlesignon";
  1106. String query = "AdminUserPassword=" + URLEncoder.encode(adminPWD);
  1107. query += "&";
  1108. query += "instanceID=" + URLEncoder.encode(instanceID);
  1109. query += "&serverRoot=" + URLEncoder.encode(serverRoot);
  1110. query += "&singleSignonPwd=" + URLEncoder.encode(SingleSignOnPWD);
  1111. query += "&singleSignonPWTags=" + URLEncoder.encode(PWTags);
  1112. query += "&Internal=" + URLEncoder.encode(tokenPWD);
  1113. query += "&Internal LDAP Database=" + URLEncoder.encode(dbPassword);
  1114. query += "&singlesignon=" + URLEncoder.encode(tokenPWD);
  1115. query += "&deletePasswdConf=false";
  1116. query += "&opType=" + URLEncoder.encode("OP_MODIFY");
  1117. query += "&taskID=" + URLEncoder.encode("doMiscStuffs");
  1118. query += "&cmsSeed=0";
  1119. setPostQueryString(query);
  1120. return Connect(myStringUrl);
  1121. }
  1122. private boolean exitDeamon() {
  1123. System.out.println("configuring Cert Instance : Exit Deamon");
  1124. setDeamonURL();
  1125. String myStringUrl = "http://" + host + ":" + adminPort + configURL;
  1126. System.out.println(myStringUrl);
  1127. String query = "AdminUserPassword=" + URLEncoder.encode(adminPWD);
  1128. query += "&";
  1129. query += "instanceID=" + URLEncoder.encode(instanceID);
  1130. query += "&serverRoot=" + URLEncoder.encode(serverRoot);
  1131. query += "&opType=" + URLEncoder.encode("OP_MODIFY");
  1132. query += "&taskID=" + URLEncoder.encode("exit");
  1133. query += "&cmsSeed=0";
  1134. setPostQueryString(query);
  1135. return Connect(myStringUrl);
  1136. }
  1137. private boolean ConfOCSP() {
  1138. // Step 1. Start Deamon
  1139. if (!startDeamon()) {
  1140. System.out.println(
  1141. "Configuring Cert Instance: Unable to start deamon");
  1142. return false;
  1143. }
  1144. // Sometimes it takes time to start deamon so wait for few seconds
  1145. try {
  1146. System.out.println("going to sleep for 10 seconds");
  1147. Thread.sleep(10000);
  1148. } catch (InterruptedException ie) {
  1149. System.out.println("sleep exection");
  1150. }
  1151. // Step 1a: Initialize Token ( Changed in 6.0)jjj
  1152. if (!initializePWD()) {
  1153. System.out.println(
  1154. "Configuring Cert Instance: error initializing pwd token");
  1155. return false;
  1156. }
  1157. // Step 2. Configure Internal DB
  1158. if (!configInternalDB()) {
  1159. System.out.println(
  1160. "Configuring Cert Instance: error configuring internal db");
  1161. return false;
  1162. }
  1163. // Step 3. Create Admin Values
  1164. if (!createAdminValu

Large files files are truncated, but you can click here to view the full file