[java-identity-provider] branch maint-3.4 updated: IDP-1389 Handle mapping to null and empty strings
Rod Widdowson
rdw at steadingsoftware.com
Fri Sep 6 05:53:30 EDT 2019
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch maint-3.4
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=93e9df8962a3deca123e5c9e6d0595f8b5706aef
The following commit(s) were added to refs/heads/maint-3.4 by this push:
new 93e9df8 IDP-1389 Handle mapping to null and empty strings
93e9df8 is described below
commit 93e9df8962a3deca123e5c9e6d0595f8b5706aef
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Sat Jan 12 14:10:53 2019 +0000
IDP-1389 Handle mapping to null and empty strings
https://issues.shibboleth.net/jira/browse/IDP-1389
---
.../resolver/ad/mapped/impl/ValueMap.java | 28 +++++++++++---------
.../ad/mapped/impl/MappedAttributeTest.java | 30 ++++++++++++++++++++++
2 files changed, 46 insertions(+), 12 deletions(-)
diff --git a/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/ad/mapped/impl/ValueMap.java b/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/ad/mapped/impl/ValueMap.java
index be6d4c5..a53cbe7 100644
--- a/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/ad/mapped/impl/ValueMap.java
+++ b/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/ad/mapped/impl/ValueMap.java
@@ -27,14 +27,6 @@ import java.util.regex.PatternSyntaxException;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import net.shibboleth.idp.attribute.StringAttributeValue;
-import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
-import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
-import net.shibboleth.utilities.java.support.annotation.constraint.NullableElements;
-import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
-import net.shibboleth.utilities.java.support.logic.Constraint;
-import net.shibboleth.utilities.java.support.primitive.StringSupport;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -43,6 +35,14 @@ import com.google.common.base.Predicates;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
+import net.shibboleth.idp.attribute.StringAttributeValue;
+import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+import net.shibboleth.utilities.java.support.annotation.constraint.NullableElements;
+import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
+import net.shibboleth.utilities.java.support.logic.Constraint;
+import net.shibboleth.utilities.java.support.primitive.StringSupport;
+
/**
* Performs many to one mapping of source values to a return value. SourceValue strings may include regular expressions
* and the ReturnValue may include back references to capturing groups as supported by {@link java.util.regex.Pattern}.
@@ -108,8 +108,8 @@ public class ValueMap implements Function<String, Set<StringAttributeValue>> {
* @return set of new values the incoming value mapped to
*/
/** {@inheritDoc} */
- @Override
- @Nullable public Set<StringAttributeValue> apply(@Nullable final String attributeValue) {
+ // CheckStyle: CyclomaticComplexity OFF
+ @Override @Nullable public Set<StringAttributeValue> apply(@Nullable final String attributeValue) {
if (attributeValue == null) {
log.debug("Input value was null, returning empty set");
@@ -145,12 +145,16 @@ public class ValueMap implements Function<String, Set<StringAttributeValue>> {
}
}
- if (newValue != null) {
+ if (newValue == null) {
+ log.debug("Value {} yielded a null value", attributeValue);
+ } else if ("".equals(newValue)) {
+ log.debug("Value {} yielded an empty value", attributeValue);
+ } else {
mappedValues.add(new StringAttributeValue(newValue));
}
}
return mappedValues;
}
-
+ // CheckStyle: CyclomaticComplexity ON
}
\ No newline at end of file
diff --git a/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/ad/mapped/impl/MappedAttributeTest.java b/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/ad/mapped/impl/MappedAttributeTest.java
index b38d62a..696d004 100644
--- a/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/ad/mapped/impl/MappedAttributeTest.java
+++ b/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/ad/mapped/impl/MappedAttributeTest.java
@@ -261,4 +261,34 @@ public class MappedAttributeTest {
return retVal;
}
+ @Test public void IdP1389() throws Exception {
+ final SourceValue source = new SourceValue();
+ source.setValue(".*(.*)");
+ source.setPartialMatch(false);
+ source.initialize();
+
+ final ValueMap valueMap = new ValueMap();
+ valueMap.setReturnValue("$1");
+ valueMap.setSourceValues(Collections.singleton(source));
+
+ final MappedAttributeDefinition definition = new MappedAttributeDefinition();
+ definition.setId(TEST_ATTRIBUTE_NAME);
+ definition.setDependencies(Collections.singleton(TestSources.makeResolverPluginDependency("connector1",
+ ResolverTestSupport.EPA_ATTRIB_ID)));
+
+ definition.setValueMaps(Collections.singleton(valueMap));
+ definition.initialize();
+
+ final AttributeResolutionContext resolutionContext =
+ ResolverTestSupport.buildResolutionContext(ResolverTestSupport.buildDataConnector("connector1",
+ ResolverTestSupport.buildAttribute(ResolverTestSupport.EPE_ATTRIB_ID,
+ ResolverTestSupport.EPE1_VALUES), ResolverTestSupport.buildAttribute(
+ ResolverTestSupport.EPA_ATTRIB_ID, "Val", "val")));
+
+ final IdPAttribute result = definition.resolve(resolutionContext);
+
+
+
+ }
+
}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list