diff options
author | Ade Lee <alee@redhat.com> | 2011-12-07 16:58:12 -0500 |
---|---|---|
committer | Ade Lee <alee@redhat.com> | 2011-12-07 16:58:12 -0500 |
commit | 32150d3ee32f8ac27118af7c792794b538c78a2f (patch) | |
tree | 52dd96f664a6fa51be25b28b6f10adc5f2c9f660 /pki/base/silent/src/com/netscape/pkisilent/common/Con2Agent.java | |
parent | f05d58a46795553beb8881039cc922974b40db34 (diff) | |
download | pki-32150d3ee32f8ac27118af7c792794b538c78a2f.tar.gz pki-32150d3ee32f8ac27118af7c792794b538c78a2f.tar.xz pki-32150d3ee32f8ac27118af7c792794b538c78a2f.zip |
Formatting
Formatted project according to eclipse project settings
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, 42 insertions, 36 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 6be4daf49..146a4d937 100644 --- a/pki/base/silent/src/com/netscape/pkisilent/common/Con2Agent.java +++ b/pki/base/silent/src/com/netscape/pkisilent/common/Con2Agent.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 @@ -35,10 +36,9 @@ 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,18 +51,20 @@ 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; @@ -71,7 +73,8 @@ 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; } @@ -95,10 +98,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() { @@ -106,7 +109,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) { @@ -114,7 +117,7 @@ public class Con2Agent implements SSLClientCertificateSelectionCallback, } /* - *Set token password + * Set token password */ public void setTokenPassword(String pwd) { @@ -138,7 +141,7 @@ public class Con2Agent implements SSLClientCertificateSelectionCallback, } /* - * set Agent port number + * set Agent port number */ public void setPort(int p) { @@ -146,7 +149,7 @@ public class Con2Agent implements SSLClientCertificateSelectionCallback, } /* - * Set Agent cert nickname + * Set Agent cert nickname */ public void setCertNickName(String cname) { @@ -154,21 +157,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; } @@ -176,7 +179,8 @@ 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"); @@ -184,7 +188,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"); @@ -196,8 +200,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) { @@ -205,8 +209,9 @@ 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(); @@ -239,12 +244,13 @@ 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"); } @@ -256,12 +262,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) { @@ -276,7 +282,7 @@ public class Con2Agent implements SSLClientCertificateSelectionCallback, e.printStackTrace(); return false; } - + } public boolean Send_withGET() { @@ -285,7 +291,7 @@ public class Con2Agent implements SSLClientCertificateSelectionCallback, try { - if (!loginCertDB()) { + if (!loginCertDB()) { return false; } @@ -297,7 +303,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); @@ -306,8 +312,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) { @@ -326,4 +332,4 @@ public class Con2Agent implements SSLClientCertificateSelectionCallback, } -} // end of class +} // end of class |