[java-identity-provider] branch master updated: IDP-1210 - Insulate public joda-time references.

Scott Cantor cantor.2 at osu.edu
Wed Mar 28 10:31:14 EDT 2018


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

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

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

The following commit(s) were added to refs/heads/master by this push:
       new  38fcfa8   IDP-1210 - Insulate public joda-time references.
38fcfa8 is described below

commit 38fcfa892b9eec4f072ceb08fce4d5ca5294270c
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Mar 28 10:31:11 2018 -0400

    IDP-1210 - Insulate public joda-time references.
    
    https://issues.shibboleth.net/jira/browse/IDP-1210
    
    Remediate expiring-password config.
---
 .../expiring-password-intercept-config.xml         | 10 ++----
 .../idp/profile/logic/DateAttributePredicate.java  | 40 +++++++++++++++++++---
 2 files changed, 37 insertions(+), 13 deletions(-)

diff --git a/idp-conf/src/main/resources/conf/intercept/expiring-password-intercept-config.xml b/idp-conf/src/main/resources/conf/intercept/expiring-password-intercept-config.xml
index 5447b16..b3bf96d 100644
--- a/idp-conf/src/main/resources/conf/intercept/expiring-password-intercept-config.xml
+++ b/idp-conf/src/main/resources/conf/intercept/expiring-password-intercept-config.xml
@@ -19,14 +19,8 @@
     The format pattern parses the value and the negative offset determines how soon to warn the user beforehand.
     -->
     <bean id="shibboleth.expiring-password.Condition" class="net.shibboleth.idp.profile.logic.DateAttributePredicate"
-            c:attribute="passwordExpiration" p:resultIfMissing="true">
-        <constructor-arg name="formatter">
-            <bean class="org.joda.time.format.DateTimeFormat" factory-method="forPattern" c:_0="yyyyMMddHHmmss'T'" />
-        </constructor-arg>
-        <property name="systemTimeOffset">
-            <bean class="org.joda.time.Duration" factory-method="standardDays" c:_0="-14" />
-        </property>
-    </bean>
+            c:attribute="passwordExpiration" c:formatString="yyyyMMddHHmmss'T'"
+            p:resultIfMissing="true" p:offset="-P14D" />
     
     <!-- Name of cookie to track when user was last notified. -->
     <bean id="shibboleth.expiring-password.NotifyCookieName" class="java.lang.String" c:_0="shib_idp_exp_pwd" />
diff --git a/idp-profile-api/src/main/java/net/shibboleth/idp/profile/logic/DateAttributePredicate.java b/idp-profile-api/src/main/java/net/shibboleth/idp/profile/logic/DateAttributePredicate.java
index 5a21d1a..9bc1926 100644
--- a/idp-profile-api/src/main/java/net/shibboleth/idp/profile/logic/DateAttributePredicate.java
+++ b/idp-profile-api/src/main/java/net/shibboleth/idp/profile/logic/DateAttributePredicate.java
@@ -20,17 +20,20 @@ package net.shibboleth.idp.profile.logic;
 import net.shibboleth.idp.attribute.IdPAttribute;
 import net.shibboleth.idp.attribute.IdPAttributeValue;
 import net.shibboleth.idp.attribute.StringAttributeValue;
+import net.shibboleth.utilities.java.support.annotation.Duration;
 import net.shibboleth.utilities.java.support.annotation.ParameterName;
 import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
 import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
 import net.shibboleth.utilities.java.support.logic.Constraint;
-import org.joda.time.Duration;
+import org.joda.time.format.DateTimeFormat;
 import org.joda.time.format.DateTimeFormatter;
 import org.joda.time.format.ISODateTimeFormat;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
 import java.util.Map;
 
 /**
@@ -53,7 +56,7 @@ public class DateAttributePredicate extends AbstractAttributePredicate {
     @Nonnull private final DateTimeFormatter dateTimeFormatter;
 
     /** Offset from system time used for date comparisons. */
-    @Nonnull private Duration systemTimeOffset;
+    @Nullable private org.joda.time.Duration systemTimeOffset;
     
     /** Result of predicate if attribute is missing or has no values. */
     private boolean resultIfMissing;
@@ -75,26 +78,53 @@ public class DateAttributePredicate extends AbstractAttributePredicate {
      * @param attribute Attribute name that provides candidate date values to test.
      * @param formatter Date/time parser.
      */
+    @Deprecated
     public DateAttributePredicate(@Nonnull @NotEmpty @ParameterName(name="attribute") final String attribute,
             @Nonnull @ParameterName(name="formatter") final DateTimeFormatter formatter) {
         attributeName = Constraint.isNotNull(attribute, "Attribute cannot be null");
         dateTimeFormatter = Constraint.isNotNull(formatter, "Formatter cannot be null");
-        systemTimeOffset = Duration.ZERO;
         resultIfMissing = false;
     }
 
     /**
+     * Create a new instance that performs date comparisons against the given attribute
+     * using the given date parser.
+     *
+     * @param attribute Attribute name that provides candidate date values to test.
+     * @param formatString date/time parsing string, currently based on {@link DateTimeFormatter}
+     */
+    public DateAttributePredicate(@Nonnull @NotEmpty @ParameterName(name="attribute") final String attribute,
+            @Nonnull @NotEmpty @ParameterName(name="formatString") final String formatString) {
+        attributeName = Constraint.isNotNull(attribute, "Attribute cannot be null");
+        dateTimeFormatter = DateTimeFormat.forPattern(
+                Constraint.isNotNull(formatString, "Format string cannot be null"));
+        resultIfMissing = false;
+    }
+    
+    /**
      * Set the system time offset, which affects the reference date for comparisons.
      * By default all comparisons are against system time, i.e. zero offset.
      *
      * @param offset System time offset. A negative value decreases the target date (sooner);
      *                         a positive value increases the target date (later).
      */
-    public void setSystemTimeOffset(@Nonnull final Duration offset) {
-        systemTimeOffset = Constraint.isNotNull(offset, "Offset cannot not be null");
+    @Deprecated
+    public void setSystemTimeOffset(@Nonnull final org.joda.time.Duration offset) {
+        systemTimeOffset = Constraint.isNotNull(offset, "Offset cannot be null");
     }
 
     /**
+     * Set the system time offset, which affects the reference date for comparisons.
+     * By default all comparisons are against system time, i.e. zero offset.
+     *
+     * @param offset System time offset. A negative value decreases the target date (sooner);
+     *                         a positive value increases the target date (later).
+     */
+    @Duration public void setOffset(@Duration final long offset) {
+        systemTimeOffset = org.joda.time.Duration.millis(offset);
+    }
+    
+    /**
      * Set the result to return if the attribute to check is missing or has no values.
      * 
      * @param flag  flag to set

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


More information about the commits mailing list