[java-opensaml] branch main updated: IDP-1877 - Allow ByReference filter to apply to multiple providers
Scott Cantor
cantor.2 at osu.edu
Fri Nov 5 20:03:31 UTC 2021
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository java-opensaml.
View the commit online:
http://git.shibboleth.net/view/?p=java-opensaml.git;a=commit;h=666773ae1106dd89868ab7cd32394c1d3801780e
The following commit(s) were added to refs/heads/main by this push:
new 666773ae1 IDP-1877 - Allow ByReference filter to apply to multiple providers
666773ae1 is described below
commit 666773ae1106dd89868ab7cd32394c1d3801780e
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Fri Nov 5 16:03:28 2021 -0400
IDP-1877 - Allow ByReference filter to apply to multiple providers
https://shibboleth.atlassian.net/browse/IDP-1877
Extend setter to allow a collection on the map key side.
---
.../filter/impl/ByReferenceMetadataFilter.java | 22 +++++++++++++++++-----
.../filter/impl/ByReferenceMetadataFilterTest.java | 3 ++-
2 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/filter/impl/ByReferenceMetadataFilter.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/filter/impl/ByReferenceMetadataFilter.java
index 9907f00dd..47e26febc 100644
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/filter/impl/ByReferenceMetadataFilter.java
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/filter/impl/ByReferenceMetadataFilter.java
@@ -17,6 +17,7 @@
package org.opensaml.saml.metadata.resolver.filter.impl;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -63,14 +64,25 @@ public class ByReferenceMetadataFilter implements MetadataFilter {
*
* @param map filter mappings
*/
- public void setFilterMappings(@Nonnull @NonnullElements final Map<String,MetadataFilter> map) {
+ public void setFilterMappings(@Nonnull @NonnullElements final Map<Object,MetadataFilter> map) {
Constraint.isNotNull(map, "Filter mappings cannot be null");
filterMap = new HashMap<>(map.size());
- for (final Map.Entry<String,MetadataFilter> entry : map.entrySet()) {
- final String trimmed = StringSupport.trimOrNull(entry.getKey());
- if (trimmed != null && entry.getValue() != null) {
- filterMap.put(trimmed, entry.getValue());
+ for (final Map.Entry<Object,MetadataFilter> entry : map.entrySet()) {
+ if (entry.getKey() instanceof String) {
+ final String trimmed = StringSupport.trimOrNull((String) entry.getKey());
+ if (trimmed != null && entry.getValue() != null) {
+ filterMap.put(trimmed, entry.getValue());
+ }
+ } else if (entry.getKey() instanceof Collection) {
+ for (final Object k : (Collection<?>) entry.getKey()) {
+ if (k instanceof String && entry.getValue() != null) {
+ final String trimmed = StringSupport.trimOrNull((String) k);
+ if (trimmed != null) {
+ filterMap.put(trimmed, entry.getValue());
+ }
+ }
+ }
}
}
}
diff --git a/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/filter/impl/ByReferenceMetadataFilterTest.java b/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/filter/impl/ByReferenceMetadataFilterTest.java
index 6d74af78b..0b5a602f5 100644
--- a/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/filter/impl/ByReferenceMetadataFilterTest.java
+++ b/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/filter/impl/ByReferenceMetadataFilterTest.java
@@ -23,6 +23,7 @@ import java.net.URL;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.List;
import java.util.function.Predicate;
import org.opensaml.core.criterion.EntityIdCriterion;
@@ -90,7 +91,7 @@ public class ByReferenceMetadataFilterTest extends XMLObjectBaseTestCase impleme
nameIDFilter.setRules(Collections.<Predicate<EntityDescriptor>,Collection<String>>singletonMap(this, formats));
nameIDFilter.initialize();
- refFilter.setFilterMappings(Collections.singletonMap("ICMD", nameIDFilter));
+ refFilter.setFilterMappings(Collections.singletonMap(List.of("ICMD", "Foo"), nameIDFilter));
metadataProvider.initialize();
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list