summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEndi Sukma Dewata <edewata@redhat.com>2012-11-16 10:13:33 -0500
committerEndi Sukma Dewata <edewata@redhat.com>2012-11-30 14:45:29 -0500
commite1ffb0cda0cc708eea4c043301468484d36ca8c7 (patch)
treedae84ebdc4572be4830028012b2ae74d924c5558
parent4937a033860c7d7c2c5bcf1da9edb390b93d4d88 (diff)
downloadpki-ticket-416-2.zip
pki-ticket-416-2.tar.gz
pki-ticket-416-2.tar.xz
Fixed issuedOn parameters for cert-find.ticket-416-2
The CertSearchRequest has been modified to fix the infinite loop in getIssuedOnTo(). The CertFindCLI has been modified to accept dates with format YYYY-MM-DD instead of epoch time. Ticket #416
-rw-r--r--base/common/src/com/netscape/certsrv/cert/CertSearchRequest.java8
-rw-r--r--base/java-tools/src/com/netscape/cmstools/cert/CertFindCLI.java31
2 files changed, 30 insertions, 9 deletions
diff --git a/base/common/src/com/netscape/certsrv/cert/CertSearchRequest.java b/base/common/src/com/netscape/certsrv/cert/CertSearchRequest.java
index d2a4eee..29e36f7 100644
--- a/base/common/src/com/netscape/certsrv/cert/CertSearchRequest.java
+++ b/base/common/src/com/netscape/certsrv/cert/CertSearchRequest.java
@@ -430,7 +430,11 @@ public class CertSearchRequest {
}
public String getIssuedOnTo() {
- return getIssuedOnTo();
+ return issuedOnTo;
+ }
+
+ public void setIssuedOnTo(String issuedOnTo) {
+ this.issuedOnTo = issuedOnTo;
}
//Valid Not After
@@ -651,6 +655,7 @@ public class CertSearchRequest {
private void buildDateFilter(String prefix,
String outStr, long adjustment,
StringBuffer filter) {
+ if (prefix == null || prefix.length() == 0) return;
long epoch = 0;
try {
epoch = Long.parseLong(prefix);
@@ -703,7 +708,6 @@ public class CertSearchRequest {
return;
}
String issuedBy = getIssuedBy();
- ;
if (issuedBy == null || issuedBy.equals("")) {
filter.append("(certIssuedBy=*)");
} else {
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 397df3f..7df9995 100644
--- a/base/java-tools/src/com/netscape/cmstools/cert/CertFindCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/cert/CertFindCLI.java
@@ -21,6 +21,8 @@ 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;
@@ -40,6 +42,7 @@ 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) {
@@ -51,7 +54,7 @@ public class CertFindCLI extends CLI {
formatter.printHelp(parent.name + "-" + name + " [OPTIONS...]", options);
}
- public void execute(String[] args) {
+ public void execute(String[] args) throws Exception {
addOptions();
@@ -217,9 +220,15 @@ public class CertFindCLI extends CLI {
option.setArgName("user id");
options.addOption(option);
- //issuedFor(period)
- option = new Option(null, "issuedOn", true, "Date issued");
- option.setArgName("date");
+ //issuedOn
+ option = new Option(null, "issuedOnFrom", true,
+ "Issued on or after this date");
+ option.setArgName("YYYY-MM-DD");
+ options.addOption(option);
+
+ option = new Option(null, "issuedOnTo", true,
+ "Issued on or before this date");
+ option.setArgName("YYYY-MM-DD");
options.addOption(option);
//certTypeinUse
@@ -267,7 +276,9 @@ public class CertFindCLI extends CLI {
options.addOption(option);
}
- public void addSearchAttribute(CommandLine cmd, CertSearchRequest csd) {
+ public void addSearchAttribute(CommandLine cmd, CertSearchRequest csd)
+ throws java.text.ParseException {
+
if (cmd.hasOption("minSerialNumber")) {
csd.setSerialNumberRangeInUse(true);
csd.setSerialFrom(cmd.getOptionValue("minSerialNumber"));
@@ -331,9 +342,15 @@ public class CertFindCLI extends CLI {
csd.setIssuedByInUse(true);
csd.setIssuedBy(cmd.getOptionValue("issuedBy"));
}
- if (cmd.hasOption("issuedOn")) {
+ if (cmd.hasOption("issuedOnFrom")) {
+ csd.setIssuedOnInUse(true);
+ Date date = dateFormat.parse(cmd.getOptionValue("issuedOnFrom"));
+ csd.setIssuedOnFrom(""+date.getTime());
+ }
+ if (cmd.hasOption("issuedOnTo")) {
csd.setIssuedOnInUse(true);
- csd.setIssuedOnFrom(cmd.getOptionValue("issuedOn"));
+ Date date = dateFormat.parse(cmd.getOptionValue("issuedOnTo"));
+ csd.setIssuedOnTo(""+date.getTime());
}
if (cmd.hasOption("certTypeSubEmailCA")) {
csd.setCertTypeInUse(true);