>From f9c47759be2ebf1bd87f0c9e9e8af5688ff79306 Mon Sep 17 00:00:00 2001
From: Abhishek Koneru <akoneru@redhat.com>
Date: Wed, 13 Jun 2012 11:43:19 -0400
Subject: [PATCH] Fixes for Review Comments

---
 .classpath                                         |    2 +-
 .../certsrv/authentication/IAuthToken.java         |    2 +-
 .../src/com/netscape/certsrv/request/IService.java |    3 --
 .../com/netscape/cms/authentication/CMCAuth.java   |    2 +-
 .../servlet/cert/ChallengeRevocationServlet1.java  |    2 +-
 .../src/com/netscape/cmscore/dbs/DBSubsystem.java  |    2 +-
 .../certsrv/authentication/AuthTokenTest.java      |    2 +-
 base/kra/src/com/netscape/kra/RecoveryService.java |    4 +--
 .../src/com/netscape/pkisilent/common/CMSLDAP.java |    2 +-
 .../com/netscape/pkisilent/http/HTTPClient.java    |   34 +++++++-------------
 .../src/netscape/security/util/DerInputStream.java |    2 +-
 11 files changed, 20 insertions(+), 37 deletions(-)

diff --git a/.classpath b/.classpath
index 7d84d45c3f3e6f469b65ad37874dc0ddbcf6521d..c34b7f4c054659b6ea28e3b91d05456771ccb162 100644
--- a/.classpath
+++ b/.classpath
@@ -41,7 +41,7 @@
 	<classpathentry kind="lib" path="/usr/share/java/xml-commons-apis.jar"/>
 	<classpathentry kind="lib" path="/usr/share/tomcat6/lib/catalina.jar"/>
 	<classpathentry kind="lib" path="/usr/share/java/istack-commons-runtime.jar"/>
-	<classpathentry kind="lib" path="/usr/share/java/jss4.jar"/>
+	<classpathentry kind="lib" path="/usr/share/java/jss/jss4.jar"/>
 	<classpathentry kind="lib" path="/usr/share/java/apache-commons-lang.jar"/>
 	<classpathentry kind="lib" path="/usr/share/java/resteasy/resteasy-atom-provider.jar"/>
 	<classpathentry kind="output" path="build/classes"/>
diff --git a/base/common/src/com/netscape/certsrv/authentication/IAuthToken.java b/base/common/src/com/netscape/certsrv/authentication/IAuthToken.java
index e2044494e85e7c8529c20e3c5c34d3f93a99d5fa..e469f378659974f537af4b0fd5d16e136810fd42 100644
--- a/base/common/src/com/netscape/certsrv/authentication/IAuthToken.java
+++ b/base/common/src/com/netscape/certsrv/authentication/IAuthToken.java
@@ -215,7 +215,7 @@ public interface IAuthToken {
      * Retrieves the byte[][] value for name.
      *
      * @param name The attribute name.
-     * @return The value or null on error.
+     * @return The value.
      * @throws IOException
      */
     public byte[][] getInByteArrayArray(String name) throws IOException;
diff --git a/base/common/src/com/netscape/certsrv/request/IService.java b/base/common/src/com/netscape/certsrv/request/IService.java
index af77210b2b1cdb40d8627df481696c2f1f4270cc..0756be8932f046e0919a31b98754f50409299798 100644
--- a/base/common/src/com/netscape/certsrv/request/IService.java
+++ b/base/common/src/com/netscape/certsrv/request/IService.java
@@ -17,8 +17,6 @@
 // --- END COPYRIGHT BLOCK ---
 package com.netscape.certsrv.request;
 
-import java.security.cert.CertificateException;
-
 import com.netscape.certsrv.base.EBaseException;
 
 /**
@@ -44,7 +42,6 @@ public interface IService {
      *         an indication of whether this request is still pending.
      *         'false' means the request will wait for further notification.
      * @exception EBaseException indicates major processing failure.
-     * @throws CertificateException
      */
     boolean serviceRequest(IRequest request)
             throws EBaseException;
diff --git a/base/common/src/com/netscape/cms/authentication/CMCAuth.java b/base/common/src/com/netscape/cms/authentication/CMCAuth.java
index 865b8e24bea76f0a0323d0a5125102f68aeeda58..2844601f40da807f6ee636be29708a72016e415a 100644
--- a/base/common/src/com/netscape/cms/authentication/CMCAuth.java
+++ b/base/common/src/com/netscape/cms/authentication/CMCAuth.java
@@ -904,7 +904,7 @@ public class CMCAuth implements IAuthManager, IExtendedPluginInfo,
             CMS.debug("CMCAuth: " + e.toString());
         } catch (IOException e) {
             CMS.debug("CMCAuth: " + e.toString());
-        }catch (Exception e) {
+        } catch (Exception e) {
             throw new EInvalidCredentials(CMS.getUserMessage("CMS_AUTHENTICATION_INVALID_CREDENTIAL"));
         }
         return null;
diff --git a/base/common/src/com/netscape/cms/servlet/cert/ChallengeRevocationServlet1.java b/base/common/src/com/netscape/cms/servlet/cert/ChallengeRevocationServlet1.java
index e3680fd6b8991321f61a6085cb36e389bc666d82..0b59fdc97ef81312f5f63f6dc3ac1aa5f4e4b7ea 100644
--- a/base/common/src/com/netscape/cms/servlet/cert/ChallengeRevocationServlet1.java
+++ b/base/common/src/com/netscape/cms/servlet/cert/ChallengeRevocationServlet1.java
@@ -132,7 +132,7 @@ public class ChallengeRevocationServlet1 extends CMSServlet {
      * </ul>
      *
      * @param cmsReq the object holding the request and response information
-     * @throws IOException
+     * @throws EBaseException
      */
     protected void process(CMSRequest cmsReq) throws EBaseException {
         IArgBlock httpParams = cmsReq.getHttpParams();
diff --git a/base/common/src/com/netscape/cmscore/dbs/DBSubsystem.java b/base/common/src/com/netscape/cmscore/dbs/DBSubsystem.java
index ecab3c9bc570f1b7ac7c503ed542e3b28c9e6414..c0bb627c225c2eba55590f435c3ca0f264e97fb4 100644
--- a/base/common/src/com/netscape/cmscore/dbs/DBSubsystem.java
+++ b/base/common/src/com/netscape/cmscore/dbs/DBSubsystem.java
@@ -409,7 +409,7 @@ public class DBSubsystem implements IDBSubsystem {
             LDAPEntry entry = conn.read(dn);
             LDAPAttribute attr = entry.getAttribute(PROP_NEXT_RANGE);
             if (attr == null) {
-                throw new Exception("Missing Attribute PROP_NEXT_RANGE in Entry " + dn);
+                throw new Exception("Missing Attribute" + PROP_NEXT_RANGE + "in Entry " + dn);
             }
             nextRange = (String) attr.getStringValues().nextElement();
 
diff --git a/base/common/test/com/netscape/certsrv/authentication/AuthTokenTest.java b/base/common/test/com/netscape/certsrv/authentication/AuthTokenTest.java
index a5b5c4737f30d0f98603a166378163baeb99bf1b..370973f0a9912f70b7736f4b6e284cdbd1bdd569 100644
--- a/base/common/test/com/netscape/certsrv/authentication/AuthTokenTest.java
+++ b/base/common/test/com/netscape/certsrv/authentication/AuthTokenTest.java
@@ -141,7 +141,7 @@ public class AuthTokenTest extends CMSBaseTestCase {
         assertFalse(cmsStub.aToBCalled);
         String[] retval = authToken.getInStringArray("key");
         if (retval == null) {
-            throw new IOException();
+            throw new IOException("Unable to get key as String Array");
         }
         assertTrue(cmsStub.aToBCalled);
         assertEquals(4, retval.length);
diff --git a/base/kra/src/com/netscape/kra/RecoveryService.java b/base/kra/src/com/netscape/kra/RecoveryService.java
index 4664f17b2d0a60f8cf518ac49a0c7256b257f0bb..19d6b515798c714a62a37a0342724d855080ffb4 100644
--- a/base/kra/src/com/netscape/kra/RecoveryService.java
+++ b/base/kra/src/com/netscape/kra/RecoveryService.java
@@ -25,7 +25,6 @@ import java.security.NoSuchAlgorithmException;
 import java.security.PublicKey;
 import java.security.SecureRandom;
 import java.security.cert.CertificateEncodingException;
-import java.security.cert.CertificateException;
 import java.security.cert.X509Certificate;
 import java.util.Hashtable;
 import java.util.Random;
@@ -129,7 +128,6 @@ public class RecoveryService implements IService {
      * @param request recovery request
      * @return operation success or not
      * @exception EBaseException failed to serve
-     * @throws CertificateException
      */
     public boolean serviceRequest(IRequest request) throws EBaseException {
 
@@ -197,7 +195,7 @@ public class RecoveryService implements IService {
         X509Certificate x509cert =
                 request.getExtDataInCert(ATTR_USER_CERT);
         if (x509cert == null) {
-            throw new EKRAException(CMS.getLogMessage("CMS_KRA_INVALID_KEYRECORD"));
+            throw new EKRAException(CMS.getUserMessage("CMS_KRA_INVALID_KEYRECORD"));
         }
         byte inputPubData[] = x509cert.getPublicKey().getEncoded();
 
diff --git a/base/silent/src/com/netscape/pkisilent/common/CMSLDAP.java b/base/silent/src/com/netscape/pkisilent/common/CMSLDAP.java
index 528e48092b46d20d74fc5da12f145da62b29a64e..80613525dda195518b3e70141398a2ab5f500ecc 100644
--- a/base/silent/src/com/netscape/pkisilent/common/CMSLDAP.java
+++ b/base/silent/src/com/netscape/pkisilent/common/CMSLDAP.java
@@ -209,7 +209,7 @@ public class CMSLDAP {
             return the_cert;
         } catch (Exception e) {
             System.out.println("ERROR: getXCertificate " + e.toString());
-            throw new Exception(e.toString());
+            throw e;
         }
 
     }
diff --git a/base/silent/src/com/netscape/pkisilent/http/HTTPClient.java b/base/silent/src/com/netscape/pkisilent/http/HTTPClient.java
index 6398fdcddbe0fd529f2044aeab12bd812b1f003c..80335c61f9629f9d239ce1ac1a4e6c9beab7cc8e 100644
--- a/base/silent/src/com/netscape/pkisilent/http/HTTPClient.java
+++ b/base/silent/src/com/netscape/pkisilent/http/HTTPClient.java
@@ -375,7 +375,7 @@ public class HTTPClient implements SSLCertificateApprovalCallback {
                                 String url, String query) throws Exception {
 
         HTTPResponse hr = null;
-
+        PrintStream ps = null;
         try {
 
             System.out.println("#############################################");
@@ -395,7 +395,7 @@ public class HTTPClient implements SSLCertificateApprovalCallback {
 
             OutputStream rawos = socket.getOutputStream();
             BufferedOutputStream os = new BufferedOutputStream(rawos);
-            PrintStream ps = new PrintStream(os);
+            ps = new PrintStream(os);
 
             System.out.println("Connected.");
 
@@ -421,29 +421,18 @@ public class HTTPClient implements SSLCertificateApprovalCallback {
             ps.flush();
             os.flush();
 
-            try {
                 hr = readResponse(socket.getInputStream());
                 hr.parseContent();
 
-            } catch (Exception e) {
-                System.out.println("Exception");
-                e.printStackTrace();
-                throw e;
-            } finally {
-                socket.close();
-                os.close();
-                rawos.close();
+        } catch (Exception e) {
+            System.err.println("Exception: Unable to Send Request:" + e);
+            e.printStackTrace();
+            throw e;
+        } finally {
+            if (ps != null) {
                 ps.close();
-
-                os = null;
-                rawos = null;
                 ps = null;
             }
-
-        } catch (Exception e) {
-            System.err.println("Exception: Unable to Send Request:" + e);
-            e.printStackTrace();
-            throw e;
         }
 
         return hr;
@@ -1183,8 +1172,8 @@ public class HTTPClient implements SSLCertificateApprovalCallback {
                 // ssl client auth call
 
                 hr = hc.sslConnectClientAuth(cs_hostname, cs_port,
-                                        client_cert_nickname,
-                                        uri, query);
+                        client_cert_nickname,
+                        uri, query);
             }
 
             else {
@@ -1193,8 +1182,7 @@ public class HTTPClient implements SSLCertificateApprovalCallback {
             }
         } else if (ssl != null && ssl.equalsIgnoreCase("false")) {
             // non ssl connect
-                hr = hc.nonsslConnect(cs_hostname, cs_port, uri, query);
-
+            hr = hc.nonsslConnect(cs_hostname, cs_port, uri, query);
         } else {
             System.out.println("ERROR: ssl parameter is null");
             System.exit(-1);
diff --git a/base/util/src/netscape/security/util/DerInputStream.java b/base/util/src/netscape/security/util/DerInputStream.java
index 95bd73364768242af6410969df519ed03868669d..ff1c54ba234e8a2a1bd8607a591f50eb1e9f84f1 100644
--- a/base/util/src/netscape/security/util/DerInputStream.java
+++ b/base/util/src/netscape/security/util/DerInputStream.java
@@ -112,7 +112,7 @@ public class DerInputStream {
     /**
      * Return what has been written to this DerInputStream
      * as a byte array. Useful for debugging.
-     * @throws Exception
+     * @throws IOException
      */
     public byte[] toByteArray() throws IOException {
         return buffer.toByteArray();
-- 
1.7.10.2

