[java-identity-provider] branch master updated: IDP-1362 - Allow Template attribute to handle missing attributes
Scott Cantor
cantor.2 at osu.edu
Fri Nov 16 19:36:32 EST 2018
This is an automated email from the git hooks/post-receive script.
scantor 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=752968c6da4ba01523c23937a3c707d1f5a58b4a
The following commit(s) were added to refs/heads/master by this push:
new 752968c IDP-1362 - Allow Template attribute to handle missing attributes
752968c is described below
commit 752968c6da4ba01523c23937a3c707d1f5a58b4a
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Fri Nov 16 19:36:26 2018 -0500
IDP-1362 - Allow Template attribute to handle missing attributes
https://issues.shibboleth.net/jira/browse/IDP-1362
---
.../ad/impl/TemplateAttributeDefinition.java | 12 ++++-----
.../resolver/ad/impl/TemplateAttributeTest.java | 30 ++++++++++++++++++++++
2 files changed, 35 insertions(+), 7 deletions(-)
diff --git a/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/ad/impl/TemplateAttributeDefinition.java b/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/ad/impl/TemplateAttributeDefinition.java
index 61a294d..433666c 100644
--- a/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/ad/impl/TemplateAttributeDefinition.java
+++ b/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/ad/impl/TemplateAttributeDefinition.java
@@ -264,9 +264,6 @@ public class TemplateAttributeDefinition extends AbstractAttributeDefinition {
* iterator to give all the names. We also return how deep the iteration will be and throw an exception if there is
* a mismatch in number of elements in any attribute.
*
- * <p>Finally, the names of the source attributes is checked against the dependency attributes and if there is a
- * mismatch then a warning is emitted.</p>
- *
* @param workContext source for dependencies
* @param sourceValues to populate with the attribute iterators
*
@@ -285,9 +282,10 @@ public class TemplateAttributeDefinition extends AbstractAttributeDefinition {
for (final String attributeName : sourceAttributes) {
- List<IdPAttributeValue<?>> attributeValues = dependencyAttributes.get(attributeName);
- if (null == attributeValues) {
- attributeValues = Collections.emptyList();
+ final List<IdPAttributeValue<?>> attributeValues = dependencyAttributes.get(attributeName);
+ if (null == attributeValues || 0 == attributeValues.size()) {
+ log.debug("{} Ignoring input attribute '{}' with no values", getLogPrefix(), attributeName);
+ continue;
}
if (!valueCountSet) {
@@ -296,7 +294,7 @@ public class TemplateAttributeDefinition extends AbstractAttributeDefinition {
} else if (attributeValues.size() != valueCount) {
final String msg = getLogPrefix() + " All source attributes used in"
+ " TemplateAttributeDefinition must have the same number of values: '" + attributeName + "'" ;
- log.error(msg);
+ log.error("{} {}", getLogPrefix(), msg);
throw new ResolutionException(msg);
}
diff --git a/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/ad/impl/TemplateAttributeTest.java b/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/ad/impl/TemplateAttributeTest.java
index 30ae8b2..06bf607 100644
--- a/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/ad/impl/TemplateAttributeTest.java
+++ b/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/ad/impl/TemplateAttributeTest.java
@@ -351,6 +351,36 @@ public class TemplateAttributeTest {
}
}
+ @Test public void allowingOneEmpty() throws ResolutionException, ComponentInitializationException {
+ final String name = TEST_ATTRIBUTE_BASE_NAME + "3";
+
+ final TemplateAttributeDefinition templateDef = new TemplateAttributeDefinition();
+ templateDef.setId(name);
+ templateDef.setVelocityEngine(getEngine());
+ templateDef.setTemplateText(TEST_ATTRIBUTES_TEMPLATE_CONNECTOR);
+ final String otherDefName = TestSources.STATIC_ATTRIBUTE_NAME + "2";
+ final String otherAttrName = TestSources.DEPENDS_ON_ATTRIBUTE_NAME_ATTR + "2";
+
+ final Set<ResolverPluginDependency> ds = new LazySet<>();
+ ds.add(TestSources.makeResolverPluginDependency(TestSources.STATIC_ATTRIBUTE_NAME,
+ TestSources.DEPENDS_ON_ATTRIBUTE_NAME_ATTR));
+ ds.add(TestSources.makeResolverPluginDependency(otherDefName, otherAttrName));
+ templateDef.setDependencies(ds);
+ templateDef.setSourceAttributes(Arrays.asList(TestSources.DEPENDS_ON_ATTRIBUTE_NAME_ATTR, otherAttrName));
+ templateDef.initialize();
+
+ final Set<AttributeDefinition> attrDefinitions = new LazySet<>();
+ attrDefinitions.add(templateDef);
+ attrDefinitions.add(TestSources.populatedStaticAttribute());
+ attrDefinitions.add(TestSources.populatedStaticAttribute(otherDefName, otherAttrName, 0));
+
+ final AttributeResolverImpl resolver = AttributeResolverImplTest.newAttributeResolverImpl("foo", attrDefinitions, Collections.EMPTY_SET, null);
+ resolver.initialize();
+
+ final AttributeResolutionContext context = new AttributeResolutionContext();
+ resolver.resolveAttributes(context);
+ }
+
@Test public void wrongType() throws ResolutionException, ComponentInitializationException {
final String name = TEST_ATTRIBUTE_BASE_NAME + "3";
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list