aboutsummaryrefslogtreecommitdiff
path: root/common/src/main/java/at/gv/egovernment
diff options
context:
space:
mode:
authorkstranacher <kstranacher@d688527b-c9ab-4aba-bd8d-4036d912da1d>2012-01-26 21:59:33 +0000
committerkstranacher <kstranacher@d688527b-c9ab-4aba-bd8d-4036d912da1d>2012-01-26 21:59:33 +0000
commita9b2e962d2853b74d314cb9f614cab446a7134c0 (patch)
treeebf5e54d2a8321162da208f2b7dba1285dc926f9 /common/src/main/java/at/gv/egovernment
parentfd49902f62d361acb1102024c98c304fac265fa1 (diff)
downloadmoa-id-spss-a9b2e962d2853b74d314cb9f614cab446a7134c0.tar.gz
moa-id-spss-a9b2e962d2853b74d314cb9f614cab446a7134c0.tar.bz2
moa-id-spss-a9b2e962d2853b74d314cb9f614cab446a7134c0.zip
* optionalen useUTC Parameter in Konfig eingefügt (damit IssueInstant in SAML Assertion auf UTC einstellbar)
* optionalen sourceID Parameter bei MOA-ID Aufruf eingefügt (wird 1:1 in SAML Assertion übernommen) * Update Doku (useUTC, sourceID, Vollmachten-Profile) * Ablaufänderung bei Vollmachten-Modus (Signatur Zertifikat wird aus Signatur entnommen und nicht mittels eigenem Infobox-Request) git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@1233 d688527b-c9ab-4aba-bd8d-4036d912da1d
Diffstat (limited to 'common/src/main/java/at/gv/egovernment')
-rw-r--r--common/src/main/java/at/gv/egovernment/moa/util/DateTimeUtils.java83
1 files changed, 51 insertions, 32 deletions
diff --git a/common/src/main/java/at/gv/egovernment/moa/util/DateTimeUtils.java b/common/src/main/java/at/gv/egovernment/moa/util/DateTimeUtils.java
index 92e845967..d70073db8 100644
--- a/common/src/main/java/at/gv/egovernment/moa/util/DateTimeUtils.java
+++ b/common/src/main/java/at/gv/egovernment/moa/util/DateTimeUtils.java
@@ -26,6 +26,7 @@ package at.gv.egovernment.moa.util;
import java.io.StringWriter;
import java.text.ParseException;
+import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
@@ -48,38 +49,56 @@ public class DateTimeUtils {
* @param cal the <code>Calendar</code> value
* @return the <code>dateTime</code> value
*/
- public static String buildDateTime(Calendar cal) {
- StringWriter out = new StringWriter();
- out.write("" + cal.get(Calendar.YEAR));
- out.write("-");
- out.write(to2DigitString(cal.get(Calendar.MONTH) + 1));
- out.write("-");
- out.write(to2DigitString(cal.get(Calendar.DAY_OF_MONTH)));
- out.write("T");
- out.write(to2DigitString(cal.get(Calendar.HOUR_OF_DAY)));
- out.write(":");
- out.write(to2DigitString(cal.get(Calendar.MINUTE)));
- out.write(":");
- out.write(to2DigitString(cal.get(Calendar.SECOND)));
- int tzOffsetMilliseconds =
- cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET);
- if (tzOffsetMilliseconds != 0) {
- int tzOffsetMinutes = tzOffsetMilliseconds / (1000 * 60);
- int tzOffsetHours = tzOffsetMinutes / 60;
- tzOffsetMinutes -= tzOffsetHours * 60;
- if (tzOffsetMilliseconds > 0) {
- out.write("+");
- out.write(to2DigitString(tzOffsetHours));
- out.write(":");
- out.write(to2DigitString(tzOffsetMinutes));
- } else {
- out.write("-");
- out.write(to2DigitString(-tzOffsetHours));
- out.write(":");
- out.write(to2DigitString(-tzOffsetMinutes));
- }
- }
- return out.toString();
+ public static String buildDateTime(Calendar cal, boolean useUTC) {
+
+ if (useUTC)
+ return buildDateTimeUTC(cal);
+ else {
+ StringWriter out = new StringWriter();
+ out.write("" + cal.get(Calendar.YEAR));
+ out.write("-");
+ out.write(to2DigitString(cal.get(Calendar.MONTH) + 1));
+ out.write("-");
+ out.write(to2DigitString(cal.get(Calendar.DAY_OF_MONTH)));
+ out.write("T");
+ out.write(to2DigitString(cal.get(Calendar.HOUR_OF_DAY)));
+ out.write(":");
+ out.write(to2DigitString(cal.get(Calendar.MINUTE)));
+ out.write(":");
+ out.write(to2DigitString(cal.get(Calendar.SECOND)));
+ int tzOffsetMilliseconds =
+ cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET);
+ if (tzOffsetMilliseconds != 0) {
+ int tzOffsetMinutes = tzOffsetMilliseconds / (1000 * 60);
+ int tzOffsetHours = tzOffsetMinutes / 60;
+ tzOffsetMinutes -= tzOffsetHours * 60;
+ if (tzOffsetMilliseconds > 0) {
+ out.write("+");
+ out.write(to2DigitString(tzOffsetHours));
+ out.write(":");
+ out.write(to2DigitString(tzOffsetMinutes));
+ } else {
+ out.write("-");
+ out.write(to2DigitString(-tzOffsetHours));
+ out.write(":");
+ out.write(to2DigitString(-tzOffsetMinutes));
+ }
+ }
+ return out.toString();
+ }
+ }
+
+ /**
+ * Builds a <code>dateTime</code> value in UTC from a <code>Calendar</code> value.
+ * @param cal the <code>Calendar</code> value
+ * @return the <code>dateTime</code> value
+ */
+ public static String buildDateTimeUTC(Calendar cal) {
+
+ SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
+ f.setTimeZone(TimeZone.getTimeZone("UTC"));
+
+ return f.format(cal.getTime());
}
/**