[java-oidfed-common] branch main updated: A new abstract helper bean shibboleth.oidfed.BiConsumerEntityConfigurationMetadataDecorator
Codeberg
noreply at shibboleth.net
Wed Sep 2 13:22:24 UTC 2026
This is an automated email from the git hooks/post-receive script.
codeberg pushed a commit to branch main
in repository java-oidfed-common.
View the commit online:
https://codeberg.org/Shibboleth/java-oidfed-common/commit/6145b530c2a22b8bb539b4c30cd1ff9ea6108edf
The following commit(s) were added to refs/heads/main by this push:
new 6145b53 A new abstract helper bean shibboleth.oidfed.BiConsumerEntityConfigurationMetadataDecorator
6145b53 is described below
commit 6145b530c2a22b8bb539b4c30cd1ff9ea6108edf
Author: Henri Mikkonen <henri.mikkonen at iki.fi>
AuthorDate: Wed Sep 2 16:22:08 2026 +0300
A new abstract helper bean shibboleth.oidfed.BiConsumerEntityConfigurationMetadataDecorator
- Can be used for wiring bi-consumers for metadata decoration
- Included a test based on shibboleth.BiConsumers.Scripted
---
.../META-INF/net.shibboleth.idp/postconfig.xml | 4 ++
.../oidfed/flow/EntityConfigurationFlowTest.java | 3 +-
.../net/shibboleth/idp/module/conf/global.xml | 15 +++++
...nsumerEntityConfigurationMetadataDecorator.java | 73 ++++++++++++++++++++++
4 files changed, 94 insertions(+), 1 deletion(-)
diff --git a/oidfed-common-conf-impl/src/main/resources/META-INF/net.shibboleth.idp/postconfig.xml b/oidfed-common-conf-impl/src/main/resources/META-INF/net.shibboleth.idp/postconfig.xml
index 1b2e5d9..abbd97e 100644
--- a/oidfed-common-conf-impl/src/main/resources/META-INF/net.shibboleth.idp/postconfig.xml
+++ b/oidfed-common-conf-impl/src/main/resources/META-INF/net.shibboleth.idp/postconfig.xml
@@ -1069,6 +1069,10 @@
</property>
</bean>
+ <bean id="shibboleth.oidfed.BiConsumerEntityConfigurationMetadataDecorator"
+ class="net.shibboleth.oidfed.profile.impl.BiConsumerEntityConfigurationMetadataDecorator"
+ abstract="true" />
+
<import resource="${idp.home}/conf/oidfed/oidfed-trustchain-resolver.xml"/>
</beans>
\ No newline at end of file
diff --git a/oidfed-common-conf-impl/src/test/java/net/shibboleth/oidfed/flow/EntityConfigurationFlowTest.java b/oidfed-common-conf-impl/src/test/java/net/shibboleth/oidfed/flow/EntityConfigurationFlowTest.java
index a4f8527..2e769ab 100644
--- a/oidfed-common-conf-impl/src/test/java/net/shibboleth/oidfed/flow/EntityConfigurationFlowTest.java
+++ b/oidfed-common-conf-impl/src/test/java/net/shibboleth/oidfed/flow/EntityConfigurationFlowTest.java
@@ -110,7 +110,7 @@ public class EntityConfigurationFlowTest extends AbstractFederationFlowTest {
entityStatement = EntityConfigurationImpl.parse(
SignedJWT.parse(response.toHTTPResponse().getContent()), payloadObjectMapper);
} catch (JsonProcessingException | java.text.ParseException e) {
- Assert.fail();
+ Assert.fail("Could not parse the response contents", e);
return;
}
final Metadata metadata = entityStatement.getParsedPayload().getMetadata();
@@ -120,6 +120,7 @@ public class EntityConfigurationFlowTest extends AbstractFederationFlowTest {
assert entityMetadata != null;
Assert.assertEquals(entityMetadata.get("organization_name"), "Example organization");
Assert.assertEquals(entityMetadata.get("contacts"), List.of("contact at example.org"));
+ Assert.assertEquals(entityMetadata.get("scriptedClaim"), "scriptedValue");
final EntityConfigurationPayload payload = (EntityConfigurationPayload) entityStatement.getParsedPayload();
Assert.assertEquals(payload.getAuthorityHints(),
List.of("https://anchor1.example.org","https://anchor2.example.org"));
diff --git a/oidfed-common-conf-impl/src/test/resources/net/shibboleth/idp/module/conf/global.xml b/oidfed-common-conf-impl/src/test/resources/net/shibboleth/idp/module/conf/global.xml
index 480cd19..1014de5 100644
--- a/oidfed-common-conf-impl/src/test/resources/net/shibboleth/idp/module/conf/global.xml
+++ b/oidfed-common-conf-impl/src/test/resources/net/shibboleth/idp/module/conf/global.xml
@@ -15,6 +15,21 @@
<bean id="CustomEntityConfigurationMetadataDecorator"
class="net.shibboleth.oidfed.flow.support.CustomEntityConfigurationMetadataDecorator" />
+ <bean id="ScriptedEntityConfigurationMetadataDecorator" parent="shibboleth.oidfed.BiConsumerEntityConfigurationMetadataDecorator">
+ <property name="biConsumer">
+ <bean parent="shibboleth.BiConsumers.Scripted" factory-method="inlineScript">
+ <constructor-arg>
+ <value>
+ <![CDATA[
+ input1.get("federation_entity").put("scriptedClaim", "scriptedValue");
+ null;
+ ]]>
+ </value>
+ </constructor-arg>
+ </bean>
+ </property>
+ </bean>
+
<bean id="MockitoMockFactory" class="org.mockito.Mockito" />
<bean id="shibboleth.oidfed.HttpClient"
diff --git a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/profile/impl/BiConsumerEntityConfigurationMetadataDecorator.java b/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/profile/impl/BiConsumerEntityConfigurationMetadataDecorator.java
new file mode 100644
index 0000000..fa94e3e
--- /dev/null
+++ b/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/profile/impl/BiConsumerEntityConfigurationMetadataDecorator.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.oidfed.profile.impl;
+
+import java.util.Map;
+import java.util.function.BiConsumer;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import org.opensaml.profile.context.ProfileRequestContext;
+
+import net.shibboleth.oidfed.profile.EntityConfigurationMetadataDecorator;
+import net.shibboleth.shared.annotation.constraint.NonnullAfterInit;
+import net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent;
+import net.shibboleth.shared.component.ComponentInitializationException;
+import net.shibboleth.shared.logic.Constraint;
+
+/**
+ * A {@link EntityConfigurationMetadataDecorator} which calls out to a supplied bi-consumer.
+ */
+public class BiConsumerEntityConfigurationMetadataDecorator
+ extends AbstractIdentifiableInitializableComponent
+ implements EntityConfigurationMetadataDecorator {
+
+ @NonnullAfterInit private BiConsumer<Map<String,Map<String,Object>>, ProfileRequestContext> biConsumer;
+
+ /**
+ * Constructor.
+ */
+ public BiConsumerEntityConfigurationMetadataDecorator() {
+ super();
+ }
+
+ /**
+ * Set the bi-consumer used as the decorator.
+ *
+ * @param consumer decorator bi-consumer
+ */
+ public void setBiConsumer(
+ @Nonnull final BiConsumer<Map<String,Map<String,Object>>, ProfileRequestContext> consumer) {
+ biConsumer = Constraint.isNotNull(consumer, "BiConsumer cannot be null");
+ }
+
+ /** {@inheritDoc} */
+ protected void doInitialize() throws ComponentInitializationException {
+ super.doInitialize();
+
+ if (biConsumer == null) {
+ throw new ComponentInitializationException("BiConsumer can not be null");
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void accept(@Nullable final Map<String, Map<String, Object>> metadata,
+ @Nullable final ProfileRequestContext profileRequestContext) {
+ biConsumer.accept(metadata, profileRequestContext);
+ }
+
+}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list