[java-identity-provider] branch master updated: IDP-1186 - Undeprecate Issuer policy rules

Scott Cantor cantor.2 at osu.edu
Thu Jun 8 15:51:01 EDT 2017


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=70256cb5968c3d6f4c6e5d1e04bc9f573b5a8757

The following commit(s) were added to refs/heads/master by this push:
       new  70256cb   IDP-1186 - Undeprecate Issuer policy rules
70256cb is described below

commit 70256cb5968c3d6f4c6e5d1e04bc9f573b5a8757
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Jun 8 15:50:59 2017 -0400

    IDP-1186 - Undeprecate Issuer policy rules
    
    https://issues.shibboleth.net/jira/browse/IDP-1186
---
 .../impl/AttributeFilterNamespaceHandler.java      |  7 ++++++
 .../impl/AttributeIssuerRegexRuleParser.java       | 22 +++++++++---------
 .../policyrule/impl/AttributeIssuerRuleParser.java | 17 ++++++--------
 .../policy/AttributeIssuerRuleParserTest.java      | 26 +++++++++++++++++-----
 .../filter/policyrule/afp/attributeIssuer.xml      |  2 +-
 .../src/main/resources/schema/shibboleth-afp.xsd   | 24 +++++++++++++++++++-
 6 files changed, 69 insertions(+), 29 deletions(-)

diff --git a/idp-attribute-filter-spring/src/main/java/net/shibboleth/idp/attribute/filter/spring/impl/AttributeFilterNamespaceHandler.java b/idp-attribute-filter-spring/src/main/java/net/shibboleth/idp/attribute/filter/spring/impl/AttributeFilterNamespaceHandler.java
index 7a3546f..8e1e46b 100644
--- a/idp-attribute-filter-spring/src/main/java/net/shibboleth/idp/attribute/filter/spring/impl/AttributeFilterNamespaceHandler.java
+++ b/idp-attribute-filter-spring/src/main/java/net/shibboleth/idp/attribute/filter/spring/impl/AttributeFilterNamespaceHandler.java
@@ -28,6 +28,8 @@ import net.shibboleth.idp.attribute.filter.spring.matcher.impl.AttributeScopeMat
 import net.shibboleth.idp.attribute.filter.spring.matcher.impl.AttributeScopeRegexMatcherParser;
 import net.shibboleth.idp.attribute.filter.spring.matcher.impl.AttributeValueRegexMatcherParser;
 import net.shibboleth.idp.attribute.filter.spring.matcher.impl.AttributeValueStringMatcherParser;
+import net.shibboleth.idp.attribute.filter.spring.policyrule.impl.AttributeIssuerRegexRuleParser;
+import net.shibboleth.idp.attribute.filter.spring.policyrule.impl.AttributeIssuerRuleParser;
 import net.shibboleth.idp.attribute.filter.spring.policyrule.impl.AttributeRequesterRegexRuleParser;
 import net.shibboleth.idp.attribute.filter.spring.policyrule.impl.AttributeRequesterRuleParser;
 import net.shibboleth.idp.attribute.filter.spring.policyrule.impl.AuthenticationMethodRegexRuleParser;
@@ -94,6 +96,11 @@ public class AttributeFilterNamespaceHandler extends BaseSpringNamespaceHandler
         registerBeanDefinitionParser(AttributeRequesterRegexRuleParser.SCHEMA_TYPE_AFP,
                 new AttributeRequesterRegexRuleParser());
 
+        registerBeanDefinitionParser(AttributeIssuerRuleParser.SCHEMA_TYPE_AFP, new AttributeIssuerRuleParser());
+
+        registerBeanDefinitionParser(AttributeIssuerRegexRuleParser.SCHEMA_TYPE_AFP,
+                new AttributeIssuerRegexRuleParser());
+        
         registerBeanDefinitionParser(PrincipalNameRuleParser.SCHEMA_TYPE_AFP, new PrincipalNameRuleParser());
 
         registerBeanDefinitionParser(PrincipalNameRegexRuleParser.SCHEMA_TYPE_AFP, new PrincipalNameRegexRuleParser());
diff --git a/idp-attribute-filter-spring/src/main/java/net/shibboleth/idp/attribute/filter/spring/policyrule/impl/AttributeIssuerRegexRuleParser.java b/idp-attribute-filter-spring/src/main/java/net/shibboleth/idp/attribute/filter/spring/policyrule/impl/AttributeIssuerRegexRuleParser.java
index 8626cd9..668bc62 100644
--- a/idp-attribute-filter-spring/src/main/java/net/shibboleth/idp/attribute/filter/spring/policyrule/impl/AttributeIssuerRegexRuleParser.java
+++ b/idp-attribute-filter-spring/src/main/java/net/shibboleth/idp/attribute/filter/spring/policyrule/impl/AttributeIssuerRegexRuleParser.java
@@ -21,31 +21,29 @@ import javax.annotation.Nonnull;
 import javax.xml.namespace.QName;
 
 import net.shibboleth.idp.attribute.filter.policyrule.filtercontext.impl.AttributeIssuerRegexpPolicyRule;
+import net.shibboleth.idp.attribute.filter.spring.BaseFilterParser;
 import net.shibboleth.idp.attribute.filter.spring.basic.impl.AttributeFilterBasicNamespaceHandler;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 /**
  * Bean definition parser for {@link AttributeIssuerRegexpPolicyRule}.
  */
 public class AttributeIssuerRegexRuleParser extends AbstractRegexPolicyRuleParser {
 
     /** Schema type. */
-    public static final QName SCHEMA_TYPE = new QName(AttributeFilterBasicNamespaceHandler.NAMESPACE,
+    @Nonnull public static final QName SCHEMA_TYPE = new QName(AttributeFilterBasicNamespaceHandler.NAMESPACE,
             "AttributeIssuerRegex");
 
-    /** Class logger. */
-    private final Logger log = LoggerFactory.getLogger(AttributeIssuerRuleParser.class);
+    /** Schema type. */
+    @Nonnull public static final QName SCHEMA_TYPE_AFP = new QName(BaseFilterParser.NAMESPACE, "IssuerRegex");
 
     /** {@inheritDoc} */
-    @Override @Nonnull protected Class<AttributeIssuerRegexpPolicyRule> getNativeBeanClass() {
-        log.warn("The {} element is deprecated and will be removed in future versions", SCHEMA_TYPE);
-        return AttributeIssuerRegexpPolicyRule.class;
+    @Override protected QName getAFPName() {
+        return SCHEMA_TYPE_AFP;
     }
 
     /** {@inheritDoc} */
-    @Override protected QName getAFPName() {
-        return SCHEMA_TYPE;
+    @Override @Nonnull protected Class<AttributeIssuerRegexpPolicyRule> getNativeBeanClass() {
+        return AttributeIssuerRegexpPolicyRule.class;
     }
-}
+    
+}
\ No newline at end of file
diff --git a/idp-attribute-filter-spring/src/main/java/net/shibboleth/idp/attribute/filter/spring/policyrule/impl/AttributeIssuerRuleParser.java b/idp-attribute-filter-spring/src/main/java/net/shibboleth/idp/attribute/filter/spring/policyrule/impl/AttributeIssuerRuleParser.java
index 5aba6bc..dad946f 100644
--- a/idp-attribute-filter-spring/src/main/java/net/shibboleth/idp/attribute/filter/spring/policyrule/impl/AttributeIssuerRuleParser.java
+++ b/idp-attribute-filter-spring/src/main/java/net/shibboleth/idp/attribute/filter/spring/policyrule/impl/AttributeIssuerRuleParser.java
@@ -21,32 +21,29 @@ import javax.annotation.Nonnull;
 import javax.xml.namespace.QName;
 
 import net.shibboleth.idp.attribute.filter.policyrule.filtercontext.impl.AttributeIssuerPolicyRule;
+import net.shibboleth.idp.attribute.filter.spring.BaseFilterParser;
 import net.shibboleth.idp.attribute.filter.spring.basic.impl.AttributeFilterBasicNamespaceHandler;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 /**
  * Bean definition parser for {@link AttributeIssuerPolicyRule}.
  */
 public class AttributeIssuerRuleParser extends AbstractStringPolicyRuleParser {
 
     /** Schema type. */
-    public static final QName SCHEMA_TYPE = new QName(AttributeFilterBasicNamespaceHandler.NAMESPACE,
+    @Nonnull public static final QName SCHEMA_TYPE = new QName(AttributeFilterBasicNamespaceHandler.NAMESPACE,
             "AttributeIssuerString");
-
-    /** Class logger. */
-    private final Logger log = LoggerFactory.getLogger(AttributeIssuerRuleParser.class);
+    
+    /** Schema type. */
+    @Nonnull public static final QName SCHEMA_TYPE_AFP = new QName(BaseFilterParser.NAMESPACE, "Issuer");
 
     /** {@inheritDoc} */
     @Override @Nonnull protected Class<AttributeIssuerPolicyRule> getNativeBeanClass() {
-        log.warn("The {} element is deprecated and will be removed in future versions", SCHEMA_TYPE);
         return AttributeIssuerPolicyRule.class;
     }
 
     /** {@inheritDoc} */
     @Override protected QName getAFPName() {
-        return SCHEMA_TYPE;
+        return SCHEMA_TYPE_AFP;
     }
 
-}
+}
\ No newline at end of file
diff --git a/idp-attribute-filter-spring/src/test/java/net/shibboleth/idp/attribute/filter/spring/policy/AttributeIssuerRuleParserTest.java b/idp-attribute-filter-spring/src/test/java/net/shibboleth/idp/attribute/filter/spring/policy/AttributeIssuerRuleParserTest.java
index 1a30d3d..3b4e25c 100644
--- a/idp-attribute-filter-spring/src/test/java/net/shibboleth/idp/attribute/filter/spring/policy/AttributeIssuerRuleParserTest.java
+++ b/idp-attribute-filter-spring/src/test/java/net/shibboleth/idp/attribute/filter/spring/policy/AttributeIssuerRuleParserTest.java
@@ -17,6 +17,10 @@
 
 package net.shibboleth.idp.attribute.filter.spring.policy;
 
+import net.shibboleth.idp.attribute.filter.PolicyRequirementRule;
+import net.shibboleth.idp.attribute.filter.PolicyRequirementRule.Tristate;
+import net.shibboleth.idp.attribute.filter.context.AttributeFilterContext;
+import net.shibboleth.idp.attribute.filter.matcher.impl.DataSources;
 import net.shibboleth.idp.attribute.filter.policyrule.filtercontext.impl.AttributeIssuerPolicyRule;
 import net.shibboleth.idp.attribute.filter.spring.BaseAttributeFilterParserTest;
 import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
@@ -25,12 +29,24 @@ import org.testng.Assert;
 import org.testng.annotations.Test;
 
 public class AttributeIssuerRuleParserTest extends BaseAttributeFilterParserTest {
-
+ 
     @Test public void policy() throws ComponentInitializationException {
+        policy("attributeIssuer.xml", true);
+        policy("attributeIssuer.xml", false);
+    }
+
+    public void policy(String path, boolean isAfp) throws ComponentInitializationException {
+        final PolicyRequirementRule rule = getPolicyRule(path, isAfp);
 
-        final AttributeIssuerPolicyRule arRule = (AttributeIssuerPolicyRule) getPolicyRule("attributeIssuer.xml", false);
+        AttributeFilterContext filterContext =
+                DataSources.populatedFilterContext("principal", "urn:example:org:idp:foo", "http://example.org");
+        Assert.assertEquals(rule.matches(filterContext), Tristate.TRUE);
+        filterContext = DataSources.populatedFilterContext("principal", "issuer", "http://example.org");
+        Assert.assertEquals(rule.matches(filterContext), Tristate.FALSE);
+
+        final AttributeIssuerPolicyRule arRule = (AttributeIssuerPolicyRule) rule;
         Assert.assertEquals(arRule.getMatchString(), "urn:example:org:idp:foo");
         Assert.assertTrue(arRule.isIgnoreCase());
-}
- 
-}
+    }
+
+}
\ No newline at end of file
diff --git a/idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/policyrule/afp/attributeIssuer.xml b/idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/policyrule/afp/attributeIssuer.xml
index 1cc31da..f9240fb 100644
--- a/idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/policyrule/afp/attributeIssuer.xml
+++ b/idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/policyrule/afp/attributeIssuer.xml
@@ -1,5 +1,5 @@
 <AttributeFilterPolicy id="MostBasicExample" xmlns="urn:mace:shibboleth:2.0:afp" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="urn:mace:shibboleth:2.0:afp http://shibboleth.net/schema/idp/shibboleth-afp.xsd">
-    <PolicyRequirementRule xsi:type="AttributeIssuerString" value="urn:example:org:idp:foo"
+    <PolicyRequirementRule xsi:type="Issuer" value="urn:example:org:idp:foo"
         ignoreCase="true" />
 </AttributeFilterPolicy>
diff --git a/idp-schema/src/main/resources/schema/shibboleth-afp.xsd b/idp-schema/src/main/resources/schema/shibboleth-afp.xsd
index f0fe630..9a4714d 100644
--- a/idp-schema/src/main/resources/schema/shibboleth-afp.xsd
+++ b/idp-schema/src/main/resources/schema/shibboleth-afp.xsd
@@ -319,7 +319,18 @@
     <complexType name="Requester">
         <annotation>
             <documentation>
-                A match function that matches the attribute request against the specified value.
+                A match function that matches the attribute requester against the specified value.
+            </documentation>
+        </annotation>
+        <complexContent>
+            <extension base="afp:StringMatchType"/>
+        </complexContent>
+    </complexType>
+
+    <complexType name="Issuer">
+        <annotation>
+            <documentation>
+                A match function that matches the attribute issuer against the specified value.
             </documentation>
         </annotation>
         <complexContent>
@@ -416,6 +427,17 @@
         </complexContent>
     </complexType>
 
+    <complexType name="IssuerRegex">
+        <annotation>
+            <documentation>
+                A match function that matches the attribute issuer against the specified regular expression.
+            </documentation>
+        </annotation>
+        <complexContent>
+            <extension base="afp:RegexMatchType"/>
+        </complexContent>
+    </complexType>
+
     <complexType name="PrincipalNameRegex">
         <annotation>
             <documentation>

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


More information about the commits mailing list