summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEndi Sukma Dewata <edewata@redhat.com>2013-02-04 18:43:05 -0500
committerEndi Sukma Dewata <edewata@redhat.com>2013-02-06 11:20:30 -0500
commit08fd8b6f551b0d0889efba554a13563c41cf01e5 (patch)
tree6ca30acb3f71805788aa0d887938e4f6b582d4cd
parent981ebcce84770c9d48e80fc9b5ffd2bbf8fd0816 (diff)
downloadpki-08fd8b6f551b0d0889efba554a13563c41cf01e5.zip
pki-08fd8b6f551b0d0889efba554a13563c41cf01e5.tar.gz
pki-08fd8b6f551b0d0889efba554a13563c41cf01e5.tar.xz
Fixed date format for cert-find parameters.
All date parameters for cert-find have been modified to use the YYYY-MM-DD date format. Date parsing code in FilterBuilder has been modified not to ignore parsing errors. Ticket #497
-rw-r--r--base/common/src/com/netscape/cms/servlet/cert/FilterBuilder.java7
-rw-r--r--base/java-tools/src/com/netscape/cmstools/cert/CertFindCLI.java30
2 files changed, 19 insertions, 18 deletions
diff --git a/base/common/src/com/netscape/cms/servlet/cert/FilterBuilder.java b/base/common/src/com/netscape/cms/servlet/cert/FilterBuilder.java
index cb6ac13..86459a7 100644
--- a/base/common/src/com/netscape/cms/servlet/cert/FilterBuilder.java
+++ b/base/common/src/com/netscape/cms/servlet/cert/FilterBuilder.java
@@ -138,12 +138,7 @@ public class FilterBuilder {
String outStr, long adjustment,
StringBuffer filter) {
if (prefix == null || prefix.length() == 0) return;
- long epoch = 0;
- try {
- epoch = Long.parseLong(prefix);
- } catch (NumberFormatException e) {
- // exception safely ignored
- }
+ long epoch = Long.parseLong(prefix);
Calendar from = Calendar.getInstance();
from.setTimeInMillis(epoch);
filter.append("(");
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 7df9995..0b8d298 100644
--- a/base/java-tools/src/com/netscape/cmstools/cert/CertFindCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/cert/CertFindCLI.java
@@ -204,10 +204,10 @@ public class CertFindCLI extends CLI {
//revocationPeriod
option = new Option(null, "revokedOnFrom", true, "Revoked on or after this date");
- option.setArgName("date");
+ option.setArgName("YYYY-MM-DD");
options.addOption(option);
option = new Option(null, "revokedOnTo", true, "Revoked on or before this date");
- option.setArgName("date");
+ option.setArgName("YYYY-MM-DD");
options.addOption(option);
//revocationReason
@@ -250,18 +250,18 @@ public class CertFindCLI extends CLI {
//validationNotBeforeInUse
option = new Option(null, "validNotBeforeFrom", true, "Valid not before start date");
- option.setArgName("date");
+ option.setArgName("YYYY-MM-DD");
options.addOption(option);
option = new Option(null, "validNotBeforeTo", true, "Valid not before end date");
- option.setArgName("date");
+ option.setArgName("YYYY-MM-DD");
options.addOption(option);
//validityNotAfterinUse
option = new Option(null, "validNotAfterFrom", true, "Valid not after start date");
- option.setArgName("date");
+ option.setArgName("YYYY-MM-DD");
options.addOption(option);
option = new Option(null, "validNotAfterTo", true, "Valid not after end date");
- option.setArgName("date");
+ option.setArgName("YYYY-MM-DD");
options.addOption(option);
//validityLengthinUse
@@ -328,11 +328,13 @@ public class CertFindCLI extends CLI {
}
if (cmd.hasOption("revokedOnFrom")) {
csd.setRevokedOnInUse(true);
- csd.setRevokedOnFrom(cmd.getOptionValue("revokedOnFrom"));
+ Date date = dateFormat.parse(cmd.getOptionValue("revokedOnFrom"));
+ csd.setRevokedOnFrom(""+date.getTime());
}
if (cmd.hasOption("revokedOnTo")) {
csd.setRevokedOnInUse(true);
- csd.setRevokedOnTo(cmd.getOptionValue("revokedOnTo"));
+ Date date = dateFormat.parse(cmd.getOptionValue("revokedOnTo"));
+ csd.setRevokedOnTo(""+date.getTime());
}
if (cmd.hasOption("revocationReason")) {
csd.setRevocationReasonInUse(true);
@@ -374,19 +376,23 @@ public class CertFindCLI extends CLI {
}
if (cmd.hasOption("validNotBeforeFrom")) {
csd.setValidNotBeforeInUse(true);
- csd.setValidNotBeforeFrom(cmd.getOptionValue("validNotBeforeFrom"));
+ Date date = dateFormat.parse(cmd.getOptionValue("validNotBeforeFrom"));
+ csd.setValidNotBeforeFrom(""+date.getTime());
}
if (cmd.hasOption("validNotBeforeTo")) {
csd.setValidNotBeforeInUse(true);
- csd.setValidNotBeforeTo(cmd.getOptionValue("validNotBeforeTo"));
+ Date date = dateFormat.parse(cmd.getOptionValue("validNotBeforeTo"));
+ csd.setValidNotBeforeTo(""+date.getTime());
}
if (cmd.hasOption("validNotAfterFrom")) {
csd.setValidNotAfterInUse(true);
- csd.setValidNotAfterFrom(cmd.getOptionValue("validNotAfterFrom"));
+ Date date = dateFormat.parse(cmd.getOptionValue("validNotAfterFrom"));
+ csd.setValidNotAfterFrom(""+date.getTime());
}
if (cmd.hasOption("validNotAfterTo")) {
csd.setValidNotAfterInUse(true);
- csd.setValidNotAfterTo(cmd.getOptionValue("validNotAfterTo"));
+ Date date = dateFormat.parse(cmd.getOptionValue("validNotAfterTo"));
+ csd.setValidNotAfterTo(""+date.getTime());
}
if (cmd.hasOption("validityOperation")) {
csd.setValidityLengthInUse(true);