From 018467598ec9d771daacae70b5397ad568b2ca80 Mon Sep 17 00:00:00 2001 From: Endi Sukma Dewata Date: Mon, 26 Mar 2012 21:43:20 -0500 Subject: Replaced deprecated DataInputStream.readLine(). The deprecated readLine() method in DataInputStream has been replaced by the same method in BufferedReader. Ticket #3 --- .../src/com/netscape/pkisilent/ConfigureCA.java | 24 +++++++-------- .../com/netscape/pkisilent/common/Utilities.java | 34 ++++++++++------------ 2 files changed, 28 insertions(+), 30 deletions(-) (limited to 'base/silent') diff --git a/base/silent/src/com/netscape/pkisilent/ConfigureCA.java b/base/silent/src/com/netscape/pkisilent/ConfigureCA.java index 3c498febe..f8c90df38 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 3e5d6fb4c..22a0c3fcf 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(); -- cgit