[java-identity-provider] 09/10: IDP-1429 Deprecate ignoreCase for SourceValue (in Mapped Attribute defn)
Rod Widdowson
rdw at steadingsoftware.com
Thu Apr 11 09:00:01 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=bd2f48a44b9de9c6302c45447c846b01eefefea3
commit bd2f48a44b9de9c6302c45447c846b01eefefea3
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Wed Apr 10 16:56:23 2019 +0100
IDP-1429 Deprecate ignoreCase for SourceValue (in Mapped Attribute defn)
https://issues.shibboleth.net/jira/browse/IDP-1429
replacement is caseSensitive
---
.../resolver/ad/mapped/impl/SourceValue.java | 44 ++++++++++++++++++----
.../resolver/ad/mapped/impl/SourceValueTest.java | 26 +++++++++++--
2 files changed, 60 insertions(+), 10 deletions(-)
diff --git a/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/ad/mapped/impl/SourceValue.java b/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/ad/mapped/impl/SourceValue.java
index 076d018..a4ff4ff 100644
--- a/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/ad/mapped/impl/SourceValue.java
+++ b/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/ad/mapped/impl/SourceValue.java
@@ -26,6 +26,8 @@ import net.shibboleth.utilities.java.support.component.AbstractInitializableComp
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.logic.Constraint;
+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;
import com.google.common.base.MoreObjects;
@@ -41,9 +43,9 @@ public class SourceValue extends AbstractInitializableComponent {
private @Nullable String value;
/**
- * Whether case should be ignored when matching.
+ * Whether case should be taken into account when matching.
*/
- private boolean ignoreCase;
+ private boolean caseSensitive = true;
/** In the regexp case this contains the compiled pattern. */
private @Nullable Pattern pattern;
@@ -58,7 +60,7 @@ public class SourceValue extends AbstractInitializableComponent {
super.doInitialize();
if (!partialMatch && value != null) {
int flags = 0;
- if (ignoreCase) {
+ if (!isCaseSensitive()) {
flags = Pattern.CASE_INSENSITIVE;
}
pattern = Pattern.compile(value, flags);
@@ -68,27 +70,55 @@ public class SourceValue extends AbstractInitializableComponent {
}
/**
+ * Set whether case is sensitive.
+ *
+ * @param theCaseSensitive whether case should be ignored when matching. Null defaults to false;
+ */
+ public void setCaseSensitive( @Nullable final Boolean theCaseSensitive) {
+ ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+ if (null != theCaseSensitive) {
+ caseSensitive = theCaseSensitive;
+ } else {
+ caseSensitive = true;
+ }
+ }
+
+
+ /**
+ * Gets whether matching should be case sensitive.
+ *
+ * @return whether case should be ignored when matching
+ */
+ public boolean isCaseSensitive() {
+ return caseSensitive;
+ }
+
+ /**
* Set whether to ignore the case.
*
* @param theIgnoreCase whether case should be ignored when matching. Null defaults to false;
+ * @deprecated in V4 - use setCaseSensitive
*/
public void setIgnoreCase( @Nullable final Boolean theIgnoreCase) {
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+ DeprecationSupport.warnOnce(ObjectType.METHOD, "setIgnoreCase", null, "setCaseSensitive");
if (null != theIgnoreCase) {
- ignoreCase = theIgnoreCase;
+ setCaseSensitive(!theIgnoreCase);
} else {
- ignoreCase = false;
+ setCaseSensitive(true);
}
}
/**
* Gets whether case should be ignored when matching.
- *
+ *
* @return whether case should be ignored when matching
+ * @deprecated in V4 - use isCaseSensitive
*/
public boolean isIgnoreCase() {
- return ignoreCase;
+ DeprecationSupport.warnOnce(ObjectType.METHOD, "isIgnoreCase", null, "isCaseSensitive");
+ return !isCaseSensitive();
}
/**
diff --git a/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/ad/mapped/impl/SourceValueTest.java b/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/ad/mapped/impl/SourceValueTest.java
index d4cfecf..0abc2e1 100644
--- a/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/ad/mapped/impl/SourceValueTest.java
+++ b/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/ad/mapped/impl/SourceValueTest.java
@@ -39,7 +39,7 @@ public class SourceValueTest {
assertEquals(value.getValue(), "value");
assertTrue(value.isPartialMatch());
- assertFalse(value.isIgnoreCase());
+ assertTrue(value.isCaseSensitive());
log.info("Value = 'value', ignore = true, partial = false", value.toString());
@@ -47,17 +47,37 @@ public class SourceValueTest {
assertEquals(value.getPattern().pattern(), "eulaV");
assertFalse(value.isPartialMatch());
- assertTrue(value.isIgnoreCase());
+ assertFalse(value.isCaseSensitive());
log.info("Value = 'eulaV', ignore = false, partial = true", value.toString());
}
+ @Test public void testDefault() throws ComponentInitializationException {
+ assertTrue(new SourceValue().isCaseSensitive());
+ }
+
+ @SuppressWarnings("deprecation")
+ @Test public void deprecated() throws ComponentInitializationException {
+ final SourceValue value = new SourceValue();
+ assertTrue(value.isCaseSensitive());
+ value.setIgnoreCase(true);
+ assertFalse(value.isCaseSensitive());
+ value.setIgnoreCase(null);
+ assertTrue(value.isCaseSensitive());
+ value.setCaseSensitive(false);
+ assertFalse(value.isCaseSensitive());
+ assertTrue(value.isIgnoreCase());
+ value.setCaseSensitive(null);
+ assertTrue(value.isCaseSensitive());
+ assertFalse(value.isIgnoreCase());
+ }
+
public static SourceValue newSourceValue(final String value, final boolean ignoreCase, final boolean partialMatch)
throws ComponentInitializationException {
final SourceValue sourceValue = new SourceValue();
sourceValue.setValue(value);
- sourceValue.setIgnoreCase(ignoreCase);
+ sourceValue.setCaseSensitive(!ignoreCase);
sourceValue.setPartialMatch(partialMatch);
sourceValue.initialize();
return sourceValue;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list