>From 752ea2d13a6624414821d56e900d0007a7489a6f Mon Sep 17 00:00:00 2001
From: Abhishek Koneru <akoneru@redhat.com>
Date: Thu, 19 Jul 2012 12:46:10 -0400
Subject: [PATCH] Patch 25 - Misc Fixes

---
 .../src/com/netscape/cmscore/base/SimpleProperties.java     |    2 +-
 .../src/com/netscape/cmscore/ldap/LdapPredicateParser.java  |    1 -
 .../com/netscape/cmscore/policy/PolicyPredicateParser.java  |    1 -
 .../src/com/netscape/cmscore/security/CASigningCert.java    |    3 +--
 .../src/com/netscape/cmscore/security/CertificateInfo.java  |    2 +-
 .../src/com/netscape/cmscore/security/OCSPSigningCert.java  |    3 +--
 base/kra/src/com/netscape/kra/StorageKeyUnit.java           |   11 ++++++++---
 base/util/src/netscape/security/pkcs/PKCS8Key.java          |    9 ++-------
 .../src/netscape/security/x509/CRLDistributionPoint.java    |   11 ++---------
 9 files changed, 16 insertions(+), 27 deletions(-)

diff --git a/base/common/src/com/netscape/cmscore/base/SimpleProperties.java b/base/common/src/com/netscape/cmscore/base/SimpleProperties.java
index 2fa319ffc1a2b505bf39b52ea6aa6ec3f0ee9ae6..38c17d861bcda9dd2cc48f70bdd4bc647a5754a8 100644
--- a/base/common/src/com/netscape/cmscore/base/SimpleProperties.java
+++ b/base/common/src/com/netscape/cmscore/base/SimpleProperties.java
@@ -347,7 +347,7 @@ public class SimpleProperties extends Hashtable<String, String> {
      * @return the value in this property list with the specified key value.
      * @see java.util.Properties#defaults
      */
-    public String getProperty(String key) {
+    public synchronized String getProperty(String key) {
         String oval = super.get(key);
 
         return ((oval == null) && (defaults != null)) ? defaults.getProperty(key) : oval;
diff --git a/base/common/src/com/netscape/cmscore/ldap/LdapPredicateParser.java b/base/common/src/com/netscape/cmscore/ldap/LdapPredicateParser.java
index 699877ffa776b415c234ca7a8ca1ac5247885c24..8d98f21b723f4c94ac72da9be2d401ae2f9d8e7f 100644
--- a/base/common/src/com/netscape/cmscore/ldap/LdapPredicateParser.java
+++ b/base/common/src/com/netscape/cmscore/ldap/LdapPredicateParser.java
@@ -260,7 +260,6 @@ public class LdapPredicateParser {
 class PredicateTokenizer {
     String input;
     int currentIndex;
-    int endOfString;
     String nextToken;
 
     public PredicateTokenizer(String predString) {
diff --git a/base/common/src/com/netscape/cmscore/policy/PolicyPredicateParser.java b/base/common/src/com/netscape/cmscore/policy/PolicyPredicateParser.java
index 8494178695f9f8e37ea5e8981dc024aa14ffd4b7..c55b84ecef51a333d82bbf531949357130a22f00 100644
--- a/base/common/src/com/netscape/cmscore/policy/PolicyPredicateParser.java
+++ b/base/common/src/com/netscape/cmscore/policy/PolicyPredicateParser.java
@@ -263,7 +263,6 @@ public class PolicyPredicateParser {
 class PredicateTokenizer {
     String input;
     int currentIndex;
-    int endOfString;
     String nextToken;
 
     public PredicateTokenizer(String predString) {
diff --git a/base/common/src/com/netscape/cmscore/security/CASigningCert.java b/base/common/src/com/netscape/cmscore/security/CASigningCert.java
index 8d35acf1b0aaee2672df6fab331b86e98059b99c..701ac4c185c4d767344cb27566c2080730c83d61 100644
--- a/base/common/src/com/netscape/cmscore/security/CASigningCert.java
+++ b/base/common/src/com/netscape/cmscore/security/CASigningCert.java
@@ -91,8 +91,7 @@ public class CASigningCert extends CertificateInfo {
     }
 
     // get PQG params from the configuration file
-    public static PQGParams getPQGParams() throws EBaseException, IOException,
-            PQGParamGenException {
+    public PQGParams getPQGParams() throws EBaseException, IOException, PQGParamGenException {
 
         byte[] p = mConfig.getByteArray("ca.dsaP", null);
         byte[] q = mConfig.getByteArray("ca.dsaQ", null);
diff --git a/base/common/src/com/netscape/cmscore/security/CertificateInfo.java b/base/common/src/com/netscape/cmscore/security/CertificateInfo.java
index c4d776934d0083645ac3deb25f541d6f0463fe35..58eb9ae634cfa66fd4614cbbd5d670aa86be69b9 100644
--- a/base/common/src/com/netscape/cmscore/security/CertificateInfo.java
+++ b/base/common/src/com/netscape/cmscore/security/CertificateInfo.java
@@ -70,7 +70,7 @@ public abstract class CertificateInfo {
 
     protected KeyCertData mProperties;
     protected KeyPair mKeyPair;
-    protected static IConfigStore mConfig;
+    protected IConfigStore mConfig;
 
     public CertificateInfo(KeyCertData properties) {
         this(properties, null);
diff --git a/base/common/src/com/netscape/cmscore/security/OCSPSigningCert.java b/base/common/src/com/netscape/cmscore/security/OCSPSigningCert.java
index 07ae9ee2f1b9fd4b3671ae5dd0ff9c279ecf8073..08cdd92e8a1b0a6c95afe972680e1aeb65c3f4b5 100644
--- a/base/common/src/com/netscape/cmscore/security/OCSPSigningCert.java
+++ b/base/common/src/com/netscape/cmscore/security/OCSPSigningCert.java
@@ -69,8 +69,7 @@ public class OCSPSigningCert extends CertificateInfo {
     }
 
     // get PQG params from the configuration file
-    public static PQGParams getPQGParams() throws EBaseException, IOException,
-            PQGParamGenException {
+    public PQGParams getPQGParams() throws EBaseException, IOException, PQGParamGenException {
 
         byte[] p = mConfig.getByteArray("ca.dsaP", null);
         byte[] q = mConfig.getByteArray("ca.dsaQ", null);
diff --git a/base/kra/src/com/netscape/kra/StorageKeyUnit.java b/base/kra/src/com/netscape/kra/StorageKeyUnit.java
index 6ef3d7d16dc7af876fa0913a7d939c2966656acb..1af207f9f3b5bf2aadf7036d20986b46987de91a 100644
--- a/base/kra/src/com/netscape/kra/StorageKeyUnit.java
+++ b/base/kra/src/com/netscape/kra/StorageKeyUnit.java
@@ -168,23 +168,28 @@ public class StorageKeyUnit extends EncryptionUnit implements
             if (mKeySplitting) {
 
                 byte certFileData[] = null;
+                FileInputStream fi = null;
                 try {
                     File certFile = new File(
                             mConfig.getString(PROP_CERTDB));
 
                     certFileData = new byte[
                             (Long.valueOf(certFile.length())).intValue()];
-                    FileInputStream fi = new FileInputStream(certFile);
+                    fi = new FileInputStream(certFile);
 
                     fi.read(certFileData);
-                    fi.close();
-
                     // pick up cert by nickName
 
                 } catch (IOException e) {
                     mKRA.log(ILogger.LL_INFO,
                             CMS.getLogMessage("CMSCORE_KRA_STORAGE_READ_CERT", e.toString()));
                     throw new EBaseException(CMS.getUserMessage("CMS_BASE_CERT_ERROR", e.toString()));
+                } finally {
+                    try {
+                        fi.close();
+                    } catch (IOException e) {
+                        e.printStackTrace();
+                    }
                 }
 
                 try {
diff --git a/base/util/src/netscape/security/pkcs/PKCS8Key.java b/base/util/src/netscape/security/pkcs/PKCS8Key.java
index db1d6b27523899b9c19c252593b9a5565d38f17a..8806cd3fb4bc12fcb6184ffc09ede1156743e59b 100644
--- a/base/util/src/netscape/security/pkcs/PKCS8Key.java
+++ b/base/util/src/netscape/security/pkcs/PKCS8Key.java
@@ -331,9 +331,7 @@ public class PKCS8Key implements PrivateKey {
      * Serialization write ... PKCS#8 keys serialize as
      * themselves, and they're parsed when they get read back.
      */
-    private synchronized void
-            writeObject(java.io.ObjectOutputStream stream)
-                    throws IOException {
+    private void writeObject(java.io.ObjectOutputStream stream) throws IOException {
         stream.write(getEncoded());
     }
 
@@ -341,12 +339,9 @@ public class PKCS8Key implements PrivateKey {
      * Serialization read ... PKCS#8 keys serialize as
      * themselves, and they're parsed when they get read back.
      */
-    private synchronized void readObject(ObjectInputStream stream)
-            throws IOException {
-
+    private void readObject(ObjectInputStream stream) throws IOException {
         try {
             decode(stream);
-
         } catch (InvalidKeyException e) {
             e.printStackTrace();
             throw new IOException("deserialized key is invalid: " +
diff --git a/base/util/src/netscape/security/x509/CRLDistributionPoint.java b/base/util/src/netscape/security/x509/CRLDistributionPoint.java
index 637ee57febe0f5af8bfe0a29c12c4f33b8169e2f..7c591aee5862f14c6e22bdc80d82f6d45c24d633 100644
--- a/base/util/src/netscape/security/x509/CRLDistributionPoint.java
+++ b/base/util/src/netscape/security/x509/CRLDistributionPoint.java
@@ -251,7 +251,7 @@ public class CRLDistributionPoint implements ASN1Value {
         return templateInstance;
     }
 
-    public static void main(String args[]) throws Exception {
+    public static void main(String args[]) throws GeneralNamesException, IOException, InvalidBERException {
         ByteArrayOutputStream bos = null;
         FileOutputStream fos = null;
         try {
@@ -337,9 +337,6 @@ public class CRLDistributionPoint implements ASN1Value {
             }
             System.out.println("Done");
 
-        } catch (Exception e) {
-            e.printStackTrace();
-            throw e;
         } finally {
             if (bos != null) {
                 bos.close();
@@ -348,11 +345,7 @@ public class CRLDistributionPoint implements ASN1Value {
                 fos.close();
             }
             if (fos != null) {
-                try {
-                    fos.close();
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
+                fos.close();
             }
         }
     }
-- 
1.7.10.2

