[java-identity-provider] branch master updated: IDP-1511 - Support referencing of non-inline MetadataFilters

Scott Cantor cantor.2 at osu.edu
Tue Oct 22 12:05:23 EDT 2019


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

scantor pushed a commit to branch master
in repository java-identity-provider.

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

The following commit(s) were added to refs/heads/master by this push:
       new  c0943b7   IDP-1511 - Support referencing of non-inline MetadataFilters
c0943b7 is described below

commit c0943b7f31cabf66faa4c2d581db02c1ccab7132
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Oct 22 12:05:19 2019 -0400

    IDP-1511 - Support referencing of non-inline MetadataFilters
    
    Spring parser unit test.
---
 .../filter/ByReferenceFilterParserTest.java        | 75 ++++++++++++++++++++++
 .../metadata/filter/entityAttributesBeans.xml      |  2 +-
 .../metadata/filter/entityAttributesByRef.xml      | 28 ++++++++
 ...tesBeans.xml => entityAttributesByRefBeans.xml} |  4 +-
 .../filter/entityAttributesMetadataOnly.xml        | 56 ++++++++++++++++
 5 files changed, 163 insertions(+), 2 deletions(-)

diff --git a/idp-profile-spring/src/test/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/ByReferenceFilterParserTest.java b/idp-profile-spring/src/test/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/ByReferenceFilterParserTest.java
new file mode 100644
index 0000000..a5d3e49
--- /dev/null
+++ b/idp-profile-spring/src/test/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/ByReferenceFilterParserTest.java
@@ -0,0 +1,75 @@
+/*
+ * 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.profile.spring.relyingparty.metadata.filter;
+
+import java.io.IOException;
+import java.util.Collection;
+
+import net.shibboleth.idp.profile.spring.relyingparty.metadata.AbstractMetadataParserTest;
+import net.shibboleth.utilities.java.support.resolver.CriteriaSet;
+import net.shibboleth.utilities.java.support.resolver.ResolverException;
+
+import org.opensaml.core.criterion.EntityIdCriterion;
+import org.opensaml.core.xml.XMLObject;
+import org.opensaml.saml.ext.saml2mdattr.EntityAttributes;
+import org.opensaml.saml.metadata.resolver.MetadataResolver;
+import org.opensaml.saml.saml2.metadata.EntityDescriptor;
+import org.opensaml.saml.saml2.metadata.Extensions;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class ByReferenceFilterParserTest extends AbstractMetadataParserTest {
+    
+    @Test
+    public void test() throws ResolverException, IOException {
+        doTest("filter/entityAttributesMetadataOnly.xml", "filter/entityAttributesByRef.xml", "filter/entityAttributesByRefBeans.xml");
+    }
+
+    private void doTest(final String... files) throws ResolverException, IOException {
+
+        final MetadataResolver resolver = getBean(MetadataResolver.class, files);
+        
+        EntityIdCriterion key = new EntityIdCriterion("https://sp.example.org/sp/shibboleth");
+        EntityDescriptor entity = resolver.resolveSingle(new CriteriaSet(key));
+        Assert.assertNotNull(entity);
+
+        Extensions exts = entity.getExtensions();
+        Assert.assertNotNull(exts);
+        Collection<XMLObject> extElements = exts.getUnknownXMLObjects(EntityAttributes.DEFAULT_ELEMENT_NAME);
+        Assert.assertFalse(extElements.isEmpty());
+        EntityAttributes extTags = (EntityAttributes) extElements.iterator().next();
+        Assert.assertNotNull(extTags);
+        Assert.assertEquals(extTags.getAttributes().size(), 2);
+        Assert.assertEquals(extTags.getAttributes().get(0).getName(), "foo");
+        Assert.assertEquals(extTags.getAttributes().get(1).getName(), "bar");
+
+        key = new EntityIdCriterion("https://sp2.example.org/sp/shibboleth");
+        entity = resolver.resolveSingle(new CriteriaSet(key));
+        Assert.assertNotNull(entity);
+        exts = entity.getExtensions();
+        if (exts != null) {
+            extElements = exts.getUnknownXMLObjects(EntityAttributes.DEFAULT_ELEMENT_NAME);
+            if (!extElements.isEmpty()) {
+                extTags = (EntityAttributes) extElements.iterator().next();
+                if (extTags != null) {
+                    Assert.assertTrue(extTags.getAttributes().isEmpty());
+                }
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/entityAttributesBeans.xml b/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/entityAttributesBeans.xml
index 5ad20a0..41c3147 100644
--- a/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/entityAttributesBeans.xml
+++ b/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/entityAttributesBeans.xml
@@ -10,5 +10,5 @@
     default-init-method="initialize" default-destroy-method="destroy" default-lazy-init="true">
     
     <bean id="predicate.AlwaysFalse" class="com.google.common.base.Predicates" factory-method="alwaysFalse" />
-            
+                
 </beans>
\ No newline at end of file
diff --git a/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/entityAttributesByRef.xml b/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/entityAttributesByRef.xml
new file mode 100644
index 0000000..f538f19
--- /dev/null
+++ b/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/entityAttributesByRef.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<metadata:MetadataFilter xmlns="urn:oasis:names:tc:SAML:2.0:metadata"
+	xmlns:metadata="urn:mace:shibboleth:2.0:metadata"
+    xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
+    xmlns:mdattr="urn:oasis:names:tc:SAML:metadata:attribute"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="urn:mace:shibboleth:2.0:metadata http://shibboleth.net/schema/idp/shibboleth-metadata.xsd
+                       urn:oasis:names:tc:SAML:2.0:assertion http://docs.oasis-open.org/security/saml/v2.0/saml-schema-assertion-2.0.xsd
+                       urn:oasis:names:tc:SAML:2.0:metadata http://docs.oasis-open.org/security/saml/v2.0/saml-schema-metadata-2.0.xsd"
+
+	xsi:type="metadata:ByReference">
+    
+    <metadata:MetadataFilters providerRef="entityAttributes">
+    
+		<metadata:MetadataFilter xsi:type="metadata:EntityAttributes">
+	        <metadata:AttributeFilterRef>predicate.AlwaysFalse</metadata:AttributeFilterRef>
+	        <saml:Attribute Name="foo">
+	            <saml:AttributeValue>fooValue</saml:AttributeValue>        
+	        </saml:Attribute>
+	        <saml:Attribute Name="bar">
+	            <saml:AttributeValue>barValue</saml:AttributeValue>        
+	        </saml:Attribute>
+	        <metadata:Entity>https://sp.example.org/sp/shibboleth</metadata:Entity>
+	    </metadata:MetadataFilter>
+    
+    </metadata:MetadataFilters>
+
+</metadata:MetadataFilter>
diff --git a/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/entityAttributesBeans.xml b/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/entityAttributesByRefBeans.xml
similarity index 87%
copy from idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/entityAttributesBeans.xml
copy to idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/entityAttributesByRefBeans.xml
index 5ad20a0..b7f0645 100644
--- a/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/entityAttributesBeans.xml
+++ b/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/entityAttributesByRefBeans.xml
@@ -10,5 +10,7 @@
     default-init-method="initialize" default-destroy-method="destroy" default-lazy-init="true">
     
     <bean id="predicate.AlwaysFalse" class="com.google.common.base.Predicates" factory-method="alwaysFalse" />
-            
+    
+    <bean class="net.shibboleth.idp.profile.spring.relyingparty.metadata.impl.ByReferenceFilterBeanPostProcessor" />
+                
 </beans>
\ No newline at end of file
diff --git a/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/entityAttributesMetadataOnly.xml b/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/entityAttributesMetadataOnly.xml
new file mode 100644
index 0000000..9c38a67
--- /dev/null
+++ b/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/entityAttributesMetadataOnly.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<metadata:MetadataProvider xmlns="urn:oasis:names:tc:SAML:2.0:metadata"
+	xmlns:metadata="urn:mace:shibboleth:2.0:metadata"
+    xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
+    xmlns:mdattr="urn:oasis:names:tc:SAML:metadata:attribute"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="urn:mace:shibboleth:2.0:metadata http://shibboleth.net/schema/idp/shibboleth-metadata.xsd
+                       urn:oasis:names:tc:SAML:2.0:assertion http://docs.oasis-open.org/security/saml/v2.0/saml-schema-assertion-2.0.xsd
+                       urn:oasis:names:tc:SAML:2.0:metadata http://docs.oasis-open.org/security/saml/v2.0/saml-schema-metadata-2.0.xsd"
+
+	failFastInitialization="false" requireValidMetadata="false"
+
+	id="entityAttributes" xsi:type="metadata:InlineMetadataProvider">
+    
+    <EntitiesDescriptor Name="ukgroup">
+    	<EntityDescriptor ID="uk001502"
+    		entityID="https://sp.example.org/sp/shibboleth">
+            <Extensions>
+                <mdattr:EntityAttributes>
+                    <saml:Attribute Name="http://macedir.org/entity-category"
+                        NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
+                        <saml:AttributeValue>http://refeds.org/category/research-and-scholarship</saml:AttributeValue>
+                    </saml:Attribute>
+                </mdattr:EntityAttributes>
+            </Extensions>
+    		<SPSSODescriptor
+    			protocolSupportEnumeration="urn:oasis:names:tc:SAML:1.1:protocol urn:oasis:names:tc:SAML:2.0:protocol">
+    
+    			<AssertionConsumerService
+    				Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST-SimpleSign"
+    				Location="https://sp.example.org/Shibboleth.sso/SAML2/POST-SimpleSign"
+    				index="5" />
+    		</SPSSODescriptor>
+    	</EntityDescriptor>
+
+        <EntityDescriptor ID="uk001503"
+            entityID="https://sp2.example.org/sp/shibboleth">
+            <Extensions>
+                <mdattr:EntityAttributes>
+                    <saml:Attribute Name="http://macedir.org/entity-category"
+                        NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
+                        <saml:AttributeValue>http://refeds.org/category/research-and-scholarship</saml:AttributeValue>
+                    </saml:Attribute>
+                </mdattr:EntityAttributes>
+            </Extensions>
+            <SPSSODescriptor
+                protocolSupportEnumeration="urn:oasis:names:tc:SAML:1.1:protocol urn:oasis:names:tc:SAML:2.0:protocol">
+    
+                <AssertionConsumerService
+                    Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST-SimpleSign"
+                    Location="https://sp2.example.org/Shibboleth.sso/SAML2/POST-SimpleSign"
+                    index="5" />
+            </SPSSODescriptor>
+        </EntityDescriptor>
+    </EntitiesDescriptor>
+</metadata:MetadataProvider>

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


More information about the commits mailing list