[java-shib-attribute] 04/06: JSATTR-10 ignoreCase is still supported (but deprecated) in the filters
Rod Widdowson
rdw at steadingsoftware.com
Thu Nov 24 11:02:04 UTC 2022
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch main
in repository java-shib-attribute.
View the commit online:
http://git.shibboleth.net/view/?p=java-shib-attribute.git;a=commit;h=5a2d48c63a4a28557d96947dfca28d8db2d44193
commit 5a2d48c63a4a28557d96947dfca28d8db2d44193
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Wed Nov 23 16:34:49 2022 +0000
JSATTR-10 ignoreCase is still supported (but deprecated) in the filters
https://shibboleth.atlassian.net/browse/JSATTR-10
---
.../filter/matcher/impl/AbstractStringMatcher.java | 24 -----------
.../matcher/impl/AbstractStringMatcherTest.java | 46 +---------------------
.../matcher/impl/AbstractStringMatcherParser.java | 21 ----------
.../impl/AbstractStringPolicyRuleParser.java | 23 +----------
.../src/main/resources/schema/shibboleth-afp.xsd | 9 -----
.../matcher/AttributeScopeMatcherParserTest.java | 18 ---------
.../matcher/AttributeValueMatcherParserTest.java | 8 ++--
.../policy/AttributeRequesterRuleParserTest.java | 28 -------------
.../filter/matcher/attributeScopeBoth.xml | 4 --
.../filter/matcher/attributeScopeDeprecated.xml | 4 --
.../filter/policyrule/attributeRequesterBoth.xml | 4 --
.../policyrule/attributeRequesterDeprecated.xml | 4 --
12 files changed, 6 insertions(+), 187 deletions(-)
diff --git a/shib-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/matcher/impl/AbstractStringMatcher.java b/shib-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/matcher/impl/AbstractStringMatcher.java
index a3bb3b133..684812342 100644
--- a/shib-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/matcher/impl/AbstractStringMatcher.java
+++ b/shib-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/matcher/impl/AbstractStringMatcher.java
@@ -20,8 +20,6 @@ package net.shibboleth.idp.attribute.filter.matcher.impl;
import javax.annotation.Nullable;
import net.shibboleth.idp.attribute.filter.Matcher;
-import net.shibboleth.shared.primitive.DeprecationSupport;
-import net.shibboleth.shared.primitive.DeprecationSupport.ObjectType;
/**
* General {@link Matcher} for {@link String} comparison of strings in Attribute Filters.
@@ -51,28 +49,6 @@ public abstract class AbstractStringMatcher extends AbstractMatcher implements M
public void setMatchString(@Nullable final String match) {
matchString = match;
}
-
- /**
- * Gets whether the match evaluation is case insensitive.
- *
- * @return whether the match evaluation is case insensitive
- * @deprecated in V4: Use isCaseSensitive
- */
- @Deprecated public boolean isIgnoreCase() {
- DeprecationSupport.warnOnce(ObjectType.METHOD, "isIgnoreCase", null, "isCaseSensitive");
- return !isCaseSensitive();
- }
-
- /**
- * Sets whether the match evaluation is case insensitive.
- *
- * @param isCaseInsensitive whether the match evaluation is case insensitive
- * @deprecated in V4: Use setCaseSensitive
- */
- @Deprecated public void setIgnoreCase(final boolean isCaseInsensitive) {
- DeprecationSupport.warnOnce(ObjectType.METHOD, "setIgnoreCase", null, "setCaseSensitive");
- setCaseSensitive(!isCaseInsensitive);
- }
/**
* Gets whether the match evaluation is case sensitive.
diff --git a/shib-attribute-filter-impl/src/test/java/net/shibboleth/idp/attribute/filter/matcher/impl/AbstractStringMatcherTest.java b/shib-attribute-filter-impl/src/test/java/net/shibboleth/idp/attribute/filter/matcher/impl/AbstractStringMatcherTest.java
index 6aadb071e..88fb6398f 100644
--- a/shib-attribute-filter-impl/src/test/java/net/shibboleth/idp/attribute/filter/matcher/impl/AbstractStringMatcherTest.java
+++ b/shib-attribute-filter-impl/src/test/java/net/shibboleth/idp/attribute/filter/matcher/impl/AbstractStringMatcherTest.java
@@ -22,7 +22,6 @@ import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
-import org.testng.Assert;
import org.testng.annotations.Test;
import net.shibboleth.idp.attribute.IdPAttributeValue;
@@ -72,47 +71,4 @@ public class AbstractStringMatcherTest {
assertFalse(matcher.stringCompare(null));
}
- @SuppressWarnings("deprecation")
- @Test public void testDeprecatedSettersGetters() {
- AbstractStringMatcher matcher = new AbstractStringMatcher(){
-
- @Override
- protected boolean compareAttributeValue(IdPAttributeValue value) {
- return false;
- }};
-
- Assert.assertNull(matcher.getMatchString());
- Assert.assertFalse(!matcher.isIgnoreCase());
- Assert.assertFalse(matcher.isCaseSensitive());
-
- matcher.setIgnoreCase(false);
- assertFalse(matcher.isIgnoreCase());
- matcher.setIgnoreCase(true);
- assertTrue(matcher.isIgnoreCase());
-
- matcher.setMatchString(DataSources.TEST_STRING);
- assertEquals(matcher.getMatchString(), DataSources.TEST_STRING);
- }
-
- @SuppressWarnings("deprecation")
- @Test public void testDeprecatedApply() {
- AbstractStringMatcher matcher = new AbstractStringMatcher() {
-
- @Override
- protected boolean compareAttributeValue(IdPAttributeValue value) {
- return false;
- }};
- matcher.setIgnoreCase(false);
- matcher.setMatchString(DataSources.TEST_STRING);
-
- assertTrue(matcher.stringCompare(DataSources.TEST_STRING));
- assertFalse(matcher.stringCompare(DataSources.TEST_STRING_UPPER));
- matcher.setIgnoreCase(true);
- assertTrue(matcher.stringCompare(DataSources.TEST_STRING));
- assertTrue(matcher.stringCompare(DataSources.TEST_STRING_UPPER));
-
- assertFalse(matcher.stringCompare(null));
- }
-
-
-}
+ }
diff --git a/shib-attribute-filter-spring/src/main/java/net/shibboleth/idp/attribute/filter/spring/matcher/impl/AbstractStringMatcherParser.java b/shib-attribute-filter-spring/src/main/java/net/shibboleth/idp/attribute/filter/spring/matcher/impl/AbstractStringMatcherParser.java
index 0e3286365..f6ce1920b 100644
--- a/shib-attribute-filter-spring/src/main/java/net/shibboleth/idp/attribute/filter/spring/matcher/impl/AbstractStringMatcherParser.java
+++ b/shib-attribute-filter-spring/src/main/java/net/shibboleth/idp/attribute/filter/spring/matcher/impl/AbstractStringMatcherParser.java
@@ -19,16 +19,12 @@ package net.shibboleth.idp.attribute.filter.spring.matcher.impl;
import javax.annotation.Nonnull;
-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.shared.primitive.DeprecationSupport;
import net.shibboleth.shared.primitive.StringSupport;
-import net.shibboleth.shared.primitive.DeprecationSupport.ObjectType;
import net.shibboleth.shared.spring.util.SpringSupport;
/**
@@ -36,10 +32,6 @@ import net.shibboleth.shared.spring.util.SpringSupport;
*/
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,
@Nonnull final BeanDefinitionBuilder builder) {
@@ -48,22 +40,9 @@ public abstract class AbstractStringMatcherParser extends BaseAttributeValueMatc
builder.addPropertyValue("matchString", StringSupport.trimOrNull(element.getAttributeNS(null, "value")));
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", SpringSupport.getStringValueAsBoolean(
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")));
}
}
}
\ No newline at end of file
diff --git a/shib-attribute-filter-spring/src/main/java/net/shibboleth/idp/attribute/filter/spring/policyrule/impl/AbstractStringPolicyRuleParser.java b/shib-attribute-filter-spring/src/main/java/net/shibboleth/idp/attribute/filter/spring/policyrule/impl/AbstractStringPolicyRuleParser.java
index 5fe0783c8..e93b67e94 100644
--- a/shib-attribute-filter-spring/src/main/java/net/shibboleth/idp/attribute/filter/spring/policyrule/impl/AbstractStringPolicyRuleParser.java
+++ b/shib-attribute-filter-spring/src/main/java/net/shibboleth/idp/attribute/filter/spring/policyrule/impl/AbstractStringPolicyRuleParser.java
@@ -19,25 +19,18 @@ package net.shibboleth.idp.attribute.filter.spring.policyrule.impl;
import javax.annotation.Nonnull;
-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.policyrule.BasePolicyRuleParser;
-import net.shibboleth.shared.primitive.DeprecationSupport;
import net.shibboleth.shared.primitive.StringSupport;
-import net.shibboleth.shared.primitive.DeprecationSupport.ObjectType;
/**
* Base class for string matching functors of natural type PolicyRule.
*/
public abstract class AbstractStringPolicyRuleParser extends BasePolicyRuleParser {
- /** Logger. */
- private final Logger log = LoggerFactory.getLogger(AbstractStringPolicyRuleParser.class);
-
/** {@inheritDoc} */
@Override protected void doNativeParse(@Nonnull final Element element, @Nonnull final ParserContext parserContext,
@Nonnull final BeanDefinitionBuilder builder) {
@@ -46,22 +39,8 @@ public abstract class AbstractStringPolicyRuleParser extends BasePolicyRuleParse
builder.addPropertyValue("matchString", StringSupport.trimOrNull(element.getAttributeNS(null, "value")));
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")));
- }
- }
+ } }
}
\ No newline at end of file
diff --git a/shib-attribute-filter-spring/src/main/resources/schema/shibboleth-afp.xsd b/shib-attribute-filter-spring/src/main/resources/schema/shibboleth-afp.xsd
index 4cd328acc..a2fe84a8a 100644
--- a/shib-attribute-filter-spring/src/main/resources/schema/shibboleth-afp.xsd
+++ b/shib-attribute-filter-spring/src/main/resources/schema/shibboleth-afp.xsd
@@ -408,15 +408,6 @@
<documentation>The string value to match.</documentation>
</annotation>
</attribute>
- <attribute name="ignoreCase" type="afp:string">
- <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="afp:string">
<annotation>
<documentation>
diff --git a/shib-attribute-filter-spring/src/test/java/net/shibboleth/idp/attribute/filter/spring/matcher/AttributeScopeMatcherParserTest.java b/shib-attribute-filter-spring/src/test/java/net/shibboleth/idp/attribute/filter/spring/matcher/AttributeScopeMatcherParserTest.java
index 82ef6ea67..b8efefb4c 100644
--- a/shib-attribute-filter-spring/src/test/java/net/shibboleth/idp/attribute/filter/spring/matcher/AttributeScopeMatcherParserTest.java
+++ b/shib-attribute-filter-spring/src/test/java/net/shibboleth/idp/attribute/filter/spring/matcher/AttributeScopeMatcherParserTest.java
@@ -40,24 +40,6 @@ public class AttributeScopeMatcherParserTest extends BaseAttributeFilterParserTe
assertEquals(what.getMatchString(), "jSmItH");
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");
diff --git a/shib-attribute-filter-spring/src/test/java/net/shibboleth/idp/attribute/filter/spring/matcher/AttributeValueMatcherParserTest.java b/shib-attribute-filter-spring/src/test/java/net/shibboleth/idp/attribute/filter/spring/matcher/AttributeValueMatcherParserTest.java
index 6a61e300b..fe34a19f8 100644
--- a/shib-attribute-filter-spring/src/test/java/net/shibboleth/idp/attribute/filter/spring/matcher/AttributeValueMatcherParserTest.java
+++ b/shib-attribute-filter-spring/src/test/java/net/shibboleth/idp/attribute/filter/spring/matcher/AttributeValueMatcherParserTest.java
@@ -46,19 +46,19 @@ import net.shibboleth.shared.component.ComponentInitializationException;
/*
* This tests not just the parsing of the rule, but also the construction of the complex tests.<br/>
* <code>
- * <PermitValueRule xsi:type="basic:AttributeValueString" value="jsmith" attributeId="uid" ignoreCase="true"/>
+ * <PermitValueRule xsi:type="basic:AttributeValueString" value="jsmith" attributeId="uid" caseSensitive="false" />
* </code><br/>
* vs<br/>
* <code>
- * <PermitValueRule xsi:type="basic:AttributeValueString" value="jsmith" ignoreCase="true"/>
+ * <PermitValueRule xsi:type="basic:AttributeValueString" value="jsmith" caseSensitive="false" />
* </code><br/>
* vs<br/>
* <code>
- * <afp:PolicyRequirementRule xsi:type="basic:AttributeValueString" value="jsmith" ignoreCase="true"/>
+ * <afp:PolicyRequirementRule xsi:type="basic:AttributeValueString" value="jsmith" caseSensitive="false" />
* </code><br/>
* vs<br/>
* <code>
- * <afp:PolicyRequirementRule xsi:type="basic:AttributeValueString" attributeId="uid" value="jsmith" ignoreCase="true"/>
+ * <afp:PolicyRequirementRule xsi:type="basic:AttributeValueString" attributeId="uid" value="jsmith" caseSensitive="false" />
* </code><br/>
*/
@SuppressWarnings("javadoc")
diff --git a/shib-attribute-filter-spring/src/test/java/net/shibboleth/idp/attribute/filter/spring/policy/AttributeRequesterRuleParserTest.java b/shib-attribute-filter-spring/src/test/java/net/shibboleth/idp/attribute/filter/spring/policy/AttributeRequesterRuleParserTest.java
index f8fd68a75..43ecffaee 100644
--- a/shib-attribute-filter-spring/src/test/java/net/shibboleth/idp/attribute/filter/spring/policy/AttributeRequesterRuleParserTest.java
+++ b/shib-attribute-filter-spring/src/test/java/net/shibboleth/idp/attribute/filter/spring/policy/AttributeRequesterRuleParserTest.java
@@ -18,7 +18,6 @@
package net.shibboleth.idp.attribute.filter.spring.policy;
import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import java.util.Map;
@@ -75,33 +74,6 @@ public class AttributeRequesterRuleParserTest extends BaseAttributeFilterParserT
assertTrue(arRule.isCaseSensitive());
}
- @Test public void both() throws ComponentInitializationException {
- final PolicyRequirementRule rule = getPolicyRule("attributeRequesterBoth.xml");
-
- AttributeFilterContext filterContext = DataSources.populatedFilterContext("principal", "issuer", "http://example.org");
- assertEquals(rule.matches(filterContext), Tristate.FALSE);
- filterContext = DataSources.populatedFilterContext("principal", "issuer", "https://service.example.edu/shibboleth-sp");
- assertEquals(rule.matches(filterContext), Tristate.TRUE);
-
- final AttributeRequesterPolicyRule arRule = (AttributeRequesterPolicyRule) rule;
- assertEquals(arRule.getMatchString(), "https://service.example.edu/shibboleth-sp");
- assertFalse(arRule.isCaseSensitive());
- }
-
- @SuppressWarnings("deprecation")
- @Test public void deprecated() throws ComponentInitializationException {
- final PolicyRequirementRule rule = getPolicyRule("attributeRequesterDeprecated.xml");
-
- AttributeFilterContext filterContext = DataSources.populatedFilterContext("principal", "issuer", "http://example.org");
- assertEquals(rule.matches(filterContext), Tristate.FALSE);
- filterContext = DataSources.populatedFilterContext("principal", "issuer", "https://service.example.edu/shibboleth-sp");
- assertEquals(rule.matches(filterContext), Tristate.TRUE);
-
- final AttributeRequesterPolicyRule arRule = (AttributeRequesterPolicyRule) rule;
- assertEquals(arRule.getMatchString(), "https://service.example.edu/shibboleth-sp");
- assertFalse(arRule.isIgnoreCase());
- }
-
@Test public void testDefault() throws ComponentInitializationException {
final PolicyRequirementRule rule = getPolicyRule("attributeRequesterDefault.xml");
diff --git a/shib-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/matcher/attributeScopeBoth.xml b/shib-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/matcher/attributeScopeBoth.xml
deleted file mode 100644
index 5e48e97ef..000000000
--- a/shib-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/matcher/attributeScopeBoth.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<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" caseSensitive="false" />
-</AttributeRule>
\ No newline at end of file
diff --git a/shib-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/matcher/attributeScopeDeprecated.xml b/shib-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/matcher/attributeScopeDeprecated.xml
deleted file mode 100644
index 87becb3f1..000000000
--- a/shib-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/matcher/attributeScopeDeprecated.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<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" />
-</AttributeRule>
\ No newline at end of file
diff --git a/shib-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/policyrule/attributeRequesterBoth.xml b/shib-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/policyrule/attributeRequesterBoth.xml
deleted file mode 100644
index feec6dc5c..000000000
--- a/shib-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/policyrule/attributeRequesterBoth.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<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="Requester" value="https://service.example.edu/shibboleth-sp" ignoreCase="false" caseSensitive="false"/>
-</AttributeFilterPolicy>
diff --git a/shib-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/policyrule/attributeRequesterDeprecated.xml b/shib-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/policyrule/attributeRequesterDeprecated.xml
deleted file mode 100644
index 4531c4d2f..000000000
--- a/shib-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/policyrule/attributeRequesterDeprecated.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<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="Requester" value="https://service.example.edu/shibboleth-sp" ignoreCase="false" />
-</AttributeFilterPolicy>
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list