[java-identity-provider] branch master updated: Refactoring, and addition of issuer-based EntityAttribute rules.

Scott Cantor cantor.2 at osu.edu
Wed May 22 19:07:07 EDT 2019


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=9f36dc1c79b8302c25b6ff580565e7037734cc65

The following commit(s) were added to refs/heads/master by this push:
       new  9f36dc1   Refactoring, and addition of issuer-based EntityAttribute rules.
9f36dc1 is described below

commit 9f36dc1c79b8302c25b6ff580565e7037734cc65
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed May 22 19:07:03 2019 -0400

    Refactoring, and addition of issuer-based EntityAttribute rules.
---
 .../filter/context/AttributeFilterContext.java     | 66 ++++++++++++++++-----
 ...=> AbstractEntityAttributeExactPolicyRule.java} | 41 ++++---------
 ...=> AbstractEntityAttributeRegexPolicyRule.java} | 44 ++++----------
 ...ributeIssuerEntityAttributeExactPolicyRule.java | 40 +++++++++++++
 ...ributeIssuerEntityAttributeRegexPolicyRule.java | 40 +++++++++++++
 ...uteRequesterEntityAttributeExactPolicyRule.java | 61 ++------------------
 ...uteRequesterEntityAttributeRegexPolicyRule.java | 67 ++--------------------
 7 files changed, 164 insertions(+), 195 deletions(-)

diff --git a/idp-attribute-filter-api/src/main/java/net/shibboleth/idp/attribute/filter/context/AttributeFilterContext.java b/idp-attribute-filter-api/src/main/java/net/shibboleth/idp/attribute/filter/context/AttributeFilterContext.java
index 8e8f8b7..c409900 100644
--- a/idp-attribute-filter-api/src/main/java/net/shibboleth/idp/attribute/filter/context/AttributeFilterContext.java
+++ b/idp-attribute-filter-api/src/main/java/net/shibboleth/idp/attribute/filter/context/AttributeFilterContext.java
@@ -28,7 +28,6 @@ import javax.annotation.Nullable;
 import javax.annotation.concurrent.NotThreadSafe;
 
 import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
 import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
 import net.shibboleth.utilities.java.support.annotation.constraint.NullableElements;
 import net.shibboleth.utilities.java.support.collection.CollectionSupport;
@@ -65,17 +64,20 @@ public final class AttributeFilterContext extends BaseContext {
 
     /** The attribute recipient's group identity. */
     @Nullable private String attributeRecipientGroupID;
-    
-    /** How was the principal Authenticated? */
-    @Deprecated
-    @Nullable private String principalAuthenticationMethod;
 
-    /** Cache of the metadata context. */
+    /** Cache of IdP metadata context. */
+    @Nullable private SAMLMetadataContext issuerMetadataContext;
+    
+    /** Cache of SP metadata context. */
     @Nullable private SAMLMetadataContext requesterMetadataContext;
 
     /** Cache of the proxied requester context. */
     @Nullable private ProxiedRequesterContext proxiedRequesterContext;
 
+    /** Lookup strategy used to locate the IdP's metadata context. */
+    @Nullable
+    private Function<AttributeFilterContext,SAMLMetadataContext> issuerMetadataContextLookupStrategy;
+
     /** Lookup strategy used to locate the SP's metadata context. */
     @Nullable
     private Function<AttributeFilterContext,SAMLMetadataContext> requesterMetadataContextLookupStrategy;
@@ -86,8 +88,8 @@ public final class AttributeFilterContext extends BaseContext {
 
     /** Constructor. */
     public AttributeFilterContext() {
-        prefilteredAttributes = new HashMap<String, IdPAttribute>();
-        filteredAttributes = new HashMap<String, IdPAttribute>();
+        prefilteredAttributes = new HashMap<>();
+        filteredAttributes = new HashMap<>();
     }
 
     /**
@@ -244,18 +246,41 @@ public final class AttributeFilterContext extends BaseContext {
         
         return this;
     }
-    
+
     /**
-     * Get the strategy used to locate the SP's metadata context.
+     * Get the strategy used to locate the IdP's metadata context.
      * 
      * @return lookup strategy
      */
-    @NonnullAfterInit
-    public Function<AttributeFilterContext, SAMLMetadataContext> getRequesterMetadataContextLookupStrategy() {
+    @Nullable public Function<AttributeFilterContext,SAMLMetadataContext> getRequesterMetadataContextLookupStrategy() {
         return requesterMetadataContextLookupStrategy;
     }
 
     /**
+     * Set the strategy used to locate the IdP's metadata context.
+     * 
+     * @param strategy lookup strategy
+     * 
+     * @since 4.0.0
+     */
+    public void setIssuerMetadataContextLookupStrategy(
+            @Nonnull final Function<AttributeFilterContext,SAMLMetadataContext> strategy) {
+        issuerMetadataContextLookupStrategy =
+                Constraint.isNotNull(strategy, "MetadataContext lookup strategy cannot be null");
+    }
+    
+    /**
+     * Get the strategy used to locate the IdP's metadata context.
+     * 
+     * @return lookup strategy
+     * 
+     * @since 4.0.0
+     */
+    @Nullable public Function<AttributeFilterContext,SAMLMetadataContext> getIssuerMetadataContextLookupStrategy() {
+        return issuerMetadataContextLookupStrategy;
+    }
+
+    /**
      * Set the strategy used to locate the SP's metadata context.
      * 
      * @param strategy lookup strategy
@@ -273,7 +298,7 @@ public final class AttributeFilterContext extends BaseContext {
      * 
      * @since 3.4.0
      */
-    @NonnullAfterInit
+    @Nullable
     public Function<AttributeFilterContext,ProxiedRequesterContext> getProxiedRequesterContextLookupStrategy() {
         return proxiedRequesterContextLookupStrategy;
     }
@@ -291,6 +316,21 @@ public final class AttributeFilterContext extends BaseContext {
                 Constraint.isNotNull(strategy, "ProxiedRequesterContext lookup strategy cannot be null");
     }
 
+    /** Get the Issuer Metadata context.
+     * 
+     * <p>This value is cached and so only calculated once.</p>
+     * 
+     * @return the context
+     * 
+     * @since 4.0.0
+     */
+    @Nullable public SAMLMetadataContext getIssuerMetadataContext() {
+        if (null == issuerMetadataContext && null != issuerMetadataContextLookupStrategy) {
+            issuerMetadataContext = issuerMetadataContextLookupStrategy.apply(this);
+        }
+        return issuerMetadataContext;
+    }
+
     /** Get the Requester Metadata context.
      * 
      * <p>This value is cached and so only calculated once.</p>
diff --git a/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/policyrule/saml/impl/AttributeRequesterEntityAttributeExactPolicyRule.java b/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/policyrule/saml/impl/AbstractEntityAttributeExactPolicyRule.java
similarity index 70%
copy from idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/policyrule/saml/impl/AttributeRequesterEntityAttributeExactPolicyRule.java
copy to idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/policyrule/saml/impl/AbstractEntityAttributeExactPolicyRule.java
index 797cb9b..01d30f2 100644
--- a/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/policyrule/saml/impl/AttributeRequesterEntityAttributeExactPolicyRule.java
+++ b/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/policyrule/saml/impl/AbstractEntityAttributeExactPolicyRule.java
@@ -20,27 +20,17 @@ package net.shibboleth.idp.attribute.filter.policyrule.saml.impl;
 import java.util.Set;
 
 import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
 
-import net.shibboleth.idp.attribute.filter.context.AttributeFilterContext;
 import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
 import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
 import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
 import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
 import net.shibboleth.utilities.java.support.logic.Constraint;
 
-import org.opensaml.saml.common.messaging.context.SAMLMetadataContext;
-import org.opensaml.saml.saml2.metadata.EntityDescriptor;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 /**
- * Matcher that checks, via an exact match, if the attribute requester contains an entity attribute with a given value.
+ * Matcher that checks, via an exact match, for an entity attribute with a given value.
  */
-public class AttributeRequesterEntityAttributeExactPolicyRule extends AbstractEntityAttributePolicyRule {
-
-    /** Class logger. */
-    @Nonnull private final Logger log = LoggerFactory.getLogger(AttributeRequesterEntityAttributeExactPolicyRule.class);
+public abstract class AbstractEntityAttributeExactPolicyRule extends AbstractEntityAttributePolicyRule {
 
     /** The value of the entity attribute the entity must have. */
     @NonnullAfterInit @NotEmpty private String value;
@@ -65,24 +55,6 @@ public class AttributeRequesterEntityAttributeExactPolicyRule extends AbstractEn
 
     /** {@inheritDoc} */
     @Override
-    protected boolean entityAttributeValueMatches(
-            @Nonnull @NotEmpty @NonnullElements final Set<String> entityAttributeValues) {
-        return entityAttributeValues.contains(value);
-    }
-
-    /** {@inheritDoc} */
-    @Override @Nullable protected EntityDescriptor getEntityMetadata(final AttributeFilterContext filterContext) {
-        final SAMLMetadataContext metadataContext = filterContext.getRequesterMetadataContext();
-
-        if (null == metadataContext) {
-            log.warn("{} Could not locate SP metadata context", getLogPrefix());
-            return null;
-        }
-        return metadataContext.getEntityDescriptor();
-    }
-
-    /** {@inheritDoc} */
-    @Override
     protected void doInitialize() throws ComponentInitializationException {
         super.doInitialize();
         if (null == value) {
@@ -90,4 +62,11 @@ public class AttributeRequesterEntityAttributeExactPolicyRule extends AbstractEn
         }
     }
 
-}
+    /** {@inheritDoc} */
+    @Override
+    protected boolean entityAttributeValueMatches(
+            @Nonnull @NotEmpty @NonnullElements final Set<String> entityAttributeValues) {
+        return entityAttributeValues.contains(value);
+    }
+
+}
\ No newline at end of file
diff --git a/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/policyrule/saml/impl/AttributeRequesterEntityAttributeRegexPolicyRule.java b/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/policyrule/saml/impl/AbstractEntityAttributeRegexPolicyRule.java
similarity index 67%
copy from idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/policyrule/saml/impl/AttributeRequesterEntityAttributeRegexPolicyRule.java
copy to idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/policyrule/saml/impl/AbstractEntityAttributeRegexPolicyRule.java
index 803119e..bd773c6 100644
--- a/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/policyrule/saml/impl/AttributeRequesterEntityAttributeRegexPolicyRule.java
+++ b/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/policyrule/saml/impl/AbstractEntityAttributeRegexPolicyRule.java
@@ -23,30 +23,20 @@ import java.util.regex.Pattern;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
-import net.shibboleth.idp.attribute.filter.context.AttributeFilterContext;
 import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
 import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
 import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
 import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
 
-import org.opensaml.saml.common.messaging.context.SAMLMetadataContext;
-import org.opensaml.saml.saml2.metadata.EntityDescriptor;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import com.google.common.collect.Iterables;
 
 /**
- * Matcher functor that checks, via matching against a regular expression, if the attribute requester contains an entity
- * attribute with a given value.
+ * Matcher functor that checks entity attribute values via matching against a regular expression.
  */
-public class AttributeRequesterEntityAttributeRegexPolicyRule extends AbstractEntityAttributePolicyRule {
-
-    /** Class logger. */
-    private final Logger log = LoggerFactory.getLogger(AttributeRequesterEntityAttributeRegexPolicyRule.class);
+public abstract class AbstractEntityAttributeRegexPolicyRule extends AbstractEntityAttributePolicyRule {
 
     /** The value of the entity attribute the entity must have. */
-    private Pattern valueRegex;
+    @NonnullAfterInit private Pattern valueRegex;
 
     /**
      * Gets the value of the entity attribute the entity must have.
@@ -62,29 +52,11 @@ public class AttributeRequesterEntityAttributeRegexPolicyRule extends AbstractEn
      * 
      * @param attributeValueRegex value of the entity attribute the entity must have
      */
-    public void setValueRegex(final Pattern attributeValueRegex) {
+    public void setValueRegex(@Nullable final Pattern attributeValueRegex) {
         valueRegex = attributeValueRegex;
     }
 
     /** {@inheritDoc} */
-    @Override protected boolean entityAttributeValueMatches(
-            @Nonnull @NotEmpty @NonnullElements final Set<String> entityAttributeValues) {
-        
-        return Iterables.any(entityAttributeValues, v -> valueRegex.matcher(v).matches());
-    }
-
-    /** {@inheritDoc} */
-    @Override @Nullable protected EntityDescriptor getEntityMetadata(final AttributeFilterContext filterContext) {
-        final SAMLMetadataContext metadataContext = filterContext.getRequesterMetadataContext();
-
-        if (null == metadataContext) {
-            log.warn("{} Could not locate SP metadata context", getLogPrefix());
-            return null;
-        }
-        return metadataContext.getEntityDescriptor();
-    }
-
-    /** {@inheritDoc} */
     @Override protected void doInitialize() throws ComponentInitializationException {
         super.doInitialize();
         if (valueRegex == null) {
@@ -92,4 +64,10 @@ public class AttributeRequesterEntityAttributeRegexPolicyRule extends AbstractEn
         }
     }
 
-}
+    /** {@inheritDoc} */
+    @Override protected boolean entityAttributeValueMatches(
+            @Nonnull @NotEmpty @NonnullElements final Set<String> entityAttributeValues) {
+        return Iterables.any(entityAttributeValues, v -> valueRegex.matcher(v).matches());
+    }
+
+}
\ No newline at end of file
diff --git a/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/policyrule/saml/impl/AttributeIssuerEntityAttributeExactPolicyRule.java b/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/policyrule/saml/impl/AttributeIssuerEntityAttributeExactPolicyRule.java
new file mode 100644
index 0000000..d22cf25
--- /dev/null
+++ b/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/policyrule/saml/impl/AttributeIssuerEntityAttributeExactPolicyRule.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements.  See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.idp.attribute.filter.policyrule.saml.impl;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import net.shibboleth.idp.attribute.filter.context.AttributeFilterContext;
+
+import org.opensaml.saml.common.messaging.context.SAMLMetadataContext;
+import org.opensaml.saml.saml2.metadata.EntityDescriptor;
+
+/**
+ * Matcher that checks, via an exact match, if the attribute issuer contains an entity attribute with a given value.
+ */
+public class AttributeIssuerEntityAttributeExactPolicyRule extends AbstractEntityAttributeExactPolicyRule {
+
+    /** {@inheritDoc} */
+    @Override
+    @Nullable protected EntityDescriptor getEntityMetadata(@Nonnull final AttributeFilterContext filterContext) {
+        final SAMLMetadataContext metadataContext = filterContext.getIssuerMetadataContext();
+        return metadataContext != null ? metadataContext.getEntityDescriptor() : null;
+    }
+
+}
\ No newline at end of file
diff --git a/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/policyrule/saml/impl/AttributeIssuerEntityAttributeRegexPolicyRule.java b/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/policyrule/saml/impl/AttributeIssuerEntityAttributeRegexPolicyRule.java
new file mode 100644
index 0000000..38bd342
--- /dev/null
+++ b/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/policyrule/saml/impl/AttributeIssuerEntityAttributeRegexPolicyRule.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements.  See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.idp.attribute.filter.policyrule.saml.impl;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import net.shibboleth.idp.attribute.filter.context.AttributeFilterContext;
+
+import org.opensaml.saml.common.messaging.context.SAMLMetadataContext;
+import org.opensaml.saml.saml2.metadata.EntityDescriptor;
+
+/**
+ * Matcher that checks, via regex, if the attribute issuer contains an entity attribute with a given value.
+ */
+public class AttributeIssuerEntityAttributeRegexPolicyRule extends AbstractEntityAttributeRegexPolicyRule {
+
+    /** {@inheritDoc} */
+    @Override
+    @Nullable protected EntityDescriptor getEntityMetadata(@Nonnull final AttributeFilterContext filterContext) {
+        final SAMLMetadataContext metadataContext = filterContext.getIssuerMetadataContext();
+        return metadataContext != null ? metadataContext.getEntityDescriptor() : null;
+    }
+
+}
\ No newline at end of file
diff --git a/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/policyrule/saml/impl/AttributeRequesterEntityAttributeExactPolicyRule.java b/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/policyrule/saml/impl/AttributeRequesterEntityAttributeExactPolicyRule.java
index 797cb9b..262f26c 100644
--- a/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/policyrule/saml/impl/AttributeRequesterEntityAttributeExactPolicyRule.java
+++ b/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/policyrule/saml/impl/AttributeRequesterEntityAttributeExactPolicyRule.java
@@ -17,77 +17,24 @@
 
 package net.shibboleth.idp.attribute.filter.policyrule.saml.impl;
 
-import java.util.Set;
-
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
 import net.shibboleth.idp.attribute.filter.context.AttributeFilterContext;
-import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
-import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
-import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
-import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-import net.shibboleth.utilities.java.support.logic.Constraint;
 
 import org.opensaml.saml.common.messaging.context.SAMLMetadataContext;
 import org.opensaml.saml.saml2.metadata.EntityDescriptor;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * Matcher that checks, via an exact match, if the attribute requester contains an entity attribute with a given value.
  */
-public class AttributeRequesterEntityAttributeExactPolicyRule extends AbstractEntityAttributePolicyRule {
-
-    /** Class logger. */
-    @Nonnull private final Logger log = LoggerFactory.getLogger(AttributeRequesterEntityAttributeExactPolicyRule.class);
-
-    /** The value of the entity attribute the entity must have. */
-    @NonnullAfterInit @NotEmpty private String value;
-
-    /**
-     * Gets the value of the entity attribute the entity must have.
-     * 
-     * @return value of the entity attribute the entity must have
-     */
-    @NonnullAfterInit @NotEmpty public String getValue() {
-        return value;
-    }
-
-    /**
-     * Sets the value of the entity attribute the entity must have.
-     * 
-     * @param attributeValue value of the entity attribute the entity must have
-     */
-    public void setValue(@Nonnull @NotEmpty final String attributeValue) {
-        value = Constraint.isNotNull(attributeValue, "Attribute value cannot be null.");
-    }
+public class AttributeRequesterEntityAttributeExactPolicyRule extends AbstractEntityAttributeExactPolicyRule {
 
     /** {@inheritDoc} */
     @Override
-    protected boolean entityAttributeValueMatches(
-            @Nonnull @NotEmpty @NonnullElements final Set<String> entityAttributeValues) {
-        return entityAttributeValues.contains(value);
-    }
-
-    /** {@inheritDoc} */
-    @Override @Nullable protected EntityDescriptor getEntityMetadata(final AttributeFilterContext filterContext) {
+    @Nullable protected EntityDescriptor getEntityMetadata(@Nonnull final AttributeFilterContext filterContext) {
         final SAMLMetadataContext metadataContext = filterContext.getRequesterMetadataContext();
-
-        if (null == metadataContext) {
-            log.warn("{} Could not locate SP metadata context", getLogPrefix());
-            return null;
-        }
-        return metadataContext.getEntityDescriptor();
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    protected void doInitialize() throws ComponentInitializationException {
-        super.doInitialize();
-        if (null == value) {
-            throw new ComponentInitializationException(getLogPrefix() + " No value supplied to compare against");
-        }
+        return metadataContext != null ? metadataContext.getEntityDescriptor() : null;
     }
 
-}
+}
\ No newline at end of file
diff --git a/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/policyrule/saml/impl/AttributeRequesterEntityAttributeRegexPolicyRule.java b/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/policyrule/saml/impl/AttributeRequesterEntityAttributeRegexPolicyRule.java
index 803119e..c1f30cd 100644
--- a/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/policyrule/saml/impl/AttributeRequesterEntityAttributeRegexPolicyRule.java
+++ b/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/policyrule/saml/impl/AttributeRequesterEntityAttributeRegexPolicyRule.java
@@ -17,79 +17,24 @@
 
 package net.shibboleth.idp.attribute.filter.policyrule.saml.impl;
 
-import java.util.Set;
-import java.util.regex.Pattern;
-
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
 import net.shibboleth.idp.attribute.filter.context.AttributeFilterContext;
-import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
-import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
-import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
-import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
 
 import org.opensaml.saml.common.messaging.context.SAMLMetadataContext;
 import org.opensaml.saml.saml2.metadata.EntityDescriptor;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.collect.Iterables;
 
 /**
- * Matcher functor that checks, via matching against a regular expression, if the attribute requester contains an entity
- * attribute with a given value.
+ * Matcher that checks, via regex, if the attribute requester contains an entity attribute with a given value.
  */
-public class AttributeRequesterEntityAttributeRegexPolicyRule extends AbstractEntityAttributePolicyRule {
-
-    /** Class logger. */
-    private final Logger log = LoggerFactory.getLogger(AttributeRequesterEntityAttributeRegexPolicyRule.class);
-
-    /** The value of the entity attribute the entity must have. */
-    private Pattern valueRegex;
-
-    /**
-     * Gets the value of the entity attribute the entity must have.
-     * 
-     * @return value of the entity attribute the entity must have
-     */
-    @NonnullAfterInit public Pattern getValueRegex() {
-        return valueRegex;
-    }
-
-    /**
-     * Sets the value of the entity attribute the entity must have.
-     * 
-     * @param attributeValueRegex value of the entity attribute the entity must have
-     */
-    public void setValueRegex(final Pattern attributeValueRegex) {
-        valueRegex = attributeValueRegex;
-    }
+public class AttributeRequesterEntityAttributeRegexPolicyRule extends AbstractEntityAttributeRegexPolicyRule {
 
     /** {@inheritDoc} */
-    @Override protected boolean entityAttributeValueMatches(
-            @Nonnull @NotEmpty @NonnullElements final Set<String> entityAttributeValues) {
-        
-        return Iterables.any(entityAttributeValues, v -> valueRegex.matcher(v).matches());
-    }
-
-    /** {@inheritDoc} */
-    @Override @Nullable protected EntityDescriptor getEntityMetadata(final AttributeFilterContext filterContext) {
+    @Override
+    @Nullable protected EntityDescriptor getEntityMetadata(@Nonnull final AttributeFilterContext filterContext) {
         final SAMLMetadataContext metadataContext = filterContext.getRequesterMetadataContext();
-
-        if (null == metadataContext) {
-            log.warn("{} Could not locate SP metadata context", getLogPrefix());
-            return null;
-        }
-        return metadataContext.getEntityDescriptor();
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void doInitialize() throws ComponentInitializationException {
-        super.doInitialize();
-        if (valueRegex == null) {
-            throw new ComponentInitializationException(getLogPrefix() + " No regexp supplied to compare with");
-        }
+        return metadataContext != null ? metadataContext.getEntityDescriptor() : null;
     }
 
-}
+}
\ No newline at end of file

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


More information about the commits mailing list