[java-identity-provider] 07/10: IDP-1429 Deprecate ignoreCase for StringMatcher Parser
Rod Widdowson
rdw at steadingsoftware.com
Thu Apr 11 08:59:59 EDT 2019
This is an automated email from the git hooks/post-receive script.
rdw 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=fcc171b64411a8d1a532365e719c8f19bb70b25b
commit fcc171b64411a8d1a532365e719c8f19bb70b25b
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Wed Apr 10 13:22:00 2019 +0100
IDP-1429 Deprecate ignoreCase for StringMatcher Parser
https://issues.shibboleth.net/jira/browse/IDP-1429
replacement is caseSensitive
---
.../matcher/impl/AbstractStringMatcherParser.java | 30 +++++++++++++++++++---
.../matcher/AttributeScopeMatcherParserTest.java | 28 ++++++++++++++++++--
.../matcher/AttributeValueMatcherParserTest.java | 3 ++-
.../attribute/filter/matcher/attributeScope.xml | 2 +-
.../{attributeScope.xml => attributeScopeBoth.xml} | 2 +-
...buteValueNoId.xml => attributeScopeDefault.xml} | 2 +-
...ibuteScope.xml => attributeScopeDeprecated.xml} | 0
.../attribute/filter/matcher/attributeValueId.xml | 2 +-
.../filter/matcher/attributeValueNoId.xml | 2 +-
.../filter/policyrule/attributeValueId.xml | 2 +-
.../filter/policyrule/attributeValueNoId.xml | 2 +-
.../src/main/resources/schema/shibboleth-afp.xsd | 9 +++++++
12 files changed, 70 insertions(+), 14 deletions(-)
diff --git a/idp-attribute-filter-spring/src/main/java/net/shibboleth/idp/attribute/filter/spring/matcher/impl/AbstractStringMatcherParser.java b/idp-attribute-filter-spring/src/main/java/net/shibboleth/idp/attribute/filter/spring/matcher/impl/AbstractStringMatcherParser.java
index 8805841..f194c96 100644
--- a/idp-attribute-filter-spring/src/main/java/net/shibboleth/idp/attribute/filter/spring/matcher/impl/AbstractStringMatcherParser.java
+++ b/idp-attribute-filter-spring/src/main/java/net/shibboleth/idp/attribute/filter/spring/matcher/impl/AbstractStringMatcherParser.java
@@ -19,17 +19,25 @@ package net.shibboleth.idp.attribute.filter.spring.matcher.impl;
import javax.annotation.Nonnull;
-import net.shibboleth.idp.attribute.filter.spring.matcher.BaseAttributeValueMatcherParser;
-import net.shibboleth.utilities.java.support.primitive.StringSupport;
-
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.ParserContext;
import org.w3c.dom.Element;
+import net.shibboleth.idp.attribute.filter.spring.matcher.BaseAttributeValueMatcherParser;
+import net.shibboleth.utilities.java.support.primitive.DeprecationSupport;
+import net.shibboleth.utilities.java.support.primitive.DeprecationSupport.ObjectType;
+import net.shibboleth.utilities.java.support.primitive.StringSupport;
+
/**
* Base class for string matching functors of natural type Matcher (mostly attribute value matchers).
*/
public abstract class AbstractStringMatcherParser extends BaseAttributeValueMatcherParser {
+
+ /** Logger. */
+ private final Logger log = LoggerFactory.getLogger(AbstractStringMatcherParser.class);
+
/** {@inheritDoc} */
@Override protected void doNativeParse(@Nonnull final Element element, @Nonnull final ParserContext parserContext,
@@ -38,7 +46,21 @@ public abstract class AbstractStringMatcherParser extends BaseAttributeValueMatc
builder.addPropertyValue("matchString", StringSupport.trimOrNull(element.getAttributeNS(null, "value")));
- if (element.hasAttributeNS(null, "ignoreCase")) {
+ if (element.hasAttributeNS(null, "caseSensitive")) {
+ if (element.hasAttributeNS(null, "ignoreCase")) {
+ log.warn("{} \"caseSensitive\" and \"ignoreCase\" specified, \"caseSensitive\" used ",
+ parserContext.getReaderContext().getResource().getDescription());
+ }
+
+ builder.addPropertyValue("caseSensitive",
+ StringSupport.trimOrNull(element.getAttributeNS(null, "caseSensitive")));
+
+ } else if (element.hasAttributeNS(null, "ignoreCase")) {
+ DeprecationSupport.warnOnce(ObjectType.ELEMENT,
+ "ignoreCase",
+ parserContext.getReaderContext().getResource().getDescription(),
+ "caseSensitive");
+
builder.addPropertyValue("ignoreCase",
StringSupport.trimOrNull(element.getAttributeNS(null, "ignoreCase")));
}
diff --git a/idp-attribute-filter-spring/src/test/java/net/shibboleth/idp/attribute/filter/spring/matcher/AttributeScopeMatcherParserTest.java b/idp-attribute-filter-spring/src/test/java/net/shibboleth/idp/attribute/filter/spring/matcher/AttributeScopeMatcherParserTest.java
index 4428b04..00d9955 100644
--- a/idp-attribute-filter-spring/src/test/java/net/shibboleth/idp/attribute/filter/spring/matcher/AttributeScopeMatcherParserTest.java
+++ b/idp-attribute-filter-spring/src/test/java/net/shibboleth/idp/attribute/filter/spring/matcher/AttributeScopeMatcherParserTest.java
@@ -19,6 +19,7 @@ package net.shibboleth.idp.attribute.filter.spring.matcher;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test;
@@ -36,8 +37,31 @@ public class AttributeScopeMatcherParserTest extends BaseAttributeFilterParserTe
AttributeScopeStringMatcher what = (AttributeScopeStringMatcher) getMatcher("attributeScope.xml");
assertEquals(what.getMatchString(), "jSmItH");
- assertFalse(what.isIgnoreCase());
+ assertTrue(what.isCaseSensitive());
+ }
-}
+ @SuppressWarnings("deprecation")
+ @Test public void deprecated() throws ComponentInitializationException {
+ AttributeScopeStringMatcher what = (AttributeScopeStringMatcher) getMatcher("attributeScopeDeprecated.xml");
+
+ assertEquals(what.getMatchString(), "jSmItH");
+ assertFalse(what.isIgnoreCase());
+ assertTrue(what.isCaseSensitive());
+ }
+
+
+ @Test public void both() throws ComponentInitializationException {
+ AttributeScopeStringMatcher what = (AttributeScopeStringMatcher) getMatcher("attributeScopeBoth.xml");
+
+ assertEquals(what.getMatchString(), "jSmItH");
+ assertFalse(what.isCaseSensitive());
+ }
+
+ @Test public void testDefault() throws ComponentInitializationException {
+ AttributeScopeStringMatcher what = (AttributeScopeStringMatcher) getMatcher("attributeScopeDefault.xml");
+
+ assertEquals(what.getMatchString(), "jSmItH");
+ assertFalse(what.isCaseSensitive());
+ }
}
diff --git a/idp-attribute-filter-spring/src/test/java/net/shibboleth/idp/attribute/filter/spring/matcher/AttributeValueMatcherParserTest.java b/idp-attribute-filter-spring/src/test/java/net/shibboleth/idp/attribute/filter/spring/matcher/AttributeValueMatcherParserTest.java
index 381dc77..98ed793 100644
--- a/idp-attribute-filter-spring/src/test/java/net/shibboleth/idp/attribute/filter/spring/matcher/AttributeValueMatcherParserTest.java
+++ b/idp-attribute-filter-spring/src/test/java/net/shibboleth/idp/attribute/filter/spring/matcher/AttributeValueMatcherParserTest.java
@@ -18,6 +18,7 @@
package net.shibboleth.idp.attribute.filter.spring.matcher;
import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import java.util.Map;
@@ -123,7 +124,7 @@ public class AttributeValueMatcherParserTest extends BaseAttributeFilterParserTe
assertTrue(result.isEmpty());
AttributeValueStringMatcher avm = (AttributeValueStringMatcher) matcher;
- assertTrue(avm.isIgnoreCase());
+ assertFalse(avm.isCaseSensitive());
assertEquals(avm.getMatchString(), "jsmith");
}
diff --git a/idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/matcher/attributeScope.xml b/idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/matcher/attributeScope.xml
index 87becb3..11b5cb8 100644
--- a/idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/matcher/attributeScope.xml
+++ b/idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/matcher/attributeScope.xml
@@ -1,4 +1,4 @@
<AttributeRule attributeID="email" 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">
- <PermitValueRule xsi:type="Scope" value="jSmItH" ignoreCase="false" />
+ <PermitValueRule xsi:type="Scope" value="jSmItH" caseSensitive="true" />
</AttributeRule>
\ No newline at end of file
diff --git a/idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/matcher/attributeScope.xml b/idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/matcher/attributeScopeBoth.xml
similarity index 85%
copy from idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/matcher/attributeScope.xml
copy to idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/matcher/attributeScopeBoth.xml
index 87becb3..5e48e97 100644
--- a/idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/matcher/attributeScope.xml
+++ b/idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/matcher/attributeScopeBoth.xml
@@ -1,4 +1,4 @@
<AttributeRule attributeID="email" 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">
- <PermitValueRule xsi:type="Scope" value="jSmItH" ignoreCase="false" />
+ <PermitValueRule xsi:type="Scope" value="jSmItH" ignoreCase="false" caseSensitive="false" />
</AttributeRule>
\ No newline at end of file
diff --git a/idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/matcher/attributeValueNoId.xml b/idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/matcher/attributeScopeDefault.xml
similarity index 71%
copy from idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/matcher/attributeValueNoId.xml
copy to idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/matcher/attributeScopeDefault.xml
index 38addb3..5705065 100644
--- a/idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/matcher/attributeValueNoId.xml
+++ b/idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/matcher/attributeScopeDefault.xml
@@ -1,4 +1,4 @@
<AttributeRule attributeID="email" 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">
- <PermitValueRule xsi:type="Value" value="jsmith" ignoreCase="true" />
+ <PermitValueRule xsi:type="Scope" value="jSmItH" />
</AttributeRule>
\ No newline at end of file
diff --git a/idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/matcher/attributeScope.xml b/idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/matcher/attributeScopeDeprecated.xml
similarity index 100%
copy from idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/matcher/attributeScope.xml
copy to idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/matcher/attributeScopeDeprecated.xml
diff --git a/idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/matcher/attributeValueId.xml b/idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/matcher/attributeValueId.xml
index f3c20bd..cc6328c 100644
--- a/idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/matcher/attributeValueId.xml
+++ b/idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/matcher/attributeValueId.xml
@@ -3,5 +3,5 @@
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">
<PermitValueRule xsi:type="Value"
- value="jsmith" attributeID="uid" ignoreCase="true" />
+ value="jsmith" attributeID="uid" caseSensitive="false" />
</AttributeRule>
\ No newline at end of file
diff --git a/idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/matcher/attributeValueNoId.xml b/idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/matcher/attributeValueNoId.xml
index 38addb3..e077a23 100644
--- a/idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/matcher/attributeValueNoId.xml
+++ b/idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/matcher/attributeValueNoId.xml
@@ -1,4 +1,4 @@
<AttributeRule attributeID="email" 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">
- <PermitValueRule xsi:type="Value" value="jsmith" ignoreCase="true" />
+ <PermitValueRule xsi:type="Value" value="jsmith" caseSensitive="false"/>
</AttributeRule>
\ No newline at end of file
diff --git a/idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/policyrule/attributeValueId.xml b/idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/policyrule/attributeValueId.xml
index b7a782a..0d3db2d 100644
--- a/idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/policyrule/attributeValueId.xml
+++ b/idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/policyrule/attributeValueId.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="Value" value="jsmith" attributeID="uid"
- ignoreCase="true" />
+ caseSensitive="false" />
</AttributeFilterPolicy>
diff --git a/idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/policyrule/attributeValueNoId.xml b/idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/policyrule/attributeValueNoId.xml
index c52b7e1..6a39731 100644
--- a/idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/policyrule/attributeValueNoId.xml
+++ b/idp-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/policyrule/attributeValueNoId.xml
@@ -1,4 +1,4 @@
<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="Value" value="jsmith" ignoreCase="true" />
+ <PolicyRequirementRule xsi:type="Value" value="jsmith" caseSensitive="false" />
</AttributeFilterPolicy>
diff --git a/idp-schema/src/main/resources/schema/shibboleth-afp.xsd b/idp-schema/src/main/resources/schema/shibboleth-afp.xsd
index 0d2198f..cddaf3c 100644
--- a/idp-schema/src/main/resources/schema/shibboleth-afp.xsd
+++ b/idp-schema/src/main/resources/schema/shibboleth-afp.xsd
@@ -390,6 +390,15 @@
<annotation>
<documentation>
A boolean flag indicating whether case should be ignored when evaluating the match.
+
+ Deprecated in V4, use caseSenstive.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="caseSensitive" type="string">
+ <annotation>
+ <documentation>
+ A boolean flag indicating whether the match evaluation should be case sensitive.
</documentation>
</annotation>
</attribute>
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list