[java-shib-attribute] branch main updated: IDP-1735 Filter matchAny function changes value order
Rod Widdowson
rdw at steadingsoftware.com
Tue Aug 23 13:02:01 UTC 2022
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch main
in repository java-shib-attribute.
View the commit online:
http://git.shibboleth.net/view/?p=java-shib-attribute.git;a=commit;h=be46522bc2af17a5798601f610483cf93c95de13
The following commit(s) were added to refs/heads/main by this push:
new be46522bc IDP-1735 Filter matchAny function changes value order
be46522bc is described below
commit be46522bc2af17a5798601f610483cf93c95de13
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Tue Aug 23 14:00:11 2022 +0100
IDP-1735 Filter matchAny function changes value order
https://shibboleth.atlassian.net/browse/IDP-1735
Change AttributeFilterImpl to explicity keep the order of the
original attributes. Filtering is a retainAll of the results
of the filters running against the initial list
---
.../attribute/filter/impl/AttributeFilterImpl.java | 23 ++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/shib-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/impl/AttributeFilterImpl.java b/shib-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/impl/AttributeFilterImpl.java
index caa1cd520..c9bcd003a 100644
--- a/shib-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/impl/AttributeFilterImpl.java
+++ b/shib-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/impl/AttributeFilterImpl.java
@@ -17,9 +17,11 @@
package net.shibboleth.idp.attribute.filter.impl;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.function.Function;
import javax.annotation.Nonnull;
@@ -103,29 +105,30 @@ public class AttributeFilterImpl extends AbstractServiceableComponent<AttributeF
final boolean timerStarted = startTimer(filterContext);
try {
final Map<String, IdPAttribute> prefilteredAttributes = filterContext.getPrefilteredIdPAttributes();
-
+
// Create work context to hold intermediate results.
filterContext.getSubcontext(AttributeFilterWorkContext.class, true);
-
+
log.debug("{} Beginning process of filtering the following {} attributes: {}", new Object[] {getLogPrefix(),
prefilteredAttributes.size(), prefilteredAttributes.keySet(),});
-
+
final List<AttributeFilterPolicy> policies = getFilterPolicies();
for (final AttributeFilterPolicy policy : policies) {
policy.apply(filterContext);
}
-
- IdPAttribute filteredAttribute;
- for (final String attributeId : filterContext.getPrefilteredIdPAttributes().keySet()) {
- final Collection<IdPAttributeValue> filteredAttributeValues =
- getFilteredValues(attributeId, filterContext);
+
+ for (Entry<String, IdPAttribute> entry : filterContext.getPrefilteredIdPAttributes().entrySet()) {
+ final Collection<IdPAttributeValue> filteredAttributeValues = getFilteredValues(entry.getKey(), filterContext);
if (null != filteredAttributeValues && !filteredAttributeValues.isEmpty()) {
+ final IdPAttribute filteredAttribute;
try {
- filteredAttribute = prefilteredAttributes.get(attributeId).clone();
+ filteredAttribute = entry.getValue().clone();
} catch (final CloneNotSupportedException e) {
throw new AttributeFilterException(e);
}
- filteredAttribute.setValues(List.copyOf(filteredAttributeValues));
+ final List<IdPAttributeValue> values = new ArrayList<>(filteredAttribute.getValues());
+ values.retainAll(filteredAttributeValues);
+ filteredAttribute.setValues(values);
filterContext.getFilteredIdPAttributes().put(filteredAttribute.getId(), filteredAttribute);
}
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list