[java-identity-provider COMMIT] in /trunk: idp-conf/src/main/resources/system/conf/profile-intercept-system.xml idp-c...

noreply at shibboleth.net noreply at shibboleth.net
Thu Nov 20 00:42:53 EST 2014


Author: tzeller
Date: Thu Nov 20 00:42:53 2014
New Revision: 6964

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=6964&view=rev
Log:
Convert AttributePredicate to setter-based DI plus tests.

Added:
    trunk/idp-consent/src/test/java/net/shibboleth/idp/consent/logic/AttributePredicateTest.java   (with props)
Modified:
    trunk/idp-conf/src/main/resources/system/conf/profile-intercept-system.xml
    trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/logic/AttributePredicate.java

Modified: trunk/idp-conf/src/main/resources/system/conf/profile-intercept-system.xml
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-conf/src/main/resources/system/conf/profile-intercept-system.xml?rev=6964&r1=6963&r2=6964&view=diff
==============================================================================
--- trunk/idp-conf/src/main/resources/system/conf/profile-intercept-system.xml (original)
+++ trunk/idp-conf/src/main/resources/system/conf/profile-intercept-system.xml Thu Nov 20 00:42:53 2014
@@ -68,9 +68,9 @@
     <!-- Predicate used to determine if consent should be obtained for an attribute. -->
     <bean id="shibboleth.consent.AttributeConsent.AttributePredicate"
         class="net.shibboleth.idp.consent.logic.AttributePredicate"
-        c:whitelist-ref="shibboleth.attribute-release.WhitelistedAttributeIDs"
-        c:blacklist-ref="shibboleth.attribute-release.BlacklistedAttributeIDs"
-        c:matchExpression="#{getObject('shibboleth.attribute-release.MatchExpression')}"
+        p:whitelistedAttributeIds-ref="shibboleth.attribute-release.WhitelistedAttributeIDs"
+        p:blacklistedAttributeIds-ref="shibboleth.attribute-release.BlacklistedAttributeIDs"
+        p:attributeIdMatchExpression="#{getObject('shibboleth.attribute-release.MatchExpression')}"
         scope="prototype" />
 
 </beans>

Modified: trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/logic/AttributePredicate.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/logic/AttributePredicate.java?rev=6964&r1=6963&r2=6964&view=diff
==============================================================================
--- trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/logic/AttributePredicate.java (original)
+++ trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/logic/AttributePredicate.java Thu Nov 20 00:42:53 2014
@@ -18,6 +18,7 @@
 package net.shibboleth.idp.consent.logic;
 
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Set;
 import java.util.regex.Pattern;
 
@@ -26,7 +27,8 @@
 
 import net.shibboleth.idp.attribute.IdPAttribute;
 import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
-import net.shibboleth.utilities.java.support.annotation.constraint.NullableElements;
+import net.shibboleth.utilities.java.support.component.AbstractInitializableComponent;
+import net.shibboleth.utilities.java.support.component.ComponentSupport;
 import net.shibboleth.utilities.java.support.primitive.StringSupport;
 
 import com.google.common.base.Predicate;
@@ -35,7 +37,7 @@
 /**
  * Predicate to determine whether consent should be obtained for an attribute.
  */
-public class AttributePredicate implements Predicate<IdPAttribute> {
+public class AttributePredicate extends AbstractInitializableComponent implements Predicate<IdPAttribute> {
 
     /** Whitelist of attribute IDs to allow. */
     @Nonnull @NonnullElements private Set<String> whitelistedAttributeIds;
@@ -44,21 +46,45 @@
     @Nonnull @NonnullElements private Set<String> blacklistedAttributeIds;
 
     /** Regular expression to apply for acceptance testing. */
-    @Nullable private Pattern expression;
+    @Nullable private Pattern matchExpression;
+
+    /** Constructor. */
+    public AttributePredicate() {
+        whitelistedAttributeIds = Collections.emptySet();
+        blacklistedAttributeIds = Collections.emptySet();
+    }
 
     /**
+     * Set the whitelisted attribute IDs.
      * 
-     * Constructor.
-     *
      * @param whitelist whitelisted attribute IDs
+     */
+    public void setWhitelistedAttributeIds(@Nonnull @NonnullElements final Collection<String> whitelist) {
+        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+
+        whitelistedAttributeIds = Sets.newHashSet(StringSupport.normalizeStringCollection(whitelist));
+    }
+
+    /**
+     * Set the blacklisted attribute IDs.
+     * 
      * @param blacklist blacklisted attribute IDs
-     * @param matchExpression attribute ID pattern
      */
-    public AttributePredicate(@Nullable @NullableElements final Collection<String> whitelist,
-            @Nullable @NullableElements final Collection<String> blacklist, @Nullable final Pattern matchExpression) {
-        whitelistedAttributeIds = Sets.newHashSet(StringSupport.normalizeStringCollection(whitelist));
+    public void setBlacklistedAttributeIds(@Nonnull @NonnullElements final Collection<String> blacklist) {

[... 38 lines stripped ...]


More information about the commits mailing list