From 08fd8b6f551b0d0889efba554a13563c41cf01e5 Mon Sep 17 00:00:00 2001 From: Endi Sukma Dewata Date: Mon, 4 Feb 2013 18:43:05 -0500 Subject: 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 --- .../netscape/cms/servlet/cert/FilterBuilder.java | 7 +---- .../com/netscape/cmstools/cert/CertFindCLI.java | 30 +++++++++++++--------- 2 files changed, 19 insertions(+), 18 deletions(-) (limited to 'base') 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 cb6ac13e6..86459a750 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 7df99956a..0b8d298ff 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); -- cgit