[java-identity-provider] branch main updated: Add back support for relyingParties conditions in transcoding rules.
Scott Cantor
cantor.2 at osu.edu
Mon Jul 11 22:21:21 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=e25c80c02cd9039ceb0da9840609f13c3bd5b776
The following commit(s) were added to refs/heads/main by this push:
new e25c80c02 Add back support for relyingParties conditions in transcoding rules.
e25c80c02 is described below
commit e25c80c02cd9039ceb0da9840609f13c3bd5b776
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Mon Jul 11 18:21:19 2022 -0400
Add back support for relyingParties conditions in transcoding rules.
---
.../net/shibboleth/idp/conf/services-system.xml | 6 +-
.../RelyingPartiesActivationConditionFactory.java | 67 ++++++++++++++++++++++
2 files changed, 72 insertions(+), 1 deletion(-)
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 6f540b0d0..12554ea3a 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
@@ -81,7 +81,11 @@
p:beanFactoryPostProcessors-ref="shibboleth.PropertySourcesPlaceholderConfigurer">
<constructor-arg name="claz" value="net.shibboleth.idp.attribute.transcoding.AttributeTranscoderRegistry" />
<constructor-arg name="strategy">
- <bean class="net.shibboleth.idp.attribute.transcoding.impl.AttributeRegistryServiceStrategy" />
+ <bean class="net.shibboleth.idp.attribute.transcoding.impl.AttributeRegistryServiceStrategy">
+ <property name="extendedConditionFactory">
+ <bean class="net.shibboleth.idp.relyingparty.impl.RelyingPartiesActivationConditionFactory" />
+ </property>
+ </bean>
</constructor-arg>
</bean>
<bean id ="shibboleth.DefaultAttributeRegistryResources" class="net.shibboleth.ext.spring.factory.CombiningListFactoryBean"
diff --git a/idp-profile-impl/src/main/java/net/shibboleth/idp/relyingparty/impl/RelyingPartiesActivationConditionFactory.java b/idp-profile-impl/src/main/java/net/shibboleth/idp/relyingparty/impl/RelyingPartiesActivationConditionFactory.java
new file mode 100644
index 000000000..8f1b98b40
--- /dev/null
+++ b/idp-profile-impl/src/main/java/net/shibboleth/idp/relyingparty/impl/RelyingPartiesActivationConditionFactory.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements. See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You 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.idp.relyingparty.impl;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.function.Predicate;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import org.opensaml.profile.context.ProfileRequestContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.shibboleth.idp.attribute.transcoding.AttributeTranscoderRegistry;
+import net.shibboleth.idp.profile.logic.RelyingPartyIdPredicate;
+import net.shibboleth.utilities.java.support.primitive.StringSupport;
+
+/**
+ * Factory function for manufacturing activation conditions based on
+ * {@link AttributeTranscoderRegistry#PROP_RELYINGPARTIES}.
+ *
+ * @since 5.0.0
+ */
+public class RelyingPartiesActivationConditionFactory
+ implements Function<Map<String,Object>,Predicate<ProfileRequestContext>> {
+
+ /** Class logger. */
+ @Nonnull private final Logger log = LoggerFactory.getLogger(RelyingPartiesActivationConditionFactory.class);
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Nullable public Predicate<ProfileRequestContext> apply(@Nullable final Map<String,Object> rule) {
+ final Object relyingParties = rule.get(AttributeTranscoderRegistry.PROP_RELYINGPARTIES);
+
+ if (relyingParties instanceof Collection) {
+ return new RelyingPartyIdPredicate((Collection<String>) relyingParties);
+ } else if (relyingParties instanceof String) {
+ final Collection<String> parsed = StringSupport.normalizeStringCollection(
+ StringSupport.stringToList((String) relyingParties, " "));
+ return new RelyingPartyIdPredicate(parsed);
+ } else if (relyingParties != null) {
+ log.error("{} property did not contain a Collection or String, ignored",
+ AttributeTranscoderRegistry.PROP_RELYINGPARTIES);
+ }
+
+ return null;
+ }
+
+}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list