diff options
author | Adam Young <ayoung@redhat.com> | 2011-12-02 17:21:55 -0500 |
---|---|---|
committer | Adam Young <ayoung@redhat.com> | 2011-12-02 17:22:32 -0500 |
commit | 4982426d746fcac1b381c8d6f0498ecdfc4110b8 (patch) | |
tree | f70c1179fdc9e6ce10ba31c72ab22497359f0f61 /pki/base/common/src/com/netscape | |
parent | 1f775b2e89af6e09fa56ea218ed92dc3dccaeb79 (diff) | |
download | pki-4982426d746fcac1b381c8d6f0498ecdfc4110b8.tar.gz pki-4982426d746fcac1b381c8d6f0498ecdfc4110b8.tar.xz pki-4982426d746fcac1b381c8d6f0498ecdfc4110b8.zip |
Revert "Remove Deprecated Date Functions"
This reverts commit d7d71804b885118e74928e413a8e7fb91b78706c.
It was commited by mistake. It changes the Certificate Geenrate code, and requires a unit test
Diffstat (limited to 'pki/base/common/src/com/netscape')
5 files changed, 32 insertions, 51 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 90c7ec748..59116bd91 100644 --- a/pki/base/common/src/com/netscape/cms/jobs/RenewalNotificationJob.java +++ b/pki/base/common/src/com/netscape/cms/jobs/RenewalNotificationJob.java @@ -20,7 +20,6 @@ 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; @@ -488,18 +487,15 @@ public class RenewalNotificationJob } } - private String makeLDAPDateString(Date date) { + private String makeLDAPDateString(Date d) { - Calendar calendar = Calendar.getInstance(); - calendar.setTime(date); - - String ldfYear = "" + Integer.toString(calendar.get(Calendar.YEAR) - 1900); + String ldfYear = "" + Integer.toString(d.getYear()); - 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)); + 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()); 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 f32d6c189..649d70169 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,7 +19,6 @@ 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; @@ -348,9 +347,8 @@ 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)); - Calendar calendar= Calendar.getInstance(); - calendar.set(year, month, date, hour, minute, second); - d = calendar.getTime(); + + d = new Date(year, month, date, hour, minute, second); } catch (NumberFormatException nfe) { } } else if (z != null && z.length() > 1 && z.charAt(0) == '-') { // -5 @@ -367,25 +365,21 @@ public class Monitor extends CMSServlet { } String DateToZString(Date d) { - Calendar calendar = Calendar.getInstance(); - calendar.setTime(d); - - - String time = "" + (calendar.get(Calendar.YEAR)); - int i = calendar.get(Calendar.MONTH) + 1; + String time = "" + (d.getYear() + 1900); + int i = d.getMonth() + 1; if (i < 10) time += "0"; time += i; - i = calendar.get(Calendar.DAY_OF_MONTH); + i = d.getDate(); if (i < 10) time += "0"; time += i; - i = calendar.get(Calendar.HOUR_OF_DAY); + i = d.getHours(); if (i < 10) time += "0"; time += i; - i = calendar.get(Calendar.MINUTE); + i = d.getMinutes(); if (i < 10) time += "0"; time += i; - i = calendar.get(Calendar.SECOND); + i = d.getSeconds(); 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 1ea07bfff..86fa0dc57 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,7 +19,6 @@ 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; @@ -598,20 +597,20 @@ public class RemoteAuthConfig extends CMSServlet { } private String makeInstanceName() { - Calendar now = Calendar.getInstance(); - int y = now.get(Calendar.YEAR); + Date now = new Date(); + int y = 1900 + now.getYear(); String name = "R" + y; - 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); + 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(); 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 3420aaee0..811c5f107 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,7 +22,6 @@ 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; @@ -191,11 +190,8 @@ public class RenewalServlet extends CMSServlet { if (beginYear != -1 && beginMonth != -1 && beginDate != -1 && endYear != -1 && endMonth != -1 && endDate != -1) { - Calendar calendar = Calendar.getInstance(); - calendar.set(beginYear, beginMonth, beginDate); - notBefore = calendar.getTime(); - calendar.set(endYear, endMonth, endDate); - notAfter = calendar.getTime(); + notBefore = new Date(beginYear, beginMonth, beginDate); + notAfter = new Date(endYear, endMonth, endDate); } } // 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 dc240dac2..c492feac0 100644 --- a/pki/base/common/src/com/netscape/cmscore/security/CertificateInfo.java +++ b/pki/base/common/src/com/netscape/cmscore/security/CertificateInfo.java @@ -27,7 +27,6 @@ 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; @@ -143,13 +142,10 @@ public abstract class CertificateInfo { int afterSec = Integer.parseInt(mProperties.getAfterSec()); - Calendar calendar = Calendar.getInstance(); - calendar.set(beginYear, beginMonth, beginDate, + notBeforeDate = new Date(beginYear, beginMonth, beginDate, beginHour, beginMin, beginSec); - notBeforeDate = calendar.getTime(); - calendar.set(afterYear, afterMonth, afterDate, - afterHour, afterMin, afterSec); - notAfterDate = calendar.getTime(); + notAfterDate = new Date(afterYear, afterMonth, afterDate, + afterHour, afterMin, afterSec); } return new CertificateValidity(notBeforeDate, notAfterDate); } |