summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pki/base/common/src/com/netscape/cms/jobs/RenewalNotificationJob.java18
-rw-r--r--pki/base/common/src/com/netscape/cms/servlet/cert/Monitor.java22
-rw-r--r--pki/base/common/src/com/netscape/cms/servlet/cert/RemoteAuthConfig.java25
-rw-r--r--pki/base/common/src/com/netscape/cms/servlet/cert/RenewalServlet.java8
-rw-r--r--pki/base/common/src/com/netscape/cmscore/security/CertificateInfo.java10
5 files changed, 51 insertions, 32 deletions
diff --git a/pki/base/common/src/com/netscape/cms/jobs/RenewalNotificationJob.java b/pki/base/common/src/com/netscape/cms/jobs/RenewalNotificationJob.java
index 59116bd9..90c7ec74 100644
--- a/pki/base/common/src/com/netscape/cms/jobs/RenewalNotificationJob.java
+++ b/pki/base/common/src/com/netscape/cms/jobs/RenewalNotificationJob.java
@@ -20,6 +20,7 @@ package com.netscape.cms.jobs;
import java.io.IOException;
import java.text.DateFormat;
+import java.util.Calendar;
import java.util.Date;
import java.util.Enumeration;
import java.util.Locale;
@@ -487,15 +488,18 @@ public class RenewalNotificationJob
}
}
- private String makeLDAPDateString(Date d) {
+ private String makeLDAPDateString(Date date) {
- String ldfYear = "" + Integer.toString(d.getYear());
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+
+ String ldfYear = "" + Integer.toString(calendar.get(Calendar.YEAR) - 1900);
- String ldfMonth = getPadded(d.getMonth());
- String ldfDate = getPadded(d.getDate());
- String ldfHours = getPadded(d.getHours());
- String ldfMinutes = getPadded(d.getMinutes());
- String ldfSeconds = getPadded(d.getSeconds());
+ String ldfMonth = getPadded(calendar.get(Calendar.MONTH));
+ String ldfDate = getPadded(calendar.get(Calendar.DAY_OF_MONTH));
+ String ldfHours = getPadded(calendar.get(Calendar.HOUR));
+ String ldfMinutes = getPadded(calendar.get(Calendar.MINUTE));
+ String ldfSeconds = getPadded(calendar.get(Calendar.SECOND));
return ldfYear + ldfMonth + ldfDate + ldfHours + ldfMinutes + ldfSeconds + "Z";
}
diff --git a/pki/base/common/src/com/netscape/cms/servlet/cert/Monitor.java b/pki/base/common/src/com/netscape/cms/servlet/cert/Monitor.java
index b584316c..1355bebb 100644
--- a/pki/base/common/src/com/netscape/cms/servlet/cert/Monitor.java
+++ b/pki/base/common/src/com/netscape/cms/servlet/cert/Monitor.java
@@ -19,6 +19,7 @@ package com.netscape.cms.servlet.cert;
import java.io.IOException;
+import java.util.Calendar;
import java.util.Date;
import java.util.Enumeration;
import java.util.Locale;
@@ -343,8 +344,9 @@ public class Monitor extends CMSServlet {
int hour = Integer.parseInt(z.substring(8, 10));
int minute = Integer.parseInt(z.substring(10, 12));
int second = Integer.parseInt(z.substring(12, 14));
-
- d = new Date(year, month, date, hour, minute, second);
+ Calendar calendar= Calendar.getInstance();
+ calendar.set(year, month, date, hour, minute, second);
+ d = calendar.getTime();
} catch (NumberFormatException nfe) {
}
} else if (z != null && z.length() > 1 && z.charAt(0) == '-') { // -5
@@ -361,21 +363,25 @@ public class Monitor extends CMSServlet {
}
String DateToZString(Date d) {
- String time = "" + (d.getYear() + 1900);
- int i = d.getMonth() + 1;
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(d);
+
+
+ String time = "" + (calendar.get(Calendar.YEAR));
+ int i = calendar.get(Calendar.MONTH) + 1;
if (i < 10) time += "0";
time += i;
- i = d.getDate();
+ i = calendar.get(Calendar.DAY_OF_MONTH);
if (i < 10) time += "0";
time += i;
- i = d.getHours();
+ i = calendar.get(Calendar.HOUR_OF_DAY);
if (i < 10) time += "0";
time += i;
- i = d.getMinutes();
+ i = calendar.get(Calendar.MINUTE);
if (i < 10) time += "0";
time += i;
- i = d.getSeconds();
+ i = calendar.get(Calendar.SECOND);
if (i < 10) time += "0";
time += i + "Z";
return time;
diff --git a/pki/base/common/src/com/netscape/cms/servlet/cert/RemoteAuthConfig.java b/pki/base/common/src/com/netscape/cms/servlet/cert/RemoteAuthConfig.java
index 465e129c..ee75b6a2 100644
--- a/pki/base/common/src/com/netscape/cms/servlet/cert/RemoteAuthConfig.java
+++ b/pki/base/common/src/com/netscape/cms/servlet/cert/RemoteAuthConfig.java
@@ -19,6 +19,7 @@ package com.netscape.cms.servlet.cert;
import java.io.IOException;
+import java.util.Calendar;
import java.util.Date;
import java.util.Enumeration;
import java.util.Locale;
@@ -593,20 +594,20 @@ public class RemoteAuthConfig extends CMSServlet {
}
private String makeInstanceName() {
- Date now = new Date();
- int y = 1900 + now.getYear();
+ Calendar now = Calendar.getInstance();
+ int y = now.get(Calendar.YEAR);
String name = "R" + y;
- if (now.getMonth() < 10) name += "0";
- name += now.getMonth();
- if (now.getDate() < 10) name += "0";
- name += now.getDate();
- if (now.getHours() < 10) name += "0";
- name += now.getHours();
- if (now.getMinutes() < 10) name += "0";
- name += now.getMinutes();
- if (now.getSeconds() < 10) name += "0";
- name += now.getSeconds();
+ if (now.get(Calendar.MONTH) < 10) name += "0";
+ name += now.get(Calendar.MONTH);
+ if (now.get(Calendar.DAY_OF_MONTH) < 10) name += "0";
+ name += now.get(Calendar.DAY_OF_MONTH);
+ if (now.get(Calendar.HOUR_OF_DAY) < 10) name += "0";
+ name += now.get(Calendar.HOUR_OF_DAY);
+ if (now.get(Calendar.MINUTE) < 10) name += "0";
+ name += now.get(Calendar.MINUTE);
+ if (now.get(Calendar.SECOND) < 10) name += "0";
+ name += now.get(Calendar.SECOND);
return name;
}
}
diff --git a/pki/base/common/src/com/netscape/cms/servlet/cert/RenewalServlet.java b/pki/base/common/src/com/netscape/cms/servlet/cert/RenewalServlet.java
index a83c390d..72a5e809 100644
--- a/pki/base/common/src/com/netscape/cms/servlet/cert/RenewalServlet.java
+++ b/pki/base/common/src/com/netscape/cms/servlet/cert/RenewalServlet.java
@@ -22,6 +22,7 @@ import java.io.IOException;
import java.math.BigInteger;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
+import java.util.Calendar;
import java.util.Date;
import java.util.Enumeration;
import java.util.Vector;
@@ -185,8 +186,11 @@ public class RenewalServlet extends CMSServlet {
if (beginYear != -1 && beginMonth != -1 && beginDate != -1 &&
endYear != -1 && endMonth != -1 && endDate != -1) {
- notBefore = new Date(beginYear, beginMonth, beginDate);
- notAfter = new Date(endYear, endMonth, endDate);
+ Calendar calendar = Calendar.getInstance();
+ calendar.set(beginYear, beginMonth, beginDate);
+ notBefore = calendar.getTime();
+ calendar.set(endYear, endMonth, endDate);
+ notAfter = calendar.getTime();
}
} // coming from client
else {
diff --git a/pki/base/common/src/com/netscape/cmscore/security/CertificateInfo.java b/pki/base/common/src/com/netscape/cmscore/security/CertificateInfo.java
index c492feac..dc240dac 100644
--- a/pki/base/common/src/com/netscape/cmscore/security/CertificateInfo.java
+++ b/pki/base/common/src/com/netscape/cmscore/security/CertificateInfo.java
@@ -27,6 +27,7 @@ import java.security.PublicKey;
import java.security.cert.CertificateEncodingException;
import java.security.cert.CertificateException;
import java.security.cert.CertificateParsingException;
+import java.util.Calendar;
import java.util.Date;
import netscape.security.util.DerInputStream;
@@ -142,10 +143,13 @@ public abstract class CertificateInfo {
int afterSec =
Integer.parseInt(mProperties.getAfterSec());
- notBeforeDate = new Date(beginYear, beginMonth, beginDate,
+ Calendar calendar = Calendar.getInstance();
+ calendar.set(beginYear, beginMonth, beginDate,
beginHour, beginMin, beginSec);
- notAfterDate = new Date(afterYear, afterMonth, afterDate,
- afterHour, afterMin, afterSec);
+ notBeforeDate = calendar.getTime();
+ calendar.set(afterYear, afterMonth, afterDate,
+ afterHour, afterMin, afterSec);
+ notAfterDate = calendar.getTime();
}
return new CertificateValidity(notBeforeDate, notAfterDate);
}