[java-identity-provider] branch maint-4 updated: JSATTR-4 Remove springResources from data connector

Rod Widdowson rdw at steadingsoftware.com
Tue Oct 25 10:44:00 UTC 2022


This is an automated email from the git hooks/post-receive script.

rdw pushed a commit to branch maint-4
in repository java-identity-provider.

View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=7063a5fb9b6a25efccf8efc3014cb7e8c2a5a79c

The following commit(s) were added to refs/heads/maint-4 by this push:
     new 7063a5fb9 JSATTR-4 Remove springResources from data connector
7063a5fb9 is described below

commit 7063a5fb9b6a25efccf8efc3014cb7e8c2a5a79c
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Tue Oct 25 11:18:02 2022 +0100

    JSATTR-4 Remove springResources from data connector
    
    https://shibboleth.atlassian.net/browse/JSATTR-4
    
    add 'attributeListRef="bean"' to the Static Data Connector.
---
 .../spring/dc/impl/StaticDataConnectorParser.java        |  9 +++++++++
 .../spring/dc/StaticDataConnectorParserTest.java         | 16 ++++++++++++++++
 .../idp/attribute/resolver/spring/customBean.xml         | 16 ++++++++++++++++
 .../resolver/spring/dc/resolver/staticAttributesRef.xml  | 10 ++++++++++
 .../resources/schema/shibboleth-attribute-resolver.xsd   |  7 +++++++
 5 files changed, 58 insertions(+)

diff --git a/idp-attribute-resolver-spring/src/main/java/net/shibboleth/idp/attribute/resolver/spring/dc/impl/StaticDataConnectorParser.java b/idp-attribute-resolver-spring/src/main/java/net/shibboleth/idp/attribute/resolver/spring/dc/impl/StaticDataConnectorParser.java
index 2ba3dc094..d75c5b43d 100644
--- a/idp-attribute-resolver-spring/src/main/java/net/shibboleth/idp/attribute/resolver/spring/dc/impl/StaticDataConnectorParser.java
+++ b/idp-attribute-resolver-spring/src/main/java/net/shibboleth/idp/attribute/resolver/spring/dc/impl/StaticDataConnectorParser.java
@@ -63,6 +63,15 @@ public class StaticDataConnectorParser extends AbstractDataConnectorParser {
         
         final List<Element> children = ElementSupport.getChildElements(config, ATTRIBUTE_ELEMENT_NAME_RESOLVER);
         final List<BeanDefinition> attributes = new ManagedList<>(children.size());
+        final String attrListRef = StringSupport.trimOrNull(config.getAttributeNS(null, "attributeListRef"));
+        if (null != attrListRef) {
+            if (children.size() > 0) {
+                log.error("{} : 'attributeListRef' is incompatible with <Attribute/> elements, ignoring them",
+                        getLogPrefix());
+            }
+            builder.addPropertyReference("values", attrListRef);
+            return;
+        }
 
         for (final Element child : children) {
 
diff --git a/idp-attribute-resolver-spring/src/test/java/net/shibboleth/idp/attribute/resolver/spring/dc/StaticDataConnectorParserTest.java b/idp-attribute-resolver-spring/src/test/java/net/shibboleth/idp/attribute/resolver/spring/dc/StaticDataConnectorParserTest.java
index f70237346..bb8dd1d77 100644
--- a/idp-attribute-resolver-spring/src/test/java/net/shibboleth/idp/attribute/resolver/spring/dc/StaticDataConnectorParserTest.java
+++ b/idp-attribute-resolver-spring/src/test/java/net/shibboleth/idp/attribute/resolver/spring/dc/StaticDataConnectorParserTest.java
@@ -61,6 +61,22 @@ public class StaticDataConnectorParserTest extends BaseAttributeDefinitionParser
     @Test public void hybrid() {
         final StaticDataConnector connector = getDataConnector("resolver/staticAttributesHybrid.xml", StaticDataConnector.class);
         assertTrue(connector.isExportAllAttributes());
+
+        assertEquals(connector.getAttributes().keySet().size(), 2);
+        final IdPAttribute epe = connector.getAttributes().get("eduPersonEntitlement");
+        List<IdPAttributeValue> values = epe.getValues();
+        assertEquals(values.size(), 2);
+        assertTrue(values.contains(new StringAttributeValue("urn:example.org:entitlement:entitlement1")));
+        assertTrue(values.contains(new StringAttributeValue("urn:mace:dir:entitlement:common-lib-terms")));
+
+        values = connector.getAttributes().get("staticEpA").getValues();
+        assertEquals(values.size(), 1);
+        assertTrue(values.contains(new StringAttributeValue("member")));
+    }
+
+    @Test public void ref() {
+        final StaticDataConnector connector = getDataConnector("resolver/staticAttributesRef.xml", StaticDataConnector.class);
+        assertTrue(connector.isExportAllAttributes());
         
         assertEquals(connector.getAttributes().keySet().size(), 2);
         final IdPAttribute epe = connector.getAttributes().get("eduPersonEntitlement");
diff --git a/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/customBean.xml b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/customBean.xml
index f75f53321..8cd7aca6c 100644
--- a/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/customBean.xml
+++ b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/customBean.xml
@@ -47,6 +47,22 @@
     <bean id="SAML1XMLObjectTranscoder"
         class="net.shibboleth.idp.saml.attribute.transcoding.impl.SAML1XMLObjectAttributeTranscoder" />
 
+    <util:list id="StaticConnectorValues">
+        <bean class="net.shibboleth.idp.attribute.IdPAttribute" c:attributeId="staticEpA">
+            <property name="values">
+                <bean class="net.shibboleth.idp.attribute.StringAttributeValue" c:attributeValue="member" />
+            </property>
+        </bean>
+        <bean class="net.shibboleth.idp.attribute.IdPAttribute" c:attributeId="eduPersonEntitlement">
+            <property name="values">
+                <list>
+                    <bean class="net.shibboleth.idp.attribute.StringAttributeValue" c:attributeValue="urn:example.org:entitlement:entitlement1" />
+                    <bean class="net.shibboleth.idp.attribute.StringAttributeValue" c:attributeValue="urn:mace:dir:entitlement:common-lib-terms" />
+                </list>
+            </property>
+        </bean>
+    </util:list>
+
 </beans>
 
        
\ No newline at end of file
diff --git a/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/resolver/staticAttributesRef.xml b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/resolver/staticAttributesRef.xml
new file mode 100644
index 000000000..6b76e1cf7
--- /dev/null
+++ b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/resolver/staticAttributesRef.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<DataConnector id="staticAttributes" xsi:type="Static"
+    exportAllAttributes="true"
+    xmlns="urn:mace:shibboleth:2.0:resolver"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="urn:mace:shibboleth:2.0:resolver http://shibboleth.net/schema/idp/shibboleth-attribute-resolver.xsd"
+    attributeListRef="StaticConnectorValues">
+    <Attribute id="staticEpA">
+        <Value>member</Value>
+    </Attribute>
+</DataConnector>
diff --git a/idp-schema/src/main/resources/schema/shibboleth-attribute-resolver.xsd b/idp-schema/src/main/resources/schema/shibboleth-attribute-resolver.xsd
index 714085c97..5341fd526 100644
--- a/idp-schema/src/main/resources/schema/shibboleth-attribute-resolver.xsd
+++ b/idp-schema/src/main/resources/schema/shibboleth-attribute-resolver.xsd
@@ -1523,6 +1523,13 @@
                         </complexType>
                     </element>
                 </choice>
+                <attribute name="attributeListRef" type="resolver:string">
+                    <annotation>
+                        <documentation>
+                            The name of a bean defined somewhere else which describes a List of IdPAttributes
+                        </documentation>
+                    </annotation>
+                </attribute>
             </extension>
         </complexContent>
     </complexType>

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list