[java-identity-provider] 02/06: IDP-1811 Expose suppressDisplayInformation as a resolver plugin option
Rod Widdowson
rdw at steadingsoftware.com
Tue May 11 14:39:50 UTC 2021
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch dev/IDP-1811
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=3a23c581953a7ef2ad5d50ba6bf4a3468987c16c
commit 3a23c581953a7ef2ad5d50ba6bf4a3468987c16c
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Wed May 5 16:18:36 2021 +0100
IDP-1811 Expose suppressDisplayInformation as a resolver plugin option
https://issues.shibboleth.net/jira/browse/IDP-1811
This is now controlled globally via a property called
idp.service.attribute.resolver.suppressDisplayInfo (default false)
---
.../attribute/resolver/AbstractResolverPlugin.java | 1 -
.../resolver/impl/AttributeResolverImpl.java | 36 ++++++++++++++++++--
.../impl/AttributeResolverServiceStrategy.java | 38 +++++++++++++++++-----
.../net/shibboleth/idp/conf/services-system.xml | 1 +
.../src/main/resources/conf/services.properties | 1 +
5 files changed, 64 insertions(+), 13 deletions(-)
diff --git a/idp-attribute-resolver-api/src/main/java/net/shibboleth/idp/attribute/resolver/AbstractResolverPlugin.java b/idp-attribute-resolver-api/src/main/java/net/shibboleth/idp/attribute/resolver/AbstractResolverPlugin.java
index 66e1e66db..8f5571f1a 100644
--- a/idp-attribute-resolver-api/src/main/java/net/shibboleth/idp/attribute/resolver/AbstractResolverPlugin.java
+++ b/idp-attribute-resolver-api/src/main/java/net/shibboleth/idp/attribute/resolver/AbstractResolverPlugin.java
@@ -100,7 +100,6 @@ public abstract class AbstractResolverPlugin<ResolvedType> extends AbstractIdent
* @param what true if we suppress the addition.
*/
public void setSuppressDisplayInformation(final boolean what) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
suppressDisplayInformation = what;
diff --git a/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/AttributeResolverImpl.java b/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/AttributeResolverImpl.java
index 53d630084..50b2fb841 100644
--- a/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/AttributeResolverImpl.java
+++ b/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/AttributeResolverImpl.java
@@ -46,6 +46,7 @@ import net.shibboleth.idp.attribute.EmptyAttributeValue;
import net.shibboleth.idp.attribute.IdPAttribute;
import net.shibboleth.idp.attribute.IdPAttributeValue;
import net.shibboleth.idp.attribute.context.AttributeContext;
+import net.shibboleth.idp.attribute.resolver.AbstractResolverPlugin;
import net.shibboleth.idp.attribute.resolver.AttributeDefinition;
import net.shibboleth.idp.attribute.resolver.AttributeResolver;
import net.shibboleth.idp.attribute.resolver.DataConnector;
@@ -94,10 +95,13 @@ public class AttributeResolverImpl extends AbstractServiceableComponent<Attribut
/** PreRequestedAttributes, resolved first and made available for late-comers. */
@NonnullAfterInit private List<String> preRequestedAttributes;
-
+
/** Whether to strip null attribute values. */
private boolean stripNulls;
-
+
+ /** Whether to attach DisplayInfo to attributes. */
+ private boolean suppressDisplayInformation;
+
/** Strategy to get the {@link ProfileRequestContext}. */
@Nonnull private Function<AttributeResolutionContext,ProfileRequestContext> profileContextStrategy;
@@ -183,6 +187,24 @@ public class AttributeResolverImpl extends AbstractServiceableComponent<Attribut
stripNulls = doStripNulls;
}
+ /** Do we allow addition of Display Information?
+ * @return whether we are suppressing
+ */
+ public boolean isSuppressDisplayInformation() {
+ return suppressDisplayInformation;
+ }
+
+ /**
+ * Set whether we suppress addition of Display Information.
+ *
+ * @param what true if we suppress the addition.
+ */
+ public void setSuppressDisplayInformation(final boolean what) {
+ ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
+
+ suppressDisplayInformation = what;
+ }
+
/**
* Set the mechanism to obtain the {@link ProfileRequestContext}.
*
@@ -573,7 +595,9 @@ public class AttributeResolverImpl extends AbstractServiceableComponent<Attribut
}
final IdPAttribute newAttr = new IdPAttribute(attribute.getId());
newAttr.setValues(values);
- dataConnector.addDisplayInformation(resolutionContext, newAttr);
+ if (!isSuppressDisplayInformation()) {
+ dataConnector.addDisplayInformation(resolutionContext, newAttr);
+ }
resolvedAttributes.put(attribute.getId(), newAttr);
}
}
@@ -659,11 +683,17 @@ public class AttributeResolverImpl extends AbstractServiceableComponent<Attribut
for (final DataConnector plugin : dataConnectors.values()) {
log.debug("{} Checking if data connector '{}' has a circular dependency", logPrefix, plugin.getId());
checkPlugInDependencies(plugin.getId(), plugin, dependencyVerifiedPlugins);
+ if (plugin instanceof AbstractResolverPlugin<?>) {
+ ((AbstractResolverPlugin<?>) plugin).setSuppressDisplayInformation(isSuppressDisplayInformation());
+ }
}
for (final AttributeDefinition plugin : attributeDefinitions.values()) {
log.debug("{} Checking if attribute definition '{}' has a circular dependency", logPrefix, plugin.getId());
checkPlugInDependencies(plugin.getId(), plugin, dependencyVerifiedPlugins);
+ if (plugin instanceof AbstractResolverPlugin<?>) {
+ ((AbstractResolverPlugin<?>) plugin).setSuppressDisplayInformation(isSuppressDisplayInformation());
+ }
}
}
diff --git a/idp-attribute-resolver-spring/src/main/java/net/shibboleth/idp/attribute/resolver/spring/impl/AttributeResolverServiceStrategy.java b/idp-attribute-resolver-spring/src/main/java/net/shibboleth/idp/attribute/resolver/spring/impl/AttributeResolverServiceStrategy.java
index 8a48decf5..24cfdc636 100644
--- a/idp-attribute-resolver-spring/src/main/java/net/shibboleth/idp/attribute/resolver/spring/impl/AttributeResolverServiceStrategy.java
+++ b/idp-attribute-resolver-spring/src/main/java/net/shibboleth/idp/attribute/resolver/spring/impl/AttributeResolverServiceStrategy.java
@@ -49,21 +49,40 @@ public class AttributeResolverServiceStrategy extends AbstractIdentifiableInitia
/** Whether to strip null attribute values. */
private boolean stripNulls;
+
+ /** Whether to attach DisplayInfo to attributes. */
+ private boolean suppressDisplayInformation;
/** Do we strip nulls from attribute values.
* @return Returns whether to strip nulls from attribute values
*/
- public boolean isStripNulls() {
- return stripNulls;
- }
+ public boolean isStripNulls() {
+ return stripNulls;
+ }
- /**
- * Sets whether to strip nulls from attribute values.
- * @param doStripNulls what to set
- */
- public void setStripNulls(final boolean doStripNulls) {
+ /**
+ * Sets whether to strip nulls from attribute values.
+ * @param doStripNulls what to set
+ */
+ public void setStripNulls(final boolean doStripNulls) {
stripNulls = doStripNulls;
- }
+ }
+
+ /** Do we allow addition of Display Information?
+ * @return whether we are suppressing
+ */
+ public boolean isSuppressDisplayInformation() {
+ return suppressDisplayInformation;
+ }
+
+ /**
+ * Set whether we suppress addition of Display Information.
+ *
+ * @param what true if we suppress the addition.
+ */
+ public void setSuppressDisplayInformation(final boolean what) {
+ suppressDisplayInformation = what;
+ }
/** {@inheritDoc} */
@Nullable public ServiceableComponent<AttributeResolver> apply(@Nullable final ApplicationContext appContext) {
@@ -81,6 +100,7 @@ public class AttributeResolverServiceStrategy extends AbstractIdentifiableInitia
resolver.setDataConnectors(connectors);
resolver.setId(getId());
resolver.setStripNulls(isStripNulls());
+ resolver.setSuppressDisplayInformation(isSuppressDisplayInformation());
resolver.setApplicationContext(appContext);
try {
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/services-system.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/services-system.xml
index 2c37febe0..4e1d57d38 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/services-system.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/services-system.xml
@@ -58,6 +58,7 @@
<constructor-arg name="claz" value="net.shibboleth.idp.attribute.resolver.AttributeResolver" />
<constructor-arg name="strategy">
<bean class="net.shibboleth.idp.attribute.resolver.spring.impl.AttributeResolverServiceStrategy"
+ p:suppressDisplayInformation="%{idp.service.attribute.resolver.suppressDisplayInfo:false}"
p:stripNulls="%{idp.service.attribute.resolver.stripNulls:false}"
id="ShibbolethAttributeResolver"/>
</constructor-arg>
diff --git a/idp-conf/src/main/resources/conf/services.properties b/idp-conf/src/main/resources/conf/services.properties
index 8150d3a03..33ef064b1 100644
--- a/idp-conf/src/main/resources/conf/services.properties
+++ b/idp-conf/src/main/resources/conf/services.properties
@@ -35,6 +35,7 @@ idp.service.attribute.registry.encodeType = false
idp.service.attribute.resolver.checkInterval = PT15M
#idp.service.attribute.resolver.maskFailures = true
#idp.service.attribute.resolver.stripNulls = false
+#idp.service.attribute.resolver.suppressDisplayInfo = false
#idp.service.attribute.filter.resources = shibboleth.AttributeFilterResources
# NOTE: Failing the filter fast leaves no filters enabled.
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list