summaryrefslogtreecommitdiffstats
path: root/base/migrate/47ToTxt/src/Main.java
diff options
context:
space:
mode:
Diffstat (limited to 'base/migrate/47ToTxt/src/Main.java')
-rw-r--r--base/migrate/47ToTxt/src/Main.java132
1 files changed, 66 insertions, 66 deletions
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);
}
}