diff options
Diffstat (limited to 'pki/base/silent/src/com/netscape/pkisilent/common/DirEnroll.java')
-rw-r--r-- | pki/base/silent/src/com/netscape/pkisilent/common/DirEnroll.java | 104 |
1 files changed, 55 insertions, 49 deletions
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 59820fe7a..ab52d7b49 100644 --- a/pki/base/silent/src/com/netscape/pkisilent/common/DirEnroll.java +++ b/pki/base/silent/src/com/netscape/pkisilent/common/DirEnroll.java @@ -1,4 +1,5 @@ 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 @@ -17,7 +18,6 @@ package com.netscape.pkisilent.common; // All rights reserved. // --- END COPYRIGHT BLOCK --- - import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.InputStreamReader; @@ -29,15 +29,13 @@ import java.util.GregorianCalendar; import org.mozilla.jss.ssl.SSLSocket; - - /** - * CMS Test framework - Legacyenrollment forms for Directory based enrollmnet and Portal based enrollment . - * Certificate issuance through Legacy Directory based enrollment and Portal based enrollment form. - *<P> + * CMS Test framework - Legacyenrollment forms for Directory based enrollmnet + * and Portal based enrollment . Certificate issuance through Legacy Directory + * based enrollment and Portal based enrollment form. + * <P> */ - public class DirEnroll extends TestClient { private int i; @@ -53,7 +51,8 @@ public class DirEnroll extends TestClient { /** * Constructor . Takes the parameter for Properties file name * <p> - * @param propfilename name of the parameter file + * + * @param propfilename name of the parameter file */ public DirEnroll(String pfile) { @@ -63,6 +62,7 @@ public class DirEnroll extends TestClient { /** * Constructor. Takes hostname , EESSLportnumber as parameter * <p> + * * @param hostname * @param portnumber */ @@ -73,8 +73,11 @@ public class DirEnroll extends TestClient { } /** - * Constructor. Takes hostname,EESSLportnumber,uid,password,certdbdirectorypath,certdbpassword,certificatenickname,keysize,teytype + * Constructor. Takes + * hostname,EESSLportnumber,uid,password,certdbdirectorypath + * ,certdbpassword,certificatenickname,keysize,teytype * <p> + * * @param hostname * @param portnumber * @param subjectdn @@ -82,8 +85,9 @@ public class DirEnroll extends TestClient { * @param adminpassword */ - - public DirEnroll(String hs, String p, String uid, String pw, String certdir, String certtokenpwd, String nickname, String ksz, String kt) { + public DirEnroll(String hs, String p, String uid, String pw, + String certdir, String certtokenpwd, String nickname, String ksz, + String kt) { host = hs; ports = p; @@ -96,18 +100,18 @@ public class DirEnroll extends TestClient { keytype = "RSA"; } - // Set and Get functions + // Set and Get functions /** - * Use this method to set User Info - */ + * Use this method to set User Info + */ public void setUIDInfo(String uid, String pw) { UID = uid; PWD = pw; } /** - * Returns a string "UserDir" / "Portal" + * Returns a string "UserDir" / "Portal" */ public String getAuthenticator() { @@ -115,26 +119,27 @@ public class DirEnroll extends TestClient { } /** - * Valid values for s - UserDir for Directory based Authntication - * Portal for Portal based Authentication + * Valid values for s - UserDir for Directory based Authntication Portal for + * Portal based Authentication */ - public void setAuthenticator(String s) { + public void setAuthenticator(String s) { Authenticator = s; } public boolean enroll_load() { buildquery(); - return(Send()); + return (Send()); } private boolean pkcs10() { - System.out.println(" In pkcs10 Keysize , key type " + keysize + keytype); + System.out.println(" In pkcs10 Keysize , key type " + keysize + + keytype); cCrypt.setCertDir(cdir); cCrypt.setCertnickname("cn=test"); cCrypt.setKeySize(keysize); cCrypt.setKeyType(keytype); cCrypt.setTokenPWD(tokenpwd); - + cCrypt.setDebug(debug); cCrypt.setGenerateRequest(true); if (!cCrypt.generateRequest()) { @@ -147,7 +152,7 @@ public class DirEnroll extends TestClient { buildquery(); System.out.println(query); setStatusString("Congratulations, your certificate has been issued."); - return(Send()); + return (Send()); } catch (Exception e) { System.err.println("some exception:" + e); } @@ -157,10 +162,11 @@ public class DirEnroll extends TestClient { } /** - * Enroll for certificate . Before calling this mentod SetAuthenticator and setUIDInfo + * Enroll for certificate . Before calling this mentod SetAuthenticator and + * setUIDInfo */ public boolean enroll() { - return(pkcs10()); + return (pkcs10()); } private boolean readProperties() { @@ -169,8 +175,8 @@ public class DirEnroll extends TestClient { try { getProperties(propfileName); } catch (Exception e) { - System.out.println( - "exception reading Properties File " + e.getMessage()); + System.out.println("exception reading Properties File " + + e.getMessage()); return false; } @@ -212,7 +218,7 @@ public class DirEnroll extends TestClient { return true; } - // Private functions + // Private functions private boolean importCert(String certpack) { @@ -226,8 +232,8 @@ public class DirEnroll extends TestClient { } if (debug) { - System.out.println( - "importing cert" + certpack + "certnick" + certnickname); + System.out.println("importing cert" + certpack + "certnick" + + certnickname); } cCrypt.importCert(certpack, certnickname); @@ -289,8 +295,8 @@ public class DirEnroll extends TestClient { ps.println("\r"); ps.flush(); os.flush(); - BufferedReader stdin = new BufferedReader( - new InputStreamReader(socket.getInputStream())); + BufferedReader stdin = new BufferedReader(new InputStreamReader( + socket.getInputStream())); if (debug) { System.out.println("Step 4: Received the page"); @@ -310,7 +316,7 @@ public class DirEnroll extends TestClient { } if (line.indexOf("record.base64Cert=") > -1) { - String baseCert = line; + String baseCert = line; System.out.println("BaseCert : " + baseCert); if (importcert.equals("true")) { @@ -319,7 +325,8 @@ public class DirEnroll extends TestClient { int n = strbase.length() + 1; baseCert = baseCert.substring(n); - String tmp = baseCert.substring(0, baseCert.length() - 2); + String tmp = baseCert.substring(0, + baseCert.length() - 2); if (importCert(tmp)) { impStatus = true; @@ -352,13 +359,13 @@ public class DirEnroll extends TestClient { } return st; - + } private void buildquery() { StringBuffer queryStrBuf = new StringBuffer(); - + queryStrBuf.append("certType=client"); queryStrBuf.append("&importCert=off"); queryStrBuf.append("&non_repudiation=true"); @@ -376,7 +383,7 @@ public class DirEnroll extends TestClient { queryStrBuf.append(URLEncoder.encode(UID)); queryStrBuf.append("&pwd="); queryStrBuf.append(URLEncoder.encode(PWD)); - queryStrBuf.append("&email=true"); + queryStrBuf.append("&email=true"); queryStrBuf.append("&cryptprovider=1"); } @@ -412,7 +419,7 @@ public class DirEnroll extends TestClient { queryStrBuf.append("&l="); queryStrBuf.append(URLEncoder.encode(L)); - queryStrBuf.append("&email=true"); + queryStrBuf.append("&email=true"); } @@ -423,7 +430,7 @@ public class DirEnroll extends TestClient { queryStrBuf.append(URLEncoder.encode(UID)); queryStrBuf.append("&pwd="); queryStrBuf.append(URLEncoder.encode(PWD)); - queryStrBuf.append("&email=true"); + queryStrBuf.append("&email=true"); } @@ -432,37 +439,36 @@ public class DirEnroll extends TestClient { query = queryStrBuf.toString(); System.out.println(query); - + } public static void main(String args[]) { // Exit Status - (0) for error/Fail // - requestId Pass boolean st; - + System.out.println(args.length); if (args.length < 1) { System.out.println("Usage : propertiesfile"); System.exit(0); - } + } DirEnroll t = new DirEnroll(args[0]); t.readProperties(); st = t.enroll(); - if (st) { - System.out.println( - t.getAuthenticator() + " based enrollment successfull. "); + if (st) { + System.out.println(t.getAuthenticator() + + " based enrollment successfull. "); System.exit(1); } else { - System.out.println( - t.getAuthenticator() - + " based enrollment was not successful." - + "Error: " + t.getErrorDetail()); + System.out.println(t.getAuthenticator() + + " based enrollment was not successful." + "Error: " + + t.getErrorDetail()); System.exit(0); } }// end of function main -} // end of class +} // end of class |