diff options
author | Ade Lee <alee@redhat.com> | 2011-12-08 21:15:59 -0500 |
---|---|---|
committer | Ade Lee <alee@redhat.com> | 2011-12-08 21:15:59 -0500 |
commit | 171aaece4f23709d33d180cf36eb3af5e454b0c9 (patch) | |
tree | 1485f9f0a7bd10de4ff25030db575dbb8dafae74 /pki/base/silent/src/com/netscape/pkisilent/common/Con2Agent.java | |
parent | adad2fcee8a29fdb82376fbce07dedb11fccc182 (diff) | |
download | pki-171aaece4f23709d33d180cf36eb3af5e454b0c9.tar.gz pki-171aaece4f23709d33d180cf36eb3af5e454b0c9.tar.xz pki-171aaece4f23709d33d180cf36eb3af5e454b0c9.zip |
Revert "Formatting"
This reverts commit 32150d3ee32f8ac27118af7c792794b538c78a2f.
Diffstat (limited to 'pki/base/silent/src/com/netscape/pkisilent/common/Con2Agent.java')
-rw-r--r-- | pki/base/silent/src/com/netscape/pkisilent/common/Con2Agent.java | 78 |
1 files changed, 36 insertions, 42 deletions
diff --git a/pki/base/silent/src/com/netscape/pkisilent/common/Con2Agent.java b/pki/base/silent/src/com/netscape/pkisilent/common/Con2Agent.java index 146a4d937..6be4daf49 100644 --- a/pki/base/silent/src/com/netscape/pkisilent/common/Con2Agent.java +++ b/pki/base/silent/src/com/netscape/pkisilent/common/Con2Agent.java @@ -1,5 +1,4 @@ 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 @@ -36,9 +35,10 @@ import org.mozilla.jss.ssl.SSLClientCertificateSelectionCallback; import org.mozilla.jss.ssl.SSLSocket; import org.mozilla.jss.util.Password; + /** - * CMS Test framework . Submits a requests to agent port with sslclient - * authentication. + * CMS Test framework . + * Submits a requests to agent port with sslclient authentication. */ public class Con2Agent implements SSLClientCertificateSelectionCallback, @@ -51,20 +51,18 @@ public class Con2Agent implements SSLClientCertificateSelectionCallback, private BufferedReader stdin = null; private StringBuffer stdout = new StringBuffer(); - public Con2Agent() { - } + public Con2Agent() {} /** - * Constructor. Takes hostname , portnumber , certificate nickname, token - * password ,client certdb directory - * - * @param hostname + *Constructor. Takes hostname , portnumber , certificate nickname, token password ,client certdb directory + * @param hostname * @param portnumber * @param agent cert nickname - * @param token password + * @param token password * @param certdb directory */ + public Con2Agent(String hs, int p, String cname, String tpwd, String cdir) { host = hs; port = p; @@ -73,8 +71,7 @@ public class Con2Agent implements SSLClientCertificateSelectionCallback, certdir = cdir; } - public boolean approve(X509Certificate x509, - SSLCertificateApprovalCallback.ValidityStatus status) { + public boolean approve(X509Certificate x509, SSLCertificateApprovalCallback.ValidityStatus status) { return true; } @@ -98,10 +95,10 @@ public class Con2Agent implements SSLClientCertificateSelectionCallback, } - // Get and Set methods + // Get and Set methods /* - * Get the page returned by the server + * Get the page returned by the server */ public StringBuffer getPage() { @@ -109,7 +106,7 @@ public class Con2Agent implements SSLClientCertificateSelectionCallback, } /* - * Set the query string to be submitted to the server + * Set the query string to be submitted to the server */ public void setQueryString(String qu) { @@ -117,7 +114,7 @@ public class Con2Agent implements SSLClientCertificateSelectionCallback, } /* - * Set token password + *Set token password */ public void setTokenPassword(String pwd) { @@ -141,7 +138,7 @@ public class Con2Agent implements SSLClientCertificateSelectionCallback, } /* - * set Agent port number + * set Agent port number */ public void setPort(int p) { @@ -149,7 +146,7 @@ public class Con2Agent implements SSLClientCertificateSelectionCallback, } /* - * Set Agent cert nickname + * Set Agent cert nickname */ public void setCertNickName(String cname) { @@ -157,21 +154,21 @@ public class Con2Agent implements SSLClientCertificateSelectionCallback, } /* - * Set action URL + * Set action URL */ public void setActionURL(String url) { ACTIONURL = url; } - // Submit requests + // Submit requests public boolean Send() { boolean st = false; try { - if (!loginCertDB()) { + if (!loginCertDB()) { return false; } @@ -179,8 +176,7 @@ public class Con2Agent implements SSLClientCertificateSelectionCallback, System.out.println("Con2Agent.java: host = " + host); System.out.println("Con2Agent.java: port = " + port); - System.out - .println("Con2Agent.java: certnickname = " + certnickname); + System.out.println("Con2Agent.java: certnickname = " + certnickname); socket.setClientCertNickname(certnickname); System.out.println("Connected to the socket"); @@ -188,7 +184,7 @@ public class Con2Agent implements SSLClientCertificateSelectionCallback, OutputStream rawos = socket.getOutputStream(); BufferedOutputStream os = new BufferedOutputStream(rawos); PrintStream ps = new PrintStream(os); - + System.out.println(ACTIONURL); System.out.println("Query :" + query); ps.println("POST " + ACTIONURL + " HTTP/1.0"); @@ -200,8 +196,8 @@ public class Con2Agent implements SSLClientCertificateSelectionCallback, ps.println("\r"); ps.flush(); os.flush(); - BufferedReader stdin1 = new BufferedReader(new InputStreamReader( - socket.getInputStream())); + BufferedReader stdin1 = new BufferedReader( + new InputStreamReader(socket.getInputStream())); String line; while ((line = stdin1.readLine()) != null) { @@ -209,9 +205,8 @@ public class Con2Agent implements SSLClientCertificateSelectionCallback, System.out.println(line); } - // Send Connection: close to let the server close the connection. - // Else the socket on the server side continues to remain in - // TIME_WAIT state + // Send Connection: close to let the server close the connection. + // Else the socket on the server side continues to remain in TIME_WAIT state ps.println("Connection: close"); ps.flush(); @@ -244,13 +239,12 @@ public class Con2Agent implements SSLClientCertificateSelectionCallback, try { System.out.println("Step 1: Initializing CryptoManager"); CryptoManager.initialize(certdir); - - System.out.println("Step 2: Login to Cert Database"); + + System.out.println("Step 2: Login to Cert Database"); manager = CryptoManager.getInstance(); - CryptoToken token = (PK11Token) manager - .getInternalKeyStorageToken(); + CryptoToken token = (PK11Token) manager.getInternalKeyStorageToken(); - if (token.isLoggedIn()) { + if (token.isLoggedIn()) { System.out.println("Con2Agent: Logged in incorrect"); } @@ -262,12 +256,12 @@ public class Con2Agent implements SSLClientCertificateSelectionCallback, pass1 = new Password((char[]) passchar1.clone()); token.login(pass1); - X509Certificate cert2 = manager.findCertByNickname(certnickname); + X509Certificate cert2 = manager.findCertByNickname(certnickname); certname = cert2.getNickname(); return true; - } catch (AlreadyInitializedException e) { + } catch (AlreadyInitializedException e) { System.out.println("Crypto manager already initialized"); return true; } catch (NumberFormatException e) { @@ -282,7 +276,7 @@ public class Con2Agent implements SSLClientCertificateSelectionCallback, e.printStackTrace(); return false; } - + } public boolean Send_withGET() { @@ -291,7 +285,7 @@ public class Con2Agent implements SSLClientCertificateSelectionCallback, try { - if (!loginCertDB()) { + if (!loginCertDB()) { return false; } @@ -303,7 +297,7 @@ public class Con2Agent implements SSLClientCertificateSelectionCallback, OutputStream rawos = socket.getOutputStream(); BufferedOutputStream os = new BufferedOutputStream(rawos); PrintStream ps = new PrintStream(os); - + System.out.println("Query in con2agent :" + query); System.out.println("ACTIONURL in con2agent : " + ACTIONURL); @@ -312,8 +306,8 @@ public class Con2Agent implements SSLClientCertificateSelectionCallback, ps.println("\r"); ps.flush(); os.flush(); - BufferedReader stdin2 = new BufferedReader(new InputStreamReader( - socket.getInputStream())); + BufferedReader stdin2 = new BufferedReader( + new InputStreamReader(socket.getInputStream())); String line; while ((line = stdin2.readLine()) != null) { @@ -332,4 +326,4 @@ public class Con2Agent implements SSLClientCertificateSelectionCallback, } -} // end of class +} // end of class |