summaryrefslogtreecommitdiffstats
path: root/base/java-tools/src/com/netscape/cmstools/cert/CertCLI.java
diff options
context:
space:
mode:
Diffstat (limited to 'base/java-tools/src/com/netscape/cmstools/cert/CertCLI.java')
-rw-r--r--base/java-tools/src/com/netscape/cmstools/cert/CertCLI.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/base/java-tools/src/com/netscape/cmstools/cert/CertCLI.java b/base/java-tools/src/com/netscape/cmstools/cert/CertCLI.java
index b912253..f43ef97 100644
--- a/base/java-tools/src/com/netscape/cmstools/cert/CertCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/cert/CertCLI.java
@@ -18,6 +18,7 @@
package com.netscape.cmstools.cert;
+import java.text.SimpleDateFormat;
import java.util.Arrays;
import org.apache.commons.lang.StringUtils;
@@ -36,6 +37,8 @@ import com.netscape.cmstools.cli.MainCLI;
*/
public class CertCLI extends CLI {
+ public static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+
public MainCLI parent;
public CertClient client;
@@ -103,11 +106,44 @@ public class CertCLI extends CLI {
}
}
+ public static String getAlgorithmNameFromOID(String oid) {
+ if (oid == null)
+ return "";
+ else if (oid.equals("1.2.840.113549.1.1.1"))
+ return "PKCS #1 RSA";
+ else if (oid.equals("1.2.840.113549.1.1.4"))
+ return "PKCS #1 MD5 With RSA";
+ else if (oid.equals("1.2.840.10040.4.1"))
+ return "DSA";
+ else
+ return "OID."+oid;
+ }
+
public static void printCertInfo(CertDataInfo info) {
System.out.println(" Serial Number: "+info.getID().toHexString());
System.out.println(" Subject DN: "+info.getSubjectDN());
System.out.println(" Status: "+info.getStatus());
+ String type = info.getType();
+ Integer version = info.getVersion();
+ if (version != null) {
+ type += " version " + (version + 1);
+ }
+ System.out.println(" Type: "+type);
+
+ String keyAlgorithm = getAlgorithmNameFromOID(info.getKeyAlgorithmOID());
+ Integer keyLength = info.getKeyLength();
+ if (keyLength != null) {
+ keyAlgorithm += " with " + keyLength + "-bit key";
+ }
+ System.out.println(" Key Algorithm: "+keyAlgorithm);
+
+ System.out.println(" Not Valid Before: "+info.getNotValidBefore());
+ System.out.println(" Not Valid After: "+info.getNotValidAfter());
+
+ System.out.println(" Issued On: "+info.getIssuedOn());
+ System.out.println(" Issued By: "+info.getIssuedBy());
+
Link link = info.getLink();
if (verbose && link != null) {
System.out.println(" Link: " + link.getHref());