[java-shib-metadata] branch main updated: Fix dependency cycle by moving Attribute-aware NodeProcessor.
Scott Cantor
cantor.2 at osu.edu
Fri Jun 17 18:54:13 UTC 2022
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository java-shib-metadata.
View the commit online:
http://git.shibboleth.net/view/?p=java-shib-metadata.git;a=commit;h=51efb17dc6476745985a5e65664547d5cb2638d3
The following commit(s) were added to refs/heads/main by this push:
new 51efb17dc Fix dependency cycle by moving Attribute-aware NodeProcessor.
51efb17dc is described below
commit 51efb17dc6476745985a5e65664547d5cb2638d3
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Fri Jun 17 14:54:10 2022 -0400
Fix dependency cycle by moving Attribute-aware NodeProcessor.
---
pom.xml | 16 --
shib-metadata-impl/pom.xml | 15 +-
.../impl/AttributeMappingNodeProcessor.java | 232 ---------------------
shib-metadata-spring/pom.xml | 10 +-
4 files changed, 10 insertions(+), 263 deletions(-)
diff --git a/pom.xml b/pom.xml
index 9c64b1fe2..4896fb9ce 100644
--- a/pom.xml
+++ b/pom.xml
@@ -31,7 +31,6 @@
<java-support.version>9.0.0-SNAPSHOT</java-support.version>
<opensaml.groupId>org.opensaml</opensaml.groupId>
<opensaml.version>5.0.0-SNAPSHOT</opensaml.version>
- <shib-attribute.version>5.0.0-SNAPSHOT</shib-attribute.version>
<spring-extensions.version>7.0.0-SNAPSHOT</spring-extensions.version>
<checkstyle.configLocation>${project.basedir}/resources/checkstyle/checkstyle.xml</checkstyle.configLocation>
</properties>
@@ -101,21 +100,6 @@
<!-- Compile Dependencies -->
- <dependency>
- <groupId>net.shibboleth</groupId>
- <artifactId>shib-attribute-api</artifactId>
- <version>${shib-attribute.version}</version>
- </dependency>
- <dependency>
- <groupId>net.shibboleth</groupId>
- <artifactId>shib-saml-attribute-api</artifactId>
- <version>${shib-attribute.version}</version>
- </dependency>
- <dependency>
- <groupId>net.shibboleth</groupId>
- <artifactId>shib-saml-attribute-impl</artifactId>
- <version>${shib-attribute.version}</version>
- </dependency>
<dependency>
<groupId>net.shibboleth.utilities</groupId>
<artifactId>java-support</artifactId>
diff --git a/shib-metadata-impl/pom.xml b/shib-metadata-impl/pom.xml
index e9f35bb50..86d7f6a91 100644
--- a/shib-metadata-impl/pom.xml
+++ b/shib-metadata-impl/pom.xml
@@ -28,16 +28,6 @@
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>net.shibboleth</groupId>
- <artifactId>shib-attribute-api</artifactId>
- </dependency>
-
- <dependency>
- <groupId>net.shibboleth</groupId>
- <artifactId>shib-saml-attribute-impl</artifactId>
- </dependency>
-
<dependency>
<groupId>${opensaml.groupId}</groupId>
<artifactId>opensaml-core</artifactId>
@@ -50,6 +40,11 @@
<groupId>${opensaml.groupId}</groupId>
<artifactId>opensaml-saml-impl</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>net.shibboleth.ext</groupId>
+ <artifactId>spring-extensions</artifactId>
+ </dependency>
<dependency>
<groupId>net.shibboleth.utilities</groupId>
diff --git a/shib-metadata-impl/src/main/java/net/shibboleth/idp/saml/metadata/impl/AttributeMappingNodeProcessor.java b/shib-metadata-impl/src/main/java/net/shibboleth/idp/saml/metadata/impl/AttributeMappingNodeProcessor.java
deleted file mode 100644
index 17484b504..000000000
--- a/shib-metadata-impl/src/main/java/net/shibboleth/idp/saml/metadata/impl/AttributeMappingNodeProcessor.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * 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.saml.metadata.impl;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-import javax.annotation.concurrent.NotThreadSafe;
-
-import net.shibboleth.idp.attribute.AttributeDecodingException;
-import net.shibboleth.idp.attribute.AttributesMapContainer;
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.attribute.IdPRequestedAttribute;
-import net.shibboleth.idp.attribute.transcoding.AttributeTranscoder;
-import net.shibboleth.idp.attribute.transcoding.AttributeTranscoderRegistry;
-import net.shibboleth.idp.attribute.transcoding.TranscoderSupport;
-import net.shibboleth.idp.attribute.transcoding.TranscodingRule;
-import net.shibboleth.idp.saml.attribute.transcoding.SAML2AttributeTranscoder;
-import net.shibboleth.idp.saml.attribute.transcoding.impl.SAML2StringAttributeTranscoder;
-import net.shibboleth.utilities.java.support.annotation.constraint.Live;
-import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
-import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-import net.shibboleth.utilities.java.support.logic.Constraint;
-import net.shibboleth.utilities.java.support.logic.ConstraintViolationException;
-import net.shibboleth.utilities.java.support.service.ReloadableService;
-import net.shibboleth.utilities.java.support.service.ServiceableComponent;
-
-import org.opensaml.core.xml.XMLObject;
-import org.opensaml.saml.ext.saml2mdattr.EntityAttributes;
-import org.opensaml.saml.metadata.resolver.filter.FilterException;
-import org.opensaml.saml.metadata.resolver.filter.MetadataNodeProcessor;
-import org.opensaml.saml.saml2.core.Attribute;
-import org.opensaml.saml.saml2.metadata.AttributeConsumingService;
-import org.opensaml.saml.saml2.metadata.EntitiesDescriptor;
-import org.opensaml.saml.saml2.metadata.EntityDescriptor;
-import org.opensaml.saml.saml2.metadata.Extensions;
-import org.opensaml.saml.saml2.metadata.RequestedAttribute;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.Multimap;
-
-/**
- * An implementation of {@link MetadataNodeProcessor} which extracts {@link IdPRequestedAttribute}s from any
- * {@link AttributeConsumingService} we find and {@link IdPAttribute}s from any {@link EntityDescriptor} that we find.
- */
- at NotThreadSafe
-public class AttributeMappingNodeProcessor implements MetadataNodeProcessor {
-
- /** Class logger. */
- @Nonnull private final Logger log = LoggerFactory.getLogger(AttributeMappingNodeProcessor.class);
-
- /** Service used to get the registry of decoding rules. */
- @Nonnull private final ReloadableService<AttributeTranscoderRegistry> transcoderRegistry;
-
- /** Fallback for URI-named entity tags. */
- @Nonnull private final AttributeTranscoder<Attribute> defaultTranscoder;
-
- /**
- * Constructor.
- *
- * @param registry the service for the decoding rules
- */
- public AttributeMappingNodeProcessor(@Nonnull final ReloadableService<AttributeTranscoderRegistry> registry) {
- transcoderRegistry = Constraint.isNotNull(registry, "AttributeTranscoderRegistry cannot be null");
-
- defaultTranscoder = new SAML2StringAttributeTranscoder();
- try {
- defaultTranscoder.initialize();
- } catch (final ComponentInitializationException e) {
- throw new ConstraintViolationException("Error initializing default transcoder");
- }
- }
-
- /** {@inheritDoc} */
- @Override public void process(final XMLObject metadataNode) throws FilterException {
-
- ServiceableComponent<AttributeTranscoderRegistry> component = null;
-
- try {
- if (metadataNode instanceof AttributeConsumingService) {
- component = transcoderRegistry.getServiceableComponent();
- if (component == null) {
- log.error("Attribute transcoding service unavailable");
- } else {
- handleAttributeConsumingService(component.getComponent(), (AttributeConsumingService) metadataNode);
- }
- } else if (metadataNode instanceof EntityDescriptor) {
- component = transcoderRegistry.getServiceableComponent();
- if (component == null) {
- log.error("Attribute transcoding service unavailable");
- } else {
- handleEntityAttributes(component.getComponent(), ((EntityDescriptor) metadataNode).getExtensions());
- XMLObject parent = metadataNode.getParent();
- while (parent instanceof EntitiesDescriptor) {
- handleEntityAttributes(component.getComponent(), ((EntitiesDescriptor) parent).getExtensions());
- parent = parent.getParent();
- }
- }
- }
- } finally {
- if (component != null) {
- component.unpinComponent();
- }
- }
- }
-
- /**
- * Look inside the {@link AttributeConsumingService} for any {@link RequestedAttribute}s and map them.
- *
- * @param registry the registry service
- * @param acs the {@link AttributeConsumingService} to look at
- */
- private void handleAttributeConsumingService(@Nonnull final AttributeTranscoderRegistry registry,
- @Nonnull final AttributeConsumingService acs) {
-
- final List<RequestedAttribute> requestedAttributes = acs.getRequestedAttributes();
- if (null == requestedAttributes || requestedAttributes.isEmpty()) {
- return;
- }
-
- final Multimap<String,IdPAttribute> results = HashMultimap.create();
- for (final RequestedAttribute req : requestedAttributes) {
- try {
- decodeAttribute(registry.getTranscodingRules(req), req, results);
- } catch (final AttributeDecodingException e) {
- log.warn("Error decoding RequestedAttribute '{}'", req.getName(), e);
- }
- }
-
- if (!results.isEmpty()) {
- acs.getObjectMetadata().put(new AttributesMapContainer(results));
- }
- }
-
- /**
- * Look inside the {@link Extensions} for {@link EntityAttributes} and map them.
- *
- * @param registry the registry service
- * @param extensions the extensions block
- */
-//CheckStyle: CyclomaticComplexity OFF
- private void handleEntityAttributes(@Nonnull final AttributeTranscoderRegistry registry,
- @Nullable final Extensions extensions) {
- if (null == extensions) {
- return;
- }
-
- final List<XMLObject> entityAttributesList =
- extensions.getUnknownXMLObjects(EntityAttributes.DEFAULT_ELEMENT_NAME);
- if (null == entityAttributesList || entityAttributesList.isEmpty()) {
- return;
- }
-
- final Multimap<String,IdPAttribute> results = HashMultimap.create();
-
- for (final XMLObject xmlObj : entityAttributesList) {
- if (xmlObj instanceof EntityAttributes) {
- final EntityAttributes ea = (EntityAttributes) xmlObj;
- for (final Attribute attr : ea.getAttributes()) {
- try {
-
- Collection<TranscodingRule> rulesets = registry.getTranscodingRules(attr);
- if (rulesets.isEmpty() && Attribute.URI_REFERENCE.equals(attr.getNameFormat())) {
- log.trace("Applying default decoding rule for URI-named attribute {}", attr.getName());
- final Map<String,Object> rulemap = new HashMap<>();
- rulemap.put(AttributeTranscoderRegistry.PROP_ID, attr.getName());
- rulemap.put(AttributeTranscoderRegistry.PROP_TRANSCODER, defaultTranscoder);
- rulemap.put(SAML2AttributeTranscoder.PROP_NAME, attr.getName());
- final TranscodingRule defaultRule = new TranscodingRule(rulemap);
- rulesets = Collections.singletonList(defaultRule);
- }
-
- decodeAttribute(rulesets, attr, results);
- } catch (final AttributeDecodingException e) {
- log.warn("Error decoding RequestedAttribute '{}'", attr.getName(), e);
- }
- }
- }
- }
-
- if (!results.isEmpty()) {
- extensions.getParent().getObjectMetadata().put(new AttributesMapContainer(results));
- }
- }
- //CheckStyle: CyclomaticComplexity ON
-
- /**
- * Access the registry of transcoding rules to decode the input object.
- *
- * @param <T> input type
- * @param rules transcoding rules
- * @param input input object
- * @param results collection to add results to
- *
- * @throws AttributeDecodingException if an error occurs or no results were obtained
- */
- private <T> void decodeAttribute(@Nonnull @NonnullElements final Collection<TranscodingRule> rules,
- @Nonnull final T input, @Nonnull @NonnullElements @Live final Multimap<String,IdPAttribute> results)
- throws AttributeDecodingException {
-
- for (final TranscodingRule rule : rules) {
- final AttributeTranscoder<T> transcoder = TranscoderSupport.getTranscoder(rule);
- final IdPAttribute decodedAttribute = transcoder.decode(null, input, rule);
- if (decodedAttribute != null) {
- results.put(decodedAttribute.getId(), decodedAttribute);
- }
- }
- }
-
-}
\ No newline at end of file
diff --git a/shib-metadata-spring/pom.xml b/shib-metadata-spring/pom.xml
index 2a72833ba..00f663abf 100644
--- a/shib-metadata-spring/pom.xml
+++ b/shib-metadata-spring/pom.xml
@@ -37,6 +37,11 @@
<artifactId>spring-extensions</artifactId>
</dependency>
+ <dependency>
+ <groupId>net.shibboleth.utilities</groupId>
+ <artifactId>java-support</artifactId>
+ </dependency>
+
<dependency>
<groupId>${spring.groupId}</groupId>
<artifactId>spring-beans</artifactId>
@@ -67,11 +72,6 @@
<artifactId>opensaml-spring</artifactId>
</dependency>
- <dependency>
- <groupId>net.shibboleth.utilities</groupId>
- <artifactId>java-support</artifactId>
- </dependency>
-
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list