[java-identity-provider] branch main updated: Adjust null component handling.
Scott Cantor
cantor.2 at osu.edu
Mon Nov 28 18:22:39 UTC 2022
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=6d1943bcb03ed3e9c3e38523dc0e945e8a79004e
The following commit(s) were added to refs/heads/main by this push:
new 6d1943bcb Adjust null component handling.
6d1943bcb is described below
commit 6d1943bcb03ed3e9c3e38523dc0e945e8a79004e
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Mon Nov 28 13:22:36 2022 -0500
Adjust null component handling.
---
.../idp/profile/impl/FilterAttributes.java | 31 +++++++++-----------
.../idp/profile/impl/ResolveAttributes.java | 33 +++++++++++-----------
.../idp/profile/impl/FilterAttributesTest.java | 10 +++++--
.../idp/profile/impl/ResolveAttributesTest.java | 1 -
4 files changed, 37 insertions(+), 38 deletions(-)
diff --git a/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/FilterAttributes.java b/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/FilterAttributes.java
index 93208bcc2..68b8312dc 100644
--- a/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/FilterAttributes.java
+++ b/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/FilterAttributes.java
@@ -49,6 +49,7 @@ import net.shibboleth.idp.profile.context.navigate.RelyingPartyIdLookupFunction;
import net.shibboleth.idp.profile.context.navigate.ResponderIdLookupFunction;
import net.shibboleth.shared.logic.Constraint;
import net.shibboleth.shared.service.ReloadableService;
+import net.shibboleth.shared.service.ServiceException;
import net.shibboleth.shared.service.ServiceableComponent;
/**
@@ -374,23 +375,11 @@ public class FilterAttributes extends AbstractProfileAction {
populateFilterContext(profileRequestContext, filterContext);
- try (final ServiceableComponent<AttributeFilter> component =
- attributeFilterService.getServiceableComponent()) {
- if (null == component) {
- log.error("{} Error encountered while filtering attributes : Invalid Attribute Filter configuration",
- getLogPrefix());
- if (maskFailures) {
- log.warn("Filter error masked, clearing resolved attributes");
- attributeContext.setIdPAttributes(null);
- } else {
- ActionSupport.buildEvent(profileRequestContext, IdPEventIds.UNABLE_FILTER_ATTRIBS);
- }
- } else {
- final AttributeFilter filter = component.getComponent();
- filter.filterAttributes(filterContext);
- filterContext.getParent().removeSubcontext(filterContext);
- attributeContext.setIdPAttributes(filterContext.getFilteredIdPAttributes().values());
- }
+ try (final ServiceableComponent<AttributeFilter> component = attributeFilterService.getServiceableComponent()) {
+ final AttributeFilter filter = component.getComponent();
+ filter.filterAttributes(filterContext);
+ filterContext.getParent().removeSubcontext(filterContext);
+ attributeContext.setIdPAttributes(filterContext.getFilteredIdPAttributes().values());
} catch (final AttributeFilterException e) {
log.error("{} Error encountered while filtering attributes", getLogPrefix(), e);
if (maskFailures) {
@@ -399,6 +388,14 @@ public class FilterAttributes extends AbstractProfileAction {
} else {
ActionSupport.buildEvent(profileRequestContext, IdPEventIds.UNABLE_FILTER_ATTRIBS);
}
+ } catch (final ServiceException e) {
+ log.error("{} Invalid Attribute Filter service configuration", getLogPrefix(), e);
+ if (maskFailures) {
+ log.warn("Filter error masked, clearing resolved attributes");
+ attributeContext.setIdPAttributes(null);
+ } else {
+ ActionSupport.buildEvent(profileRequestContext, IdPEventIds.UNABLE_FILTER_ATTRIBS);
+ }
}
}
diff --git a/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/ResolveAttributes.java b/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/ResolveAttributes.java
index 0f5543e69..a0965cfba 100644
--- a/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/ResolveAttributes.java
+++ b/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/ResolveAttributes.java
@@ -48,6 +48,7 @@ import net.shibboleth.shared.logic.Constraint;
import net.shibboleth.shared.logic.FunctionSupport;
import net.shibboleth.shared.primitive.StringSupport;
import net.shibboleth.shared.service.ReloadableService;
+import net.shibboleth.shared.service.ServiceException;
import net.shibboleth.shared.service.ServiceableComponent;
/**
@@ -268,30 +269,28 @@ public final class ResolveAttributes extends AbstractProfileAction {
}
}
- try (final ServiceableComponent<AttributeResolver> component
- = attributeResolverService.getServiceableComponent()) {
- if (null == component) {
- log.error("{} Error resolving attributes: Invalid Attribute resolver configuration", getLogPrefix());
- if (!maskFailures) {
- ActionSupport.buildEvent(profileRequestContext, IdPEventIds.UNABLE_RESOLVE_ATTRIBS);
- }
- } else {
- final AttributeResolver attributeResolver = component.getComponent();
- attributeResolver.resolveAttributes(resolutionContext);
- profileRequestContext.removeSubcontext(resolutionContext);
+ try (final ServiceableComponent<AttributeResolver> component =
+ attributeResolverService.getServiceableComponent()) {
+ final AttributeResolver attributeResolver = component.getComponent();
+ attributeResolver.resolveAttributes(resolutionContext);
+ profileRequestContext.removeSubcontext(resolutionContext);
- final AttributeContext attributeCtx = attributeContextCreationStrategy.apply(profileRequestContext);
- if (null == attributeCtx) {
- throw new ResolutionException("Unable to create or locate AttributeContext to populate");
- }
- attributeCtx.setIdPAttributes(resolutionContext.getResolvedIdPAttributes().values());
- attributeCtx.setUnfilteredIdPAttributes(resolutionContext.getResolvedIdPAttributes().values());
+ final AttributeContext attributeCtx = attributeContextCreationStrategy.apply(profileRequestContext);
+ if (null == attributeCtx) {
+ throw new ResolutionException("Unable to create or locate AttributeContext to populate");
}
+ attributeCtx.setIdPAttributes(resolutionContext.getResolvedIdPAttributes().values());
+ attributeCtx.setUnfilteredIdPAttributes(resolutionContext.getResolvedIdPAttributes().values());
} catch (final ResolutionException e) {
log.error("{} Error resolving attributes", getLogPrefix(), e);
if (!maskFailures) {
ActionSupport.buildEvent(profileRequestContext, IdPEventIds.UNABLE_RESOLVE_ATTRIBS);
}
+ } catch (final ServiceException e) {
+ log.error("{} Invalid AttributeResolver configuration", getLogPrefix(), e);
+ if (!maskFailures) {
+ ActionSupport.buildEvent(profileRequestContext, IdPEventIds.UNABLE_RESOLVE_ATTRIBS);
+ }
}
}
diff --git a/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/impl/FilterAttributesTest.java b/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/impl/FilterAttributesTest.java
index 868602b87..419f66334 100644
--- a/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/impl/FilterAttributesTest.java
+++ b/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/impl/FilterAttributesTest.java
@@ -39,7 +39,6 @@ import net.shibboleth.idp.profile.context.navigate.WebflowRequestContextProfileR
import net.shibboleth.idp.profile.testing.ActionTestingSupport;
import net.shibboleth.idp.profile.testing.RequestContextBuilder;
import net.shibboleth.shared.component.ComponentInitializationException;
-import net.shibboleth.shared.testing.MockApplicationContext;
import net.shibboleth.shared.testing.MockReloadableService;
import org.opensaml.profile.context.ProfileRequestContext;
@@ -56,6 +55,11 @@ public class FilterAttributesTest {
private ProfileRequestContext prc;
+ /**
+ * Set up tests.
+ *
+ * @throws ComponentInitializationException
+ */
@BeforeMethod public void setUpAction() throws ComponentInitializationException {
src = new RequestContextBuilder().buildRequestContext();
prc = new WebflowRequestContextProfileRequestContextLookup().apply(src);
@@ -69,7 +73,7 @@ public class FilterAttributesTest {
@Test public void testNoAttributeContext() throws Exception {
prc.getSubcontext(SubjectContext.class, true);
- final AttributeFilterImpl engine = new AttributeFilterImpl("test", Collections.EMPTY_LIST);
+ final AttributeFilterImpl engine = new AttributeFilterImpl("test", Collections.emptyList());
engine.initialize();
final FilterAttributes action = new FilterAttributes(new MockReloadableService<>(engine));
@@ -89,7 +93,7 @@ public class FilterAttributesTest {
prc.getSubcontext(RelyingPartyContext.class).getSubcontext(AttributeContext.class, true);
- final AttributeFilterImpl engine = new AttributeFilterImpl("test", Collections.EMPTY_LIST);
+ final AttributeFilterImpl engine = new AttributeFilterImpl("test", Collections.emptyList());
engine.initialize();
final FilterAttributes action = new FilterAttributes(new MockReloadableService<>(engine));
diff --git a/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/impl/ResolveAttributesTest.java b/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/impl/ResolveAttributesTest.java
index 53bad73b0..246b94051 100644
--- a/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/impl/ResolveAttributesTest.java
+++ b/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/impl/ResolveAttributesTest.java
@@ -42,7 +42,6 @@ import net.shibboleth.idp.profile.testing.RequestContextBuilder;
import net.shibboleth.shared.annotation.constraint.NotEmpty;
import net.shibboleth.shared.collection.LazySet;
import net.shibboleth.shared.component.ComponentInitializationException;
-import net.shibboleth.shared.testing.MockApplicationContext;
import net.shibboleth.shared.testing.MockReloadableService;
import org.opensaml.profile.context.ProfileRequestContext;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list