[java-identity-provider] 16/16: IDP-1214 - Timestamp doesn't have configurable date handling

Scott Cantor cantor.2 at osu.edu
Tue Sep 26 12:41:26 EDT 2017


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch maint-3.3
in repository java-identity-provider.

View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=5bfe858f1dbb5ef230cec73dddd6b3725687b035

commit 5bfe858f1dbb5ef230cec73dddd6b3725687b035
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Sep 6 17:45:48 2017 -0400

    IDP-1214 - Timestamp doesn't have configurable date handling
    
    https://issues.shibboleth.net/jira/browse/IDP-1214
---
 .../system/flows/admin/admin-abstract-beans.xml    |  2 ++
 .../system/flows/cas/cas-abstract-beans.xml        |  2 ++
 .../flows/intercept/attribute-release-beans.xml    |  2 ++
 .../system/flows/intercept/terms-of-use-beans.xml  |  2 ++
 .../resources/system/flows/logout/logout-beans.xml |  2 ++
 .../flows/logout/logout-propagation-beans.xml      |  5 ++-
 .../system/flows/saml/saml-abstract-beans.xml      |  2 ++
 .../idp/profile/audit/impl/WriteAuditLog.java      | 36 +++++++++++++++++++++-
 8 files changed, 51 insertions(+), 2 deletions(-)

diff --git a/idp-conf/src/main/resources/system/flows/admin/admin-abstract-beans.xml b/idp-conf/src/main/resources/system/flows/admin/admin-abstract-beans.xml
index d102fa6..3ff1a3e 100644
--- a/idp-conf/src/main/resources/system/flows/admin/admin-abstract-beans.xml
+++ b/idp-conf/src/main/resources/system/flows/admin/admin-abstract-beans.xml
@@ -106,6 +106,8 @@
     <bean id="WriteAuditLog" class="net.shibboleth.idp.profile.audit.impl.WriteAuditLog" scope="prototype"
         p:activationCondition-ref="shibboleth.ProfileAuditingCondition"
         p:formattingMap-ref="shibboleth.AuditFormattingMap"
+        p:dateTimeFormat="#{getObject('shibboleth.AuditDateTimeFormat')}"
+        p:useDefaultTimeZone="#{getObject('shibboleth.AuditDefaultTimeZone') ?: false}"
         p:httpServletRequest-ref="shibboleth.HttpServletRequest" />
     
     <bean id="MapEventToView"
diff --git a/idp-conf/src/main/resources/system/flows/cas/cas-abstract-beans.xml b/idp-conf/src/main/resources/system/flows/cas/cas-abstract-beans.xml
index 3789bbf..e71881d 100644
--- a/idp-conf/src/main/resources/system/flows/cas/cas-abstract-beans.xml
+++ b/idp-conf/src/main/resources/system/flows/cas/cas-abstract-beans.xml
@@ -103,6 +103,8 @@
           class="net.shibboleth.idp.profile.audit.impl.WriteAuditLog"
           scope="prototype"
           p:formattingMap-ref="shibboleth.AuditFormattingMap"
+          p:dateTimeFormat="#{getObject('shibboleth.AuditDateTimeFormat')}"
+          p:useDefaultTimeZone="#{getObject('shibboleth.AuditDefaultTimeZone') ?: false}"
           p:httpServletRequest-ref="shibboleth.HttpServletRequest" />
 
     <bean id="ErrorViewPopulateAuditContext" parent="shibboleth.AbstractPopulateAuditContext"
diff --git a/idp-conf/src/main/resources/system/flows/intercept/attribute-release-beans.xml b/idp-conf/src/main/resources/system/flows/intercept/attribute-release-beans.xml
index 239fb9d..2a6edac 100644
--- a/idp-conf/src/main/resources/system/flows/intercept/attribute-release-beans.xml
+++ b/idp-conf/src/main/resources/system/flows/intercept/attribute-release-beans.xml
@@ -157,6 +157,8 @@
         class="net.shibboleth.idp.profile.audit.impl.WriteAuditLog" scope="prototype"
         p:auditContextLookupStrategy-ref="shibboleth.consent.ChildLookup.ConsentAuditContext"
         p:formattingMap-ref="shibboleth.consent.attribute-release.AuditFormattingMap"
+        p:dateTimeFormat="#{getObject('shibboleth.AuditDateTimeFormat')}"
+        p:useDefaultTimeZone="#{getObject('shibboleth.AuditDefaultTimeZone') ?: false}"
         p:httpServletRequest-ref="shibboleth.HttpServletRequest" />
 
 </beans>
diff --git a/idp-conf/src/main/resources/system/flows/intercept/terms-of-use-beans.xml b/idp-conf/src/main/resources/system/flows/intercept/terms-of-use-beans.xml
index f919e18..520083a 100644
--- a/idp-conf/src/main/resources/system/flows/intercept/terms-of-use-beans.xml
+++ b/idp-conf/src/main/resources/system/flows/intercept/terms-of-use-beans.xml
@@ -99,6 +99,8 @@
     <bean id="WriteConsentAuditLog" class="net.shibboleth.idp.profile.audit.impl.WriteAuditLog" scope="prototype"
         p:auditContextLookupStrategy-ref="shibboleth.consent.ChildLookup.ConsentAuditContext"
         p:formattingMap-ref="shibboleth.consent.terms-of-use.AuditFormattingMap"
+        p:dateTimeFormat="#{getObject('shibboleth.AuditDateTimeFormat')}"
+        p:useDefaultTimeZone="#{getObject('shibboleth.AuditDefaultTimeZone') ?: false}"
         p:httpServletRequest-ref="shibboleth.HttpServletRequest" />
 
 </beans>
diff --git a/idp-conf/src/main/resources/system/flows/logout/logout-beans.xml b/idp-conf/src/main/resources/system/flows/logout/logout-beans.xml
index c344a7b..a46ec9d 100644
--- a/idp-conf/src/main/resources/system/flows/logout/logout-beans.xml
+++ b/idp-conf/src/main/resources/system/flows/logout/logout-beans.xml
@@ -110,6 +110,8 @@
     </bean>
     
     <bean id="WriteAuditLog" class="net.shibboleth.idp.profile.audit.impl.WriteAuditLog" scope="prototype"
+        p:dateTimeFormat="#{getObject('shibboleth.AuditDateTimeFormat')}"
+        p:useDefaultTimeZone="#{getObject('shibboleth.AuditDefaultTimeZone') ?: false}"
         p:httpServletRequest-ref="shibboleth.HttpServletRequest"
         p:formattingMap-ref="shibboleth.AuditFormattingMap" />
 
diff --git a/idp-conf/src/main/resources/system/flows/logout/logout-propagation-beans.xml b/idp-conf/src/main/resources/system/flows/logout/logout-propagation-beans.xml
index ef22a6b..4403ab2 100644
--- a/idp-conf/src/main/resources/system/flows/logout/logout-propagation-beans.xml
+++ b/idp-conf/src/main/resources/system/flows/logout/logout-propagation-beans.xml
@@ -45,7 +45,10 @@
         c:selector-ref="shibboleth.LogoutPropagationFlowSelector" />
 
     <bean id="WriteAuditLog" class="net.shibboleth.idp.profile.audit.impl.WriteAuditLog" scope="prototype"
-        p:formattingMap-ref="shibboleth.AuditFormattingMap" />
+        p:dateTimeFormat="#{getObject('shibboleth.AuditDateTimeFormat')}"
+        p:useDefaultTimeZone="#{getObject('shibboleth.AuditDefaultTimeZone') ?: false}"
+        p:formattingMap-ref="shibboleth.AuditFormattingMap"
+        p:httpServletRequest-ref="shibboleth.HttpServletRequest" />
 
     <bean id="RecordResponseComplete"
         class="net.shibboleth.idp.profile.impl.RecordResponseComplete" scope="prototype" />
diff --git a/idp-conf/src/main/resources/system/flows/saml/saml-abstract-beans.xml b/idp-conf/src/main/resources/system/flows/saml/saml-abstract-beans.xml
index 1db0b9f..5693e94 100644
--- a/idp-conf/src/main/resources/system/flows/saml/saml-abstract-beans.xml
+++ b/idp-conf/src/main/resources/system/flows/saml/saml-abstract-beans.xml
@@ -324,6 +324,8 @@
 
     <bean id="WriteAuditLog" class="net.shibboleth.idp.profile.audit.impl.WriteAuditLog" scope="prototype"
         p:formattingMap-ref="shibboleth.AuditFormattingMap"
+        p:dateTimeFormat="#{getObject('shibboleth.AuditDateTimeFormat')}"
+        p:useDefaultTimeZone="#{getObject('shibboleth.AuditDefaultTimeZone') ?: false}"
         p:httpServletRequest-ref="shibboleth.HttpServletRequest" />
         
     <bean id="WriteFTICKSLog" class="net.shibboleth.idp.saml.audit.impl.WriteFTICKSLog" scope="prototype"
diff --git a/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/audit/impl/WriteAuditLog.java b/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/audit/impl/WriteAuditLog.java
index 18ad2cd..914856f 100644
--- a/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/audit/impl/WriteAuditLog.java
+++ b/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/audit/impl/WriteAuditLog.java
@@ -73,6 +73,12 @@ public class WriteAuditLog extends AbstractProfileAction {
     /** Map of log category to formatting tokens and literals to output. */
     @Nonnull @NotEmpty private Map<String,List<String>> formattingMap;
 
+    /** Formatting string for {@link DateTime} fields. */
+    @Nullable private String dateTimeFormat;
+    
+    /** Convert {@link DateTime} fields to default time zone. */
+    private boolean useDefaultTimeZone;
+
     /** The Spring RequestContext to operate on. */
     @Nullable private RequestContext requestContext;
 
@@ -164,6 +170,27 @@ public class WriteAuditLog extends AbstractProfileAction {
     }
 // Checkstyle: CyclomaticComplexity ON
 
+    /**
+     * Set the {@link DateTime} formatting string to apply when extracting {@link DateTime}-valued fields.
+     * 
+     * @param format formatting string
+     */
+    public void setDateTimeFormat(@Nullable @NotEmpty final String format) {
+        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+        
+        dateTimeFormat = StringSupport.trimOrNull(format);
+    }
+    
+    /**
+     * Convert {@link DateTime}-valued fields to default time zone.
+     * 
+     * @param flag flag to set
+     */
+    public void setUseDefaultTimeZone(final boolean flag) {
+        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+        
+        useDefaultTimeZone = flag;
+    }
 
     /** {@inheritDoc} */
     @Override
@@ -205,7 +232,14 @@ public class WriteAuditLog extends AbstractProfileAction {
                         final String field = token.substring(1);
                         
                         if (IdPAuditFields.EVENT_TIME.equals(field)) {
-                            record.append(new DateTime().toString(v2Formatter.withZone(DateTimeZone.UTC)));
+                            if (dateTimeFormat != null) {
+                                record.append(new DateTime(
+                                        useDefaultTimeZone ? DateTimeZone.getDefault() : DateTimeZone.UTC).toString(
+                                                dateTimeFormat));
+                            } else {
+                                record.append(new DateTime().toString(v2Formatter.withZone(
+                                        useDefaultTimeZone ? DateTimeZone.getDefault() : DateTimeZone.UTC)));
+                            }
                         } else if (IdPAuditFields.EVENT_TYPE.equals(field)) {
                             final Event event = requestContext.getCurrentEvent();
                             if (event != null && !event.getId().equals(EventIds.PROCEED_EVENT_ID)) {

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list