summaryrefslogtreecommitdiffstats
path: root/pki/base/silent/src/com/netscape/pkisilent/common/Utilities.java
diff options
context:
space:
mode:
Diffstat (limited to 'pki/base/silent/src/com/netscape/pkisilent/common/Utilities.java')
-rw-r--r--pki/base/silent/src/com/netscape/pkisilent/common/Utilities.java63
1 files changed, 29 insertions, 34 deletions
diff --git a/pki/base/silent/src/com/netscape/pkisilent/common/Utilities.java b/pki/base/silent/src/com/netscape/pkisilent/common/Utilities.java
index 192ba056..5a0b3b85 100644
--- a/pki/base/silent/src/com/netscape/pkisilent/common/Utilities.java
+++ b/pki/base/silent/src/com/netscape/pkisilent/common/Utilities.java
@@ -1,4 +1,5 @@
package com.netscape.pkisilent.common;
+
// --- BEGIN COPYRIGHT BLOCK ---
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -84,7 +85,7 @@ public class Utilities {
StringBuffer buf = new StringBuffer();
int end = token.length();
int begin = 0;
-
+
if (token.endsWith(";")) {
end--;
}
@@ -159,10 +160,8 @@ public class Utilities {
}
/*
- * format of the file should be like this:
- * -----BEGIN CERTIFICATE-----
- * base64 encoded certificate
- * -----END CERTIFICATE-----
+ * format of the file should be like this: -----BEGIN CERTIFICATE-----
+ * base64 encoded certificate -----END CERTIFICATE-----
*/
public String getcertfromfile(String filename) {
StringBuffer tempBuffer = new StringBuffer();
@@ -180,7 +179,7 @@ public class Utilities {
}
tempBuffer.append(temp);
}
-
+
return tempBuffer.toString();
} catch (Exception e) {
System.out.println("ERROR: getcertfromfile" + e.toString());
@@ -203,17 +202,15 @@ public class Utilities {
}
return tempBuffer.toString();
} catch (Exception e) {
- System.out.println(
- "ERROR: getcertfromfile_withheaders" + e.toString());
+ System.out.println("ERROR: getcertfromfile_withheaders"
+ + e.toString());
return null;
}
}
/*
- * format of the file should be like this:
- * -----BEGIN CERTIFICATE REVOCATION LIST-----
- * base64 encoded CRL
- * -----END CERTIFICATE REVOCATION LIST-----
+ * format of the file should be like this: -----BEGIN CERTIFICATE REVOCATION
+ * LIST----- base64 encoded CRL -----END CERTIFICATE REVOCATION LIST-----
*/
public String getcrlfromfile(String filename) {
StringBuffer tempBuffer = new StringBuffer();
@@ -227,7 +224,7 @@ public class Utilities {
tempBuffer.append(temp);
}
-
+
return tempBuffer.toString();
} catch (Exception e) {
System.out.println("ERROR: getcrlfromfile" + e.toString());
@@ -237,10 +234,8 @@ public class Utilities {
}
/*
- * format of the file should be like this:
- * -----BEGIN CERTIFICATE-----
- * base64 encoded certificate
- * -----END CERTIFICATE-----
+ * format of the file should be like this: -----BEGIN CERTIFICATE-----
+ * base64 encoded certificate -----END CERTIFICATE-----
*/
public String getcafromfile(String filename) {
StringBuffer tempBuffer = new StringBuffer();
@@ -254,7 +249,7 @@ public class Utilities {
tempBuffer.append(temp);
}
-
+
return tempBuffer.toString();
} catch (Exception e) {
System.out.println("ERROR: getcafromfile" + e.toString());
@@ -264,12 +259,12 @@ public class Utilities {
}
/*
- * function for RFC 2254. converts a x509 certificate given as
- * a binary array[] to a Ldap filter string
+ * function for RFC 2254. converts a x509 certificate given as a binary
+ * array[] to a Ldap filter string
*/
public static String escapeBinaryData(byte data[]) {
String result = "";
-
+
for (int i = 0; i < data.length; i++) {
String s = Integer.toHexString((int) (0xff & data[i]));
@@ -314,23 +309,25 @@ public class Utilities {
X509CertInfo certinfo = (X509CertInfo) x509_cert.get("x509.INFO");
/* Get Serial Number */
- CertificateSerialNumber csn = (CertificateSerialNumber)
- certinfo.get(X509CertInfo.SERIAL_NUMBER);
+ CertificateSerialNumber csn = (CertificateSerialNumber) certinfo
+ .get(X509CertInfo.SERIAL_NUMBER);
SerialNumber sn = (SerialNumber) csn.get("NUMBER");
- // just adding serialnumber for add.
- // we can add mode here like subject name, extensions,issuer to this record.
+ // just adding serialnumber for add.
+ // we can add mode here like subject name, extensions,issuer to this
+ // record.
cr.serialNumber = sn.getNumber().toString().trim();
/* Get Subject Name */
- CertificateSubjectName csn1 = (CertificateSubjectName)
- certinfo.get(X509CertInfo.SUBJECT);
+ CertificateSubjectName csn1 = (CertificateSubjectName) certinfo
+ .get(X509CertInfo.SUBJECT);
@SuppressWarnings("unchecked")
- Enumeration<String> en = csn1.getElements();
+ Enumeration<String> en = csn1.getElements();
- X500Name dname = (X500Name) csn1.get(CertificateSubjectName.DN_NAME);
+ X500Name dname = (X500Name) csn1
+ .get(CertificateSubjectName.DN_NAME);
String pp = "";
RDN[] rdns = dname.getNames();
@@ -342,7 +339,8 @@ public class Utilities {
cr.subject = pp;
} catch (Exception e) {
- System.out.println("ERROR: Exception when decoding certificate=" + e);
+ System.out.println("ERROR: Exception when decoding certificate="
+ + e);
e.printStackTrace();
return null;
}
@@ -351,7 +349,4 @@ public class Utilities {
}
-}
-
-
-; // end class
+}; // end class