diff options
author | Endi Sukma Dewata <edewata@redhat.com> | 2012-04-05 14:49:11 -0500 |
---|---|---|
committer | Endi Sukma Dewata <edewata@redhat.com> | 2012-04-09 10:03:25 -0500 |
commit | 7c7b9d023cd466c1771068badc020dab36beb553 (patch) | |
tree | 178877eb83e25336be7577953945fbdb0b9e1a15 /base/migrate | |
parent | da1e6e2f49f66fd46c8039ff1aa4386309fba8f4 (diff) | |
download | pki-7c7b9d023cd466c1771068badc020dab36beb553.tar.gz pki-7c7b9d023cd466c1771068badc020dab36beb553.tar.xz pki-7c7b9d023cd466c1771068badc020dab36beb553.zip |
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
Diffstat (limited to 'base/migrate')
24 files changed, 1343 insertions, 1343 deletions
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); } } diff --git a/base/migrate/42SP2ToTxt/src/Main.java b/base/migrate/42SP2ToTxt/src/Main.java index 1a324d8ee..b76b17b71 100644 --- a/base/migrate/42SP2ToTxt/src/Main.java +++ b/base/migrate/42SP2ToTxt/src/Main.java @@ -37,7 +37,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) @@ -46,15 +46,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 @@ -77,14 +77,14 @@ public class Main class CMS42SP2LdifParser { // 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 @@ -104,16 +104,16 @@ class CMS42SP2LdifParser } 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; } @@ -121,7 +121,7 @@ class CMS42SP2LdifParser requestAttributes = new StringBuffer(); // System.out.println(line); requestAttributes.append( - line.substring(REQUEST_ATTRIBUTES.length(), + line.substring(REQUEST_ATTRIBUTES.length(), line.length()).trim()); continue; } @@ -137,41 +137,41 @@ class CMS42SP2LdifParser 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) { @@ -182,7 +182,7 @@ class CMS42SP2LdifParser mErrorPrintWriter.println("Skipped " + key); } } - } + } System.out.println(END); } @@ -190,22 +190,22 @@ class CMS42SP2LdifParser { 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(); @@ -215,7 +215,7 @@ class CMS42SP2LdifParser } 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(); @@ -225,7 +225,7 @@ class CMS42SP2LdifParser } 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(); @@ -235,68 +235,68 @@ class CMS42SP2LdifParser } 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) { @@ -337,12 +337,12 @@ class CMS42SP2LdifParser } 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 = @@ -425,22 +425,22 @@ class CMS42SP2LdifParser } 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) @@ -459,7 +459,7 @@ class CMS42SP2LdifParser } } else { System.out.println(" " + - key + ":" + obj.getClass().getName() + "=" + + key + ":" + obj.getClass().getName() + "=" + obj); } } diff --git a/base/migrate/42ToTxt/src/Main.java b/base/migrate/42ToTxt/src/Main.java index 55e64df08..76adfb16e 100644 --- a/base/migrate/42ToTxt/src/Main.java +++ b/base/migrate/42ToTxt/src/Main.java @@ -37,7 +37,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) @@ -46,15 +46,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 @@ -77,14 +77,14 @@ public class Main class CMS42LdifParser { // 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 @@ -104,16 +104,16 @@ class CMS42LdifParser } 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; } @@ -121,7 +121,7 @@ class CMS42LdifParser requestAttributes = new StringBuffer(); // System.out.println(line); requestAttributes.append( - line.substring(REQUEST_ATTRIBUTES.length(), + line.substring(REQUEST_ATTRIBUTES.length(), line.length()).trim()); continue; } @@ -137,41 +137,41 @@ class CMS42LdifParser 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) { @@ -182,7 +182,7 @@ class CMS42LdifParser mErrorPrintWriter.println("Skipped " + key); } } - } + } System.out.println(END); } @@ -190,22 +190,22 @@ class CMS42LdifParser { 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(); @@ -215,7 +215,7 @@ class CMS42LdifParser } 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(); @@ -225,7 +225,7 @@ class CMS42LdifParser } 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(); @@ -235,68 +235,68 @@ class CMS42LdifParser } 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) { @@ -337,12 +337,12 @@ class CMS42LdifParser } 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 = @@ -425,22 +425,22 @@ class CMS42LdifParser } 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) @@ -459,7 +459,7 @@ class CMS42LdifParser } } else { System.out.println(" " + - key + ":" + obj.getClass().getName() + "=" + + key + ":" + obj.getClass().getName() + "=" + obj); } } diff --git a/base/migrate/45ToTxt/src/Main.java b/base/migrate/45ToTxt/src/Main.java index 916ca9cd1..13125fb43 100644 --- a/base/migrate/45ToTxt/src/Main.java +++ b/base/migrate/45ToTxt/src/Main.java @@ -38,7 +38,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.5 and later @@ -48,15 +48,15 @@ public class Main // The following call to "java.security.Security.insertProviderAt()" // is no longer commented out in CMS 4.5 and later 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 @@ -79,14 +79,14 @@ public class Main class CMS45LdifParser { // 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 @@ -106,16 +106,16 @@ class CMS45LdifParser } 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; } @@ -123,7 +123,7 @@ class CMS45LdifParser requestAttributes = new StringBuffer(); // System.out.println(line); requestAttributes.append( - line.substring(REQUEST_ATTRIBUTES.length(), + line.substring(REQUEST_ATTRIBUTES.length(), line.length()).trim()); continue; } @@ -139,41 +139,41 @@ class CMS45LdifParser 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) { @@ -184,7 +184,7 @@ class CMS45LdifParser mErrorPrintWriter.println("Skipped " + key); } } - } + } System.out.println(END); } @@ -192,22 +192,22 @@ class CMS45LdifParser { 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(); @@ -217,7 +217,7 @@ class CMS45LdifParser } 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(); @@ -227,7 +227,7 @@ class CMS45LdifParser } 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(); @@ -237,68 +237,68 @@ class CMS45LdifParser } 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) { @@ -339,12 +339,12 @@ class CMS45LdifParser } 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 = @@ -427,22 +427,22 @@ class CMS45LdifParser } 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) @@ -461,7 +461,7 @@ class CMS45LdifParser } } else { System.out.println(" " + - key + ":" + obj.getClass().getName() + "=" + + key + ":" + obj.getClass().getName() + "=" + obj); } } diff --git a/base/migrate/47ToTxt/src/Main.java b/base/migrate/47ToTxt/src/Main.java index 194c277f1..ebed784fb 100644 --- a/base/migrate/47ToTxt/src/Main.java +++ b/base/migrate/47ToTxt/src/Main.java @@ -45,7 +45,7 @@ import iplanet.security.util.*; public class Main { - public static void main(String args[]) + public static void main(String args[]) { try { // initialize CryptoManager in CMS 4.5 and later @@ -55,15 +55,15 @@ public class Main // The following call to "java.security.Security.insertProviderAt()" // is no longer commented out in CMS 4.5 and later java.security.Security.insertProviderAt( - new iplanet.security.provider.CMS(), 0); - java.security.Provider ps[] = + new iplanet.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 @@ -86,14 +86,14 @@ public class Main class CMS47LdifParser { // constants - private static final String DN = + private static final String DN = "dn:"; // Directory Servers in CMS 4.7 and later 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 @@ -113,16 +113,16 @@ class CMS47LdifParser } 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; } @@ -130,7 +130,7 @@ class CMS47LdifParser requestAttributes = new StringBuffer(); // System.out.println(line); requestAttributes.append( - line.substring(REQUEST_ATTRIBUTES.length(), + line.substring(REQUEST_ATTRIBUTES.length(), line.length()).trim()); continue; } @@ -146,41 +146,41 @@ class CMS47LdifParser 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) { @@ -191,7 +191,7 @@ class CMS47LdifParser mErrorPrintWriter.println("Skipped " + key); } } - } + } System.out.println(END); } @@ -211,22 +211,22 @@ class CMS47LdifParser translation = data_type; } System.out.println(" " + - key + ":" + translation + "=" + + key + ":" + translation + "=" + obj); } else if (obj instanceof iplanet.security.x509.CertificateX509Key) { iplanet.security.x509.CertificateX509Key o = (iplanet.security.x509.CertificateX509Key)obj; - ByteArrayOutputStream bos = + ByteArrayOutputStream bos = new ByteArrayOutputStream(); o.encode(bos); BASE64Encoder encoder = new BASE64Encoder(); System.out.println(" " + - key + ":" + "netscape.security.x509.CertificateX509Key" + "=" + + key + ":" + "netscape.security.x509.CertificateX509Key" + "=" + encoder.encode(bos.toByteArray())); } else if (obj instanceof iplanet.security.x509.CertificateSubjectName) { iplanet.security.x509.CertificateSubjectName o = (iplanet.security.x509.CertificateSubjectName)obj; - ByteArrayOutputStream bos = + ByteArrayOutputStream bos = new ByteArrayOutputStream(); o.encode(bos); BASE64Encoder encoder = new BASE64Encoder(); @@ -236,7 +236,7 @@ class CMS47LdifParser } else if (obj instanceof iplanet.security.x509.CertificateExtensions) { iplanet.security.x509.CertificateExtensions o = (iplanet.security.x509.CertificateExtensions)obj; - ByteArrayOutputStream bos = + ByteArrayOutputStream bos = new ByteArrayOutputStream(); o.encode(bos); BASE64Encoder encoder = new BASE64Encoder(); @@ -246,7 +246,7 @@ class CMS47LdifParser } else if (obj instanceof iplanet.security.x509.X509CertInfo) { iplanet.security.x509.X509CertInfo o = (iplanet.security.x509.X509CertInfo)obj; - ByteArrayOutputStream bos = + ByteArrayOutputStream bos = new ByteArrayOutputStream(); o.encode(bos); BASE64Encoder encoder = new BASE64Encoder(); @@ -256,57 +256,57 @@ class CMS47LdifParser } else if (obj instanceof iplanet.security.x509.X509CertImpl) { iplanet.security.x509.X509CertImpl o = (iplanet.security.x509.X509CertImpl)obj; - ByteArrayOutputStream bos = + ByteArrayOutputStream bos = new ByteArrayOutputStream(); o.encode(bos); BASE64Encoder encoder = new BASE64Encoder(); System.out.println(" " + - key + ":" + "netscape.security.x509.X509CertImpl" + "=" + + key + ":" + "netscape.security.x509.X509CertImpl" + "=" + encoder.encode(bos.toByteArray())); } else if (obj instanceof iplanet.security.x509.CertificateChain) { iplanet.security.x509.CertificateChain o = (iplanet.security.x509.CertificateChain)obj; - ByteArrayOutputStream bos = + ByteArrayOutputStream bos = new ByteArrayOutputStream(); o.encode(bos); BASE64Encoder encoder = new BASE64Encoder(); System.out.println(" " + - key + ":" + "netscape.security.x509.CertificateChain" + "=" + + key + ":" + "netscape.security.x509.CertificateChain" + "=" + encoder.encode(bos.toByteArray())); } else if (obj instanceof iplanet.security.x509.X509CertImpl[]) { iplanet.security.x509.X509CertImpl o[] = (iplanet.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 + ":" + "netscape.security.x509.X509CertImpl" +"["+o.length+","+i+"]" + "=" + + key + ":" + "netscape.security.x509.X509CertImpl" +"["+o.length+","+i+"]" + "=" + encoder.encode(bos.toByteArray())); } } else if (obj instanceof iplanet.security.x509.X509CertInfo[]) { iplanet.security.x509.X509CertInfo o[] = (iplanet.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 + ":" + "netscape.security.x509.X509CertInfo" + "["+o.length + "," + i+"]"+"=" + + key + ":" + "netscape.security.x509.X509CertInfo" + "["+o.length + "," + i+"]"+"=" + encoder.encodeBuffer(bos.toByteArray())); } } else if (obj instanceof iplanet.security.x509.RevokedCertImpl[]) { iplanet.security.x509.RevokedCertImpl o[] = (iplanet.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 + ":" + "netscape.security.x509.RevokedCertImpl" +"["+o.length+","+i+"]" + "=" + + key + ":" + "netscape.security.x509.RevokedCertImpl" +"["+o.length+","+i+"]" + "=" + encoder.encode(bos.toByteArray())); } } else if (obj instanceof java.security.cert.Certificate[]) { @@ -323,11 +323,11 @@ class CMS47LdifParser } else { translation = data_type; } - ByteArrayOutputStream bos = + ByteArrayOutputStream bos = new ByteArrayOutputStream(); BASE64Encoder encoder = new BASE64Encoder(); System.out.println(" " + - key + ":" + translation +"["+o.length+","+i+"]" + "=" + + key + ":" + translation +"["+o.length+","+i+"]" + "=" + encoder.encode(o[i].getEncoded())); } } else if (obj instanceof com.iplanet.certsrv.base.ArgBlock) { @@ -398,12 +398,12 @@ class CMS47LdifParser } else if (obj instanceof com.iplanet.certsrv.kra.ProofOfArchival) { com.iplanet.certsrv.kra.ProofOfArchival o = (com.iplanet.certsrv.kra.ProofOfArchival)obj; - DerOutputStream bos = + DerOutputStream bos = new DerOutputStream(); o.encode(bos); BASE64Encoder encoder = new BASE64Encoder(); System.out.println(" " + - key + ":" + "com.netscape.certsrv.kra.ProofOfArchival" + "=" + + key + ":" + "com.netscape.certsrv.kra.ProofOfArchival" + "=" + encoder.encode(bos.toByteArray())); } else if (obj instanceof com.iplanet.certsrv.request.AgentApprovals) { com.iplanet.certsrv.request.AgentApprovals o = @@ -516,22 +516,22 @@ class CMS47LdifParser } else if (obj instanceof iplanet.security.x509.CertificateAlgorithmId) { iplanet.security.x509.CertificateAlgorithmId o = (iplanet.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 iplanet.security.x509.CertificateValidity) { iplanet.security.x509.CertificateValidity o = (iplanet.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) @@ -570,7 +570,7 @@ class CMS47LdifParser translation = data_type; } System.out.println(" " + - key + ":" + translation + "=" + + key + ":" + translation + "=" + obj); } } diff --git a/base/migrate/60ToTxt/src/Main.java b/base/migrate/60ToTxt/src/Main.java index 72de924c4..3eb3c8150 100644 --- a/base/migrate/60ToTxt/src/Main.java +++ b/base/migrate/60ToTxt/src/Main.java @@ -40,7 +40,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.5 and later @@ -50,15 +50,15 @@ public class Main // The following call to "java.security.Security.insertProviderAt()" // is no longer commented out in CMS 4.5 and later 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 @@ -81,14 +81,14 @@ public class Main class CMS60LdifParser { // constants - private static final String DN = + private static final String DN = "dn:"; // Directory Servers in CMS 4.7 and later 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 @@ -108,16 +108,16 @@ class CMS60LdifParser } 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; } @@ -125,7 +125,7 @@ class CMS60LdifParser requestAttributes = new StringBuffer(); // System.out.println(line); requestAttributes.append( - line.substring(REQUEST_ATTRIBUTES.length(), + line.substring(REQUEST_ATTRIBUTES.length(), line.length()).trim()); continue; } @@ -141,41 +141,41 @@ class CMS60LdifParser 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) { @@ -186,7 +186,7 @@ class CMS60LdifParser mErrorPrintWriter.println("Skipped " + key); } } - } + } System.out.println(END); } @@ -194,22 +194,22 @@ class CMS60LdifParser { 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(); @@ -219,7 +219,7 @@ class CMS60LdifParser } 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(); @@ -229,7 +229,7 @@ class CMS60LdifParser } 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(); @@ -239,68 +239,68 @@ class CMS60LdifParser } 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) { @@ -345,12 +345,12 @@ class CMS60LdifParser // to "com.netscape.cmscore.kra.ProofOfArchival" com.netscape.cmscore.kra.ProofOfArchival o = (com.netscape.cmscore.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 = @@ -433,22 +433,22 @@ class CMS60LdifParser } 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) @@ -467,7 +467,7 @@ class CMS60LdifParser } } else { System.out.println(" " + - key + ":" + obj.getClass().getName() + "=" + + key + ":" + obj.getClass().getName() + "=" + obj); } } diff --git a/base/migrate/61ToTxt/src/Main.java b/base/migrate/61ToTxt/src/Main.java index cd235f73f..b99c35eb4 100644 --- a/base/migrate/61ToTxt/src/Main.java +++ b/base/migrate/61ToTxt/src/Main.java @@ -38,7 +38,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.5 and later @@ -48,15 +48,15 @@ public class Main // The following call to "java.security.Security.insertProviderAt()" // is no longer commented out in CMS 4.5 and later 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 @@ -79,14 +79,14 @@ public class Main class CMS61LdifParser { // constants - private static final String DN = + private static final String DN = "dn:"; // Directory Servers in CMS 4.7 and later 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 @@ -106,16 +106,16 @@ class CMS61LdifParser } 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; } @@ -123,7 +123,7 @@ class CMS61LdifParser requestAttributes = new StringBuffer(); // System.out.println(line); requestAttributes.append( - line.substring(REQUEST_ATTRIBUTES.length(), + line.substring(REQUEST_ATTRIBUTES.length(), line.length()).trim()); continue; } @@ -139,41 +139,41 @@ class CMS61LdifParser 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) { @@ -184,7 +184,7 @@ class CMS61LdifParser mErrorPrintWriter.println("Skipped " + key); } } - } + } System.out.println(END); } @@ -192,22 +192,22 @@ class CMS61LdifParser { 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(); @@ -217,7 +217,7 @@ class CMS61LdifParser } 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(); @@ -227,7 +227,7 @@ class CMS61LdifParser } 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(); @@ -237,68 +237,68 @@ class CMS61LdifParser } 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.cmscore.base.ArgBlock) { @@ -346,12 +346,12 @@ class CMS61LdifParser // to "com.netscape.cmscore.kra.ProofOfArchival" com.netscape.cmscore.kra.ProofOfArchival o = (com.netscape.cmscore.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 = @@ -434,22 +434,22 @@ class CMS61LdifParser } 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 byte[]) { // Since 6.1's profile framework, @@ -475,7 +475,7 @@ class CMS61LdifParser } } else { System.out.println(" " + - key + ":" + obj.getClass().getName() + "=" + + key + ":" + obj.getClass().getName() + "=" + obj); } } diff --git a/base/migrate/62ToTxt/src/Main.java b/base/migrate/62ToTxt/src/Main.java index 109162475..72b9c3838 100644 --- a/base/migrate/62ToTxt/src/Main.java +++ b/base/migrate/62ToTxt/src/Main.java @@ -38,7 +38,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.5 and later @@ -48,15 +48,15 @@ public class Main // The following call to "java.security.Security.insertProviderAt()" // is no longer commented out in CMS 4.5 and later 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 @@ -79,14 +79,14 @@ public class Main class CMS62LdifParser { // constants - private static final String DN = + private static final String DN = "dn:"; // Directory Servers in CMS 4.7 and later 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 @@ -106,16 +106,16 @@ class CMS62LdifParser } 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; } @@ -123,7 +123,7 @@ class CMS62LdifParser requestAttributes = new StringBuffer(); // System.out.println(line); requestAttributes.append( - line.substring(REQUEST_ATTRIBUTES.length(), + line.substring(REQUEST_ATTRIBUTES.length(), line.length()).trim()); continue; } @@ -139,41 +139,41 @@ class CMS62LdifParser 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) { @@ -184,7 +184,7 @@ class CMS62LdifParser mErrorPrintWriter.println("Skipped " + key); } } - } + } System.out.println(END); } @@ -192,22 +192,22 @@ class CMS62LdifParser { 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(); @@ -217,7 +217,7 @@ class CMS62LdifParser } 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(); @@ -227,7 +227,7 @@ class CMS62LdifParser } 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(); @@ -237,68 +237,68 @@ class CMS62LdifParser } 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.cmscore.base.ArgBlock) { @@ -346,12 +346,12 @@ class CMS62LdifParser // to "com.netscape.cmscore.kra.ProofOfArchival" com.netscape.cmscore.kra.ProofOfArchival o = (com.netscape.cmscore.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 = @@ -434,24 +434,24 @@ class CMS62LdifParser } 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 byte[]) { + } else if (obj instanceof byte[]) { // Since 6.1's profile framework, // req_archive_options is a byte array BASE64Encoder encoder = new BASE64Encoder(); @@ -475,7 +475,7 @@ class CMS62LdifParser } } else { System.out.println(" " + - key + ":" + obj.getClass().getName() + "=" + + key + ":" + obj.getClass().getName() + "=" + obj); } } diff --git a/base/migrate/63ToTxt/src/Main.java b/base/migrate/63ToTxt/src/Main.java index 6066801e2..efd3337d0 100644 --- a/base/migrate/63ToTxt/src/Main.java +++ b/base/migrate/63ToTxt/src/Main.java @@ -38,7 +38,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.5 and later @@ -48,15 +48,15 @@ public class Main // The following call to "java.security.Security.insertProviderAt()" // is no longer commented out in CMS 4.5 and later 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 @@ -79,14 +79,14 @@ public class Main class CMS63LdifParser { // constants - private static final String DN = + private static final String DN = "dn:"; // Directory Servers in CMS 4.7 and later 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 @@ -106,16 +106,16 @@ class CMS63LdifParser } 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; } @@ -123,7 +123,7 @@ class CMS63LdifParser requestAttributes = new StringBuffer(); // System.out.println(line); requestAttributes.append( - line.substring(REQUEST_ATTRIBUTES.length(), + line.substring(REQUEST_ATTRIBUTES.length(), line.length()).trim()); continue; } @@ -139,41 +139,41 @@ class CMS63LdifParser 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) { @@ -184,7 +184,7 @@ class CMS63LdifParser mErrorPrintWriter.println("Skipped " + key); } } - } + } System.out.println(END); } @@ -192,22 +192,22 @@ class CMS63LdifParser { 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(); @@ -217,7 +217,7 @@ class CMS63LdifParser } 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(); @@ -227,7 +227,7 @@ class CMS63LdifParser } 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(); @@ -237,68 +237,68 @@ class CMS63LdifParser } 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.cmscore.base.ArgBlock) { @@ -346,12 +346,12 @@ class CMS63LdifParser // to "com.netscape.cmscore.kra.ProofOfArchival" com.netscape.cmscore.kra.ProofOfArchival o = (com.netscape.cmscore.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 = @@ -434,22 +434,22 @@ class CMS63LdifParser } 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 byte[]) { // Since 6.1's profile framework, @@ -475,7 +475,7 @@ class CMS63LdifParser } } else { System.out.println(" " + - key + ":" + obj.getClass().getName() + "=" + + key + ":" + obj.getClass().getName() + "=" + obj); } } diff --git a/base/migrate/70ToTxt/src/Main.java b/base/migrate/70ToTxt/src/Main.java index 133671267..8c5d3811e 100644 --- a/base/migrate/70ToTxt/src/Main.java +++ b/base/migrate/70ToTxt/src/Main.java @@ -38,7 +38,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.5 and later @@ -48,15 +48,15 @@ public class Main // The following call to "java.security.Security.insertProviderAt()" // is no longer commented out in CMS 4.5 and later 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 @@ -79,14 +79,14 @@ public class Main class CMS70LdifParser { // constants - private static final String DN = + private static final String DN = "dn:"; // Directory Servers in CMS 4.7 and later 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 @@ -106,16 +106,16 @@ class CMS70LdifParser } 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; } @@ -123,7 +123,7 @@ class CMS70LdifParser requestAttributes = new StringBuffer(); // System.out.println(line); requestAttributes.append( - line.substring(REQUEST_ATTRIBUTES.length(), + line.substring(REQUEST_ATTRIBUTES.length(), line.length()).trim()); continue; } @@ -139,41 +139,41 @@ class CMS70LdifParser 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) { @@ -184,7 +184,7 @@ class CMS70LdifParser mErrorPrintWriter.println("Skipped " + key); } } - } + } System.out.println(END); } @@ -192,22 +192,22 @@ class CMS70LdifParser { 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(); @@ -217,7 +217,7 @@ class CMS70LdifParser } 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(); @@ -227,7 +227,7 @@ class CMS70LdifParser } 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(); @@ -237,68 +237,68 @@ class CMS70LdifParser } 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.cmscore.base.ArgBlock) { @@ -346,12 +346,12 @@ class CMS70LdifParser // to "com.netscape.cmscore.kra.ProofOfArchival" com.netscape.cmscore.kra.ProofOfArchival o = (com.netscape.cmscore.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 = @@ -434,22 +434,22 @@ class CMS70LdifParser } 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 byte[]) { // Since 6.1's profile framework, @@ -475,7 +475,7 @@ class CMS70LdifParser } } else { System.out.println(" " + - key + ":" + obj.getClass().getName() + "=" + + key + ":" + obj.getClass().getName() + "=" + obj); } } diff --git a/base/migrate/71ToTxt/src/Main.java b/base/migrate/71ToTxt/src/Main.java index f7f3a5b95..796653370 100644 --- a/base/migrate/71ToTxt/src/Main.java +++ b/base/migrate/71ToTxt/src/Main.java @@ -38,7 +38,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.5 and later @@ -48,15 +48,15 @@ public class Main // The following call to "java.security.Security.insertProviderAt()" // is no longer commented out in CMS 4.5 and later 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 @@ -79,14 +79,14 @@ public class Main class CMS71LdifParser { // constants - private static final String DN = + private static final String DN = "dn:"; // Directory Servers in CMS 4.7 and later 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 @@ -106,16 +106,16 @@ class CMS71LdifParser } 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; } @@ -123,7 +123,7 @@ class CMS71LdifParser requestAttributes = new StringBuffer(); // System.out.println(line); requestAttributes.append( - line.substring(REQUEST_ATTRIBUTES.length(), + line.substring(REQUEST_ATTRIBUTES.length(), line.length()).trim()); continue; } @@ -139,41 +139,41 @@ class CMS71LdifParser 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) { @@ -184,7 +184,7 @@ class CMS71LdifParser mErrorPrintWriter.println("Skipped " + key); } } - } + } System.out.println(END); } @@ -192,22 +192,22 @@ class CMS71LdifParser { 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(); @@ -217,7 +217,7 @@ class CMS71LdifParser } 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(); @@ -227,7 +227,7 @@ class CMS71LdifParser } 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(); @@ -237,68 +237,68 @@ class CMS71LdifParser } 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.cmscore.base.ArgBlock) { @@ -346,12 +346,12 @@ class CMS71LdifParser // to "com.netscape.cmscore.kra.ProofOfArchival" com.netscape.cmscore.kra.ProofOfArchival o = (com.netscape.cmscore.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 = @@ -434,22 +434,22 @@ class CMS71LdifParser } 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 byte[]) { // Since 6.1's profile framework, @@ -475,7 +475,7 @@ class CMS71LdifParser } } else { System.out.println(" " + - key + ":" + obj.getClass().getName() + "=" + + key + ":" + obj.getClass().getName() + "=" + obj); } } diff --git a/base/migrate/72ToTxt/src/Main.java b/base/migrate/72ToTxt/src/Main.java index 0a0dc812e..3b1a3693d 100644 --- a/base/migrate/72ToTxt/src/Main.java +++ b/base/migrate/72ToTxt/src/Main.java @@ -38,7 +38,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.5 and later @@ -48,15 +48,15 @@ public class Main // The following call to "java.security.Security.insertProviderAt()" // is no longer commented out in CMS 4.5 and later 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 @@ -79,14 +79,14 @@ public class Main class CMS72LdifParser { // constants - private static final String DN = + private static final String DN = "dn:"; // Directory Servers in CMS 4.7 and later 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 @@ -106,16 +106,16 @@ class CMS72LdifParser } 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; } @@ -123,7 +123,7 @@ class CMS72LdifParser requestAttributes = new StringBuffer(); // System.out.println(line); requestAttributes.append( - line.substring(REQUEST_ATTRIBUTES.length(), + line.substring(REQUEST_ATTRIBUTES.length(), line.length()).trim()); continue; } @@ -139,41 +139,41 @@ class CMS72LdifParser 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) { @@ -184,7 +184,7 @@ class CMS72LdifParser mErrorPrintWriter.println("Skipped " + key); } } - } + } System.out.println(END); } @@ -192,22 +192,22 @@ class CMS72LdifParser { 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(); @@ -217,7 +217,7 @@ class CMS72LdifParser } 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(); @@ -227,7 +227,7 @@ class CMS72LdifParser } 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(); @@ -237,68 +237,68 @@ class CMS72LdifParser } 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.cmscore.base.ArgBlock) { @@ -348,12 +348,12 @@ class CMS72LdifParser // to "com.netscape.cmscore.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 = @@ -436,22 +436,22 @@ class CMS72LdifParser } 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 byte[]) { // Since 6.1's profile framework, @@ -477,7 +477,7 @@ class CMS72LdifParser } } else { System.out.println(" " + - key + ":" + obj.getClass().getName() + "=" + + key + ":" + obj.getClass().getName() + "=" + obj); } } diff --git a/base/migrate/73ToTxt/src/Main.java b/base/migrate/73ToTxt/src/Main.java index be26e9858..e6526b6c1 100644 --- a/base/migrate/73ToTxt/src/Main.java +++ b/base/migrate/73ToTxt/src/Main.java @@ -38,7 +38,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.5 and later @@ -48,15 +48,15 @@ public class Main // The following call to "java.security.Security.insertProviderAt()" // is no longer commented out in CMS 4.5 and later 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 @@ -79,14 +79,14 @@ public class Main class CMS73LdifParser { // constants - private static final String DN = + private static final String DN = "dn:"; // Directory Servers in CMS 4.7 and later 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 @@ -106,16 +106,16 @@ class CMS73LdifParser } 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; } @@ -123,7 +123,7 @@ class CMS73LdifParser requestAttributes = new StringBuffer(); // System.out.println(line); requestAttributes.append( - line.substring(REQUEST_ATTRIBUTES.length(), + line.substring(REQUEST_ATTRIBUTES.length(), line.length()).trim()); continue; } @@ -139,41 +139,41 @@ class CMS73LdifParser 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) { @@ -184,7 +184,7 @@ class CMS73LdifParser mErrorPrintWriter.println("Skipped " + key); } } - } + } System.out.println(END); } @@ -192,22 +192,22 @@ class CMS73LdifParser { 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(); @@ -217,7 +217,7 @@ class CMS73LdifParser } 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(); @@ -227,7 +227,7 @@ class CMS73LdifParser } 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(); @@ -237,68 +237,68 @@ class CMS73LdifParser } 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.cmscore.base.ArgBlock) { @@ -348,12 +348,12 @@ class CMS73LdifParser // to "com.netscape.cmscore.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 = @@ -436,22 +436,22 @@ class CMS73LdifParser } 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 byte[]) { // Since 6.1's profile framework, @@ -477,7 +477,7 @@ class CMS73LdifParser } } else { System.out.println(" " + - key + ":" + obj.getClass().getName() + "=" + + key + ":" + obj.getClass().getName() + "=" + obj); } } diff --git a/base/migrate/80/MigrateSecurityDomain.java b/base/migrate/80/MigrateSecurityDomain.java index 4624f1259..32dca511d 100644 --- a/base/migrate/80/MigrateSecurityDomain.java +++ b/base/migrate/80/MigrateSecurityDomain.java @@ -179,7 +179,7 @@ public class MigrateSecurityDomain { } } - // create system entries + // create system entries String tlist[] = { "CA", "OCSP", "KRA", "RA", "TKS", "TPS" }; Document doc = parser.getDocument(); for (int j = 0; j < 6; j++) { diff --git a/base/migrate/TxtTo60/src/Main.java b/base/migrate/TxtTo60/src/Main.java index 3c47d8ad7..a2f8fbd48 100644 --- a/base/migrate/TxtTo60/src/Main.java +++ b/base/migrate/TxtTo60/src/Main.java @@ -37,7 +37,7 @@ import java.lang.reflect.*; public class Main { - public static void main(String args[]) + public static void main(String args[]) { try { // initialize CryptoManager in CMS 4.5 and later @@ -47,15 +47,15 @@ public class Main // The following call to "java.security.Security.insertProviderAt()" // is no longer commented out in CMS 4.5 and later 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 @@ -78,14 +78,14 @@ public class Main class CMS60LdifParser { // constants - private static final String DN = + private static final String DN = "dn:"; // Directory Servers in CMS 4.7 and later 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 @@ -105,16 +105,16 @@ class CMS60LdifParser } 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; Vector requestAttributes = null; - while ((line = reader.readLine()) != null) { + while ((line = reader.readLine()) != null) { if (line.startsWith(DN)) { dn = line; } @@ -137,33 +137,33 @@ class CMS60LdifParser } else { requestAttributes.setElementAt( (String) - requestAttributes.lastElement() + - "\n" + + requestAttributes.lastElement() + + "\n" + line, requestAttributes.size() - 1); } - } + } } - private byte[] encode(Object value) throws Exception - { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); + private byte[] encode(Object value) throws Exception + { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream os = new ObjectOutputStream(bos); - os.writeObject(value); - os.close(); - return bos.toByteArray(); + os.writeObject(value); + os.close(); + return bos.toByteArray(); } public void parseAttributes(String dn, Vector attrs) throws Exception - { + { Hashtable hashtable = new Hashtable(); for (int i = 0; i < attrs.size(); i++) { String attr = (String)attrs.elementAt(i); buildHashtable(dn, hashtable, attr); } - ByteArrayOutputStream bos = new ByteArrayOutputStream(); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream os = new ObjectOutputStream(bos); Enumeration e = hashtable.keys(); while (e.hasMoreElements()) { @@ -172,8 +172,8 @@ class CMS60LdifParser try { byte data[] = null; - data = encode(value); - os.writeObject(key); + data = encode(value); + os.writeObject(key); os.writeObject(data); } catch (Exception ex) { if (mErrorPrintWriter != null) { @@ -184,12 +184,12 @@ class CMS60LdifParser } } } // while - os.writeObject(null); + os.writeObject(null); os.close(); // print the BASE64 encoding of the Hashtable BASE64Encoder encoder = new BASE64Encoder(); - String attrsStr = encoder.encodeBuffer(bos.toByteArray()); + String attrsStr = encoder.encodeBuffer(bos.toByteArray()); // trim the last "\n" StringBuffer buffer = null; attrsStr = attrsStr.trim(); @@ -203,14 +203,14 @@ class CMS60LdifParser } } - System.out.println(REQUEST_ATTRIBUTES + " " + buffer); + System.out.println(REQUEST_ATTRIBUTES + " " + buffer); } - public void buildHashtable(String dn, Hashtable table, String attr) + public void buildHashtable(String dn, Hashtable table, String attr) throws Exception - { + { // attribute format [name]:[type]=[value] - + int colon = attr.indexOf(':'); if (colon == -1) { if (mErrorPrintWriter != null) { @@ -308,7 +308,7 @@ class CMS60LdifParser com.netscape.certsrv.authentication.AuthToken obj = (com.netscape.certsrv.authentication.AuthToken)table.get(name); if (obj == null) { - com.netscape.certsrv.authentication.IAuthManager mgr = + com.netscape.certsrv.authentication.IAuthManager mgr = new DummyAuthManager(); obj = new com.netscape.certsrv.authentication.AuthToken(mgr); table.put(name, obj); @@ -318,14 +318,14 @@ class CMS60LdifParser String valuevalue = value.substring(value.indexOf('=')+1); if (valuetype.equals("java.lang.String")) { // Processes 'java.math.BigInteger[]': - // + // // Bugzilla Bug #225031 (a.k.a - Raidzilla Bug #58356) - // + // // Processes 'java.lang.String[]': - // + // // Bugzilla Bug #224763 (a.k.a - Raidzilla Bug #57949) // Bugzilla Bug #252240 - // + // obj.set(valuekey, valuevalue); } else if (valuetype.equals("java.util.Date")) { obj.set(valuekey, new Date(Long.parseLong(valuevalue))); @@ -354,45 +354,45 @@ class CMS60LdifParser table.put(name, decoder.decodeBuffer(value)); } else if (type.startsWith("netscape.security.x509.CertificateAlgorithmId")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateAlgorithmId obj = + netscape.security.x509.CertificateAlgorithmId obj = new netscape.security.x509.CertificateAlgorithmId(new ByteArrayInputStream(decoder.decodeBuffer(value))); table.put(name, obj); } else if (type.equals("netscape.security.x509.CertificateChain")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateChain obj = + netscape.security.x509.CertificateChain obj = new netscape.security.x509.CertificateChain(); ByteArrayInputStream bis = new ByteArrayInputStream(decoder.decodeBuffer(value)); obj.decode(bis); table.put(name, obj); } else if (type.equals("netscape.security.x509.CertificateExtensions")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateExtensions obj = + netscape.security.x509.CertificateExtensions obj = new netscape.security.x509.CertificateExtensions( new DerInputStream(decoder.decodeBuffer(value))); table.put(name, obj); } else if (type.equals("netscape.security.x509.CertificateSubjectName")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateSubjectName obj = + netscape.security.x509.CertificateSubjectName obj = new netscape.security.x509.CertificateSubjectName( new ByteArrayInputStream(decoder.decodeBuffer(value))); table.put(name, obj); } else if (type.startsWith("netscape.security.x509.CertificateValidity")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateValidity obj = + netscape.security.x509.CertificateValidity obj = new netscape.security.x509.CertificateValidity(); ByteArrayInputStream bis = new ByteArrayInputStream(decoder.decodeBuffer(value)); obj.decode(bis); table.put(name, obj); } else if (type.equals("netscape.security.x509.CertificateX509Key")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateX509Key obj = + netscape.security.x509.CertificateX509Key obj = new netscape.security.x509.CertificateX509Key( new ByteArrayInputStream(decoder.decodeBuffer(value))); table.put(name, obj); } else if (type.startsWith("com.netscape.certsrv.cert.CertInfo")) { int size = Integer.parseInt(type.substring(type.indexOf('[')+ 1, type.indexOf(','))); int index = Integer.parseInt(type.substring(type.indexOf(',')+1, type.indexOf(']'))); - netscape.security.extensions.CertInfo objs[] = (netscape.security.extensions.CertInfo[])table.get(name); + netscape.security.extensions.CertInfo objs[] = (netscape.security.extensions.CertInfo[])table.get(name); BASE64Decoder decoder = new BASE64Decoder(); if (objs == null) { objs = new netscape.security.extensions.CertInfo[size]; @@ -414,7 +414,7 @@ class CMS60LdifParser } else if (type.startsWith("Integer[")) { int size = Integer.parseInt(type.substring(type.indexOf('[')+ 1, type.indexOf(','))); int index = Integer.parseInt(type.substring(type.indexOf(',')+1, type.indexOf(']'))); - Integer objs[] = (Integer[])table.get(name); + Integer objs[] = (Integer[])table.get(name); if (objs == null) { objs = new Integer[size]; table.put(name, objs); @@ -445,7 +445,7 @@ class CMS60LdifParser obj.set(valuekey, com.netscape.certsrv.dbs.keydb.KeyState.toKeyState(valuevalue)); } else if (valuetype.equals("[B")) { // byte array - + BASE64Decoder decoder = new BASE64Decoder(); obj.set(valuekey, decoder.decodeBuffer(valuevalue)); } else { @@ -455,15 +455,15 @@ class CMS60LdifParser } else if (type.startsWith("com.netscape.certsrv.kra.ProofOfArchival") || type.startsWith("com.netscape.cmscore.kra.ProofOfArchival")) { BASE64Decoder decoder = new BASE64Decoder(); - + ByteArrayInputStream bis = new ByteArrayInputStream(decoder.decodeBuffer(value)); - com.netscape.cmscore.kra.ProofOfArchival obj = + com.netscape.cmscore.kra.ProofOfArchival obj = buildPOA(decoder.decodeBuffer(value)); table.put(name, obj); } else if (type.startsWith("netscape.security.x509.RevokedCertImpl")) { int size = Integer.parseInt(type.substring(type.indexOf('[')+ 1, type.indexOf(','))); int index = Integer.parseInt(type.substring(type.indexOf(',')+1, type.indexOf(']'))); - netscape.security.x509.RevokedCertImpl objs[] = (netscape.security.x509.RevokedCertImpl[])table.get(name); + netscape.security.x509.RevokedCertImpl objs[] = (netscape.security.x509.RevokedCertImpl[])table.get(name); BASE64Decoder decoder = new BASE64Decoder(); if (objs == null) { objs = new netscape.security.x509.RevokedCertImpl[size]; @@ -493,7 +493,7 @@ class CMS60LdifParser } else if (type.startsWith("netscape.security.x509.X509CertImpl[")) { int size = Integer.parseInt(type.substring(type.indexOf('[')+ 1, type.indexOf(','))); int index = Integer.parseInt(type.substring(type.indexOf(',')+1, type.indexOf(']'))); - netscape.security.x509.X509CertImpl objs[] = (netscape.security.x509.X509CertImpl[])table.get(name); + netscape.security.x509.X509CertImpl objs[] = (netscape.security.x509.X509CertImpl[])table.get(name); BASE64Decoder decoder = new BASE64Decoder(); if (objs == null) { objs = new netscape.security.x509.X509CertImpl[size]; @@ -502,14 +502,14 @@ class CMS60LdifParser objs[index] = new netscape.security.x509.X509CertImpl(decoder.decodeBuffer(value)); } else if (type.equals("netscape.security.x509.X509CertImpl")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.X509CertImpl obj = + netscape.security.x509.X509CertImpl obj = new netscape.security.x509.X509CertImpl( decoder.decodeBuffer(value)); table.put(name, obj); } else if (type.startsWith("netscape.security.x509.X509CertInfo")) { int size = Integer.parseInt(type.substring(type.indexOf('[')+ 1, type.indexOf(','))); int index = Integer.parseInt(type.substring(type.indexOf(',')+1, type.indexOf(']'))); - netscape.security.x509.X509CertInfo objs[] = (netscape.security.x509.X509CertInfo[])table.get(name); + netscape.security.x509.X509CertInfo objs[] = (netscape.security.x509.X509CertInfo[])table.get(name); BASE64Decoder decoder = new BASE64Decoder(); if (objs == null) { objs = new netscape.security.x509.X509CertInfo[size]; @@ -519,7 +519,7 @@ class CMS60LdifParser objs[index].decode(new ByteArrayInputStream(decoder.decodeBuffer(value))); } else if (type.equals("netscape.security.x509.X509CertInfo")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.X509CertInfo obj = + netscape.security.x509.X509CertInfo obj = new netscape.security.x509.X509CertInfo( decoder.decodeBuffer(value)); table.put(name, obj); @@ -538,26 +538,26 @@ class CMS60LdifParser public com.netscape.cmscore.kra.ProofOfArchival buildPOA(byte data[]) throws Exception - { - DerInputStream dis = new DerInputStream(data); + { + DerInputStream dis = new DerInputStream(data); DerValue seq[] = dis.getSequence(0); BigInteger mSerialNo = seq[0].getInteger().toBigInteger(); // subject DerValue subject = seq[1]; - netscape.security.x509.X500Name mSubject = + netscape.security.x509.X500Name mSubject = new netscape.security.x509.X500Name(subject.toByteArray()); // issuer DerValue issuer = seq[2]; - netscape.security.x509.X500Name mIssuer = + netscape.security.x509.X500Name mIssuer = new netscape.security.x509.X500Name(issuer.toByteArray()); // date of archival DerInputStream dateOfArchival = new DerInputStream(seq[3].toByteArray()); Date mDateOfArchival = dateOfArchival.getUTCTime(); - com.netscape.cmscore.kra.ProofOfArchival obj = + com.netscape.cmscore.kra.ProofOfArchival obj = new com.netscape.cmscore.kra.ProofOfArchival(mSerialNo, mSubject.toString(), mIssuer.toString(), mDateOfArchival); return obj; @@ -623,7 +623,7 @@ class DummyAuthManager implements com.netscape.certsrv.authentication.IAuthManag * @return The configuration store of this authentication manager. */ public IConfigStore getConfigStore() - { + { return null; } } diff --git a/base/migrate/TxtTo61/src/Main.java b/base/migrate/TxtTo61/src/Main.java index 8b95ccc97..7f4725f6f 100644 --- a/base/migrate/TxtTo61/src/Main.java +++ b/base/migrate/TxtTo61/src/Main.java @@ -41,7 +41,7 @@ import java.lang.reflect.*; public class Main { - public static void main(String args[]) + public static void main(String args[]) { try { // initialize CryptoManager in CMS 4.5 and later @@ -51,15 +51,15 @@ public class Main // The following call to "java.security.Security.insertProviderAt()" // is no longer commented out in CMS 4.5 and later 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 @@ -82,14 +82,14 @@ public class Main class CMS61LdifParser { // constants - private static final String DN = + private static final String DN = "dn:"; // Directory Servers in CMS 4.7 and later 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 @@ -109,16 +109,16 @@ class CMS61LdifParser } 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; Vector requestAttributes = null; - while ((line = reader.readLine()) != null) { + while ((line = reader.readLine()) != null) { if (line.startsWith(DN)) { dn = line; } @@ -141,33 +141,33 @@ class CMS61LdifParser } else { requestAttributes.setElementAt( (String) - requestAttributes.lastElement() + - "\n" + + requestAttributes.lastElement() + + "\n" + line, requestAttributes.size() - 1); } - } + } } - private byte[] encode(Object value) throws Exception - { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); + private byte[] encode(Object value) throws Exception + { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream os = new ObjectOutputStream(bos); - os.writeObject(value); - os.close(); - return bos.toByteArray(); + os.writeObject(value); + os.close(); + return bos.toByteArray(); } public void parseAttributes(String dn, Vector attrs) throws Exception - { + { Hashtable hashtable = new Hashtable(); for (int i = 0; i < attrs.size(); i++) { String attr = (String)attrs.elementAt(i); buildHashtable(dn, hashtable, attr); } - ByteArrayOutputStream bos = new ByteArrayOutputStream(); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream os = new ObjectOutputStream(bos); Enumeration e = hashtable.keys(); while (e.hasMoreElements()) { @@ -176,8 +176,8 @@ class CMS61LdifParser try { byte data[] = null; - data = encode(value); - os.writeObject(key); + data = encode(value); + os.writeObject(key); os.writeObject(data); } catch (Exception ex) { if (mErrorPrintWriter != null) { @@ -188,12 +188,12 @@ class CMS61LdifParser } } } // while - os.writeObject(null); + os.writeObject(null); os.close(); // print the BASE64 encoding of the Hashtable BASE64Encoder encoder = new BASE64Encoder(); - String attrsStr = encoder.encodeBuffer(bos.toByteArray()); + String attrsStr = encoder.encodeBuffer(bos.toByteArray()); // trim the last "\n" StringBuffer buffer = null; attrsStr = attrsStr.trim(); @@ -207,14 +207,14 @@ class CMS61LdifParser } } - System.out.println(REQUEST_ATTRIBUTES + " " + buffer); + System.out.println(REQUEST_ATTRIBUTES + " " + buffer); } - public void buildHashtable(String dn, Hashtable table, String attr) + public void buildHashtable(String dn, Hashtable table, String attr) throws Exception - { + { // attribute format [name]:[type]=[value] - + int colon = attr.indexOf(':'); if (colon == -1) { if (mErrorPrintWriter != null) { @@ -319,7 +319,7 @@ class CMS61LdifParser com.netscape.certsrv.authentication.AuthToken obj = (com.netscape.certsrv.authentication.AuthToken)table.get(name); if (obj == null) { - com.netscape.certsrv.authentication.IAuthManager mgr = + com.netscape.certsrv.authentication.IAuthManager mgr = new DummyAuthManager(); obj = new com.netscape.certsrv.authentication.AuthToken(mgr); table.put(name, obj); @@ -329,14 +329,14 @@ class CMS61LdifParser String valuevalue = value.substring(value.indexOf('=')+1); if (valuetype.equals("java.lang.String")) { // Processes 'java.math.BigInteger[]': - // + // // Bugzilla Bug #225031 (a.k.a - Raidzilla Bug #58356) - // + // // Processes 'java.lang.String[]': - // + // // Bugzilla Bug #224763 (a.k.a - Raidzilla Bug #57949) // Bugzilla Bug #252240 - // + // obj.set(valuekey, valuevalue); } else if (valuetype.equals("java.util.Date")) { obj.set(valuekey, new Date(Long.parseLong(valuevalue))); @@ -365,45 +365,45 @@ class CMS61LdifParser table.put(name, decoder.decodeBuffer(value)); } else if (type.startsWith("netscape.security.x509.CertificateAlgorithmId")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateAlgorithmId obj = + netscape.security.x509.CertificateAlgorithmId obj = new netscape.security.x509.CertificateAlgorithmId(new ByteArrayInputStream(decoder.decodeBuffer(value))); table.put(name, obj); } else if (type.equals("netscape.security.x509.CertificateChain")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateChain obj = + netscape.security.x509.CertificateChain obj = new netscape.security.x509.CertificateChain(); ByteArrayInputStream bis = new ByteArrayInputStream(decoder.decodeBuffer(value)); obj.decode(bis); table.put(name, obj); } else if (type.equals("netscape.security.x509.CertificateExtensions")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateExtensions obj = + netscape.security.x509.CertificateExtensions obj = new netscape.security.x509.CertificateExtensions( new DerInputStream(decoder.decodeBuffer(value))); table.put(name, obj); } else if (type.equals("netscape.security.x509.CertificateSubjectName")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateSubjectName obj = + netscape.security.x509.CertificateSubjectName obj = new netscape.security.x509.CertificateSubjectName( new ByteArrayInputStream(decoder.decodeBuffer(value))); table.put(name, obj); } else if (type.startsWith("netscape.security.x509.CertificateValidity")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateValidity obj = + netscape.security.x509.CertificateValidity obj = new netscape.security.x509.CertificateValidity(); ByteArrayInputStream bis = new ByteArrayInputStream(decoder.decodeBuffer(value)); obj.decode(bis); table.put(name, obj); } else if (type.equals("netscape.security.x509.CertificateX509Key")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateX509Key obj = + netscape.security.x509.CertificateX509Key obj = new netscape.security.x509.CertificateX509Key( new ByteArrayInputStream(decoder.decodeBuffer(value))); table.put(name, obj); } else if (type.startsWith("com.netscape.certsrv.cert.CertInfo")) { int size = Integer.parseInt(type.substring(type.indexOf('[')+ 1, type.indexOf(','))); int index = Integer.parseInt(type.substring(type.indexOf(',')+1, type.indexOf(']'))); - netscape.security.extensions.CertInfo objs[] = (netscape.security.extensions.CertInfo[])table.get(name); + netscape.security.extensions.CertInfo objs[] = (netscape.security.extensions.CertInfo[])table.get(name); BASE64Decoder decoder = new BASE64Decoder(); if (objs == null) { objs = new netscape.security.extensions.CertInfo[size]; @@ -425,7 +425,7 @@ class CMS61LdifParser } else if (type.startsWith("Integer[")) { int size = Integer.parseInt(type.substring(type.indexOf('[')+ 1, type.indexOf(','))); int index = Integer.parseInt(type.substring(type.indexOf(',')+1, type.indexOf(']'))); - Integer objs[] = (Integer[])table.get(name); + Integer objs[] = (Integer[])table.get(name); if (objs == null) { objs = new Integer[size]; table.put(name, objs); @@ -456,7 +456,7 @@ class CMS61LdifParser obj.set(valuekey, com.netscape.certsrv.dbs.keydb.KeyState.toKeyState(valuevalue)); } else if (valuetype.equals("[B")) { // byte array - + BASE64Decoder decoder = new BASE64Decoder(); obj.set(valuekey, decoder.decodeBuffer(valuevalue)); } else { @@ -466,15 +466,15 @@ class CMS61LdifParser } else if (type.startsWith("com.netscape.certsrv.kra.ProofOfArchival") || type.startsWith("com.netscape.cmscore.kra.ProofOfArchival")) { BASE64Decoder decoder = new BASE64Decoder(); - + ByteArrayInputStream bis = new ByteArrayInputStream(decoder.decodeBuffer(value)); - com.netscape.cmscore.kra.ProofOfArchival obj = + com.netscape.cmscore.kra.ProofOfArchival obj = buildPOA(decoder.decodeBuffer(value)); table.put(name, obj); } else if (type.startsWith("netscape.security.x509.RevokedCertImpl")) { int size = Integer.parseInt(type.substring(type.indexOf('[')+ 1, type.indexOf(','))); int index = Integer.parseInt(type.substring(type.indexOf(',')+1, type.indexOf(']'))); - netscape.security.x509.RevokedCertImpl objs[] = (netscape.security.x509.RevokedCertImpl[])table.get(name); + netscape.security.x509.RevokedCertImpl objs[] = (netscape.security.x509.RevokedCertImpl[])table.get(name); BASE64Decoder decoder = new BASE64Decoder(); if (objs == null) { objs = new netscape.security.x509.RevokedCertImpl[size]; @@ -504,7 +504,7 @@ class CMS61LdifParser } else if (type.startsWith("netscape.security.x509.X509CertImpl[")) { int size = Integer.parseInt(type.substring(type.indexOf('[')+ 1, type.indexOf(','))); int index = Integer.parseInt(type.substring(type.indexOf(',')+1, type.indexOf(']'))); - netscape.security.x509.X509CertImpl objs[] = (netscape.security.x509.X509CertImpl[])table.get(name); + netscape.security.x509.X509CertImpl objs[] = (netscape.security.x509.X509CertImpl[])table.get(name); BASE64Decoder decoder = new BASE64Decoder(); if (objs == null) { objs = new netscape.security.x509.X509CertImpl[size]; @@ -513,7 +513,7 @@ class CMS61LdifParser objs[index] = new netscape.security.x509.X509CertImpl(decoder.decodeBuffer(value)); } else if (type.equals("netscape.security.x509.X509CertImpl")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.X509CertImpl obj = + netscape.security.x509.X509CertImpl obj = new netscape.security.x509.X509CertImpl( decoder.decodeBuffer(value)); table.put(name, obj); @@ -523,7 +523,7 @@ class CMS61LdifParser // "netscape.security.x509.X509CertInfo[" int size = Integer.parseInt(type.substring(type.indexOf('[')+ 1, type.indexOf(','))); int index = Integer.parseInt(type.substring(type.indexOf(',')+1, type.indexOf(']'))); - netscape.security.x509.X509CertInfo objs[] = (netscape.security.x509.X509CertInfo[])table.get(name); + netscape.security.x509.X509CertInfo objs[] = (netscape.security.x509.X509CertInfo[])table.get(name); BASE64Decoder decoder = new BASE64Decoder(); if (objs == null) { objs = new netscape.security.x509.X509CertInfo[size]; @@ -533,7 +533,7 @@ class CMS61LdifParser objs[index].decode(new ByteArrayInputStream(decoder.decodeBuffer(value))); } else if (type.equals("netscape.security.x509.X509CertInfo")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.X509CertInfo obj = + netscape.security.x509.X509CertInfo obj = new netscape.security.x509.X509CertInfo( decoder.decodeBuffer(value)); table.put(name, obj); @@ -552,26 +552,26 @@ class CMS61LdifParser public com.netscape.cmscore.kra.ProofOfArchival buildPOA(byte data[]) throws Exception - { - DerInputStream dis = new DerInputStream(data); + { + DerInputStream dis = new DerInputStream(data); DerValue seq[] = dis.getSequence(0); BigInteger mSerialNo = seq[0].getInteger().toBigInteger(); // subject DerValue subject = seq[1]; - netscape.security.x509.X500Name mSubject = + netscape.security.x509.X500Name mSubject = new netscape.security.x509.X500Name(subject.toByteArray()); // issuer DerValue issuer = seq[2]; - netscape.security.x509.X500Name mIssuer = + netscape.security.x509.X500Name mIssuer = new netscape.security.x509.X500Name(issuer.toByteArray()); // date of archival DerInputStream dateOfArchival = new DerInputStream(seq[3].toByteArray()); Date mDateOfArchival = dateOfArchival.getUTCTime(); - com.netscape.cmscore.kra.ProofOfArchival obj = + com.netscape.cmscore.kra.ProofOfArchival obj = new com.netscape.cmscore.kra.ProofOfArchival(mSerialNo, mSubject.toString(), mIssuer.toString(), mDateOfArchival); return obj; @@ -637,7 +637,7 @@ class DummyAuthManager implements com.netscape.certsrv.authentication.IAuthManag * @return The configuration store of this authentication manager. */ public IConfigStore getConfigStore() - { + { return null; } } diff --git a/base/migrate/TxtTo62/src/Main.java b/base/migrate/TxtTo62/src/Main.java index da48981b7..4af432442 100644 --- a/base/migrate/TxtTo62/src/Main.java +++ b/base/migrate/TxtTo62/src/Main.java @@ -41,7 +41,7 @@ import java.lang.reflect.*; public class Main { - public static void main(String args[]) + public static void main(String args[]) { try { // initialize CryptoManager in CMS 4.5 and later @@ -51,15 +51,15 @@ public class Main // The following call to "java.security.Security.insertProviderAt()" // is no longer commented out in CMS 4.5 and later 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 @@ -82,14 +82,14 @@ public class Main class CMS62LdifParser { // constants - private static final String DN = + private static final String DN = "dn:"; // Directory Servers in CMS 4.7 and later 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 @@ -109,16 +109,16 @@ class CMS62LdifParser } 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; Vector requestAttributes = null; - while ((line = reader.readLine()) != null) { + while ((line = reader.readLine()) != null) { if (line.startsWith(DN)) { dn = line; } @@ -141,33 +141,33 @@ class CMS62LdifParser } else { requestAttributes.setElementAt( (String) - requestAttributes.lastElement() + - "\n" + + requestAttributes.lastElement() + + "\n" + line, requestAttributes.size() - 1); } - } + } } - private byte[] encode(Object value) throws Exception - { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); + private byte[] encode(Object value) throws Exception + { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream os = new ObjectOutputStream(bos); - os.writeObject(value); - os.close(); - return bos.toByteArray(); + os.writeObject(value); + os.close(); + return bos.toByteArray(); } public void parseAttributes(String dn, Vector attrs) throws Exception - { + { Hashtable hashtable = new Hashtable(); for (int i = 0; i < attrs.size(); i++) { String attr = (String)attrs.elementAt(i); buildHashtable(dn, hashtable, attr); } - ByteArrayOutputStream bos = new ByteArrayOutputStream(); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream os = new ObjectOutputStream(bos); Enumeration e = hashtable.keys(); while (e.hasMoreElements()) { @@ -176,8 +176,8 @@ class CMS62LdifParser try { byte data[] = null; - data = encode(value); - os.writeObject(key); + data = encode(value); + os.writeObject(key); os.writeObject(data); } catch (Exception ex) { if (mErrorPrintWriter != null) { @@ -188,12 +188,12 @@ class CMS62LdifParser } } } // while - os.writeObject(null); + os.writeObject(null); os.close(); // print the BASE64 encoding of the Hashtable BASE64Encoder encoder = new BASE64Encoder(); - String attrsStr = encoder.encodeBuffer(bos.toByteArray()); + String attrsStr = encoder.encodeBuffer(bos.toByteArray()); // trim the last "\n" StringBuffer buffer = null; attrsStr = attrsStr.trim(); @@ -207,14 +207,14 @@ class CMS62LdifParser } } - System.out.println(REQUEST_ATTRIBUTES + " " + buffer); + System.out.println(REQUEST_ATTRIBUTES + " " + buffer); } - public void buildHashtable(String dn, Hashtable table, String attr) + public void buildHashtable(String dn, Hashtable table, String attr) throws Exception - { + { // attribute format [name]:[type]=[value] - + int colon = attr.indexOf(':'); if (colon == -1) { if (mErrorPrintWriter != null) { @@ -319,7 +319,7 @@ class CMS62LdifParser com.netscape.certsrv.authentication.AuthToken obj = (com.netscape.certsrv.authentication.AuthToken)table.get(name); if (obj == null) { - com.netscape.certsrv.authentication.IAuthManager mgr = + com.netscape.certsrv.authentication.IAuthManager mgr = new DummyAuthManager(); obj = new com.netscape.certsrv.authentication.AuthToken(mgr); table.put(name, obj); @@ -329,14 +329,14 @@ class CMS62LdifParser String valuevalue = value.substring(value.indexOf('=')+1); if (valuetype.equals("java.lang.String")) { // Processes 'java.math.BigInteger[]': - // + // // Bugzilla Bug #225031 (a.k.a - Raidzilla Bug #58356) - // + // // Processes 'java.lang.String[]': - // + // // Bugzilla Bug #224763 (a.k.a - Raidzilla Bug #57949) // Bugzilla Bug #252240 - // + // obj.set(valuekey, valuevalue); } else if (valuetype.equals("java.util.Date")) { obj.set(valuekey, new Date(Long.parseLong(valuevalue))); @@ -365,19 +365,19 @@ class CMS62LdifParser table.put(name, decoder.decodeBuffer(value)); } else if (type.startsWith("netscape.security.x509.CertificateAlgorithmId")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateAlgorithmId obj = + netscape.security.x509.CertificateAlgorithmId obj = new netscape.security.x509.CertificateAlgorithmId(new ByteArrayInputStream(decoder.decodeBuffer(value))); table.put(name, obj); } else if (type.equals("netscape.security.x509.CertificateChain")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateChain obj = + netscape.security.x509.CertificateChain obj = new netscape.security.x509.CertificateChain(); ByteArrayInputStream bis = new ByteArrayInputStream(decoder.decodeBuffer(value)); obj.decode(bis); table.put(name, obj); } else if (type.equals("netscape.security.x509.CertificateExtensions")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateExtensions obj = + netscape.security.x509.CertificateExtensions obj = new netscape.security.x509.CertificateExtensions(); obj.decodeEx(new ByteArrayInputStream(decoder.decodeBuffer(value))); // CMS 6.2: revised method of decoding objects of type @@ -385,28 +385,28 @@ class CMS62LdifParser table.put(name, obj); } else if (type.equals("netscape.security.x509.CertificateSubjectName")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateSubjectName obj = + netscape.security.x509.CertificateSubjectName obj = new netscape.security.x509.CertificateSubjectName(new DerInputStream(decoder.decodeBuffer(value))); // CMS 6.2: revised method of decoding objects of type // "netscape.security.x509.CertificateSubjectName" table.put(name, obj); } else if (type.startsWith("netscape.security.x509.CertificateValidity")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateValidity obj = + netscape.security.x509.CertificateValidity obj = new netscape.security.x509.CertificateValidity(); ByteArrayInputStream bis = new ByteArrayInputStream(decoder.decodeBuffer(value)); obj.decode(bis); table.put(name, obj); } else if (type.equals("netscape.security.x509.CertificateX509Key")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateX509Key obj = + netscape.security.x509.CertificateX509Key obj = new netscape.security.x509.CertificateX509Key( new ByteArrayInputStream(decoder.decodeBuffer(value))); table.put(name, obj); } else if (type.startsWith("com.netscape.certsrv.cert.CertInfo")) { int size = Integer.parseInt(type.substring(type.indexOf('[')+ 1, type.indexOf(','))); int index = Integer.parseInt(type.substring(type.indexOf(',')+1, type.indexOf(']'))); - netscape.security.extensions.CertInfo objs[] = (netscape.security.extensions.CertInfo[])table.get(name); + netscape.security.extensions.CertInfo objs[] = (netscape.security.extensions.CertInfo[])table.get(name); BASE64Decoder decoder = new BASE64Decoder(); if (objs == null) { objs = new netscape.security.extensions.CertInfo[size]; @@ -428,7 +428,7 @@ class CMS62LdifParser } else if (type.startsWith("Integer[")) { int size = Integer.parseInt(type.substring(type.indexOf('[')+ 1, type.indexOf(','))); int index = Integer.parseInt(type.substring(type.indexOf(',')+1, type.indexOf(']'))); - Integer objs[] = (Integer[])table.get(name); + Integer objs[] = (Integer[])table.get(name); if (objs == null) { objs = new Integer[size]; table.put(name, objs); @@ -459,7 +459,7 @@ class CMS62LdifParser obj.set(valuekey, com.netscape.certsrv.dbs.keydb.KeyState.toKeyState(valuevalue)); } else if (valuetype.equals("[B")) { // byte array - + BASE64Decoder decoder = new BASE64Decoder(); obj.set(valuekey, decoder.decodeBuffer(valuevalue)); } else { @@ -469,15 +469,15 @@ class CMS62LdifParser } else if (type.startsWith("com.netscape.certsrv.kra.ProofOfArchival") || type.startsWith("com.netscape.cmscore.kra.ProofOfArchival")) { BASE64Decoder decoder = new BASE64Decoder(); - + ByteArrayInputStream bis = new ByteArrayInputStream(decoder.decodeBuffer(value)); - com.netscape.cmscore.kra.ProofOfArchival obj = + com.netscape.cmscore.kra.ProofOfArchival obj = buildPOA(decoder.decodeBuffer(value)); table.put(name, obj); } else if (type.startsWith("netscape.security.x509.RevokedCertImpl")) { int size = Integer.parseInt(type.substring(type.indexOf('[')+ 1, type.indexOf(','))); int index = Integer.parseInt(type.substring(type.indexOf(',')+1, type.indexOf(']'))); - netscape.security.x509.RevokedCertImpl objs[] = (netscape.security.x509.RevokedCertImpl[])table.get(name); + netscape.security.x509.RevokedCertImpl objs[] = (netscape.security.x509.RevokedCertImpl[])table.get(name); BASE64Decoder decoder = new BASE64Decoder(); if (objs == null) { objs = new netscape.security.x509.RevokedCertImpl[size]; @@ -511,7 +511,7 @@ class CMS62LdifParser } else if (type.startsWith("netscape.security.x509.X509CertImpl[")) { int size = Integer.parseInt(type.substring(type.indexOf('[')+ 1, type.indexOf(','))); int index = Integer.parseInt(type.substring(type.indexOf(',')+1, type.indexOf(']'))); - netscape.security.x509.X509CertImpl objs[] = (netscape.security.x509.X509CertImpl[])table.get(name); + netscape.security.x509.X509CertImpl objs[] = (netscape.security.x509.X509CertImpl[])table.get(name); BASE64Decoder decoder = new BASE64Decoder(); if (objs == null) { objs = new netscape.security.x509.X509CertImpl[size]; @@ -520,7 +520,7 @@ class CMS62LdifParser objs[index] = new netscape.security.x509.X509CertImpl(decoder.decodeBuffer(value)); } else if (type.equals("netscape.security.x509.X509CertImpl")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.X509CertImpl obj = + netscape.security.x509.X509CertImpl obj = new netscape.security.x509.X509CertImpl( decoder.decodeBuffer(value)); table.put(name, obj); @@ -534,7 +534,7 @@ class CMS62LdifParser // "netscape.security.x509.X509CertInfo[" int size = Integer.parseInt(type.substring(type.indexOf('[')+ 1, type.indexOf(','))); int index = Integer.parseInt(type.substring(type.indexOf(',')+1, type.indexOf(']'))); - netscape.security.x509.X509CertInfo objs[] = (netscape.security.x509.X509CertInfo[])table.get(name); + netscape.security.x509.X509CertInfo objs[] = (netscape.security.x509.X509CertInfo[])table.get(name); BASE64Decoder decoder = new BASE64Decoder(); if (objs == null) { objs = new netscape.security.x509.X509CertInfo[size]; @@ -544,7 +544,7 @@ class CMS62LdifParser objs[index].decode(new ByteArrayInputStream(decoder.decodeBuffer(value))); } else if (type.equals("netscape.security.x509.X509CertInfo")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.X509CertInfo obj = + netscape.security.x509.X509CertInfo obj = new netscape.security.x509.X509CertInfo( decoder.decodeBuffer(value)); table.put(name, obj); @@ -563,26 +563,26 @@ class CMS62LdifParser public com.netscape.cmscore.kra.ProofOfArchival buildPOA(byte data[]) throws Exception - { - DerInputStream dis = new DerInputStream(data); + { + DerInputStream dis = new DerInputStream(data); DerValue seq[] = dis.getSequence(0); BigInteger mSerialNo = seq[0].getInteger().toBigInteger(); // subject DerValue subject = seq[1]; - netscape.security.x509.X500Name mSubject = + netscape.security.x509.X500Name mSubject = new netscape.security.x509.X500Name(subject.toByteArray()); // issuer DerValue issuer = seq[2]; - netscape.security.x509.X500Name mIssuer = + netscape.security.x509.X500Name mIssuer = new netscape.security.x509.X500Name(issuer.toByteArray()); // date of archival DerInputStream dateOfArchival = new DerInputStream(seq[3].toByteArray()); Date mDateOfArchival = dateOfArchival.getUTCTime(); - com.netscape.cmscore.kra.ProofOfArchival obj = + com.netscape.cmscore.kra.ProofOfArchival obj = new com.netscape.cmscore.kra.ProofOfArchival(mSerialNo, mSubject.toString(), mIssuer.toString(), mDateOfArchival); return obj; @@ -648,7 +648,7 @@ class DummyAuthManager implements com.netscape.certsrv.authentication.IAuthManag * @return The configuration store of this authentication manager. */ public IConfigStore getConfigStore() - { + { return null; } } diff --git a/base/migrate/TxtTo70/src/Main.java b/base/migrate/TxtTo70/src/Main.java index bcb1b5a15..967bb5d63 100644 --- a/base/migrate/TxtTo70/src/Main.java +++ b/base/migrate/TxtTo70/src/Main.java @@ -41,7 +41,7 @@ import java.lang.reflect.*; public class Main { - public static void main(String args[]) + public static void main(String args[]) { try { // initialize CryptoManager in CMS 4.5 and later @@ -51,15 +51,15 @@ public class Main // The following call to "java.security.Security.insertProviderAt()" // is no longer commented out in CMS 4.5 and later 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 @@ -82,14 +82,14 @@ public class Main class CMS70LdifParser { // constants - private static final String DN = + private static final String DN = "dn:"; // Directory Servers in CMS 4.7 and later 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 @@ -109,16 +109,16 @@ class CMS70LdifParser } 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; Vector requestAttributes = null; - while ((line = reader.readLine()) != null) { + while ((line = reader.readLine()) != null) { if (line.startsWith(DN)) { dn = line; } @@ -141,33 +141,33 @@ class CMS70LdifParser } else { requestAttributes.setElementAt( (String) - requestAttributes.lastElement() + - "\n" + + requestAttributes.lastElement() + + "\n" + line, requestAttributes.size() - 1); } - } + } } - private byte[] encode(Object value) throws Exception - { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); + private byte[] encode(Object value) throws Exception + { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream os = new ObjectOutputStream(bos); - os.writeObject(value); - os.close(); - return bos.toByteArray(); + os.writeObject(value); + os.close(); + return bos.toByteArray(); } public void parseAttributes(String dn, Vector attrs) throws Exception - { + { Hashtable hashtable = new Hashtable(); for (int i = 0; i < attrs.size(); i++) { String attr = (String)attrs.elementAt(i); buildHashtable(dn, hashtable, attr); } - ByteArrayOutputStream bos = new ByteArrayOutputStream(); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream os = new ObjectOutputStream(bos); Enumeration e = hashtable.keys(); while (e.hasMoreElements()) { @@ -176,8 +176,8 @@ class CMS70LdifParser try { byte data[] = null; - data = encode(value); - os.writeObject(key); + data = encode(value); + os.writeObject(key); os.writeObject(data); } catch (Exception ex) { if (mErrorPrintWriter != null) { @@ -188,12 +188,12 @@ class CMS70LdifParser } } } // while - os.writeObject(null); + os.writeObject(null); os.close(); // print the BASE64 encoding of the Hashtable BASE64Encoder encoder = new BASE64Encoder(); - String attrsStr = encoder.encodeBuffer(bos.toByteArray()); + String attrsStr = encoder.encodeBuffer(bos.toByteArray()); // trim the last "\n" StringBuffer buffer = null; attrsStr = attrsStr.trim(); @@ -207,14 +207,14 @@ class CMS70LdifParser } } - System.out.println(REQUEST_ATTRIBUTES + " " + buffer); + System.out.println(REQUEST_ATTRIBUTES + " " + buffer); } - public void buildHashtable(String dn, Hashtable table, String attr) + public void buildHashtable(String dn, Hashtable table, String attr) throws Exception - { + { // attribute format [name]:[type]=[value] - + int colon = attr.indexOf(':'); if (colon == -1) { if (mErrorPrintWriter != null) { @@ -319,7 +319,7 @@ class CMS70LdifParser com.netscape.certsrv.authentication.AuthToken obj = (com.netscape.certsrv.authentication.AuthToken)table.get(name); if (obj == null) { - com.netscape.certsrv.authentication.IAuthManager mgr = + com.netscape.certsrv.authentication.IAuthManager mgr = new DummyAuthManager(); obj = new com.netscape.certsrv.authentication.AuthToken(mgr); table.put(name, obj); @@ -329,14 +329,14 @@ class CMS70LdifParser String valuevalue = value.substring(value.indexOf('=')+1); if (valuetype.equals("java.lang.String")) { // Processes 'java.math.BigInteger[]': - // + // // Bugzilla Bug #225031 (a.k.a - Raidzilla Bug #58356) - // + // // Processes 'java.lang.String[]': - // + // // Bugzilla Bug #224763 (a.k.a - Raidzilla Bug #57949) // Bugzilla Bug #252240 - // + // obj.set(valuekey, valuevalue); } else if (valuetype.equals("java.util.Date")) { obj.set(valuekey, new Date(Long.parseLong(valuevalue))); @@ -365,19 +365,19 @@ class CMS70LdifParser table.put(name, decoder.decodeBuffer(value)); } else if (type.startsWith("netscape.security.x509.CertificateAlgorithmId")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateAlgorithmId obj = + netscape.security.x509.CertificateAlgorithmId obj = new netscape.security.x509.CertificateAlgorithmId(new ByteArrayInputStream(decoder.decodeBuffer(value))); table.put(name, obj); } else if (type.equals("netscape.security.x509.CertificateChain")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateChain obj = + netscape.security.x509.CertificateChain obj = new netscape.security.x509.CertificateChain(); ByteArrayInputStream bis = new ByteArrayInputStream(decoder.decodeBuffer(value)); obj.decode(bis); table.put(name, obj); } else if (type.equals("netscape.security.x509.CertificateExtensions")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateExtensions obj = + netscape.security.x509.CertificateExtensions obj = new netscape.security.x509.CertificateExtensions(); obj.decodeEx(new ByteArrayInputStream(decoder.decodeBuffer(value))); // CMS 6.2: revised method of decoding objects of type @@ -385,28 +385,28 @@ class CMS70LdifParser table.put(name, obj); } else if (type.equals("netscape.security.x509.CertificateSubjectName")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateSubjectName obj = + netscape.security.x509.CertificateSubjectName obj = new netscape.security.x509.CertificateSubjectName(new DerInputStream(decoder.decodeBuffer(value))); // CMS 6.2: revised method of decoding objects of type // "netscape.security.x509.CertificateSubjectName" table.put(name, obj); } else if (type.startsWith("netscape.security.x509.CertificateValidity")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateValidity obj = + netscape.security.x509.CertificateValidity obj = new netscape.security.x509.CertificateValidity(); ByteArrayInputStream bis = new ByteArrayInputStream(decoder.decodeBuffer(value)); obj.decode(bis); table.put(name, obj); } else if (type.equals("netscape.security.x509.CertificateX509Key")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateX509Key obj = + netscape.security.x509.CertificateX509Key obj = new netscape.security.x509.CertificateX509Key( new ByteArrayInputStream(decoder.decodeBuffer(value))); table.put(name, obj); } else if (type.startsWith("com.netscape.certsrv.cert.CertInfo")) { int size = Integer.parseInt(type.substring(type.indexOf('[')+ 1, type.indexOf(','))); int index = Integer.parseInt(type.substring(type.indexOf(',')+1, type.indexOf(']'))); - netscape.security.extensions.CertInfo objs[] = (netscape.security.extensions.CertInfo[])table.get(name); + netscape.security.extensions.CertInfo objs[] = (netscape.security.extensions.CertInfo[])table.get(name); BASE64Decoder decoder = new BASE64Decoder(); if (objs == null) { objs = new netscape.security.extensions.CertInfo[size]; @@ -428,7 +428,7 @@ class CMS70LdifParser } else if (type.startsWith("Integer[")) { int size = Integer.parseInt(type.substring(type.indexOf('[')+ 1, type.indexOf(','))); int index = Integer.parseInt(type.substring(type.indexOf(',')+1, type.indexOf(']'))); - Integer objs[] = (Integer[])table.get(name); + Integer objs[] = (Integer[])table.get(name); if (objs == null) { objs = new Integer[size]; table.put(name, objs); @@ -459,7 +459,7 @@ class CMS70LdifParser obj.set(valuekey, com.netscape.certsrv.dbs.keydb.KeyState.toKeyState(valuevalue)); } else if (valuetype.equals("[B")) { // byte array - + BASE64Decoder decoder = new BASE64Decoder(); obj.set(valuekey, decoder.decodeBuffer(valuevalue)); } else { @@ -473,15 +473,15 @@ class CMS70LdifParser } else if (type.startsWith("com.netscape.certsrv.kra.ProofOfArchival") || type.startsWith("com.netscape.cmscore.kra.ProofOfArchival")) { BASE64Decoder decoder = new BASE64Decoder(); - + ByteArrayInputStream bis = new ByteArrayInputStream(decoder.decodeBuffer(value)); - com.netscape.cmscore.kra.ProofOfArchival obj = + com.netscape.cmscore.kra.ProofOfArchival obj = buildPOA(decoder.decodeBuffer(value)); table.put(name, obj); } else if (type.startsWith("netscape.security.x509.RevokedCertImpl")) { int size = Integer.parseInt(type.substring(type.indexOf('[')+ 1, type.indexOf(','))); int index = Integer.parseInt(type.substring(type.indexOf(',')+1, type.indexOf(']'))); - netscape.security.x509.RevokedCertImpl objs[] = (netscape.security.x509.RevokedCertImpl[])table.get(name); + netscape.security.x509.RevokedCertImpl objs[] = (netscape.security.x509.RevokedCertImpl[])table.get(name); BASE64Decoder decoder = new BASE64Decoder(); if (objs == null) { objs = new netscape.security.x509.RevokedCertImpl[size]; @@ -511,7 +511,7 @@ class CMS70LdifParser } else if (type.startsWith("netscape.security.x509.X509CertImpl[")) { int size = Integer.parseInt(type.substring(type.indexOf('[')+ 1, type.indexOf(','))); int index = Integer.parseInt(type.substring(type.indexOf(',')+1, type.indexOf(']'))); - netscape.security.x509.X509CertImpl objs[] = (netscape.security.x509.X509CertImpl[])table.get(name); + netscape.security.x509.X509CertImpl objs[] = (netscape.security.x509.X509CertImpl[])table.get(name); BASE64Decoder decoder = new BASE64Decoder(); if (objs == null) { objs = new netscape.security.x509.X509CertImpl[size]; @@ -520,7 +520,7 @@ class CMS70LdifParser objs[index] = new netscape.security.x509.X509CertImpl(decoder.decodeBuffer(value)); } else if (type.equals("netscape.security.x509.X509CertImpl")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.X509CertImpl obj = + netscape.security.x509.X509CertImpl obj = new netscape.security.x509.X509CertImpl( decoder.decodeBuffer(value)); table.put(name, obj); @@ -534,7 +534,7 @@ class CMS70LdifParser // "netscape.security.x509.X509CertInfo[" int size = Integer.parseInt(type.substring(type.indexOf('[')+ 1, type.indexOf(','))); int index = Integer.parseInt(type.substring(type.indexOf(',')+1, type.indexOf(']'))); - netscape.security.x509.X509CertInfo objs[] = (netscape.security.x509.X509CertInfo[])table.get(name); + netscape.security.x509.X509CertInfo objs[] = (netscape.security.x509.X509CertInfo[])table.get(name); BASE64Decoder decoder = new BASE64Decoder(); if (objs == null) { objs = new netscape.security.x509.X509CertInfo[size]; @@ -544,7 +544,7 @@ class CMS70LdifParser objs[index].decode(new ByteArrayInputStream(decoder.decodeBuffer(value))); } else if (type.equals("netscape.security.x509.X509CertInfo")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.X509CertInfo obj = + netscape.security.x509.X509CertInfo obj = new netscape.security.x509.X509CertInfo( decoder.decodeBuffer(value)); table.put(name, obj); @@ -563,26 +563,26 @@ class CMS70LdifParser public com.netscape.cmscore.kra.ProofOfArchival buildPOA(byte data[]) throws Exception - { - DerInputStream dis = new DerInputStream(data); + { + DerInputStream dis = new DerInputStream(data); DerValue seq[] = dis.getSequence(0); BigInteger mSerialNo = seq[0].getInteger().toBigInteger(); // subject DerValue subject = seq[1]; - netscape.security.x509.X500Name mSubject = + netscape.security.x509.X500Name mSubject = new netscape.security.x509.X500Name(subject.toByteArray()); // issuer DerValue issuer = seq[2]; - netscape.security.x509.X500Name mIssuer = + netscape.security.x509.X500Name mIssuer = new netscape.security.x509.X500Name(issuer.toByteArray()); // date of archival DerInputStream dateOfArchival = new DerInputStream(seq[3].toByteArray()); Date mDateOfArchival = dateOfArchival.getUTCTime(); - com.netscape.cmscore.kra.ProofOfArchival obj = + com.netscape.cmscore.kra.ProofOfArchival obj = new com.netscape.cmscore.kra.ProofOfArchival(mSerialNo, mSubject.toString(), mIssuer.toString(), mDateOfArchival); return obj; @@ -648,7 +648,7 @@ class DummyAuthManager implements com.netscape.certsrv.authentication.IAuthManag * @return The configuration store of this authentication manager. */ public IConfigStore getConfigStore() - { + { return null; } } diff --git a/base/migrate/TxtTo71/src/Main.java b/base/migrate/TxtTo71/src/Main.java index 7dcb13943..a9421ebdc 100644 --- a/base/migrate/TxtTo71/src/Main.java +++ b/base/migrate/TxtTo71/src/Main.java @@ -41,7 +41,7 @@ import java.lang.reflect.*; public class Main { - public static void main(String args[]) + public static void main(String args[]) { try { // initialize CryptoManager in CMS 4.5 and later @@ -51,15 +51,15 @@ public class Main // The following call to "java.security.Security.insertProviderAt()" // is no longer commented out in CMS 4.5 and later 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 @@ -82,14 +82,14 @@ public class Main class CMS71LdifParser { // constants - private static final String DN = + private static final String DN = "dn:"; // Directory Servers in CMS 4.7 and later 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 @@ -109,16 +109,16 @@ class CMS71LdifParser } 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; Vector requestAttributes = null; - while ((line = reader.readLine()) != null) { + while ((line = reader.readLine()) != null) { if (line.startsWith(DN)) { dn = line; } @@ -141,33 +141,33 @@ class CMS71LdifParser } else { requestAttributes.setElementAt( (String) - requestAttributes.lastElement() + - "\n" + + requestAttributes.lastElement() + + "\n" + line, requestAttributes.size() - 1); } - } + } } - private byte[] encode(Object value) throws Exception - { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); + private byte[] encode(Object value) throws Exception + { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream os = new ObjectOutputStream(bos); - os.writeObject(value); - os.close(); - return bos.toByteArray(); + os.writeObject(value); + os.close(); + return bos.toByteArray(); } public void parseAttributes(String dn, Vector attrs) throws Exception - { + { Hashtable hashtable = new Hashtable(); for (int i = 0; i < attrs.size(); i++) { String attr = (String)attrs.elementAt(i); buildHashtable(dn, hashtable, attr); } - ByteArrayOutputStream bos = new ByteArrayOutputStream(); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream os = new ObjectOutputStream(bos); Enumeration e = hashtable.keys(); while (e.hasMoreElements()) { @@ -176,8 +176,8 @@ class CMS71LdifParser try { byte data[] = null; - data = encode(value); - os.writeObject(key); + data = encode(value); + os.writeObject(key); os.writeObject(data); } catch (Exception ex) { if (mErrorPrintWriter != null) { @@ -188,12 +188,12 @@ class CMS71LdifParser } } } // while - os.writeObject(null); + os.writeObject(null); os.close(); // print the BASE64 encoding of the Hashtable BASE64Encoder encoder = new BASE64Encoder(); - String attrsStr = encoder.encodeBuffer(bos.toByteArray()); + String attrsStr = encoder.encodeBuffer(bos.toByteArray()); // trim the last "\n" StringBuffer buffer = null; attrsStr = attrsStr.trim(); @@ -207,14 +207,14 @@ class CMS71LdifParser } } - System.out.println(REQUEST_ATTRIBUTES + " " + buffer); + System.out.println(REQUEST_ATTRIBUTES + " " + buffer); } - public void buildHashtable(String dn, Hashtable table, String attr) + public void buildHashtable(String dn, Hashtable table, String attr) throws Exception - { + { // attribute format [name]:[type]=[value] - + int colon = attr.indexOf(':'); if (colon == -1) { if (mErrorPrintWriter != null) { @@ -319,7 +319,7 @@ class CMS71LdifParser com.netscape.certsrv.authentication.AuthToken obj = (com.netscape.certsrv.authentication.AuthToken)table.get(name); if (obj == null) { - com.netscape.certsrv.authentication.IAuthManager mgr = + com.netscape.certsrv.authentication.IAuthManager mgr = new DummyAuthManager(); obj = new com.netscape.certsrv.authentication.AuthToken(mgr); table.put(name, obj); @@ -329,14 +329,14 @@ class CMS71LdifParser String valuevalue = value.substring(value.indexOf('=')+1); if (valuetype.equals("java.lang.String")) { // Processes 'java.math.BigInteger[]': - // + // // Bugzilla Bug #225031 (a.k.a - Raidzilla Bug #58356) - // + // // Processes 'java.lang.String[]': - // + // // Bugzilla Bug #224763 (a.k.a - Raidzilla Bug #57949) // Bugzilla Bug #252240 - // + // obj.set(valuekey, valuevalue); } else if (valuetype.equals("java.util.Date")) { obj.set(valuekey, new Date(Long.parseLong(valuevalue))); @@ -365,19 +365,19 @@ class CMS71LdifParser table.put(name, decoder.decodeBuffer(value)); } else if (type.startsWith("netscape.security.x509.CertificateAlgorithmId")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateAlgorithmId obj = + netscape.security.x509.CertificateAlgorithmId obj = new netscape.security.x509.CertificateAlgorithmId(new ByteArrayInputStream(decoder.decodeBuffer(value))); table.put(name, obj); } else if (type.equals("netscape.security.x509.CertificateChain")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateChain obj = + netscape.security.x509.CertificateChain obj = new netscape.security.x509.CertificateChain(); ByteArrayInputStream bis = new ByteArrayInputStream(decoder.decodeBuffer(value)); obj.decode(bis); table.put(name, obj); } else if (type.equals("netscape.security.x509.CertificateExtensions")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateExtensions obj = + netscape.security.x509.CertificateExtensions obj = new netscape.security.x509.CertificateExtensions(); obj.decodeEx(new ByteArrayInputStream(decoder.decodeBuffer(value))); // CMS 6.2: revised method of decoding objects of type @@ -385,28 +385,28 @@ class CMS71LdifParser table.put(name, obj); } else if (type.equals("netscape.security.x509.CertificateSubjectName")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateSubjectName obj = + netscape.security.x509.CertificateSubjectName obj = new netscape.security.x509.CertificateSubjectName(new DerInputStream(decoder.decodeBuffer(value))); // CMS 6.2: revised method of decoding objects of type // "netscape.security.x509.CertificateSubjectName" table.put(name, obj); } else if (type.startsWith("netscape.security.x509.CertificateValidity")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateValidity obj = + netscape.security.x509.CertificateValidity obj = new netscape.security.x509.CertificateValidity(); ByteArrayInputStream bis = new ByteArrayInputStream(decoder.decodeBuffer(value)); obj.decode(bis); table.put(name, obj); } else if (type.equals("netscape.security.x509.CertificateX509Key")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateX509Key obj = + netscape.security.x509.CertificateX509Key obj = new netscape.security.x509.CertificateX509Key( new ByteArrayInputStream(decoder.decodeBuffer(value))); table.put(name, obj); } else if (type.startsWith("com.netscape.certsrv.cert.CertInfo")) { int size = Integer.parseInt(type.substring(type.indexOf('[')+ 1, type.indexOf(','))); int index = Integer.parseInt(type.substring(type.indexOf(',')+1, type.indexOf(']'))); - netscape.security.extensions.CertInfo objs[] = (netscape.security.extensions.CertInfo[])table.get(name); + netscape.security.extensions.CertInfo objs[] = (netscape.security.extensions.CertInfo[])table.get(name); BASE64Decoder decoder = new BASE64Decoder(); if (objs == null) { objs = new netscape.security.extensions.CertInfo[size]; @@ -428,7 +428,7 @@ class CMS71LdifParser } else if (type.startsWith("Integer[")) { int size = Integer.parseInt(type.substring(type.indexOf('[')+ 1, type.indexOf(','))); int index = Integer.parseInt(type.substring(type.indexOf(',')+1, type.indexOf(']'))); - Integer objs[] = (Integer[])table.get(name); + Integer objs[] = (Integer[])table.get(name); if (objs == null) { objs = new Integer[size]; table.put(name, objs); @@ -459,7 +459,7 @@ class CMS71LdifParser obj.set(valuekey, com.netscape.certsrv.dbs.keydb.KeyState.toKeyState(valuevalue)); } else if (valuetype.equals("[B")) { // byte array - + BASE64Decoder decoder = new BASE64Decoder(); obj.set(valuekey, decoder.decodeBuffer(valuevalue)); } else { @@ -473,15 +473,15 @@ class CMS71LdifParser } else if (type.startsWith("com.netscape.certsrv.kra.ProofOfArchival") || type.startsWith("com.netscape.cmscore.kra.ProofOfArchival")) { BASE64Decoder decoder = new BASE64Decoder(); - + ByteArrayInputStream bis = new ByteArrayInputStream(decoder.decodeBuffer(value)); - com.netscape.cmscore.kra.ProofOfArchival obj = + com.netscape.cmscore.kra.ProofOfArchival obj = buildPOA(decoder.decodeBuffer(value)); table.put(name, obj); } else if (type.startsWith("netscape.security.x509.RevokedCertImpl")) { int size = Integer.parseInt(type.substring(type.indexOf('[')+ 1, type.indexOf(','))); int index = Integer.parseInt(type.substring(type.indexOf(',')+1, type.indexOf(']'))); - netscape.security.x509.RevokedCertImpl objs[] = (netscape.security.x509.RevokedCertImpl[])table.get(name); + netscape.security.x509.RevokedCertImpl objs[] = (netscape.security.x509.RevokedCertImpl[])table.get(name); BASE64Decoder decoder = new BASE64Decoder(); if (objs == null) { objs = new netscape.security.x509.RevokedCertImpl[size]; @@ -511,7 +511,7 @@ class CMS71LdifParser } else if (type.startsWith("netscape.security.x509.X509CertImpl[")) { int size = Integer.parseInt(type.substring(type.indexOf('[')+ 1, type.indexOf(','))); int index = Integer.parseInt(type.substring(type.indexOf(',')+1, type.indexOf(']'))); - netscape.security.x509.X509CertImpl objs[] = (netscape.security.x509.X509CertImpl[])table.get(name); + netscape.security.x509.X509CertImpl objs[] = (netscape.security.x509.X509CertImpl[])table.get(name); BASE64Decoder decoder = new BASE64Decoder(); if (objs == null) { objs = new netscape.security.x509.X509CertImpl[size]; @@ -520,7 +520,7 @@ class CMS71LdifParser objs[index] = new netscape.security.x509.X509CertImpl(decoder.decodeBuffer(value)); } else if (type.equals("netscape.security.x509.X509CertImpl")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.X509CertImpl obj = + netscape.security.x509.X509CertImpl obj = new netscape.security.x509.X509CertImpl( decoder.decodeBuffer(value)); table.put(name, obj); @@ -534,7 +534,7 @@ class CMS71LdifParser // "netscape.security.x509.X509CertInfo[" int size = Integer.parseInt(type.substring(type.indexOf('[')+ 1, type.indexOf(','))); int index = Integer.parseInt(type.substring(type.indexOf(',')+1, type.indexOf(']'))); - netscape.security.x509.X509CertInfo objs[] = (netscape.security.x509.X509CertInfo[])table.get(name); + netscape.security.x509.X509CertInfo objs[] = (netscape.security.x509.X509CertInfo[])table.get(name); BASE64Decoder decoder = new BASE64Decoder(); if (objs == null) { objs = new netscape.security.x509.X509CertInfo[size]; @@ -544,7 +544,7 @@ class CMS71LdifParser objs[index].decode(new ByteArrayInputStream(decoder.decodeBuffer(value))); } else if (type.equals("netscape.security.x509.X509CertInfo")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.X509CertInfo obj = + netscape.security.x509.X509CertInfo obj = new netscape.security.x509.X509CertInfo( decoder.decodeBuffer(value)); table.put(name, obj); @@ -563,26 +563,26 @@ class CMS71LdifParser public com.netscape.cmscore.kra.ProofOfArchival buildPOA(byte data[]) throws Exception - { - DerInputStream dis = new DerInputStream(data); + { + DerInputStream dis = new DerInputStream(data); DerValue seq[] = dis.getSequence(0); BigInteger mSerialNo = seq[0].getInteger().toBigInteger(); // subject DerValue subject = seq[1]; - netscape.security.x509.X500Name mSubject = + netscape.security.x509.X500Name mSubject = new netscape.security.x509.X500Name(subject.toByteArray()); // issuer DerValue issuer = seq[2]; - netscape.security.x509.X500Name mIssuer = + netscape.security.x509.X500Name mIssuer = new netscape.security.x509.X500Name(issuer.toByteArray()); // date of archival DerInputStream dateOfArchival = new DerInputStream(seq[3].toByteArray()); Date mDateOfArchival = dateOfArchival.getUTCTime(); - com.netscape.cmscore.kra.ProofOfArchival obj = + com.netscape.cmscore.kra.ProofOfArchival obj = new com.netscape.cmscore.kra.ProofOfArchival(mSerialNo, mSubject.toString(), mIssuer.toString(), mDateOfArchival); return obj; @@ -648,7 +648,7 @@ class DummyAuthManager implements com.netscape.certsrv.authentication.IAuthManag * @return The configuration store of this authentication manager. */ public IConfigStore getConfigStore() - { + { return null; } } diff --git a/base/migrate/TxtTo72/src/Main.java b/base/migrate/TxtTo72/src/Main.java index 9b22cd84d..002485055 100644 --- a/base/migrate/TxtTo72/src/Main.java +++ b/base/migrate/TxtTo72/src/Main.java @@ -41,7 +41,7 @@ import java.lang.reflect.*; public class Main { - public static void main(String args[]) + public static void main(String args[]) { try { // initialize CryptoManager in CMS 4.5 and later @@ -51,15 +51,15 @@ public class Main // The following call to "java.security.Security.insertProviderAt()" // is no longer commented out in CMS 4.5 and later 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 @@ -82,14 +82,14 @@ public class Main class CMS72LdifParser { // constants - private static final String DN = + private static final String DN = "dn:"; // Directory Servers in CMS 4.7 and later 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 @@ -109,16 +109,16 @@ class CMS72LdifParser } 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; Vector requestAttributes = null; - while ((line = reader.readLine()) != null) { + while ((line = reader.readLine()) != null) { if (line.startsWith(DN)) { dn = line; } @@ -141,33 +141,33 @@ class CMS72LdifParser } else { requestAttributes.setElementAt( (String) - requestAttributes.lastElement() + - "\n" + + requestAttributes.lastElement() + + "\n" + line, requestAttributes.size() - 1); } - } + } } - private byte[] encode(Object value) throws Exception - { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); + private byte[] encode(Object value) throws Exception + { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream os = new ObjectOutputStream(bos); - os.writeObject(value); - os.close(); - return bos.toByteArray(); + os.writeObject(value); + os.close(); + return bos.toByteArray(); } public void parseAttributes(String dn, Vector attrs) throws Exception - { + { Hashtable hashtable = new Hashtable(); for (int i = 0; i < attrs.size(); i++) { String attr = (String)attrs.elementAt(i); buildHashtable(dn, hashtable, attr); } - ByteArrayOutputStream bos = new ByteArrayOutputStream(); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream os = new ObjectOutputStream(bos); Enumeration e = hashtable.keys(); while (e.hasMoreElements()) { @@ -176,8 +176,8 @@ class CMS72LdifParser try { byte data[] = null; - data = encode(value); - os.writeObject(key); + data = encode(value); + os.writeObject(key); os.writeObject(data); } catch (Exception ex) { if (mErrorPrintWriter != null) { @@ -188,12 +188,12 @@ class CMS72LdifParser } } } // while - os.writeObject(null); + os.writeObject(null); os.close(); // print the BASE64 encoding of the Hashtable BASE64Encoder encoder = new BASE64Encoder(); - String attrsStr = encoder.encodeBuffer(bos.toByteArray()); + String attrsStr = encoder.encodeBuffer(bos.toByteArray()); // trim the last "\n" StringBuffer buffer = null; attrsStr = attrsStr.trim(); @@ -207,14 +207,14 @@ class CMS72LdifParser } } - System.out.println(REQUEST_ATTRIBUTES + " " + buffer); + System.out.println(REQUEST_ATTRIBUTES + " " + buffer); } - public void buildHashtable(String dn, Hashtable table, String attr) + public void buildHashtable(String dn, Hashtable table, String attr) throws Exception - { + { // attribute format [name]:[type]=[value] - + int colon = attr.indexOf(':'); if (colon == -1) { if (mErrorPrintWriter != null) { @@ -319,7 +319,7 @@ class CMS72LdifParser com.netscape.certsrv.authentication.AuthToken obj = (com.netscape.certsrv.authentication.AuthToken)table.get(name); if (obj == null) { - com.netscape.certsrv.authentication.IAuthManager mgr = + com.netscape.certsrv.authentication.IAuthManager mgr = new DummyAuthManager(); obj = new com.netscape.certsrv.authentication.AuthToken(mgr); table.put(name, obj); @@ -329,14 +329,14 @@ class CMS72LdifParser String valuevalue = value.substring(value.indexOf('=')+1); if (valuetype.equals("java.lang.String")) { // Processes 'java.math.BigInteger[]': - // + // // Bugzilla Bug #225031 (a.k.a - Raidzilla Bug #58356) - // + // // Processes 'java.lang.String[]': - // + // // Bugzilla Bug #224763 (a.k.a - Raidzilla Bug #57949) // Bugzilla Bug #252240 - // + // obj.set(valuekey, valuevalue); } else if (valuetype.equals("java.util.Date")) { obj.set(valuekey, new Date(Long.parseLong(valuevalue))); @@ -365,19 +365,19 @@ class CMS72LdifParser table.put(name, decoder.decodeBuffer(value)); } else if (type.startsWith("netscape.security.x509.CertificateAlgorithmId")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateAlgorithmId obj = + netscape.security.x509.CertificateAlgorithmId obj = new netscape.security.x509.CertificateAlgorithmId(new ByteArrayInputStream(decoder.decodeBuffer(value))); table.put(name, obj); } else if (type.equals("netscape.security.x509.CertificateChain")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateChain obj = + netscape.security.x509.CertificateChain obj = new netscape.security.x509.CertificateChain(); ByteArrayInputStream bis = new ByteArrayInputStream(decoder.decodeBuffer(value)); obj.decode(bis); table.put(name, obj); } else if (type.equals("netscape.security.x509.CertificateExtensions")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateExtensions obj = + netscape.security.x509.CertificateExtensions obj = new netscape.security.x509.CertificateExtensions(); obj.decodeEx(new ByteArrayInputStream(decoder.decodeBuffer(value))); // CMS 6.2: revised method of decoding objects of type @@ -385,28 +385,28 @@ class CMS72LdifParser table.put(name, obj); } else if (type.equals("netscape.security.x509.CertificateSubjectName")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateSubjectName obj = + netscape.security.x509.CertificateSubjectName obj = new netscape.security.x509.CertificateSubjectName(new DerInputStream(decoder.decodeBuffer(value))); // CMS 6.2: revised method of decoding objects of type // "netscape.security.x509.CertificateSubjectName" table.put(name, obj); } else if (type.startsWith("netscape.security.x509.CertificateValidity")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateValidity obj = + netscape.security.x509.CertificateValidity obj = new netscape.security.x509.CertificateValidity(); ByteArrayInputStream bis = new ByteArrayInputStream(decoder.decodeBuffer(value)); obj.decode(bis); table.put(name, obj); } else if (type.equals("netscape.security.x509.CertificateX509Key")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateX509Key obj = + netscape.security.x509.CertificateX509Key obj = new netscape.security.x509.CertificateX509Key( new ByteArrayInputStream(decoder.decodeBuffer(value))); table.put(name, obj); } else if (type.startsWith("com.netscape.certsrv.cert.CertInfo")) { int size = Integer.parseInt(type.substring(type.indexOf('[')+ 1, type.indexOf(','))); int index = Integer.parseInt(type.substring(type.indexOf(',')+1, type.indexOf(']'))); - netscape.security.extensions.CertInfo objs[] = (netscape.security.extensions.CertInfo[])table.get(name); + netscape.security.extensions.CertInfo objs[] = (netscape.security.extensions.CertInfo[])table.get(name); BASE64Decoder decoder = new BASE64Decoder(); if (objs == null) { objs = new netscape.security.extensions.CertInfo[size]; @@ -428,7 +428,7 @@ class CMS72LdifParser } else if (type.startsWith("Integer[")) { int size = Integer.parseInt(type.substring(type.indexOf('[')+ 1, type.indexOf(','))); int index = Integer.parseInt(type.substring(type.indexOf(',')+1, type.indexOf(']'))); - Integer objs[] = (Integer[])table.get(name); + Integer objs[] = (Integer[])table.get(name); if (objs == null) { objs = new Integer[size]; table.put(name, objs); @@ -463,7 +463,7 @@ class CMS72LdifParser obj.set(valuekey, com.netscape.certsrv.dbs.keydb.KeyState.toKeyState(valuevalue)); } else if (valuetype.equals("[B")) { // byte array - + BASE64Decoder decoder = new BASE64Decoder(); obj.set(valuekey, decoder.decodeBuffer(valuevalue)); } else { @@ -477,15 +477,15 @@ class CMS72LdifParser } else if (type.startsWith("com.netscape.certsrv.kra.ProofOfArchival") || type.startsWith("com.netscape.cmscore.kra.ProofOfArchival")) { BASE64Decoder decoder = new BASE64Decoder(); - + ByteArrayInputStream bis = new ByteArrayInputStream(decoder.decodeBuffer(value)); - com.netscape.certsrv.kra.ProofOfArchival obj = + com.netscape.certsrv.kra.ProofOfArchival obj = buildPOA(decoder.decodeBuffer(value)); table.put(name, obj); } else if (type.startsWith("netscape.security.x509.RevokedCertImpl")) { int size = Integer.parseInt(type.substring(type.indexOf('[')+ 1, type.indexOf(','))); int index = Integer.parseInt(type.substring(type.indexOf(',')+1, type.indexOf(']'))); - netscape.security.x509.RevokedCertImpl objs[] = (netscape.security.x509.RevokedCertImpl[])table.get(name); + netscape.security.x509.RevokedCertImpl objs[] = (netscape.security.x509.RevokedCertImpl[])table.get(name); BASE64Decoder decoder = new BASE64Decoder(); if (objs == null) { objs = new netscape.security.x509.RevokedCertImpl[size]; @@ -515,7 +515,7 @@ class CMS72LdifParser } else if (type.startsWith("netscape.security.x509.X509CertImpl[")) { int size = Integer.parseInt(type.substring(type.indexOf('[')+ 1, type.indexOf(','))); int index = Integer.parseInt(type.substring(type.indexOf(',')+1, type.indexOf(']'))); - netscape.security.x509.X509CertImpl objs[] = (netscape.security.x509.X509CertImpl[])table.get(name); + netscape.security.x509.X509CertImpl objs[] = (netscape.security.x509.X509CertImpl[])table.get(name); BASE64Decoder decoder = new BASE64Decoder(); if (objs == null) { objs = new netscape.security.x509.X509CertImpl[size]; @@ -524,7 +524,7 @@ class CMS72LdifParser objs[index] = new netscape.security.x509.X509CertImpl(decoder.decodeBuffer(value)); } else if (type.equals("netscape.security.x509.X509CertImpl")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.X509CertImpl obj = + netscape.security.x509.X509CertImpl obj = new netscape.security.x509.X509CertImpl( decoder.decodeBuffer(value)); table.put(name, obj); @@ -538,7 +538,7 @@ class CMS72LdifParser // "netscape.security.x509.X509CertInfo[" int size = Integer.parseInt(type.substring(type.indexOf('[')+ 1, type.indexOf(','))); int index = Integer.parseInt(type.substring(type.indexOf(',')+1, type.indexOf(']'))); - netscape.security.x509.X509CertInfo objs[] = (netscape.security.x509.X509CertInfo[])table.get(name); + netscape.security.x509.X509CertInfo objs[] = (netscape.security.x509.X509CertInfo[])table.get(name); BASE64Decoder decoder = new BASE64Decoder(); if (objs == null) { objs = new netscape.security.x509.X509CertInfo[size]; @@ -548,7 +548,7 @@ class CMS72LdifParser objs[index].decode(new ByteArrayInputStream(decoder.decodeBuffer(value))); } else if (type.equals("netscape.security.x509.X509CertInfo")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.X509CertInfo obj = + netscape.security.x509.X509CertInfo obj = new netscape.security.x509.X509CertInfo( decoder.decodeBuffer(value)); table.put(name, obj); @@ -567,26 +567,26 @@ class CMS72LdifParser public com.netscape.certsrv.kra.ProofOfArchival buildPOA(byte data[]) throws Exception - { - DerInputStream dis = new DerInputStream(data); + { + DerInputStream dis = new DerInputStream(data); DerValue seq[] = dis.getSequence(0); BigInteger mSerialNo = seq[0].getInteger().toBigInteger(); // subject DerValue subject = seq[1]; - netscape.security.x509.X500Name mSubject = + netscape.security.x509.X500Name mSubject = new netscape.security.x509.X500Name(subject.toByteArray()); // issuer DerValue issuer = seq[2]; - netscape.security.x509.X500Name mIssuer = + netscape.security.x509.X500Name mIssuer = new netscape.security.x509.X500Name(issuer.toByteArray()); // date of archival DerInputStream dateOfArchival = new DerInputStream(seq[3].toByteArray()); Date mDateOfArchival = dateOfArchival.getUTCTime(); - com.netscape.certsrv.kra.ProofOfArchival obj = + com.netscape.certsrv.kra.ProofOfArchival obj = new com.netscape.certsrv.kra.ProofOfArchival(mSerialNo, mSubject.toString(), mIssuer.toString(), mDateOfArchival); return obj; @@ -652,7 +652,7 @@ class DummyAuthManager implements com.netscape.certsrv.authentication.IAuthManag * @return The configuration store of this authentication manager. */ public IConfigStore getConfigStore() - { + { return null; } } diff --git a/base/migrate/TxtTo73/src/Main.java b/base/migrate/TxtTo73/src/Main.java index 4ffe0c120..6272b33a4 100644 --- a/base/migrate/TxtTo73/src/Main.java +++ b/base/migrate/TxtTo73/src/Main.java @@ -41,7 +41,7 @@ import java.lang.reflect.*; public class Main { - public static void main(String args[]) + public static void main(String args[]) { try { // initialize CryptoManager in CMS 4.5 and later @@ -51,15 +51,15 @@ public class Main // The following call to "java.security.Security.insertProviderAt()" // is no longer commented out in CMS 4.5 and later 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 @@ -82,14 +82,14 @@ public class Main class CMS73LdifParser { // constants - private static final String DN = + private static final String DN = "dn:"; // Directory Servers in CMS 4.7 and later 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 @@ -109,16 +109,16 @@ class CMS73LdifParser } 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; Vector requestAttributes = null; - while ((line = reader.readLine()) != null) { + while ((line = reader.readLine()) != null) { if (line.startsWith(DN)) { dn = line; } @@ -141,33 +141,33 @@ class CMS73LdifParser } else { requestAttributes.setElementAt( (String) - requestAttributes.lastElement() + - "\n" + + requestAttributes.lastElement() + + "\n" + line, requestAttributes.size() - 1); } - } + } } - private byte[] encode(Object value) throws Exception - { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); + private byte[] encode(Object value) throws Exception + { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream os = new ObjectOutputStream(bos); - os.writeObject(value); - os.close(); - return bos.toByteArray(); + os.writeObject(value); + os.close(); + return bos.toByteArray(); } public void parseAttributes(String dn, Vector attrs) throws Exception - { + { Hashtable hashtable = new Hashtable(); for (int i = 0; i < attrs.size(); i++) { String attr = (String)attrs.elementAt(i); buildHashtable(dn, hashtable, attr); } - ByteArrayOutputStream bos = new ByteArrayOutputStream(); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream os = new ObjectOutputStream(bos); Enumeration e = hashtable.keys(); while (e.hasMoreElements()) { @@ -176,8 +176,8 @@ class CMS73LdifParser try { byte data[] = null; - data = encode(value); - os.writeObject(key); + data = encode(value); + os.writeObject(key); os.writeObject(data); } catch (Exception ex) { if (mErrorPrintWriter != null) { @@ -188,12 +188,12 @@ class CMS73LdifParser } } } // while - os.writeObject(null); + os.writeObject(null); os.close(); // print the BASE64 encoding of the Hashtable BASE64Encoder encoder = new BASE64Encoder(); - String attrsStr = encoder.encodeBuffer(bos.toByteArray()); + String attrsStr = encoder.encodeBuffer(bos.toByteArray()); // trim the last "\n" StringBuffer buffer = null; attrsStr = attrsStr.trim(); @@ -207,14 +207,14 @@ class CMS73LdifParser } } - System.out.println(REQUEST_ATTRIBUTES + " " + buffer); + System.out.println(REQUEST_ATTRIBUTES + " " + buffer); } - public void buildHashtable(String dn, Hashtable table, String attr) + public void buildHashtable(String dn, Hashtable table, String attr) throws Exception - { + { // attribute format [name]:[type]=[value] - + int colon = attr.indexOf(':'); if (colon == -1) { if (mErrorPrintWriter != null) { @@ -319,7 +319,7 @@ class CMS73LdifParser com.netscape.certsrv.authentication.AuthToken obj = (com.netscape.certsrv.authentication.AuthToken)table.get(name); if (obj == null) { - com.netscape.certsrv.authentication.IAuthManager mgr = + com.netscape.certsrv.authentication.IAuthManager mgr = new DummyAuthManager(); obj = new com.netscape.certsrv.authentication.AuthToken(mgr); table.put(name, obj); @@ -329,14 +329,14 @@ class CMS73LdifParser String valuevalue = value.substring(value.indexOf('=')+1); if (valuetype.equals("java.lang.String")) { // Processes 'java.math.BigInteger[]': - // + // // Bugzilla Bug #225031 (a.k.a - Raidzilla Bug #58356) - // + // // Processes 'java.lang.String[]': - // + // // Bugzilla Bug #224763 (a.k.a - Raidzilla Bug #57949) // Bugzilla Bug #252240 - // + // obj.set(valuekey, valuevalue); } else if (valuetype.equals("java.util.Date")) { obj.set(valuekey, new Date(Long.parseLong(valuevalue))); @@ -365,19 +365,19 @@ class CMS73LdifParser table.put(name, decoder.decodeBuffer(value)); } else if (type.startsWith("netscape.security.x509.CertificateAlgorithmId")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateAlgorithmId obj = + netscape.security.x509.CertificateAlgorithmId obj = new netscape.security.x509.CertificateAlgorithmId(new ByteArrayInputStream(decoder.decodeBuffer(value))); table.put(name, obj); } else if (type.equals("netscape.security.x509.CertificateChain")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateChain obj = + netscape.security.x509.CertificateChain obj = new netscape.security.x509.CertificateChain(); ByteArrayInputStream bis = new ByteArrayInputStream(decoder.decodeBuffer(value)); obj.decode(bis); table.put(name, obj); } else if (type.equals("netscape.security.x509.CertificateExtensions")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateExtensions obj = + netscape.security.x509.CertificateExtensions obj = new netscape.security.x509.CertificateExtensions(); obj.decodeEx(new ByteArrayInputStream(decoder.decodeBuffer(value))); // CMS 6.2: revised method of decoding objects of type @@ -385,28 +385,28 @@ class CMS73LdifParser table.put(name, obj); } else if (type.equals("netscape.security.x509.CertificateSubjectName")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateSubjectName obj = + netscape.security.x509.CertificateSubjectName obj = new netscape.security.x509.CertificateSubjectName(new DerInputStream(decoder.decodeBuffer(value))); // CMS 6.2: revised method of decoding objects of type // "netscape.security.x509.CertificateSubjectName" table.put(name, obj); } else if (type.startsWith("netscape.security.x509.CertificateValidity")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateValidity obj = + netscape.security.x509.CertificateValidity obj = new netscape.security.x509.CertificateValidity(); ByteArrayInputStream bis = new ByteArrayInputStream(decoder.decodeBuffer(value)); obj.decode(bis); table.put(name, obj); } else if (type.equals("netscape.security.x509.CertificateX509Key")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.CertificateX509Key obj = + netscape.security.x509.CertificateX509Key obj = new netscape.security.x509.CertificateX509Key( new ByteArrayInputStream(decoder.decodeBuffer(value))); table.put(name, obj); } else if (type.startsWith("com.netscape.certsrv.cert.CertInfo")) { int size = Integer.parseInt(type.substring(type.indexOf('[')+ 1, type.indexOf(','))); int index = Integer.parseInt(type.substring(type.indexOf(',')+1, type.indexOf(']'))); - netscape.security.extensions.CertInfo objs[] = (netscape.security.extensions.CertInfo[])table.get(name); + netscape.security.extensions.CertInfo objs[] = (netscape.security.extensions.CertInfo[])table.get(name); BASE64Decoder decoder = new BASE64Decoder(); if (objs == null) { objs = new netscape.security.extensions.CertInfo[size]; @@ -428,7 +428,7 @@ class CMS73LdifParser } else if (type.startsWith("Integer[")) { int size = Integer.parseInt(type.substring(type.indexOf('[')+ 1, type.indexOf(','))); int index = Integer.parseInt(type.substring(type.indexOf(',')+1, type.indexOf(']'))); - Integer objs[] = (Integer[])table.get(name); + Integer objs[] = (Integer[])table.get(name); if (objs == null) { objs = new Integer[size]; table.put(name, objs); @@ -463,7 +463,7 @@ class CMS73LdifParser obj.set(valuekey, com.netscape.certsrv.dbs.keydb.KeyState.toKeyState(valuevalue)); } else if (valuetype.equals("[B")) { // byte array - + BASE64Decoder decoder = new BASE64Decoder(); obj.set(valuekey, decoder.decodeBuffer(valuevalue)); } else { @@ -477,15 +477,15 @@ class CMS73LdifParser } else if (type.startsWith("com.netscape.certsrv.kra.ProofOfArchival") || type.startsWith("com.netscape.cmscore.kra.ProofOfArchival")) { BASE64Decoder decoder = new BASE64Decoder(); - + ByteArrayInputStream bis = new ByteArrayInputStream(decoder.decodeBuffer(value)); - com.netscape.certsrv.kra.ProofOfArchival obj = + com.netscape.certsrv.kra.ProofOfArchival obj = buildPOA(decoder.decodeBuffer(value)); table.put(name, obj); } else if (type.startsWith("netscape.security.x509.RevokedCertImpl")) { int size = Integer.parseInt(type.substring(type.indexOf('[')+ 1, type.indexOf(','))); int index = Integer.parseInt(type.substring(type.indexOf(',')+1, type.indexOf(']'))); - netscape.security.x509.RevokedCertImpl objs[] = (netscape.security.x509.RevokedCertImpl[])table.get(name); + netscape.security.x509.RevokedCertImpl objs[] = (netscape.security.x509.RevokedCertImpl[])table.get(name); BASE64Decoder decoder = new BASE64Decoder(); if (objs == null) { objs = new netscape.security.x509.RevokedCertImpl[size]; @@ -515,7 +515,7 @@ class CMS73LdifParser } else if (type.startsWith("netscape.security.x509.X509CertImpl[")) { int size = Integer.parseInt(type.substring(type.indexOf('[')+ 1, type.indexOf(','))); int index = Integer.parseInt(type.substring(type.indexOf(',')+1, type.indexOf(']'))); - netscape.security.x509.X509CertImpl objs[] = (netscape.security.x509.X509CertImpl[])table.get(name); + netscape.security.x509.X509CertImpl objs[] = (netscape.security.x509.X509CertImpl[])table.get(name); BASE64Decoder decoder = new BASE64Decoder(); if (objs == null) { objs = new netscape.security.x509.X509CertImpl[size]; @@ -524,7 +524,7 @@ class CMS73LdifParser objs[index] = new netscape.security.x509.X509CertImpl(decoder.decodeBuffer(value)); } else if (type.equals("netscape.security.x509.X509CertImpl")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.X509CertImpl obj = + netscape.security.x509.X509CertImpl obj = new netscape.security.x509.X509CertImpl( decoder.decodeBuffer(value)); table.put(name, obj); @@ -538,7 +538,7 @@ class CMS73LdifParser // "netscape.security.x509.X509CertInfo[" int size = Integer.parseInt(type.substring(type.indexOf('[')+ 1, type.indexOf(','))); int index = Integer.parseInt(type.substring(type.indexOf(',')+1, type.indexOf(']'))); - netscape.security.x509.X509CertInfo objs[] = (netscape.security.x509.X509CertInfo[])table.get(name); + netscape.security.x509.X509CertInfo objs[] = (netscape.security.x509.X509CertInfo[])table.get(name); BASE64Decoder decoder = new BASE64Decoder(); if (objs == null) { objs = new netscape.security.x509.X509CertInfo[size]; @@ -548,7 +548,7 @@ class CMS73LdifParser objs[index].decode(new ByteArrayInputStream(decoder.decodeBuffer(value))); } else if (type.equals("netscape.security.x509.X509CertInfo")) { BASE64Decoder decoder = new BASE64Decoder(); - netscape.security.x509.X509CertInfo obj = + netscape.security.x509.X509CertInfo obj = new netscape.security.x509.X509CertInfo( decoder.decodeBuffer(value)); table.put(name, obj); @@ -567,26 +567,26 @@ class CMS73LdifParser public com.netscape.certsrv.kra.ProofOfArchival buildPOA(byte data[]) throws Exception - { - DerInputStream dis = new DerInputStream(data); + { + DerInputStream dis = new DerInputStream(data); DerValue seq[] = dis.getSequence(0); BigInteger mSerialNo = seq[0].getInteger().toBigInteger(); // subject DerValue subject = seq[1]; - netscape.security.x509.X500Name mSubject = + netscape.security.x509.X500Name mSubject = new netscape.security.x509.X500Name(subject.toByteArray()); // issuer DerValue issuer = seq[2]; - netscape.security.x509.X500Name mIssuer = + netscape.security.x509.X500Name mIssuer = new netscape.security.x509.X500Name(issuer.toByteArray()); // date of archival DerInputStream dateOfArchival = new DerInputStream(seq[3].toByteArray()); Date mDateOfArchival = dateOfArchival.getUTCTime(); - com.netscape.certsrv.kra.ProofOfArchival obj = + com.netscape.certsrv.kra.ProofOfArchival obj = new com.netscape.certsrv.kra.ProofOfArchival(mSerialNo, mSubject.toString(), mIssuer.toString(), mDateOfArchival); return obj; @@ -652,7 +652,7 @@ class DummyAuthManager implements com.netscape.certsrv.authentication.IAuthManag * @return The configuration store of this authentication manager. */ public IConfigStore getConfigStore() - { + { return null; } } diff --git a/base/migrate/TxtTo80/src/Main.java b/base/migrate/TxtTo80/src/Main.java index ad9eb6b18..320ea8507 100644 --- a/base/migrate/TxtTo80/src/Main.java +++ b/base/migrate/TxtTo80/src/Main.java @@ -40,7 +40,7 @@ import java.lang.reflect.*; public class Main { - public static void main(String args[]) + public static void main(String args[]) { try { // initialize CryptoManager in CMS 4.5 and later @@ -50,15 +50,15 @@ public class Main // The following call to "java.security.Security.insertProviderAt()" // is no longer commented out in CMS 4.5 and later 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 @@ -81,14 +81,14 @@ public class Main class CS80LdifParser { // constants - private static final String DN = + private static final String DN = "dn:"; // Directory Servers in CS 8.0 and later use "extdata-" private static final String extAttrPrefix = "extdata-"; - 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 @@ -108,16 +108,16 @@ class CS80LdifParser } 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; Vector requestAttributes = null; - while ((line = reader.readLine()) != null) { + while ((line = reader.readLine()) != null) { if (line.startsWith(DN)) { dn = line; } @@ -154,12 +154,12 @@ class CS80LdifParser if (line.trim().length() == 0) continue; requestAttributes.setElementAt( (String) - requestAttributes.lastElement() + - "\n" + + requestAttributes.lastElement() + + "\n" + line, requestAttributes.size() - 1); } - } + } } public String getKey( String dn, String attr ) @@ -188,10 +188,10 @@ class CS80LdifParser } return key; - } + } public void parseAttributes(String dn, Vector attrs) throws Exception - { + { for( int i = 0; i < attrs.size(); i++ ) { String attr = ( String ) attrs.elementAt( i ); try { @@ -317,7 +317,7 @@ class CS80LdifParser // character sequence contained in the string buffer does not exceed // the capacity, it is not necessary to allocate a new internal buffer // array. If the internal buffer overflows, it is automatically made - // larger. + // larger. // // Start out with an output buffer at least as big as the input buffer. output = new StringBuffer( input.length ); @@ -341,11 +341,11 @@ class CS80LdifParser return( output.toString() ); } - public void translateAttributes( String dn, String attr ) + public void translateAttributes( String dn, String attr ) throws Exception { // attribute format [key]:[type]=[data] - + int colon = attr.indexOf( ':' ); if( colon == -1 ) { if( mErrorPrintWriter != null ) { @@ -436,14 +436,14 @@ class CS80LdifParser subKey + ": " + formatData( subKeyData ) ); } else if( type.startsWith( "com.netscape.certsrv.authentication.AuthToken" ) ) { // Processes 'java.math.BigInteger[]': - // + // // Bugzilla Bug #225031 (a.k.a - Raidzilla Bug #58356) - // + // // Processes 'java.lang.String[]': - // + // // Bugzilla Bug #224763 (a.k.a - Raidzilla Bug #57949) // Bugzilla Bug #252240 - // + // // Bugzilla Bug #737217 - adding proper "ext-data" array format int secondColon = data.indexOf(':'); @@ -526,7 +526,7 @@ class CS80LdifParser // since KRA requests only need to refer // to the actual "keyRecord" referenced // by the "keySerialNumber" data, - // all other "KeyRecord" request data is + // all other "KeyRecord" request data is // ignored, since it is already stored // in the actual "keyRecord". if( data.startsWith( "keySerialNumber" ) ) { diff --git a/base/migrate/kra/RecoverKey.java b/base/migrate/kra/RecoverKey.java index 06e5fc55f..6a663ea97 100755 --- a/base/migrate/kra/RecoverKey.java +++ b/base/migrate/kra/RecoverKey.java @@ -43,7 +43,7 @@ import java.util.*; import com.netscape.cmscore.shares.*; public class RecoverKey { - + public static void main(String args[]) throws Exception { if (args.length != 6) { @@ -58,7 +58,7 @@ public class RecoverKey { String nickname = args[4]; String db_path = args[5]; - CryptoManager.InitializationValues vals = + CryptoManager.InitializationValues vals = new CryptoManager.InitializationValues(alias, prefix, prefix, "secmod.db"); diff --git a/base/migrate/kra/RecoverPin.java b/base/migrate/kra/RecoverPin.java index 2ad268c37..921143154 100755 --- a/base/migrate/kra/RecoverPin.java +++ b/base/migrate/kra/RecoverPin.java @@ -43,7 +43,7 @@ import java.util.*; import com.netscape.cmscore.shares.*; public class RecoverPin { - + public static String getPassword(Hashtable shares) throws Exception { System.out.println("Share size '" + shares.size() + "'"); @@ -86,7 +86,7 @@ System.out.println("Add share " + (int)(Integer.parseInt(next) + 1)); BASE64Decoder decoder = new BASE64Decoder(); byte share[] = decoder.decodeBuffer(encrypted); - System.out.println("Got encrypted share length '" + + System.out.println("Got encrypted share length '" + share.length + "'"); System.out.println("Please input password for " + uid + ":"); @@ -127,7 +127,7 @@ System.out.println("Add share " + (int)(Integer.parseInt(next) + 1)); String password = args[2]; String path_kra_mn = args[3]; - CryptoManager.InitializationValues vals = + CryptoManager.InitializationValues vals = new CryptoManager.InitializationValues(alias, prefix, prefix, "secmod.db"); |