From c166355c3f30fceed08b8e86e83241daa450fc56 Mon Sep 17 00:00:00 2001
From: Endi Sukma Dewata <edewata@redhat.com>
Date: Mon, 26 Mar 2012 21:43:20 -0500
Subject: [PATCH] Replaced deprecated DataInputStream.readLine().

The deprecated readLine() method in DataInputStream has been replaced
by the same method in BufferedReader.

Ticket #3
---
 .../cms/publish/publishers/OCSPPublisher.java      |   11 +++---
 .../src/com/netscape/pkisilent/ConfigureCA.java    |   24 +++++++-------
 .../com/netscape/pkisilent/common/Utilities.java   |   34 +++++++++----------
 3 files changed, 34 insertions(+), 35 deletions(-)

diff --git a/base/common/src/com/netscape/cms/publish/publishers/OCSPPublisher.java b/base/common/src/com/netscape/cms/publish/publishers/OCSPPublisher.java
index 600bbd11015dd155e494a6fc35a8f7aa5f8e6a59..f3e9d3c6f619fa8807816c7db50e00f20e9e2c51 100644
--- a/base/common/src/com/netscape/cms/publish/publishers/OCSPPublisher.java
+++ b/base/common/src/com/netscape/cms/publish/publishers/OCSPPublisher.java
@@ -17,8 +17,9 @@
 // --- END COPYRIGHT BLOCK ---
 package com.netscape.cms.publish.publishers;
 
-import java.io.DataInputStream;
+import java.io.BufferedReader;
 import java.io.IOException;
+import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.net.Socket;
@@ -44,7 +45,7 @@ import com.netscape.cmsutil.http.JssSSLSocketFactory;
 /**
  * This publisher writes certificate and CRL into
  * a directory.
- * 
+ *
  * @version $Revision$, $Date$
  */
 public class OCSPPublisher implements ILdapPublisher, IExtendedPluginInfo {
@@ -202,7 +203,7 @@ public class OCSPPublisher implements ILdapPublisher, IExtendedPluginInfo {
 
     /**
      * Publishs a object to the ldap directory.
-     * 
+     *
      * @param conn a Ldap connection
      *            (null if LDAP publishing is not enabled)
      * @param dn dn of the ldap entry to publish cert
@@ -299,7 +300,7 @@ public class OCSPPublisher implements ILdapPublisher, IExtendedPluginInfo {
             // Read the response
             mLogger.log(ILogger.EV_SYSTEM, ILogger.S_OTHER,
                     ILogger.LL_INFO, "OCSPPublisher: start getting response");
-            DataInputStream dis = new DataInputStream(socket.getInputStream());
+            BufferedReader dis = new BufferedReader(new InputStreamReader(socket.getInputStream()));
             String nextline;
             String error = "";
             boolean status = false;
@@ -340,7 +341,7 @@ public class OCSPPublisher implements ILdapPublisher, IExtendedPluginInfo {
 
     /**
      * Unpublishs a object to the ldap directory.
-     * 
+     *
      * @param conn the Ldap connection
      *            (null if LDAP publishing is not enabled)
      * @param dn dn of the ldap entry to unpublish cert
diff --git a/base/silent/src/com/netscape/pkisilent/ConfigureCA.java b/base/silent/src/com/netscape/pkisilent/ConfigureCA.java
index 3c498febe9c6a2182bef22cb84c9f6a996e82c3b..f8c90df38b0969dcf5d6ba7fd1b00d8a184d226e 100644
--- a/base/silent/src/com/netscape/pkisilent/ConfigureCA.java
+++ b/base/silent/src/com/netscape/pkisilent/ConfigureCA.java
@@ -21,7 +21,6 @@ package com.netscape.pkisilent;
 import java.io.BufferedInputStream;
 import java.io.BufferedReader;
 import java.io.ByteArrayInputStream;
-import java.io.DataInputStream;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.InputStreamReader;
@@ -33,13 +32,13 @@ import org.mozilla.jss.asn1.SEQUENCE;
 import org.mozilla.jss.pkcs12.AuthenticatedSafes;
 import org.mozilla.jss.pkcs12.PFX;
 
+import com.netscape.cmsutil.util.Utils;
 import com.netscape.pkisilent.argparser.ArgParser;
 import com.netscape.pkisilent.argparser.StringHolder;
 import com.netscape.pkisilent.common.ComCrypto;
 import com.netscape.pkisilent.common.ParseXML;
 import com.netscape.pkisilent.http.HTTPClient;
 import com.netscape.pkisilent.http.HTTPResponse;
-import com.netscape.cmsutil.util.Utils;
 
 public class ConfigureCA {
 
@@ -75,7 +74,7 @@ public class ConfigureCA {
     public static String sd_admin_name = null;
     public static String sd_admin_password = null;
 
-    // Login Panel 
+    // Login Panel
     public static String pin = null;
 
     public static String domain_name = null;
@@ -159,7 +158,7 @@ public class ConfigureCA {
     public static String ca_audit_signing_cert_pp = null;
     public static String ca_audit_signing_cert_cert = null;
 
-    // names 
+    // names
     public static String ca_sign_cert_subject_name = null;
     public static String ca_subsystem_cert_subject_name = null;
     public static String ca_ocsp_cert_subject_name = null;
@@ -666,17 +665,18 @@ public class ConfigureCA {
                     try {
                         ca_cert_cert = "";
                         FileInputStream fis = new FileInputStream(ext_ca_cert_file);
-                        DataInputStream in = new DataInputStream(fis);
-                        while (in.available() != 0) {
-                            ca_cert_cert += in.readLine();
+                        BufferedReader in = new BufferedReader(new InputStreamReader(fis));
+                        String line;
+                        while ((line = in.readLine()) != null) {
+                            ca_cert_cert += line;
                         }
                         in.close();
 
                         signing_cc = "";
                         fis = new FileInputStream(ext_ca_cert_chain_file);
-                        in = new DataInputStream(fis);
-                        while (in.available() != 0) {
-                            signing_cc += in.readLine();
+                        in = new BufferedReader(new InputStreamReader(fis));
+                        while ((line = in.readLine()) != null) {
+                            signing_cc += line;
                         }
                         in.close();
                         return true;
@@ -712,7 +712,7 @@ public class ConfigureCA {
                 }
             }
 
-            // print out subject names	
+            // print out subject names
             System.out.println("ca_cert_name=" + ca_sign_cert_subject_name);
             System.out.println("ocsp_cert_name=" + ca_ocsp_cert_subject_name);
             System.out.println(
@@ -1331,7 +1331,7 @@ public class ConfigureCA {
         StringHolder x_admin_email = new StringHolder();
         StringHolder x_admin_password = new StringHolder();
 
-        // ldap 
+        // ldap
         StringHolder x_ldap_host = new StringHolder();
         StringHolder x_ldap_port = new StringHolder();
         StringHolder x_bind_dn = new StringHolder();
diff --git a/base/silent/src/com/netscape/pkisilent/common/Utilities.java b/base/silent/src/com/netscape/pkisilent/common/Utilities.java
index 3e5d6fb4cf70df679a2186211ecc34b9e8baf477..22a0c3fcff3f1cdd3db91d74dab9eec01348a4c3 100644
--- a/base/silent/src/com/netscape/pkisilent/common/Utilities.java
+++ b/base/silent/src/com/netscape/pkisilent/common/Utilities.java
@@ -18,8 +18,9 @@ package com.netscape.pkisilent.common;
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-import java.io.DataInputStream;
+import java.io.BufferedReader;
 import java.io.FileInputStream;
+import java.io.InputStreamReader;
 
 import netscape.security.x509.CertificateSerialNumber;
 import netscape.security.x509.CertificateSubjectName;
@@ -165,10 +166,10 @@ public class Utilities {
 
         try {
             FileInputStream fis = new FileInputStream(filename);
-            DataInputStream in = new DataInputStream(fis);
+            BufferedReader in = new BufferedReader(new InputStreamReader(fis));
 
-            while (in.available() != 0) {
-                String temp = in.readLine();
+            String temp;
+            while ((temp = in.readLine()) != null) {
 
                 if (temp.equalsIgnoreCase("-----BEGIN CERTIFICATE-----")
                         || temp.equalsIgnoreCase("-----END CERTIFICATE-----")) {
@@ -190,11 +191,10 @@ public class Utilities {
 
         try {
             FileInputStream fis = new FileInputStream(filename);
-            DataInputStream in = new DataInputStream(fis);
-
-            while (in.available() != 0) {
-                String temp = in.readLine();
+            BufferedReader in = new BufferedReader(new InputStreamReader(fis));
 
+            String temp;
+            while ((temp = in.readLine()) != null) {
                 tempBuffer.append(temp);
             }
             return tempBuffer.toString();
@@ -216,11 +216,10 @@ public class Utilities {
 
         try {
             FileInputStream fis = new FileInputStream(filename);
-            DataInputStream in = new DataInputStream(fis);
-
-            while (in.available() != 0) {
-                String temp = in.readLine();
+            BufferedReader in = new BufferedReader(new InputStreamReader(fis));
 
+            String temp;
+            while ((temp = in.readLine()) != null) {
                 tempBuffer.append(temp);
             }
 
@@ -243,11 +242,10 @@ public class Utilities {
 
         try {
             FileInputStream fis = new FileInputStream(filename);
-            DataInputStream in = new DataInputStream(fis);
-
-            while (in.available() != 0) {
-                String temp = in.readLine();
+            BufferedReader in = new BufferedReader(new InputStreamReader(fis));
 
+            String temp;
+            while ((temp = in.readLine()) != null) {
                 tempBuffer.append(temp);
             }
 
@@ -267,7 +265,7 @@ public class Utilities {
         String result = "";
 
         for (int i = 0; i < data.length; i++) {
-            String s = Integer.toHexString((int) (0xff & data[i]));
+            String s = Integer.toHexString(0xff & data[i]);
 
             if (s.length() == 1) {
                 s = "0" + s;
@@ -314,7 +312,7 @@ public class Utilities {
                     certinfo.get(X509CertInfo.SERIAL_NUMBER);
             SerialNumber sn = (SerialNumber) csn.get("NUMBER");
 
-            // just adding serialnumber for add. 
+            // just adding serialnumber for add.
             // we can add mode here like subject name, extensions,issuer to this record.
             cr.serialNumber = sn.getNumber().toString().trim();
 
-- 
1.7.7.4

