[java-oidfed-common] branch main updated: Exploit metadata policy from java-oidc-common
Codeberg
noreply at shibboleth.net
Thu Nov 12 16:35:11 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/d986ed84bea5e621d3d72d9857246a1f0026babe
The following commit(s) were added to refs/heads/main by this push:
new d986ed8 Exploit metadata policy from java-oidc-common
d986ed8 is described below
commit d986ed84bea5e621d3d72d9857246a1f0026babe
Author: Henri Mikkonen <henri.mikkonen at iki.fi>
AuthorDate: Thu Nov 12 18:34:08 2026 +0200
Exploit metadata policy from java-oidc-common
- Delete the classes that were moved to java-oidc-common and update references
- Bump java-oidc-common dependency into 4.0.0-SNAPSHOT
---
.../META-INF/net.shibboleth.idp/postconfig.xml | 16 +-
.../oidfed/resolve-entity/resolve-entity-beans.xml | 5 +-
.../resolve-trust-chains-beans.xml | 5 +-
.../FederationMetadataPolicyDeserializer.java | 168 ---------------------
.../policy/FederationMetadataPolicyHelper.java | 80 ----------
.../policy/FederationMetadataPolicyOperator.java | 57 -------
.../AbstractFederationMetadataPolicyOperator.java | 56 -------
...DefaultFederationMetadataPolicyAddOperator.java | 115 --------------
...ultFederationMetadataPolicyDefaultOperator.java | 44 ------
.../DefaultFederationMetadataPolicyEnforcer.java | 106 -------------
...tFederationMetadataPolicyEssentialOperator.java | 46 ------
...ultFederationMetadataPolicyMergingStrategy.java | 118 ---------------
...faultFederationMetadataPolicyOneOfOperator.java | 72 ---------
...ltFederationMetadataPolicySubsetOfOperator.java | 94 ------------
...FederationMetadataPolicySupersetOfOperator.java | 92 -----------
...faultFederationMetadataPolicyValueOperator.java | 88 -----------
.../impl/AbstractTrustChainResolutionAction.java | 8 +-
...faultMetadataPolicyOperatorsLookupStrategy.java | 14 +-
.../impl/MetadataPolicyCritClaimsValidator.java | 6 +-
.../metadata/jackson/JacksonTestingSupport.java | 4 +-
pom.xml | 2 +-
21 files changed, 31 insertions(+), 1165 deletions(-)
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 d25ff76..3a91dca 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
@@ -1018,7 +1018,7 @@
<property name="arguments">
<list>
<value>#{ T(net.shibboleth.oidc.metadata.policy.MetadataPolicy)}</value>
- <bean class="net.shibboleth.oidfed.metadata.policy.FederationMetadataPolicyDeserializer"
+ <bean class="net.shibboleth.oidc.metadata.policy.impl.DefaultMetadataPolicyDeserializer"
c:_0="%{idp.oidfed.policy.arraysAsSpaceSeparatedList:scope}"/>
</list>
</property>
@@ -1100,13 +1100,13 @@
</bean>
<util:list id="shibboleth.oidfed.StandardMetadataPolicyOperators">
- <bean class="net.shibboleth.oidfed.metadata.policy.impl.DefaultFederationMetadataPolicyValueOperator"/>
- <bean class="net.shibboleth.oidfed.metadata.policy.impl.DefaultFederationMetadataPolicyAddOperator"/>
- <bean class="net.shibboleth.oidfed.metadata.policy.impl.DefaultFederationMetadataPolicyDefaultOperator"/>
- <bean class="net.shibboleth.oidfed.metadata.policy.impl.DefaultFederationMetadataPolicyOneOfOperator"/>
- <bean class="net.shibboleth.oidfed.metadata.policy.impl.DefaultFederationMetadataPolicySubsetOfOperator"/>
- <bean class="net.shibboleth.oidfed.metadata.policy.impl.DefaultFederationMetadataPolicySupersetOfOperator"/>
- <bean class="net.shibboleth.oidfed.metadata.policy.impl.DefaultFederationMetadataPolicyEssentialOperator"/>
+ <bean class="net.shibboleth.oidc.metadata.policy.impl.DefaultMetadataPolicyValueOperator"/>
+ <bean class="net.shibboleth.oidc.metadata.policy.impl.DefaultMetadataPolicyAddOperator"/>
+ <bean class="net.shibboleth.oidc.metadata.policy.impl.DefaultMetadataPolicyDefaultOperator"/>
+ <bean class="net.shibboleth.oidc.metadata.policy.impl.DefaultMetadataPolicyOneOfOperator"/>
+ <bean class="net.shibboleth.oidc.metadata.policy.impl.DefaultMetadataPolicySubsetOfOperator"/>
+ <bean class="net.shibboleth.oidc.metadata.policy.impl.DefaultMetadataPolicySupersetOfOperator"/>
+ <bean class="net.shibboleth.oidc.metadata.policy.impl.DefaultMetadataPolicyEssentialOperator"/>
</util:list>
<bean id="DefaultTrustMarkClaimsValidationLookupStrategy" parent="shibboleth.Functions.Constant"
diff --git a/oidfed-common-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oidfed/resolve-entity/resolve-entity-beans.xml b/oidfed-common-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oidfed/resolve-entity/resolve-entity-beans.xml
index cc4db5f..9178f4e 100644
--- a/oidfed-common-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oidfed/resolve-entity/resolve-entity-beans.xml
+++ b/oidfed-common-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oidfed/resolve-entity/resolve-entity-beans.xml
@@ -141,7 +141,8 @@
c:expression="'true'.equals(#input.getSubcontext(T(net.shibboleth.idp.authn.context.AuthenticationContext))?.getAuthenticationStateMap()?.get('idp.resolve-entity.resolveForAuthentication')) ? #input.getInboundMessageContext()?.getMessage().getClientAuthentication()?.getClientID()?.getValue() : #input.getInboundMessageContext()?.getMessage()?.getSubject()"/>
<bean id="FlowDefaultMetadataPolicyEnforcer"
- class="net.shibboleth.oidfed.metadata.policy.impl.DefaultFederationMetadataPolicyEnforcer"
+ class="net.shibboleth.oidc.metadata.policy.impl.DefaultMetadataPolicyEnforcer"
+ p:failureOnUnknownOperators="false"
p:metadataPolicyOperators-ref="#{'%{idp.oidfed.resolveEntity.MetadataPolicyOperators:shibboleth.oidfed.StandardMetadataPolicyOperators}'.trim()}"/>
<bean id="FlowDefaultTrustChainMetadataPolicyMergingStrategy"
@@ -150,7 +151,7 @@
p:localMetadataPolicyStrategy-ref="#{'%{idp.oidfed.resolveEntity.LocalMetadataPolicyStrategy:FlowDefaultLocalMetadataPolicyStrategy}'.trim()}"/>
<bean id="FlowDefaultMetadataPolicyMergingStrategy"
- class="net.shibboleth.oidfed.metadata.policy.impl.DefaultFederationMetadataPolicyMergingStrategy"
+ class="net.shibboleth.oidc.metadata.policy.impl.DefaultMetadataPolicyMergingStrategy"
p:metadataPolicyOperators-ref="#{'%{idp.oidfed.resolveEntity.MetadataPolicyOperators:shibboleth.oidfed.StandardMetadataPolicyOperators}'.trim()}"/>
<bean id="FlowDefaultLocalMetadataPolicyStrategy"
diff --git a/oidfed-common-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oidfed/resolve-trust-chains/resolve-trust-chains-beans.xml b/oidfed-common-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oidfed/resolve-trust-chains/resolve-trust-chains-beans.xml
index 3d4464a..d998d2b 100644
--- a/oidfed-common-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oidfed/resolve-trust-chains/resolve-trust-chains-beans.xml
+++ b/oidfed-common-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oidfed/resolve-trust-chains/resolve-trust-chains-beans.xml
@@ -47,14 +47,15 @@
class="net.shibboleth.oidfed.profile.navigate.DefaultMetadataValidationCondition" />
<bean id="shibboleth.oidfed.trust-chain-resolver.DefaultMetadataPolicyEnforcer"
- class="net.shibboleth.oidfed.metadata.policy.impl.DefaultFederationMetadataPolicyEnforcer"
+ class="net.shibboleth.oidc.metadata.policy.impl.DefaultMetadataPolicyEnforcer"
+ p:failureOnUnknownOperators="false"
p:metadataPolicyOperators-ref="#{'%{idp.oidfed.MetadataPolicyOperators:shibboleth.oidfed.StandardMetadataPolicyOperators}'.trim()}"/>
<bean id="shibboleth.oidfed.trust-chain-resolver.DefaultTrustChainMetadataPolicyMergingStrategy"
class="net.shibboleth.oidfed.profile.navigate.DefaultTrustChainMetadataPolicyMergingStrategy"
p:localMetadataPolicyStrategy-ref="#{'%{idp.oidfed.LocalMetadataPolicyStrategy:shibboleth.oidfed.trust-chain-resolver.DefaultLocalMetadataPolicyStrategy}'.trim()}">
<property name="metadataPolicyMergingStrategy">
- <bean class="net.shibboleth.oidfed.metadata.policy.impl.DefaultFederationMetadataPolicyMergingStrategy"
+ <bean class="net.shibboleth.oidc.metadata.policy.impl.DefaultMetadataPolicyMergingStrategy"
p:metadataPolicyOperators-ref="#{'%{idp.oidfed.MetadataPolicyOperators:shibboleth.oidfed.StandardMetadataPolicyOperators}'.trim()}"/>
</property>
</bean>
diff --git a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/FederationMetadataPolicyDeserializer.java b/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/FederationMetadataPolicyDeserializer.java
deleted file mode 100644
index e03af5e..0000000
--- a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/FederationMetadataPolicyDeserializer.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * 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.metadata.policy;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import org.slf4j.Logger;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JavaType;
-import com.fasterxml.jackson.databind.JsonDeserializer;
-import com.fasterxml.jackson.databind.type.MapType;
-import com.fasterxml.jackson.databind.type.TypeFactory;
-
-import net.shibboleth.oidc.metadata.policy.MetadataPolicy;
-import net.shibboleth.shared.annotation.ParameterName;
-import net.shibboleth.shared.logic.Constraint;
-import net.shibboleth.shared.primitive.LoggerFactory;
-
-/**
- * Default deserializer for the {@link MetadataPolicy} used within OpenID Federation. If the value for the "value"
- * -operator is explicitly set to null in JSON, this deserializer sets {@link MetadataPolicy#setValue(Object)} into
- * {@link Optional#empty()}.
- */
-public class FederationMetadataPolicyDeserializer extends JsonDeserializer<MetadataPolicy> {
-
- /** Class logger. */
- @Nonnull private final Logger log = LoggerFactory.getLogger(FederationMetadataPolicyDeserializer.class);
-
- /** List of claim names who are transformed from a space-separated String into a List. */
- @Nonnull private final List<String> arraysAsSpaceSeparatedList;
-
- /**
- * Constructor.
- */
- public FederationMetadataPolicyDeserializer() {
- this("scope");
- }
-
- /**
- * Constructor.
- *
- * @param string comma-separated list of claim names who are transformed from a space-separated String into a List.
- */
- public FederationMetadataPolicyDeserializer(
- @Nonnull @ParameterName(name = "arraysAsSpaceSeparatedList") final String string) {
- final List<String> list = Arrays.asList(Constraint.isNotEmpty(string, "The string cannot be empty").split(","));
- assert list != null;
- arraysAsSpaceSeparatedList = list;
- }
-
- /** {@inheritDoc} */
- @Override @Nonnull
- public MetadataPolicy deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext)
- throws IOException, JsonProcessingException {
- final MetadataPolicy policy = new MetadataPolicy();
- log.debug("Starting deseralize");
- final JavaType objectType = TypeFactory.defaultInstance().constructType(Object.class);
- final JavaType stringType = TypeFactory.defaultInstance().constructType(String.class);
- final MapType objectMapType =
- TypeFactory.defaultInstance().constructMapType(Map.class, stringType, objectType);
-
- final Map<String,Object> map = deserializationContext.readValue(jsonParser, objectMapType);
- final String claim = jsonParser.getParsingContext().getCurrentName();
- if (claim == null) {
- throw new IOException("Could not find the parent claim name for the metadata policy");
- }
- log.debug("Processing claim {}, value {}", claim, map);
-
- if (map != null) {
- log.debug("Processing map object {}", map);
- for (final String key : map.keySet().stream().filter(Objects::nonNull).toList()) {
- switch (key) {
- case "value":
- final Object value;
- if (map.get("value") instanceof String) {
- value = FederationMetadataPolicyHelper.transformSpaceSeparatedStringIntoList(
- arraysAsSpaceSeparatedList, claim, map.get("value"));
- } else {
- value = map.get("value");
- }
- policy.setValue(value != null ? value : Optional.empty());
- break;
- case "add":
- policy.setAdd(transformObjectIntoList("add", map.get("add")));
- break;
- case "default":
- final Object defaultValue = map.get("default");
- if (defaultValue instanceof String) {
- policy.setDefaultValue(
- FederationMetadataPolicyHelper.transformSpaceSeparatedStringIntoList(
- arraysAsSpaceSeparatedList, claim, defaultValue));
- } else {
- policy.setDefaultValue(defaultValue);
- }
- break;
- case "essential":
- policy.setEssential(map.get("essential") != null ?
- Boolean.valueOf(String.valueOf(map.get("essential"))).booleanValue() : false);
- break;
- case "one_of":
- policy.setOneOfValues(transformObjectIntoList("one_of", map.get("one_of")));
- break;
- case "subset_of":
- policy.setSubsetOfValues(transformObjectIntoList("subset_of", map.get("subset_of")));
- break;
- case "superset_of":
- policy.setSupersetOfValues(transformObjectIntoList("superset_of", map.get("superset_of")));
- break;
- case "regexp":
- policy.setRegexp(map.get("regexp") == null ? null : "" + map.get("regexp"));
- break;
- default:
- policy.setCustomOperator(key, map.get(key));
- break;
- }
- }
- } else {
- log.debug("No map object could be parsed from the input, leaving the policy empty");
- }
- return policy;
- }
-
- /**
- * Transforms the given value into a list of objects.
- *
- * @param id the key for the map of objects
- * @param object the object value
- * @return the value for the key as list or null
- * @throws IOException if a non-null value could not be transformed into a list or the list contained null elements
- */
- @Nullable private List<Object> transformObjectIntoList(@Nonnull final String id,
- @Nullable final Object object) throws IOException {
- if (object instanceof List<?> list) {
- final List<Object> result = list.stream().map(Object.class::cast).toList();
- if (result.contains(null)) {
- throw new IOException("The list value '" + object + "' for '" + id + "' contains null elements");
- }
- return result;
- } else if (object != null) {
- throw new IOException("The value '" + object + "' for '" + id + "' is not a list");
- }
- return null;
- }
-
-}
\ No newline at end of file
diff --git a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/FederationMetadataPolicyHelper.java b/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/FederationMetadataPolicyHelper.java
deleted file mode 100644
index e9d7c74..0000000
--- a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/FederationMetadataPolicyHelper.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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.metadata.policy;
-
-import java.util.List;
-import java.util.stream.Collectors;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import net.shibboleth.shared.logic.ConstraintViolationException;
-
-/**
- * Static utility method related to federation metadata policies.
- */
-public class FederationMetadataPolicyHelper {
-
- /**
- * Transforms a list into a space-separated string. Operation is done for non-null values if the given claim is
- * included in the given list of claims that are to be transformed.
- *
- * @param arraysAsSpaceSeparatedList the list of claim names to be transformed
- * @param claim the candidate claim
- * @param value the candidate claim value
- * @return the claim value transformed into a space-separated string if it met the requirements, or initial value
- * if not
- * @throws ConstraintViolationException if the non-null value to be transformed was not a list
- */
- @Nullable
- public static Object transformListIntoSpaceSeparatedString(@Nonnull final List<String> arraysAsSpaceSeparatedList,
- @Nonnull final String claim, @Nullable final Object value) throws ConstraintViolationException {
- if (arraysAsSpaceSeparatedList.contains(claim)) {
- if (value instanceof List<?> list) {
- return list.stream()
- .map(item -> String.valueOf(item))
- .collect(Collectors.joining(" "));
- } else if (value != null) {
- throw new ConstraintViolationException(
- "Unexpected value for claim " + claim + ": the value is not a List");
- }
- }
- return value;
- }
-
- /**
- * Transforms a space-separated string into a list. Operation is done for non-null values if the given claim is
- * included in the given list of claims that are to be transformed.
- *
- * @param arraysAsSpaceSeparatedList the list of claim names to be transformed
- * @param claim the candidate claim
- * @param value the candidate claim value
- * @return the claim value transformed into a list if it met the requirements, or initial value
- * @throws ConstraintViolationException if the non-null value to be transformed was not a string
- */
- @Nullable
- public static Object transformSpaceSeparatedStringIntoList(@Nonnull final List<String> arraysAsSpaceSeparatedList,
- @Nonnull final String claim, @Nullable final Object value) throws ConstraintViolationException {
- if (arraysAsSpaceSeparatedList.contains(claim)) {
- if (value instanceof String string) {
- return List.of(string.split(" "));
- } else if (value != null) {
- throw new ConstraintViolationException(
- "Unexpected value for claim " + claim + ": the value is not a String");
- }
- }
- return value;
- }
-}
diff --git a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/FederationMetadataPolicyOperator.java b/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/FederationMetadataPolicyOperator.java
deleted file mode 100644
index dceaa24..0000000
--- a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/FederationMetadataPolicyOperator.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.metadata.policy;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import net.shibboleth.oidc.metadata.policy.MetadataPolicy;
-import net.shibboleth.shared.annotation.constraint.NotEmpty;
-import net.shibboleth.shared.logic.ConstraintViolationException;
-
-/**
- * Interface to be implemented by the federation metadata policy operators.
- *
- * TODO: once moved to commons, merge with net.shibboleth.oidc.metadata.policy.impl.CustomMetadataPolicyOperator
- */
-public interface FederationMetadataPolicyOperator {
-
- /**
- * The unique case-sensitive name of this operator.
- *
- * @return the operator name.
- */
- @Nonnull @NotEmpty public String getOperatorName();
-
- /**
- * Validate whether the operator is compatible with the other operators in the policy.
- *
- * @param policy The metadata policy to be used by the custom policy operator.
- * @return true if the policy is valid for this operator, false otherwise.
- */
- public boolean validate(@Nonnull final MetadataPolicy policy);
-
- /**
- * Apply the operator for the given input that has the given metadata policy attached.
- *
- * @param inputValue The value to be used by the custom policy operator.
- * @param policy The metadata policy to be used by the custom policy operator.
- * @return The value returned by the custom policy operator.
- * @throws ConstraintViolationException If the value-check of the custom operator fails.
- */
- @Nullable public Object apply(@Nullable final Object inputValue, @Nonnull final MetadataPolicy policy)
- throws ConstraintViolationException;
-
-}
diff --git a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/impl/AbstractFederationMetadataPolicyOperator.java b/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/impl/AbstractFederationMetadataPolicyOperator.java
deleted file mode 100644
index 080e8de..0000000
--- a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/impl/AbstractFederationMetadataPolicyOperator.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.metadata.policy.impl;
-
-import java.util.List;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import net.shibboleth.oidc.metadata.policy.MetadataPolicy;
-import net.shibboleth.oidfed.metadata.policy.FederationMetadataPolicyOperator;
-import net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent;
-import net.shibboleth.shared.logic.ConstraintViolationException;
-
-/**
- * Base implementation for the classes implementing {@link FederationMetadataPolicyOperator}.
- */
-public abstract class AbstractFederationMetadataPolicyOperator extends AbstractIdentifiableInitializableComponent
- implements FederationMetadataPolicyOperator {
-
- /** {@inheritDoc} */
- @Override
- public boolean validate(@Nonnull final MetadataPolicy policy) {
- return true;
- }
-
- /**
- * Parses a list from the given object.
- *
- * @param object the object to be parsed
- * @return a list of it couöd be parsed from the object, or null if input was null
- * @throws ConstraintViolationException thrown if non-null input value was not a list
- */
- @Nullable protected static List<Object> parseList(@Nullable final Object object)
- throws ConstraintViolationException {
- if (object instanceof List<?> list) {
- return list.stream().filter(Object.class::isInstance).map(Object.class::cast).toList();
- } else if (object != null) {
- throw new ConstraintViolationException("Could not parse list from the given object");
- }
- return null;
- }
-
-}
diff --git a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/impl/DefaultFederationMetadataPolicyAddOperator.java b/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/impl/DefaultFederationMetadataPolicyAddOperator.java
deleted file mode 100644
index 54fac3d..0000000
--- a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/impl/DefaultFederationMetadataPolicyAddOperator.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * 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.metadata.policy.impl;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.stream.Stream;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import org.slf4j.Logger;
-
-import net.shibboleth.oidc.metadata.policy.MetadataPolicy;
-import net.shibboleth.oidc.metadata.policy.impl.MetadataPolicyHelper;
-import net.shibboleth.shared.annotation.constraint.NotEmpty;
-import net.shibboleth.shared.collection.CollectionSupport;
-import net.shibboleth.shared.logic.ConstraintViolationException;
-import net.shibboleth.shared.primitive.LoggerFactory;
-
-/**
- * Default implementation for the 'add'-operator.
- */
-public class DefaultFederationMetadataPolicyAddOperator extends AbstractFederationMetadataPolicyOperator {
-
- /** Class logger. */
- @Nonnull private final Logger log = LoggerFactory.getLogger(DefaultFederationMetadataPolicyAddOperator.class);
-
- /** {@inheritDoc} */
- @Nonnull @NotEmpty public String getOperatorName() {
- return "add";
- }
-
- /** {@inheritDoc} */
- @Override
- @Nullable public Object apply(@Nullable final Object candidate, @Nonnull final MetadataPolicy policy)
- throws ConstraintViolationException {
- final List<Object> add = parseList(policy.getAdd());
- if (add != null) {
- if (candidate instanceof List<?> list) {
- log.debug("Combining candidate {} and add {}", list, add);
- return buildResult(Stream.concat(list.stream(), add.stream()));
- } else if (candidate == null) {
- log.debug("Returning the contents of the add operator: {}", add);
- return buildResult(add.stream());
- } else {
- log.debug("Candidate value {} is not a list/array", candidate);
- throw new ConstraintViolationException("Candidate " + candidate + " is not a list/array");
- }
- }
- return candidate;
- }
-
- /**
- * Builds a list from the given stream.
- *
- * @param stream the stream
- * @return the list
- */
- @Nonnull protected List<Object> buildResult(final Stream<?> stream) {
- final List<Object> result = stream
- .filter(Object.class::isInstance)
- .map(Object.class::cast)
- .distinct()
- .toList();
- assert result != null;
- return CollectionSupport.copyToList(result);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean validate(@Nonnull final MetadataPolicy policy) {
- final List<Object> add;
- try {
- add = parseList(policy.getAdd());
- } catch (final ConstraintViolationException e) {
- log.warn("The value for add operator {} is not a list/array", policy.getAdd());
- return false;
- }
- if (add == null || add.isEmpty()) {
- return true;
- }
- boolean validation = true;
- final Object value = policy.getValue();
- if (value instanceof Collection<?> valueCollection) {
- if (!MetadataPolicyHelper.isSubsetOfValues(add, valueCollection)) {
- log.debug("The value for add operator {} is not a subset of value {}", add, valueCollection);
- validation = false;
- }
- } else if (value != null) {
- log.warn("The value {} is not a list/array", value);
- validation = false;
- }
- final List<Object> subsetOf = policy.getSubsetOfValues();
- if (subsetOf != null && !MetadataPolicyHelper.isSubsetOfValues(add, subsetOf)) {
- log.debug("The value for add operator {} is not a subset of value for the subset_of operator {}", add,
- subsetOf);
- validation = false;
- }
- return validation;
- }
-
-}
diff --git a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/impl/DefaultFederationMetadataPolicyDefaultOperator.java b/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/impl/DefaultFederationMetadataPolicyDefaultOperator.java
deleted file mode 100644
index c80d6ee..0000000
--- a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/impl/DefaultFederationMetadataPolicyDefaultOperator.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.metadata.policy.impl;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import net.shibboleth.oidc.metadata.policy.MetadataPolicy;
-import net.shibboleth.shared.annotation.constraint.NotEmpty;
-import net.shibboleth.shared.logic.ConstraintViolationException;
-
-/**
- * Default implementation for the 'default' -operator.
- */
-public class DefaultFederationMetadataPolicyDefaultOperator extends AbstractFederationMetadataPolicyOperator {
-
- /** {@inheritDoc} */
- @Nonnull @NotEmpty public String getOperatorName() {
- return "default";
- }
-
- /** {@inheritDoc} */
- @Override
- @Nullable public Object apply(@Nullable final Object candidate, @Nonnull final MetadataPolicy policy)
- throws ConstraintViolationException {
- if (candidate != null) {
- return candidate;
- }
- final Object defaultValue = policy.getDefaultValue();
- return defaultValue != null ? defaultValue : candidate;
- }
-}
diff --git a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/impl/DefaultFederationMetadataPolicyEnforcer.java b/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/impl/DefaultFederationMetadataPolicyEnforcer.java
deleted file mode 100644
index 11602d8..0000000
--- a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/impl/DefaultFederationMetadataPolicyEnforcer.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * 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.metadata.policy.impl;
-
-import java.util.List;
-import java.util.Optional;
-import java.util.function.BiFunction;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import org.slf4j.Logger;
-
-import net.shibboleth.oidc.metadata.policy.MetadataPolicy;
-import net.shibboleth.oidfed.metadata.policy.FederationMetadataPolicyOperator;
-import net.shibboleth.shared.annotation.constraint.NonnullAfterInit;
-import net.shibboleth.shared.collection.Pair;
-import net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent;
-import net.shibboleth.shared.component.ComponentInitializationException;
-import net.shibboleth.shared.logic.Constraint;
-import net.shibboleth.shared.logic.ConstraintViolationException;
-import net.shibboleth.shared.primitive.LoggerFactory;
-
-/**
- * <p>A function that applies the given {@link MetadataPolicy} to the given object. The input is given as a {@link
- * Pair} of the object and the policy. The policy is applied to the incoming object as specified in the OpenID
- * Federation specification 1.0.</p>
- *
- * <p>The function returns a {@link Pair} of the object for which the value modifiers of the metadata policy have
- * been applied to, and a flag indicating if the object was compatible with the value checks of the metadata policy.
- * </p>
- */
-public class DefaultFederationMetadataPolicyEnforcer extends AbstractIdentifiableInitializableComponent
- implements BiFunction<Object,MetadataPolicy,Pair<Object,Boolean>> {
-
- /** Class logger. */
- @Nonnull private final Logger log = LoggerFactory.getLogger(DefaultFederationMetadataPolicyEnforcer.class);
-
- /** The list of metadata policy operators used for enforcing the metadata policy. */
- @NonnullAfterInit List<FederationMetadataPolicyOperator> operators;
-
- /**
- * Set the list of metadata policy operators used for enforcing the metadata policy.
- *
- * @param policyOperators What to set
- */
- public void setMetadataPolicyOperators(@Nonnull final List<FederationMetadataPolicyOperator> policyOperators) {
- checkSetterPreconditions();
- Constraint.isNotEmpty(policyOperators, "List of metadata policy operators cannot be empty");
- assert policyOperators != null;
- operators = policyOperators;
- }
-
- /** {@inheritDoc} */
- protected void doInitialize() throws ComponentInitializationException {
- super.doInitialize();
-
- if (operators == null) {
- throw new ComponentInitializationException("List of metadata policy operators cannot be null");
- }
- }
-
- /** {@inheritDoc} */
- @Override @Nullable public Pair<Object, Boolean> apply(@Nullable final Object candidate,
- @Nullable final MetadataPolicy policy) {
- checkComponentActive();
- if (policy == null) {
- return new Pair<>(candidate, Boolean.TRUE);
- }
- Object operatorResult = candidate;
- for (final FederationMetadataPolicyOperator operator : operators) {
- try {
- operatorResult = operator.apply(operatorResult, policy);
- } catch (final ConstraintViolationException e) {
- log.debug("Operator {} returned a non-success result", operator.getClass());
- return new Pair<>(operatorResult, Boolean.FALSE);
- }
- }
- return new Pair<>(operatorResult, Boolean.TRUE);
- }
-
- /**
- * Checks if the given result of metadata policy operator is a success result.
- *
- * @param result operator result to be verified
- * @return true if success, false otherwise (including null)
- */
- protected boolean isSuccessResult(@Nullable final Pair<Object,Boolean> result) {
- return Optional.ofNullable(result)
- .map(pair -> pair.getSecond())
- .map(second -> second.booleanValue())
- .orElse(false);
- }
-}
diff --git a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/impl/DefaultFederationMetadataPolicyEssentialOperator.java b/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/impl/DefaultFederationMetadataPolicyEssentialOperator.java
deleted file mode 100644
index bab1b52..0000000
--- a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/impl/DefaultFederationMetadataPolicyEssentialOperator.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.metadata.policy.impl;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import net.shibboleth.oidc.metadata.policy.MetadataPolicy;
-import net.shibboleth.shared.annotation.constraint.NotEmpty;
-import net.shibboleth.shared.logic.ConstraintViolationException;
-
-/**
- * Default implementation for the 'essential' -operator.
- */
-public class DefaultFederationMetadataPolicyEssentialOperator extends AbstractFederationMetadataPolicyOperator {
-
- /** {@inheritDoc} */
- @Nonnull @NotEmpty public String getOperatorName() {
- return "essential";
- }
-
- /** {@inheritDoc} */
- @Override
- @Nullable public Object apply(@Nullable final Object candidate, @Nonnull final MetadataPolicy policy)
- throws ConstraintViolationException {
- if (candidate != null) {
- return candidate;
- }
- if (policy.isEssential()) {
- throw new ConstraintViolationException("Essential value is missing");
- }
- return candidate;
- }
-}
diff --git a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/impl/DefaultFederationMetadataPolicyMergingStrategy.java b/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/impl/DefaultFederationMetadataPolicyMergingStrategy.java
deleted file mode 100644
index 6257899..0000000
--- a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/impl/DefaultFederationMetadataPolicyMergingStrategy.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * 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.metadata.policy.impl;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.function.BiFunction;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import org.slf4j.Logger;
-
-import net.shibboleth.oidc.metadata.policy.MetadataPolicy;
-import net.shibboleth.oidc.metadata.policy.impl.MetadataPolicyHelper;
-import net.shibboleth.oidfed.metadata.policy.FederationMetadataPolicyOperator;
-import net.shibboleth.shared.annotation.constraint.NonnullAfterInit;
-import net.shibboleth.shared.collection.CollectionSupport;
-import net.shibboleth.shared.collection.Pair;
-import net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent;
-import net.shibboleth.shared.component.ComponentInitializationException;
-import net.shibboleth.shared.logic.Constraint;
-import net.shibboleth.shared.logic.ConstraintViolationException;
-import net.shibboleth.shared.primitive.LoggerFactory;
-
-/**
- * A function that merges two maps of metadata policies according to the rules specified in the OID federation spec
- * section 6.1. The function returns a pair of map of merged metadata policies and a boolean indicating if the merging
- * operators in the policies were compliant.
- */
-public class DefaultFederationMetadataPolicyMergingStrategy extends AbstractIdentifiableInitializableComponent
- implements BiFunction<Map<String, MetadataPolicy>, Map<String, MetadataPolicy>,
- Pair<Map<String, MetadataPolicy>, Boolean>> {
-
- /** Class logger. */
- @Nonnull private final Logger log = LoggerFactory.getLogger(DefaultFederationMetadataPolicyMergingStrategy.class);
-
- /** The list of metadata policy operators used for enforcing the metadata policy. */
- @NonnullAfterInit List<FederationMetadataPolicyOperator> operators;
-
- /**
- * Set the list of metadata policy operators used for merging the metadata policy.
- *
- * @param policyOperators What to set
- */
- public void setMetadataPolicyOperators(@Nonnull final List<FederationMetadataPolicyOperator> policyOperators) {
- checkSetterPreconditions();
- Constraint.isNotEmpty(policyOperators, "List of metadata policy operators cannot be empty");
- assert policyOperators != null;
- operators = policyOperators;
- }
-
- /** {@inheritDoc} */
- protected void doInitialize() throws ComponentInitializationException {
- super.doInitialize();
-
- if (operators == null) {
- throw new ComponentInitializationException("List of metadata policy operators cannot be null");
- }
- }
-
- /** {@inheritDoc} */
- @Nonnull
- public Pair<Map<String, MetadataPolicy>, Boolean> apply(@Nullable final Map<String,MetadataPolicy> firstMap,
- @Nullable final Map<String,MetadataPolicy> secondMap) {
- checkComponentActive();
- if (firstMap == null && secondMap == null) {
- return new Pair<>(null, Boolean.TRUE);
- }
- final Map<String,MetadataPolicy> first = firstMap != null ? firstMap : CollectionSupport.emptyMap();
- final Map<String,MetadataPolicy> second = secondMap != null ? secondMap : CollectionSupport.emptyMap();
- final Set<String> combinedKeys = Stream.concat(first.keySet().stream(),
- second.keySet().stream()).collect(Collectors.toSet());
- final Map<String, MetadataPolicy> result = new HashMap<>();
- boolean valid = true;
- for (final String key : combinedKeys) {
- try {
- final MetadataPolicy merged =
- MetadataPolicyHelper.mergeMetadataPolicies(first.get(key), second.get(key));
- log.debug("Merging result of {} with {}: {}", first.get(key), second.get(key), merged);
- if (merged != null) {
- if (merged.getOneOfValues() != null && merged.getOneOfValues().isEmpty()) {
- log.warn("Value of 'one_of' operator is empty after merging");
- valid = false;
- }
- result.put(key, merged);
- }
- for (final FederationMetadataPolicyOperator operator : operators) {
- if (merged != null && !operator.validate(merged)) {
- valid = false;
- }
- }
- } catch (final ConstraintViolationException e) {
- log.warn("Incompatible metadata policies for claim '{}' that cannot be merged: {}", key,
- e.getMessage());
- valid = false;
- }
- }
- return new Pair<>(CollectionSupport.copyToMap(result), Boolean.valueOf(valid));
- }
-
-}
\ No newline at end of file
diff --git a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/impl/DefaultFederationMetadataPolicyOneOfOperator.java b/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/impl/DefaultFederationMetadataPolicyOneOfOperator.java
deleted file mode 100644
index 114943c..0000000
--- a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/impl/DefaultFederationMetadataPolicyOneOfOperator.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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.metadata.policy.impl;
-
-import java.util.List;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import org.slf4j.Logger;
-
-import net.shibboleth.oidc.metadata.policy.MetadataPolicy;
-import net.shibboleth.shared.annotation.constraint.NotEmpty;
-import net.shibboleth.shared.logic.ConstraintViolationException;
-import net.shibboleth.shared.primitive.LoggerFactory;
-
-/**
- * Default implementation for the 'one_of' -operator.
- */
-public class DefaultFederationMetadataPolicyOneOfOperator extends AbstractFederationMetadataPolicyOperator {
-
- /** Class logger. */
- @Nonnull private final Logger log = LoggerFactory.getLogger(DefaultFederationMetadataPolicyOneOfOperator.class);
-
- /** {@inheritDoc} */
- @Nonnull @NotEmpty public String getOperatorName() {
- return "one_of";
- }
-
- /** {@inheritDoc} */
- @Override
- @Nullable public Object apply(@Nullable final Object candidate, @Nonnull final MetadataPolicy policy)
- throws ConstraintViolationException {
- final List<Object> oneOf = policy.getOneOfValues();
- if (candidate == null || oneOf == null) {
- log.debug("No candidate or one_of value present. nothing to do");
- return candidate;
- }
- if (!oneOf.contains(candidate)) {
- throw new ConstraintViolationException(
- "The candidate " + candidate + " is not included in the values for one_of: " + oneOf);
- }
- return candidate;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean validate(@Nonnull final MetadataPolicy policy) {
- final List<Object> oneOf = policy.getOneOfValues();
- if (oneOf == null) {
- return true;
- }
- final Object value = policy.getValue();
- if (value != null && !oneOf.contains(value)) {
- log.debug("The value {} is not included in the values for one_of: {}", value, oneOf);
- return false;
- }
- return true;
- }
-}
diff --git a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/impl/DefaultFederationMetadataPolicySubsetOfOperator.java b/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/impl/DefaultFederationMetadataPolicySubsetOfOperator.java
deleted file mode 100644
index 098b438..0000000
--- a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/impl/DefaultFederationMetadataPolicySubsetOfOperator.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * 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.metadata.policy.impl;
-
-import java.util.List;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import org.slf4j.Logger;
-
-import net.shibboleth.oidc.metadata.policy.MetadataPolicy;
-import net.shibboleth.oidc.metadata.policy.impl.MetadataPolicyHelper;
-import net.shibboleth.shared.annotation.constraint.NotEmpty;
-import net.shibboleth.shared.collection.CollectionSupport;
-import net.shibboleth.shared.logic.ConstraintViolationException;
-import net.shibboleth.shared.primitive.LoggerFactory;
-
-/**
- * Default implementation for the 'subset_of' -operator.
- */
-public class DefaultFederationMetadataPolicySubsetOfOperator extends AbstractFederationMetadataPolicyOperator {
-
- /** Class logger. */
- @Nonnull private final Logger log = LoggerFactory.getLogger(DefaultFederationMetadataPolicySubsetOfOperator.class);
-
- /** {@inheritDoc} */
- @Nonnull @NotEmpty public String getOperatorName() {
- return "subset_of";
- }
-
- /** {@inheritDoc} */
- @Override
- @Nullable public Object apply(@Nullable final Object candidate, @Nonnull final MetadataPolicy policy)
- throws ConstraintViolationException {
- final List<Object> subsetOf = policy.getSubsetOfValues();
- if (candidate == null || subsetOf == null) {
- log.debug("No candidate or subset_of value present. nothing to do");
- return candidate;
- }
- if (candidate instanceof List<?> list) {
- final List<Object> candidateList = list.stream()
- .filter(Object.class::isInstance)
- .map(Object.class::cast)
- .filter(item -> subsetOf.contains(item))
- .toList();
- assert candidateList != null;
- return CollectionSupport.copyToList(candidateList);
- }
- log.debug("Candidate value {} is not a list/array", candidate);
- throw new ConstraintViolationException("Candidate value " + candidate + " is not a list/array");
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean validate(@Nonnull final MetadataPolicy policy) {
- final List<Object> subsetOf = policy.getSubsetOfValues();
- if (subsetOf == null) {
- return true;
- }
- boolean validation = true;
- final Object value = policy.getValue();
- if (value != null && !MetadataPolicyHelper.isSubsetOfValues(value, subsetOf)) {
- log.debug("The value {} is not a subset of the values for subset_of operator {}", value, subsetOf);
- validation = false;
- }
- final Object add = policy.getAdd();
- if (add != null && !MetadataPolicyHelper.isSubsetOfValues(add, subsetOf)) {
- log.debug("The value for add operator {} is not a subset of the values for subset_of operator {}", add,
- subsetOf);
- validation = false;
- }
- final List<Object> supersetOf = policy.getSupersetOfValues();
- if (supersetOf != null && !MetadataPolicyHelper.isSupersetOfValues(subsetOf, supersetOf)) {
- log.debug("The value for subset_of operator {} is not a subset of the values for superset_of operator {}",
- subsetOf, supersetOf);
- validation = false;
- }
- return validation;
- }
-
-}
diff --git a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/impl/DefaultFederationMetadataPolicySupersetOfOperator.java b/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/impl/DefaultFederationMetadataPolicySupersetOfOperator.java
deleted file mode 100644
index eec730a..0000000
--- a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/impl/DefaultFederationMetadataPolicySupersetOfOperator.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * 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.metadata.policy.impl;
-
-import java.util.List;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import org.slf4j.Logger;
-
-import net.shibboleth.oidc.metadata.policy.MetadataPolicy;
-import net.shibboleth.oidc.metadata.policy.impl.MetadataPolicyHelper;
-import net.shibboleth.shared.annotation.constraint.NotEmpty;
-import net.shibboleth.shared.collection.CollectionSupport;
-import net.shibboleth.shared.logic.ConstraintViolationException;
-import net.shibboleth.shared.primitive.LoggerFactory;
-
-/**
- * Default implementation for the 'superset_of' -operator.
- */
-public class DefaultFederationMetadataPolicySupersetOfOperator extends AbstractFederationMetadataPolicyOperator {
-
- /** Class logger. */
- @Nonnull private final Logger log = LoggerFactory.getLogger(DefaultFederationMetadataPolicySupersetOfOperator.class);
-
- /** {@inheritDoc} */
- @Nonnull @NotEmpty public String getOperatorName() {
- return "superset_of";
- }
-
- /** {@inheritDoc} */
- @Override
- @Nullable public Object apply(@Nullable final Object candidate, @Nonnull final MetadataPolicy policy)
- throws ConstraintViolationException {
- final List<Object> supersetOf = policy.getSupersetOfValues();
- if (candidate == null || supersetOf == null) {
- return candidate;
- }
- final List<Object> candidateList;
- if (candidate instanceof List<?> list) {
- candidateList = list.stream().filter(Object.class::isInstance).map(Object.class::cast).toList();
- } else {
- log.warn("The value for superset_of is not a list/array {}", candidate);
- throw new ConstraintViolationException("Candidate value " + candidate + " is not a list/array");
- }
- assert candidateList != null;
-
- if (!candidateList.containsAll(supersetOf)) {
- log.debug("The candidate {} did not contain all the values of superset_of: {}", candidate, supersetOf);
- throw new ConstraintViolationException(
- "Candidate value " + candidate + " did not contain all values of superset_of: " + supersetOf);
- }
-
- return CollectionSupport.copyToList(candidateList);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean validate(@Nonnull final MetadataPolicy policy) {
- final List<Object> supersetOf = policy.getSupersetOfValues();
- if (supersetOf == null) {
- return true;
- }
-
- boolean validation = true;
- final Object value = policy.getValue();
- if (value != null && !MetadataPolicyHelper.isSupersetOfValues(value, supersetOf)) {
- log.debug("The value {} is not a superset of the values for subset_of operator {}", value, supersetOf);
- validation = false;
- }
- final List<Object> subsetOf = policy.getSubsetOfValues();
- if (subsetOf != null && !MetadataPolicyHelper.isSupersetOfValues(subsetOf, supersetOf)) {
- log.debug("The value for subset_of operator {} is not a superset of the values for superset_of operator {}",
- subsetOf, supersetOf);
- validation = false;
- }
- return validation;
- }
-}
diff --git a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/impl/DefaultFederationMetadataPolicyValueOperator.java b/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/impl/DefaultFederationMetadataPolicyValueOperator.java
deleted file mode 100644
index 5e82c8c..0000000
--- a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/metadata/policy/impl/DefaultFederationMetadataPolicyValueOperator.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * 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.metadata.policy.impl;
-
-import java.util.List;
-import java.util.Optional;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import org.slf4j.Logger;
-
-import net.shibboleth.oidc.metadata.policy.MetadataPolicy;
-import net.shibboleth.oidc.metadata.policy.impl.MetadataPolicyHelper;
-import net.shibboleth.shared.annotation.constraint.NotEmpty;
-import net.shibboleth.shared.logic.ConstraintViolationException;
-import net.shibboleth.shared.primitive.LoggerFactory;
-
-/**
- * Default implementation for the 'value' -operator.
- */
-public class DefaultFederationMetadataPolicyValueOperator extends AbstractFederationMetadataPolicyOperator {
-
- /** Class logger. */
- @Nonnull private final Logger log = LoggerFactory.getLogger(DefaultFederationMetadataPolicyValueOperator.class);
-
- /** {@inheritDoc} */
- @Nonnull @NotEmpty public String getOperatorName() {
- return "value";
- }
-
- /** {@inheritDoc} */
- @Override
- @Nullable public Object apply(@Nullable final Object candidate, @Nonnull final MetadataPolicy policy)
- throws ConstraintViolationException {
- final Object value = policy.getValue();
- return value != null ?value instanceof Optional optional && optional.isEmpty() ? null : value : candidate;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean validate(@Nonnull final MetadataPolicy policy) {
- final Object value = policy.getValue();
- if (value instanceof Optional optional && optional.isEmpty()) {
- if (policy.isEssential()) {
- log.debug("Value for the value operator is null and essential is true");
- return false;
- }
- if (policy.getDefaultValue() != null) {
- log.debug("Null value cannot be combined with non-empty default: {}", policy.getDefaultValue());
- return false;
- }
- log.debug("Value for the value operator is null and essential is false");
- return true;
- } else if (value == null) {
- return true;
- }
- boolean validation = true;
- final List<Object> oneOf = policy.getOneOfValues();
- if (oneOf != null && !oneOf.contains(value)) {
- log.debug("Value {} is not included in the one_of values {}", value, oneOf);
- validation = false;
- }
- final List<Object> subsetOf = policy.getSubsetOfValues();
- if (subsetOf != null && !MetadataPolicyHelper.isSubsetOfValues(value, subsetOf)) {
- log.debug("Value {} is not included in the of subset_of values {}", value, subsetOf);
- validation = false;
- }
- final List<Object> supersetOf = policy.getSupersetOfValues();
- if (supersetOf != null && !MetadataPolicyHelper.isSupersetOfValues(value, supersetOf)) {
- log.debug("Value {} is not included in the of superset_of values {}", value, supersetOf);
- validation = false;
- }
- return validation;
- }
-}
diff --git a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/profile/impl/AbstractTrustChainResolutionAction.java b/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/profile/impl/AbstractTrustChainResolutionAction.java
index c8c084a..a501e10 100644
--- a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/profile/impl/AbstractTrustChainResolutionAction.java
+++ b/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/profile/impl/AbstractTrustChainResolutionAction.java
@@ -34,6 +34,7 @@ import org.slf4j.Logger;
import net.minidev.json.JSONObject;
import net.shibboleth.idp.profile.AbstractProfileAction;
import net.shibboleth.oidc.metadata.policy.MetadataPolicy;
+import net.shibboleth.oidc.metadata.policy.impl.MetadataPolicyHelper;
import net.shibboleth.oidfed.metadata.EntityConfiguration;
import net.shibboleth.oidfed.metadata.EntityStatement;
import net.shibboleth.oidfed.metadata.constraints.FederationPolicyConstraint;
@@ -41,7 +42,6 @@ import net.shibboleth.oidfed.metadata.constraints.FederationPolicyConstraintHelp
import net.shibboleth.oidfed.metadata.impl.EntityConfigurationImpl;
import net.shibboleth.oidfed.metadata.payload.claim.impl.MetadataImpl;
import net.shibboleth.oidfed.metadata.payload.impl.EntityConfigurationPayloadImpl;
-import net.shibboleth.oidfed.metadata.policy.FederationMetadataPolicyHelper;
import net.shibboleth.oidfed.profile.OidFederationEventIds;
import net.shibboleth.oidfed.profile.context.RelyingPartyTrustChainContext;
import net.shibboleth.oidfed.profile.context.VerifiedTrustChain;
@@ -352,7 +352,7 @@ public class AbstractTrustChainResolutionAction extends AbstractProfileAction {
@Nullable final MetadataPolicy policy) throws ConstraintViolationException {
log.debug("{} Claim {} set in policy included in the request: {}", getLogPrefix(), claim,
value == null);
- final Object enforcerInput = FederationMetadataPolicyHelper.transformSpaceSeparatedStringIntoList(
+ final Object enforcerInput = MetadataPolicyHelper.transformSpaceSeparatedStringIntoList(
arraysAsSpaceSeparatedList, claim, value);
final Pair<Object,Boolean> mergeResult = getMetadataPolicyEnforcer().apply(enforcerInput, policy);
@@ -363,8 +363,8 @@ public class AbstractTrustChainResolutionAction extends AbstractProfileAction {
log.trace("{} Validation result is OK for claim {}", getLogPrefix(), claim);
return Optional.ofNullable(mergeResult)
.map(pair -> pair.getFirst())
- .map(result -> FederationMetadataPolicyHelper.transformListIntoSpaceSeparatedString(
- arraysAsSpaceSeparatedList,claim, result))
+ .map(result -> MetadataPolicyHelper.transformListIntoSpaceSeparatedString(arraysAsSpaceSeparatedList,
+ claim, result))
.orElse(null);
}
diff --git a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/security/jwt/claims/impl/DefaultMetadataPolicyOperatorsLookupStrategy.java b/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/security/jwt/claims/impl/DefaultMetadataPolicyOperatorsLookupStrategy.java
index 3c953b7..d5d7a38 100644
--- a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/security/jwt/claims/impl/DefaultMetadataPolicyOperatorsLookupStrategy.java
+++ b/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/security/jwt/claims/impl/DefaultMetadataPolicyOperatorsLookupStrategy.java
@@ -24,7 +24,7 @@ import javax.annotation.Nullable;
import org.opensaml.profile.context.ProfileRequestContext;
import org.slf4j.Logger;
-import net.shibboleth.oidfed.metadata.policy.FederationMetadataPolicyOperator;
+import net.shibboleth.oidc.metadata.policy.MetadataPolicyOperator;
import net.shibboleth.shared.annotation.constraint.NonnullAfterInit;
import net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent;
import net.shibboleth.shared.component.ComponentInitializationException;
@@ -35,23 +35,23 @@ import net.shibboleth.shared.primitive.LoggerFactory;
* Default lookup strategy to resolve list of supported metadata policy operators.
*/
public class DefaultMetadataPolicyOperatorsLookupStrategy extends AbstractIdentifiableInitializableComponent
- implements Function<ProfileRequestContext, List<FederationMetadataPolicyOperator>> {
+ implements Function<ProfileRequestContext, List<MetadataPolicyOperator>> {
/** Class logger. */
@Nonnull private Logger log = LoggerFactory.getLogger(DefaultMetadataPolicyOperatorsLookupStrategy.class);
/** Map of supported operators by inbound message class name. */
- @NonnullAfterInit private Map<String, List<FederationMetadataPolicyOperator>> supportedOperators;
+ @NonnullAfterInit private Map<String, List<MetadataPolicyOperator>> supportedOperators;
/** List of default supported operators if inbound message class name was not mapped. */
- @NonnullAfterInit private List<FederationMetadataPolicyOperator> defaultSupportedOperators;
+ @NonnullAfterInit private List<MetadataPolicyOperator> defaultSupportedOperators;
/**
* Set the map of supported operators by inbound message class name.
*
* @param operators map of supported operators
*/
- public void setSupportedOperators(@Nonnull final Map<String, List<FederationMetadataPolicyOperator>> operators) {
+ public void setSupportedOperators(@Nonnull final Map<String, List<MetadataPolicyOperator>> operators) {
checkSetterPreconditions();
supportedOperators = Constraint.isNotNull(operators, "Map of supported operators cannot be null");
}
@@ -61,7 +61,7 @@ public class DefaultMetadataPolicyOperatorsLookupStrategy extends AbstractIdenti
*
* @param operators default list of supported operators
*/
- public void setDefaultSupportedOperators(@Nonnull List<FederationMetadataPolicyOperator> operators) {
+ public void setDefaultSupportedOperators(@Nonnull List<MetadataPolicyOperator> operators) {
checkSetterPreconditions();
defaultSupportedOperators =
Constraint.isNotNull(operators, "Default list of supported operators cannot be null");
@@ -80,7 +80,7 @@ public class DefaultMetadataPolicyOperatorsLookupStrategy extends AbstractIdenti
/** {@inheritDoc} */
@Override @Nullable
- public List<FederationMetadataPolicyOperator> apply(@Nullable final ProfileRequestContext profileRequestContext) {
+ public List<MetadataPolicyOperator> apply(@Nullable final ProfileRequestContext profileRequestContext) {
checkComponentActive();
if (profileRequestContext == null || profileRequestContext.getInboundMessageContext() == null
|| profileRequestContext.ensureInboundMessageContext().getMessage() == null) {
diff --git a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/security/jwt/claims/impl/MetadataPolicyCritClaimsValidator.java b/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/security/jwt/claims/impl/MetadataPolicyCritClaimsValidator.java
index 3fe6b59..8721e2b 100644
--- a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/security/jwt/claims/impl/MetadataPolicyCritClaimsValidator.java
+++ b/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/security/jwt/claims/impl/MetadataPolicyCritClaimsValidator.java
@@ -28,7 +28,7 @@ import com.nimbusds.jwt.JWTClaimsSet;
import net.shibboleth.oidc.jwt.claims.AbstractClaimsValidator;
import net.shibboleth.oidc.jwt.claims.ClaimsValidator;
import net.shibboleth.oidc.jwt.claims.JWTValidationException;
-import net.shibboleth.oidfed.metadata.policy.FederationMetadataPolicyOperator;
+import net.shibboleth.oidc.metadata.policy.MetadataPolicyOperator;
import net.shibboleth.shared.annotation.constraint.NonnullAfterInit;
import net.shibboleth.shared.annotation.constraint.ThreadSafeAfterInit;
import net.shibboleth.shared.collection.CollectionSupport;
@@ -48,7 +48,7 @@ public class MetadataPolicyCritClaimsValidator extends AbstractClaimsValidator {
/** The lookup strategy for the list of supported metadata policy operators . */
@NonnullAfterInit private
- Function<ProfileRequestContext, List<FederationMetadataPolicyOperator>> supportedOperatorsLookupStrategy;
+ Function<ProfileRequestContext, List<MetadataPolicyOperator>> supportedOperatorsLookupStrategy;
/**
* Set the lookup strategy for the list of supported metadata policy operators.
@@ -56,7 +56,7 @@ public class MetadataPolicyCritClaimsValidator extends AbstractClaimsValidator {
* @param strategy lookup strategy
*/
public void setSupportedOperatorsLookupStrategy(
- @Nonnull final Function<ProfileRequestContext, List<FederationMetadataPolicyOperator>> strategy) {
+ @Nonnull final Function<ProfileRequestContext, List<MetadataPolicyOperator>> strategy) {
checkSetterPreconditions();
supportedOperatorsLookupStrategy =
Constraint.isNotNull(strategy, "Supported metadata policy operators lookup strategy cannot be null");
diff --git a/oidfed-common-impl/src/test/java/net/shibboleth/oidfed/metadata/jackson/JacksonTestingSupport.java b/oidfed-common-impl/src/test/java/net/shibboleth/oidfed/metadata/jackson/JacksonTestingSupport.java
index cb97c88..a95ba54 100644
--- a/oidfed-common-impl/src/test/java/net/shibboleth/oidfed/metadata/jackson/JacksonTestingSupport.java
+++ b/oidfed-common-impl/src/test/java/net/shibboleth/oidfed/metadata/jackson/JacksonTestingSupport.java
@@ -24,9 +24,9 @@ import com.fasterxml.jackson.databind.module.SimpleModule;
import com.nimbusds.jose.jwk.JWKSet;
import net.shibboleth.oidc.metadata.policy.MetadataPolicy;
+import net.shibboleth.oidc.metadata.policy.impl.DefaultMetadataPolicyDeserializer;
import net.shibboleth.oidfed.metadata.payload.claim.Metadata;
import net.shibboleth.oidfed.metadata.payload.claim.impl.MetadataImpl;
-import net.shibboleth.oidfed.metadata.policy.FederationMetadataPolicyDeserializer;
/**
* Static support methods for testing with Jackson object mapper.
@@ -41,7 +41,7 @@ public class JacksonTestingSupport {
*/
@Nonnull public static ObjectMapper payloadObjectMapper() {
final SimpleModule jacksonModule = new SimpleModule();
- jacksonModule.addDeserializer(MetadataPolicy.class, new FederationMetadataPolicyDeserializer("scope"));
+ jacksonModule.addDeserializer(MetadataPolicy.class, new DefaultMetadataPolicyDeserializer("scope"));
jacksonModule.addDeserializer(JWKSet.class, new JWKSetDeserializer());
jacksonModule.addDeserializer(Instant.class, new InstantDeserializer());
final SimpleAbstractTypeResolver jacksonResolver = new SimpleAbstractTypeResolver();
diff --git a/pom.xml b/pom.xml
index a9c8551..503892c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,7 +26,7 @@
<oidc-config.groupId>net.shibboleth.idp.plugin.config.oidc</oidc-config.groupId>
<oidc-config.version>3.1.0-SNAPSHOT</oidc-config.version>
<oidc-common.groupId>net.shibboleth.oidc</oidc-common.groupId>
- <oidc-common.version>3.4.0-SNAPSHOT</oidc-common.version>
+ <oidc-common.version>4.0.0-SNAPSHOT</oidc-common.version>
<oidfed-common.groupId>net.shibboleth.oidfed</oidfed-common.groupId>
<shib-shared.groupId>net.shibboleth</shib-shared.groupId>
<shib-shared.version>9.0.0</shib-shared.version>
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list