[java-identity-provider] branch master updated: Add support for attributeFilterRef and unit test to schema/parser.
Scott Cantor
cantor.2 at osu.edu
Tue May 2 17:11:04 EDT 2017
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=b4ac9cbdaf505d67f2ad6c01438916ab129ff69b
The following commit(s) were added to refs/heads/master by this push:
new b4ac9cb Add support for attributeFilterRef and unit test to schema/parser.
b4ac9cb is described below
commit b4ac9cbdaf505d67f2ad6c01438916ab129ff69b
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue May 2 17:10:55 2017 -0400
Add support for attributeFilterRef and unit test to schema/parser.
---
.../filter/impl/EntityAttributesFilterParser.java | 6 ++
.../filter/EntityAttributesFilterParserTest.java | 77 ++++++++++++++++++++++
.../metadata/filter/entityAttributes.xml | 66 +++++++++++++++++++
.../metadata/filter/entityAttributesBeans.xml | 14 ++++
.../main/resources/schema/shibboleth-metadata.xsd | 8 +++
5 files changed, 171 insertions(+)
diff --git a/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/impl/EntityAttributesFilterParser.java b/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/impl/EntityAttributesFilterParser.java
index 81d2e49..570bb13 100644
--- a/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/impl/EntityAttributesFilterParser.java
+++ b/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/impl/EntityAttributesFilterParser.java
@@ -24,6 +24,7 @@ import javax.annotation.Nonnull;
import javax.xml.namespace.QName;
import net.shibboleth.idp.profile.spring.relyingparty.metadata.AbstractMetadataProviderParser;
+import net.shibboleth.utilities.java.support.primitive.StringSupport;
import net.shibboleth.utilities.java.support.xml.ElementSupport;
import org.opensaml.core.xml.XMLObject;
@@ -102,6 +103,11 @@ public class EntityAttributesFilterParser extends AbstractSingleBeanDefinitionPa
}
builder.addPropertyValue("rules", ruleMap);
+
+ if (element.hasAttributeNS(null, "attributeFilterRef")) {
+ builder.addPropertyReference("attributeFilter",
+ StringSupport.trimOrNull(element.getAttributeNS(null, "attributeFilterRef")));
+ }
}
/** {@inheritDoc} */
diff --git a/idp-profile-spring/src/test/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/EntityAttributesFilterParserTest.java b/idp-profile-spring/src/test/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/EntityAttributesFilterParserTest.java
new file mode 100644
index 0000000..3b9790c
--- /dev/null
+++ b/idp-profile-spring/src/test/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/EntityAttributesFilterParserTest.java
@@ -0,0 +1,77 @@
+/*
+ * 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.metadata.resolver.filter.impl.EntityAttributesFilter;
+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 EntityAttributesFilterParserTest extends AbstractMetadataParserTest {
+
+ @Test
+ public void test() throws ResolverException, IOException {
+
+ final MetadataResolver resolver = getBean(MetadataResolver.class,
+ "filter/entityAttributes.xml", "filter/entityAttributesBeans.xml");
+
+ final EntityAttributesFilter filter = (EntityAttributesFilter) resolver.getMetadataFilter();
+ Assert.assertNotNull(filter);
+
+ 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/entityAttributes.xml b/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/entityAttributes.xml
new file mode 100644
index 0000000..3c2d282
--- /dev/null
+++ b/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/entityAttributes.xml
@@ -0,0 +1,66 @@
+<?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">
+
+ <metadata:MetadataFilter xsi:type="metadata:EntityAttributes" attributeFilterRef="predicate.AlwaysFalse">
+ <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>
+
+ <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>
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
new file mode 100644
index 0000000..5ad20a0
--- /dev/null
+++ b/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/entityAttributesBeans.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:util="http://www.springframework.org/schema/util" xmlns:p="http://www.springframework.org/schema/p"
+ xmlns:c="http://www.springframework.org/schema/c" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
+ http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"
+
+ 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-schema/src/main/resources/schema/shibboleth-metadata.xsd b/idp-schema/src/main/resources/schema/shibboleth-metadata.xsd
index eba3a38..2c1e57d 100644
--- a/idp-schema/src/main/resources/schema/shibboleth-metadata.xsd
+++ b/idp-schema/src/main/resources/schema/shibboleth-metadata.xsd
@@ -1154,6 +1154,14 @@
</annotation>
</element>
</choice>
+ <attribute name="attributeFilterRef" type="string">
+ <annotation>
+ <documentation>
+ The ID of a Spring bean to inject as a condition Predicate to determine whether
+ pre-existing EntityAttributes child Attributes should be retained.
+ </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