[java-identity-provider] 10/10: IDP-1429 Deprecate ignoreCase for SourceValue Parser

Rod Widdowson rdw at steadingsoftware.com
Thu Apr 11 09:00:02 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=c0f3f07ae4c37b0d81e6a946b1c0d32ffd6219f0

commit c0f3f07ae4c37b0d81e6a946b1c0d32ffd6219f0
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Thu Apr 11 13:53:55 2019 +0100

    IDP-1429 Deprecate ignoreCase for SourceValue Parser
    
    https://issues.shibboleth.net/jira/browse/IDP-1429
    
    replacement is caseSensitive
---
 .../spring/ad/mapped/impl/SourceValueParser.java   | 19 ++++++++++++++++
 .../spring/ad/mapped/SourceValueParserTest.java    | 25 +++++++++++++++++++---
 .../ad/mapped/resolver/sourceValueAttributes1.xml  |  2 +-
 .../ad/mapped/resolver/sourceValueAttributes2.xml  |  2 +-
 ...rceValueAttributes1.xml => sourceValueBoth.xml} |  2 +-
 ...ValueAttributes1.xml => sourceValueDefault.xml} |  2 +-
 ...ueAttributes1.xml => sourceValueDeprecated.xml} |  0
 .../schema/shibboleth-attribute-resolver.xsd       | 11 +++++++++-
 8 files changed, 55 insertions(+), 8 deletions(-)

diff --git a/idp-attribute-resolver-spring/src/main/java/net/shibboleth/idp/attribute/resolver/spring/ad/mapped/impl/SourceValueParser.java b/idp-attribute-resolver-spring/src/main/java/net/shibboleth/idp/attribute/resolver/spring/ad/mapped/impl/SourceValueParser.java
index 3811bb7..d8287d0 100644
--- a/idp-attribute-resolver-spring/src/main/java/net/shibboleth/idp/attribute/resolver/spring/ad/mapped/impl/SourceValueParser.java
+++ b/idp-attribute-resolver-spring/src/main/java/net/shibboleth/idp/attribute/resolver/spring/ad/mapped/impl/SourceValueParser.java
@@ -30,6 +30,8 @@ import org.w3c.dom.Element;
 
 import net.shibboleth.idp.attribute.resolver.ad.mapped.impl.SourceValue;
 import net.shibboleth.idp.attribute.resolver.spring.impl.AttributeResolverNamespaceHandler;
+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;
 
 /** Bean definition parser for a {@link SourceValue}. */
@@ -61,6 +63,23 @@ public class SourceValueParser extends AbstractSingleBeanDefinitionParser {
         String ignoreCase = null;
         if (config.hasAttributeNS(null, "ignoreCase")) {
             ignoreCase = StringSupport.trimOrNull(config.getAttributeNS(null, "ignoreCase"));
+        }
+        String caseSensitive = null;
+        if (config.hasAttributeNS(null, "caseSensitive")) {
+            caseSensitive = StringSupport.trimOrNull(config.getAttributeNS(null, "caseSensitive"));
+        }
+        
+        if (caseSensitive != null) {
+            builder.addPropertyValue("caseSensitive", caseSensitive);
+            if (ignoreCase!=null) {
+                log.warn("{}: Both \"caseSensitive\" and \"ignoreCase\" specified, only the former will be used",
+                        parserContext.getReaderContext().getResource().getDescription());
+            }
+        } else if (ignoreCase!=null) {
+            DeprecationSupport.warnOnce(ObjectType.ELEMENT,
+                    "ignoreCase",
+                    parserContext.getReaderContext().getResource().getDescription(),
+                    "caseSensitive");
             builder.addPropertyValue("ignoreCase", ignoreCase);
         }
 
diff --git a/idp-attribute-resolver-spring/src/test/java/net/shibboleth/idp/attribute/resolver/spring/ad/mapped/SourceValueParserTest.java b/idp-attribute-resolver-spring/src/test/java/net/shibboleth/idp/attribute/resolver/spring/ad/mapped/SourceValueParserTest.java
index a8f59be..04f9393 100644
--- a/idp-attribute-resolver-spring/src/test/java/net/shibboleth/idp/attribute/resolver/spring/ad/mapped/SourceValueParserTest.java
+++ b/idp-attribute-resolver-spring/src/test/java/net/shibboleth/idp/attribute/resolver/spring/ad/mapped/SourceValueParserTest.java
@@ -48,7 +48,7 @@ public class SourceValueParserTest extends BaseAttributeDefinitionParserTest {
     @Test public void simple() {
         SourceValue value = getSourceValue("resolver/sourceValue.xml");
 
-        assertFalse(value.isIgnoreCase());
+        assertTrue(value.isCaseSensitive());
         assertFalse(value.isPartialMatch());
         try {
             assertNull(value.getValue());
@@ -61,7 +61,7 @@ public class SourceValueParserTest extends BaseAttributeDefinitionParserTest {
     @Test public void values1() {
         SourceValue value = getSourceValue("resolver/sourceValueAttributes1.xml");
 
-        assertTrue(value.isIgnoreCase());
+        assertFalse(value.isCaseSensitive());
         assertTrue(value.isPartialMatch());
         assertEquals(value.getValue(), "sourceValueAttributes1");
     }
@@ -69,7 +69,7 @@ public class SourceValueParserTest extends BaseAttributeDefinitionParserTest {
     @Test public void values2() {
         SourceValue value = getSourceValue("resolver/sourceValueAttributes2.xml");
 
-        assertFalse(value.isIgnoreCase());
+        assertTrue(value.isCaseSensitive());
         assertFalse(value.isPartialMatch());
         try {
             assertEquals(value.getValue(), "sourceValueAttributes2");
@@ -78,4 +78,23 @@ public class SourceValueParserTest extends BaseAttributeDefinitionParserTest {
 
         }
     }
+    
+    @SuppressWarnings("deprecation")
+    @Test public void deprecated() {
+        SourceValue value = getSourceValue("resolver/sourceValueDeprecated.xml");
+
+        assertFalse(value.isCaseSensitive());
+        assertTrue(value.isIgnoreCase());
+        assertTrue(value.isPartialMatch());
+        assertEquals(value.getValue(), "sourceValueAttributes1");
+    }
+
+    @Test public void both() {
+        SourceValue value = getSourceValue("resolver/sourceValueBoth.xml");
+
+        assertTrue(value.isCaseSensitive());
+        assertFalse(value.isPartialMatch());
+    }
+
+
 }
diff --git a/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/ad/mapped/resolver/sourceValueAttributes1.xml b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/ad/mapped/resolver/sourceValueAttributes1.xml
index 2386913..1c44a33 100644
--- a/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/ad/mapped/resolver/sourceValueAttributes1.xml
+++ b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/ad/mapped/resolver/sourceValueAttributes1.xml
@@ -5,6 +5,6 @@
     <InputAttributeDefinition ref="TheOrphan" />                    
 	<ValueMap>
 		<ReturnValue>return</ReturnValue>
-		<SourceValue ignoreCase="true" partialMatch="true">sourceValueAttributes1</SourceValue>
+		<SourceValue caseSensitive="false" partialMatch="true">sourceValueAttributes1</SourceValue>
 	</ValueMap>
 </AttributeDefinition>
diff --git a/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/ad/mapped/resolver/sourceValueAttributes2.xml b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/ad/mapped/resolver/sourceValueAttributes2.xml
index 810dcf6..a236a00 100644
--- a/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/ad/mapped/resolver/sourceValueAttributes2.xml
+++ b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/ad/mapped/resolver/sourceValueAttributes2.xml
@@ -5,6 +5,6 @@
     <InputAttributeDefinition ref="TheOrphan" />                    
 	<ValueMap>
 		<ReturnValue>return</ReturnValue>
-		<SourceValue ignoreCase="false" partialMatch="false">sourceValueAttributes2</SourceValue>
+		<SourceValue caseSensitive="true" partialMatch="false">sourceValueAttributes2</SourceValue>
 	</ValueMap>
 </AttributeDefinition>
diff --git a/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/ad/mapped/resolver/sourceValueAttributes1.xml b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/ad/mapped/resolver/sourceValueBoth.xml
similarity index 79%
copy from idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/ad/mapped/resolver/sourceValueAttributes1.xml
copy to idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/ad/mapped/resolver/sourceValueBoth.xml
index 2386913..8ff0e9c 100644
--- a/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/ad/mapped/resolver/sourceValueAttributes1.xml
+++ b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/ad/mapped/resolver/sourceValueBoth.xml
@@ -5,6 +5,6 @@
     <InputAttributeDefinition ref="TheOrphan" />                    
 	<ValueMap>
 		<ReturnValue>return</ReturnValue>
-		<SourceValue ignoreCase="true" partialMatch="true">sourceValueAttributes1</SourceValue>
+		<SourceValue ignoreCase="true" caseSensitive="true" partialMatch="false">sourceValueAttributes1</SourceValue>
 	</ValueMap>
 </AttributeDefinition>
diff --git a/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/ad/mapped/resolver/sourceValueAttributes1.xml b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/ad/mapped/resolver/sourceValueDefault.xml
similarity index 82%
copy from idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/ad/mapped/resolver/sourceValueAttributes1.xml
copy to idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/ad/mapped/resolver/sourceValueDefault.xml
index 2386913..fc32186 100644
--- a/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/ad/mapped/resolver/sourceValueAttributes1.xml
+++ b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/ad/mapped/resolver/sourceValueDefault.xml
@@ -5,6 +5,6 @@
     <InputAttributeDefinition ref="TheOrphan" />                    
 	<ValueMap>
 		<ReturnValue>return</ReturnValue>
-		<SourceValue ignoreCase="true" partialMatch="true">sourceValueAttributes1</SourceValue>
+		<SourceValue >sourceValueAttributes1</SourceValue>
 	</ValueMap>
 </AttributeDefinition>
diff --git a/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/ad/mapped/resolver/sourceValueAttributes1.xml b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/ad/mapped/resolver/sourceValueDeprecated.xml
similarity index 100%
copy from idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/ad/mapped/resolver/sourceValueAttributes1.xml
copy to idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/ad/mapped/resolver/sourceValueDeprecated.xml
diff --git a/idp-schema/src/main/resources/schema/shibboleth-attribute-resolver.xsd b/idp-schema/src/main/resources/schema/shibboleth-attribute-resolver.xsd
index 2063adb..8e7d140 100644
--- a/idp-schema/src/main/resources/schema/shibboleth-attribute-resolver.xsd
+++ b/idp-schema/src/main/resources/schema/shibboleth-attribute-resolver.xsd
@@ -284,7 +284,16 @@
                         <extension base="string">
                             <attribute name="ignoreCase" type="string">
                                 <annotation>
-                                    <documentation>If true, value matching will be case-insensitive.</documentation>
+                                    <documentation>
+                                    If true, value matching will be case-insensitive.
+
+                                    Deprecated in V4.  Use caseSensitive
+                                    </documentation>
+                                </annotation>
+                            </attribute>
+                            <attribute name="caseSensitive" type="string">
+                                <annotation>
+                                    <documentation>If true, value matching will be case-sensitive.</documentation>
                                 </annotation>
                             </attribute>
                             <attribute name="partialMatch" type="string">

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


More information about the commits mailing list