summaryrefslogtreecommitdiffstats
path: root/base/java-tools/src
diff options
context:
space:
mode:
Diffstat (limited to 'base/java-tools/src')
-rw-r--r--base/java-tools/src/com/netscape/cmstools/cert/CertCLI.java36
-rw-r--r--base/java-tools/src/com/netscape/cmstools/cert/CertFindCLI.java18
2 files changed, 44 insertions, 10 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());
diff --git a/base/java-tools/src/com/netscape/cmstools/cert/CertFindCLI.java b/base/java-tools/src/com/netscape/cmstools/cert/CertFindCLI.java
index 0b8d298..9107a57 100644
--- a/base/java-tools/src/com/netscape/cmstools/cert/CertFindCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/cert/CertFindCLI.java
@@ -21,7 +21,6 @@ package com.netscape.cmstools.cert;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
-import java.text.SimpleDateFormat;
import java.util.Date;
import javax.xml.bind.JAXBException;
@@ -42,7 +41,6 @@ import com.netscape.cmstools.cli.MainCLI;
*/
public class CertFindCLI extends CLI {
- public SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
public CertCLI parent;
public CertFindCLI(CertCLI parent) {
@@ -328,12 +326,12 @@ public class CertFindCLI extends CLI {
}
if (cmd.hasOption("revokedOnFrom")) {
csd.setRevokedOnInUse(true);
- Date date = dateFormat.parse(cmd.getOptionValue("revokedOnFrom"));
+ Date date = CertCLI.dateFormat.parse(cmd.getOptionValue("revokedOnFrom"));
csd.setRevokedOnFrom(""+date.getTime());
}
if (cmd.hasOption("revokedOnTo")) {
csd.setRevokedOnInUse(true);
- Date date = dateFormat.parse(cmd.getOptionValue("revokedOnTo"));
+ Date date = CertCLI.dateFormat.parse(cmd.getOptionValue("revokedOnTo"));
csd.setRevokedOnTo(""+date.getTime());
}
if (cmd.hasOption("revocationReason")) {
@@ -346,12 +344,12 @@ public class CertFindCLI extends CLI {
}
if (cmd.hasOption("issuedOnFrom")) {
csd.setIssuedOnInUse(true);
- Date date = dateFormat.parse(cmd.getOptionValue("issuedOnFrom"));
+ Date date = CertCLI.dateFormat.parse(cmd.getOptionValue("issuedOnFrom"));
csd.setIssuedOnFrom(""+date.getTime());
}
if (cmd.hasOption("issuedOnTo")) {
csd.setIssuedOnInUse(true);
- Date date = dateFormat.parse(cmd.getOptionValue("issuedOnTo"));
+ Date date = CertCLI.dateFormat.parse(cmd.getOptionValue("issuedOnTo"));
csd.setIssuedOnTo(""+date.getTime());
}
if (cmd.hasOption("certTypeSubEmailCA")) {
@@ -376,22 +374,22 @@ public class CertFindCLI extends CLI {
}
if (cmd.hasOption("validNotBeforeFrom")) {
csd.setValidNotBeforeInUse(true);
- Date date = dateFormat.parse(cmd.getOptionValue("validNotBeforeFrom"));
+ Date date = CertCLI.dateFormat.parse(cmd.getOptionValue("validNotBeforeFrom"));
csd.setValidNotBeforeFrom(""+date.getTime());
}
if (cmd.hasOption("validNotBeforeTo")) {
csd.setValidNotBeforeInUse(true);
- Date date = dateFormat.parse(cmd.getOptionValue("validNotBeforeTo"));
+ Date date = CertCLI.dateFormat.parse(cmd.getOptionValue("validNotBeforeTo"));
csd.setValidNotBeforeTo(""+date.getTime());
}
if (cmd.hasOption("validNotAfterFrom")) {
csd.setValidNotAfterInUse(true);
- Date date = dateFormat.parse(cmd.getOptionValue("validNotAfterFrom"));
+ Date date = CertCLI.dateFormat.parse(cmd.getOptionValue("validNotAfterFrom"));
csd.setValidNotAfterFrom(""+date.getTime());
}
if (cmd.hasOption("validNotAfterTo")) {
csd.setValidNotAfterInUse(true);
- Date date = dateFormat.parse(cmd.getOptionValue("validNotAfterTo"));
+ Date date = CertCLI.dateFormat.parse(cmd.getOptionValue("validNotAfterTo"));
csd.setValidNotAfterTo(""+date.getTime());
}
if (cmd.hasOption("validityOperation")) {