From 7c7b9d023cd466c1771068badc020dab36beb553 Mon Sep 17 00:00:00 2001 From: Endi Sukma Dewata Date: Thu, 5 Apr 2012 14:49:11 -0500 Subject: Removed whitespaces from Java code. Whitespaces in Java code have been removed with the following command: find . -not -path .git -name *.java -exec sed -i 's/[[:blank:]]\+$//' {} \; Ticket #134 --- base/migrate/41ToTxt/src/Main.java | 132 ++++++++++++++++++------------------- 1 file changed, 66 insertions(+), 66 deletions(-) (limited to 'base/migrate/41ToTxt') diff --git a/base/migrate/41ToTxt/src/Main.java b/base/migrate/41ToTxt/src/Main.java index 758d725a9..4a15ec7af 100644 --- a/base/migrate/41ToTxt/src/Main.java +++ b/base/migrate/41ToTxt/src/Main.java @@ -34,7 +34,7 @@ import netscape.security.util.*; public class Main { - public static void main(String args[]) + public static void main(String args[]) { try { // initialize CryptoManager in CMS 4.1/4.2/4.2 (SP 2) @@ -43,15 +43,15 @@ public class Main java.security.Security.removeProvider("Netscape version 1.4"); java.security.Security.removeProvider("SunRsaSign version 1.0"); // java.security.Security.insertProviderAt( -// new netscape.security.provider.CMS(), 0); - java.security.Provider ps[] = +// new netscape.security.provider.CMS(), 0); + java.security.Provider ps[] = java.security.Security.getProviders(); - if (ps == null || ps.length <= 0) { - System.err.println("Java Security Provider NONE"); - } else { - for (int x = 0; x < ps.length; x++) { - System.err.println("Java Security Provider " + x + " class=" + ps[x]); - } + if (ps == null || ps.length <= 0) { + System.err.println("Java Security Provider NONE"); + } else { + for (int x = 0; x < ps.length; x++) { + System.err.println("Java Security Provider " + x + " class=" + ps[x]); + } } // Parse the File @@ -74,14 +74,14 @@ public class Main class CMS41LdifParser { // constants - private static final String DN = + private static final String DN = "dn:"; // Directory Servers in CMS 4.1/4.2/4.2 (SP 2)/4.5 use "requestattributes" - private static final String REQUEST_ATTRIBUTES = + private static final String REQUEST_ATTRIBUTES = "requestattributes::"; - private static final String BEGIN = + private static final String BEGIN = "--- BEGIN ATTRIBUTES ---"; - private static final String END = + private static final String END = "--- END ATTRIBUTES ---"; // variables @@ -101,16 +101,16 @@ class CMS41LdifParser } public void parse() throws Exception - { + { if (mErrorFilename != null) { mErrorPrintWriter = new PrintWriter(new FileOutputStream(mErrorFilename)); } BufferedReader reader = new BufferedReader( - new FileReader(mFilename)); - String line = null; - String dn = null; + new FileReader(mFilename)); + String line = null; + String dn = null; StringBuffer requestAttributes = null; - while ((line = reader.readLine()) != null) { + while ((line = reader.readLine()) != null) { if (line.startsWith(DN)) { dn = line; } @@ -118,7 +118,7 @@ class CMS41LdifParser requestAttributes = new StringBuffer(); // System.out.println(line); requestAttributes.append( - line.substring(REQUEST_ATTRIBUTES.length(), + line.substring(REQUEST_ATTRIBUTES.length(), line.length()).trim()); continue; } @@ -134,41 +134,41 @@ class CMS41LdifParser requestAttributes = null; System.out.println(line); } - } + } } public void parseAttributes(String dn, StringBuffer attrs) throws Exception { BASE64Decoder decoder = new BASE64Decoder(); decodeHashtable(dn, decoder.decodeBuffer(attrs.toString())); - + // System.out.println(attrs); } - public Object decode(byte[] data) throws - ObjectStreamException, - IOException, - ClassNotFoundException - { - ByteArrayInputStream bis = new ByteArrayInputStream(data); - ObjectInputStream is = new ObjectInputStream(bis); - return is.readObject(); + public Object decode(byte[] data) throws + ObjectStreamException, + IOException, + ClassNotFoundException + { + ByteArrayInputStream bis = new ByteArrayInputStream(data); + ObjectInputStream is = new ObjectInputStream(bis); + return is.readObject(); } public void decodeHashtable(String dn, byte[] data) throws Exception { - ByteArrayInputStream bis = new ByteArrayInputStream(data); - ObjectInputStream is = new ObjectInputStream(bis); + ByteArrayInputStream bis = new ByteArrayInputStream(data); + ObjectInputStream is = new ObjectInputStream(bis); System.out.println(BEGIN); - String key = null; - while (true) - { - key = (String)is.readObject(); - // end of table is marked with null - if (key == null) break; + String key = null; + while (true) + { + key = (String)is.readObject(); + // end of table is marked with null + if (key == null) break; try { - byte[] bytes = (byte[])is.readObject(); + byte[] bytes = (byte[])is.readObject(); Object obj = decode(bytes); output(key, obj); } catch (Exception e) { @@ -179,7 +179,7 @@ class CMS41LdifParser mErrorPrintWriter.println("Skipped " + key); } } - } + } System.out.println(END); } @@ -187,22 +187,22 @@ class CMS41LdifParser { if (obj instanceof String) { System.out.println(" " + - key + ":" + obj.getClass().getName() + "=" + + key + ":" + obj.getClass().getName() + "=" + obj); } else if (obj instanceof netscape.security.x509.CertificateX509Key) { netscape.security.x509.CertificateX509Key o = (netscape.security.x509.CertificateX509Key)obj; - ByteArrayOutputStream bos = + ByteArrayOutputStream bos = new ByteArrayOutputStream(); o.encode(bos); BASE64Encoder encoder = new BASE64Encoder(); System.out.println(" " + - key + ":" + o.getClass().getName() + "=" + + key + ":" + o.getClass().getName() + "=" + encoder.encode(bos.toByteArray())); } else if (obj instanceof netscape.security.x509.CertificateSubjectName) { netscape.security.x509.CertificateSubjectName o = (netscape.security.x509.CertificateSubjectName)obj; - ByteArrayOutputStream bos = + ByteArrayOutputStream bos = new ByteArrayOutputStream(); o.encode(bos); BASE64Encoder encoder = new BASE64Encoder(); @@ -212,7 +212,7 @@ class CMS41LdifParser } else if (obj instanceof netscape.security.x509.CertificateExtensions) { netscape.security.x509.CertificateExtensions o = (netscape.security.x509.CertificateExtensions)obj; - ByteArrayOutputStream bos = + ByteArrayOutputStream bos = new ByteArrayOutputStream(); o.encode(bos); BASE64Encoder encoder = new BASE64Encoder(); @@ -222,7 +222,7 @@ class CMS41LdifParser } else if (obj instanceof netscape.security.x509.X509CertInfo) { netscape.security.x509.X509CertInfo o = (netscape.security.x509.X509CertInfo)obj; - ByteArrayOutputStream bos = + ByteArrayOutputStream bos = new ByteArrayOutputStream(); o.encode(bos); BASE64Encoder encoder = new BASE64Encoder(); @@ -232,68 +232,68 @@ class CMS41LdifParser } else if (obj instanceof netscape.security.x509.X509CertImpl) { netscape.security.x509.X509CertImpl o = (netscape.security.x509.X509CertImpl)obj; - ByteArrayOutputStream bos = + ByteArrayOutputStream bos = new ByteArrayOutputStream(); o.encode(bos); BASE64Encoder encoder = new BASE64Encoder(); System.out.println(" " + - key + ":" + o.getClass().getName() + "=" + + key + ":" + o.getClass().getName() + "=" + encoder.encode(bos.toByteArray())); } else if (obj instanceof netscape.security.x509.CertificateChain) { netscape.security.x509.CertificateChain o = (netscape.security.x509.CertificateChain)obj; - ByteArrayOutputStream bos = + ByteArrayOutputStream bos = new ByteArrayOutputStream(); o.encode(bos); BASE64Encoder encoder = new BASE64Encoder(); System.out.println(" " + - key + ":" + o.getClass().getName() + "=" + + key + ":" + o.getClass().getName() + "=" + encoder.encode(bos.toByteArray())); } else if (obj instanceof netscape.security.x509.X509CertImpl[]) { netscape.security.x509.X509CertImpl o[] = (netscape.security.x509.X509CertImpl[])obj; for (int i = 0; i < o.length; i++) { - ByteArrayOutputStream bos = + ByteArrayOutputStream bos = new ByteArrayOutputStream(); o[i].encode(bos); BASE64Encoder encoder = new BASE64Encoder(); System.out.println(" " + - key + ":" + o[i].getClass().getName() +"["+o.length+","+i+"]" + "=" + + key + ":" + o[i].getClass().getName() +"["+o.length+","+i+"]" + "=" + encoder.encode(bos.toByteArray())); } } else if (obj instanceof netscape.security.x509.X509CertInfo[]) { netscape.security.x509.X509CertInfo o[] = (netscape.security.x509.X509CertInfo[])obj; for (int i = 0; i < o.length; i++) { - ByteArrayOutputStream bos = + ByteArrayOutputStream bos = new ByteArrayOutputStream(); o[i].encode(bos); BASE64Encoder encoder = new BASE64Encoder(); System.out.println(" " + - key + ":" + o[i].getClass().getName() + "["+o.length + "," + i+"]"+"=" + + key + ":" + o[i].getClass().getName() + "["+o.length + "," + i+"]"+"=" + encoder.encodeBuffer(bos.toByteArray())); } } else if (obj instanceof netscape.security.x509.RevokedCertImpl[]) { netscape.security.x509.RevokedCertImpl o[] = (netscape.security.x509.RevokedCertImpl[])obj; for (int i = 0; i < o.length; i++) { - DerOutputStream bos = + DerOutputStream bos = new DerOutputStream(); o[i].encode(bos); BASE64Encoder encoder = new BASE64Encoder(); System.out.println(" " + - key + ":" + o[i].getClass().getName() +"["+o.length+","+i+"]" + "=" + + key + ":" + o[i].getClass().getName() +"["+o.length+","+i+"]" + "=" + encoder.encode(bos.toByteArray())); } } else if (obj instanceof java.security.cert.Certificate[]) { java.security.cert.Certificate o[] = (java.security.cert.Certificate[])obj; for (int i = 0; i < o.length; i++) { - ByteArrayOutputStream bos = + ByteArrayOutputStream bos = new ByteArrayOutputStream(); BASE64Encoder encoder = new BASE64Encoder(); System.out.println(" " + - key + ":" + o[i].getClass().getName() +"["+o.length+","+i+"]" + "=" + + key + ":" + o[i].getClass().getName() +"["+o.length+","+i+"]" + "=" + encoder.encode(o[i].getEncoded())); } } else if (obj instanceof com.netscape.certsrv.base.ArgBlock) { @@ -334,12 +334,12 @@ class CMS41LdifParser } else if (obj instanceof com.netscape.certsrv.kra.ProofOfArchival) { com.netscape.certsrv.kra.ProofOfArchival o = (com.netscape.certsrv.kra.ProofOfArchival)obj; - DerOutputStream bos = + DerOutputStream bos = new DerOutputStream(); o.encode(bos); BASE64Encoder encoder = new BASE64Encoder(); System.out.println(" " + - key + ":" + o.getClass().getName() + "=" + + key + ":" + o.getClass().getName() + "=" + encoder.encode(bos.toByteArray())); } else if (obj instanceof com.netscape.certsrv.request.AgentApprovals) { com.netscape.certsrv.request.AgentApprovals o = @@ -422,22 +422,22 @@ class CMS41LdifParser } else if (obj instanceof netscape.security.x509.CertificateAlgorithmId) { netscape.security.x509.CertificateAlgorithmId o = (netscape.security.x509.CertificateAlgorithmId)obj; - ByteArrayOutputStream bos = + ByteArrayOutputStream bos = new ByteArrayOutputStream(); o.encode(bos); BASE64Encoder encoder = new BASE64Encoder(); - System.out.println(" " + key + - ":netscape.security.x509.CertificateAlgorithmId="+ + System.out.println(" " + key + + ":netscape.security.x509.CertificateAlgorithmId="+ encoder.encode(bos.toByteArray())); } else if (obj instanceof netscape.security.x509.CertificateValidity) { netscape.security.x509.CertificateValidity o = (netscape.security.x509.CertificateValidity)obj; - ByteArrayOutputStream bos = + ByteArrayOutputStream bos = new ByteArrayOutputStream(); o.encode(bos); BASE64Encoder encoder = new BASE64Encoder(); - System.out.println(" " + key + - ":netscape.security.x509.CertificateValidity="+ + System.out.println(" " + key + + ":netscape.security.x509.CertificateValidity="+ encoder.encode(bos.toByteArray())); } else if (obj instanceof java.util.Hashtable) { // Bugzilla Bug #224800 (a.k.a - Raidzilla Bug #56953) @@ -456,7 +456,7 @@ class CMS41LdifParser } } else { System.out.println(" " + - key + ":" + obj.getClass().getName() + "=" + + key + ":" + obj.getClass().getName() + "=" + obj); } } -- cgit