[java-identity-provider COMMIT] in /trunk/idp-attribute-filter-impl/src: main/java/net/shibboleth/idp/attribute/filte...

noreply at shibboleth.net noreply at shibboleth.net
Wed Aug 10 15:23:51 BST 2011


Author: rdw
Date: Wed Aug 10 15:23:50 2011
New Revision: 4005

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=4005&view=rev
Log:
Move the "boolean" matchers to be set up via setters, not parameters to the constructor.

Added:
    trunk/idp-attribute-filter-impl/src/test/java/net/shibboleth/idp/attribute/filtering/impl/matcher/DestroyableAttributeValueStringMatcher.java   (with props)
Modified:
    trunk/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filtering/impl/matcher/AndMatcher.java
    trunk/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filtering/impl/matcher/NotMatcher.java
    trunk/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filtering/impl/matcher/OrMatcher.java
    trunk/idp-attribute-filter-impl/src/test/java/net/shibboleth/idp/attribute/filtering/impl/matcher/TestAndMatcher.java
    trunk/idp-attribute-filter-impl/src/test/java/net/shibboleth/idp/attribute/filtering/impl/matcher/TestNotMatcher.java
    trunk/idp-attribute-filter-impl/src/test/java/net/shibboleth/idp/attribute/filtering/impl/matcher/TestOrMatcher.java

Modified: trunk/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filtering/impl/matcher/AndMatcher.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filtering/impl/matcher/AndMatcher.java?rev=4005&r1=4004&r2=4005&view=diff
==============================================================================
--- trunk/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filtering/impl/matcher/AndMatcher.java (original)
+++ trunk/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filtering/impl/matcher/AndMatcher.java Wed Aug 10 15:23:50 2011
@@ -30,8 +30,10 @@
 import net.shibboleth.idp.attribute.filtering.AttributeFilteringException;
 import net.shibboleth.idp.attribute.filtering.AttributeValueMatcher;
 
-import org.opensaml.util.Assert;
 import org.opensaml.util.collections.CollectionSupport;
+import org.opensaml.util.component.ComponentInitializationException;
+import org.opensaml.util.component.DestructableComponent;
+import org.opensaml.util.component.InitializableComponent;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -44,45 +46,67 @@
  * However it seems likely that such a constraint is erroneous...
  */
 @ThreadSafe
-public class AndMatcher implements AttributeValueMatcher {
+public class AndMatcher implements AttributeValueMatcher, InitializableComponent, DestructableComponent {
 
     /** Class logger. */
     private final Logger log = LoggerFactory.getLogger(OrMatcher.class);
+
+    /** Initialized state. */
+    private boolean initialized;
+
+    /** Destructor state. */
+    private boolean destroyed;
 
     /**
      * The supplied matchers to be ORed together.
      * 
      * This list in unmodifiable.
      */
-    private final List<AttributeValueMatcher> matchers;
+    private List<AttributeValueMatcher> matchers = Collections.emptyList();
 
     /**
      * Constructor.
-     * 
-     * @param theMatchers a list of sub matchers.
      */
-    public AndMatcher(final List<AttributeValueMatcher> theMatchers) {
-
-        final List<AttributeValueMatcher> workingMatcherList = new ArrayList<AttributeValueMatcher>();
-
+    public AndMatcher() {
         log.info("AND matcher as part of a Permit or Deny rule is likely to be a configuration error");
-
-        CollectionSupport.addNonNull(theMatchers, workingMatcherList);
-        if (workingMatcherList.isEmpty()) {
-            log.warn("No sub-matchers provided to AND Value Matcher, this always returns no results");
-        }
-        matchers = Collections.unmodifiableList(workingMatcherList);
     }
 
-    /** private default constructor to force the invariant of matchers being non null. */
-    @SuppressWarnings("unused")
-    private AndMatcher() {
-        Assert.isFalse(true, "uncallable code");
+    /**
+     * Has initialize been called on this object. {@inheritDoc}.
+     * */
+    public boolean isInitialized() {
+        return initialized;
+    }
+
+    /** Mark the object as initialized having initialized any children. {@inheritDoc}. */
+    public void initialize() throws ComponentInitializationException {
+        if (initialized) {
+            throw new ComponentInitializationException("And Matcher is initialized multiple times");
+        }
+        for (AttributeValueMatcher matcher : matchers) {
+            if (matcher instanceof InitializableComponent) {
+                InitializableComponent init = (InitializableComponent) matcher;
+                init.initialize();
+            }
+        }
+        initialized = true;
+    }
+
+    /** tear down any destructable children. {@inheritDoc} */
+    public void destroy() {
+        destroyed = true;
+        for (AttributeValueMatcher matcher : matchers) {
+            if (matcher instanceof DestructableComponent) {
+                DestructableComponent destructee = (DestructableComponent) matcher;

[... 650 lines stripped ...]


More information about the commits mailing list