[java-identity-provider] branch master updated: Add inline/resource scripting to NameIDFormat metadata filter.

Scott Cantor cantor.2 at osu.edu
Tue May 9 15:04:03 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=26308499d117349280a3246ff192c500f6654d41

The following commit(s) were added to refs/heads/master by this push:
       new  2630849   Add inline/resource scripting to NameIDFormat metadata filter.
2630849 is described below

commit 26308499d117349280a3246ff192c500f6654d41
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue May 9 15:03:59 2017 -0400

    Add inline/resource scripting to NameIDFormat metadata filter.
---
 .../filter/impl/NameIDFormatFilterParser.java      |  8 ++++
 .../filter/NameIDFormatFilterParserTest.java       | 14 ++++++-
 .../metadata/filter/nameIDFormatWithScript.xml     | 48 ++++++++++++++++++++++
 .../main/resources/schema/shibboleth-metadata.xsd  |  8 ++++
 4 files changed, 76 insertions(+), 2 deletions(-)

diff --git a/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/impl/NameIDFormatFilterParser.java b/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/impl/NameIDFormatFilterParser.java
index 763ee1c..dc5a477 100644
--- a/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/impl/NameIDFormatFilterParser.java
+++ b/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/impl/NameIDFormatFilterParser.java
@@ -24,6 +24,8 @@ import javax.annotation.Nonnull;
 import javax.xml.namespace.QName;
 
 import net.shibboleth.idp.profile.spring.relyingparty.metadata.AbstractMetadataProviderParser;
+import net.shibboleth.idp.profile.spring.relyingparty.metadata.ScriptTypeBeanParser;
+import net.shibboleth.utilities.java.support.logic.ScriptedPredicate;
 import net.shibboleth.utilities.java.support.xml.ElementSupport;
 
 import org.opensaml.saml.common.profile.logic.EntityIdPredicate;
@@ -83,6 +85,12 @@ public class NameIDFormatFilterParser extends AbstractSingleBeanDefinitionParser
                 final ManagedList<String> forRule = new ManagedList(accumulator.size());
                 forRule.addAll(accumulator);
                 ruleMap.put(new RuntimeBeanReference(ElementSupport.getElementContentAsString(child)), forRule);
+            } else if (ElementSupport.isElementNamed(child, AbstractMetadataProviderParser.METADATA_NAMESPACE,
+                    "ConditionScript")) {
+                final ManagedList<String> forRule = new ManagedList(accumulator.size());
+                forRule.addAll(accumulator);
+                ruleMap.put(ScriptTypeBeanParser.parseScriptType(ScriptedPredicate.class, child).getBeanDefinition(),
+                        forRule);
             }
             child = ElementSupport.getNextSiblingElement(child);
         }
diff --git a/idp-profile-spring/src/test/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/NameIDFormatFilterParserTest.java b/idp-profile-spring/src/test/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/NameIDFormatFilterParserTest.java
index 2d476cc..d5c1a73 100644
--- a/idp-profile-spring/src/test/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/NameIDFormatFilterParserTest.java
+++ b/idp-profile-spring/src/test/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/NameIDFormatFilterParserTest.java
@@ -36,8 +36,18 @@ import org.testng.annotations.Test;
  */
 public class NameIDFormatFilterParserTest extends AbstractMetadataParserTest {
 
-    @Test public void test() throws ResolverException, IOException {
-        final MetadataResolver resolver = getBean(MetadataResolver.class, "filter/nameIDFormat.xml");
+    @Test
+    public void test() throws ResolverException, IOException {
+        doTest("filter/nameIDFormat.xml");
+    }
+
+    @Test
+    public void testWithScript() throws ResolverException, IOException {
+        doTest("filter/nameIDFormatWithScript.xml");
+    }
+    
+    private void doTest(final String... files) throws ResolverException, IOException {
+        final MetadataResolver resolver = getBean(MetadataResolver.class, files);
 
         final NameIDFormatFilter filter = (NameIDFormatFilter) resolver.getMetadataFilter();
         Assert.assertNotNull(filter);
diff --git a/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/nameIDFormatWithScript.xml b/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/nameIDFormatWithScript.xml
new file mode 100644
index 0000000..9a0d97f
--- /dev/null
+++ b/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/nameIDFormatWithScript.xml
@@ -0,0 +1,48 @@
+<?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: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:metadata http://docs.oasis-open.org/security/saml/v2.0/saml-schema-metadata-2.0.xsd"
+
+	failFastInitialization="false" requireValidMetadata="false"
+
+	id="nameIDFormat" xsi:type="metadata:InlineMetadataProvider">
+	<metadata:MetadataFilter xsi:type="metadata:NameIDFormat">
+        <metadata:Format>foo</metadata:Format>
+        <metadata:ConditionScript language="javascript">
+            <metadata:Script>input.getEntityID().equals("https://sp.example.org/sp/shibboleth");</metadata:Script>
+        </metadata:ConditionScript>
+        <metadata:Format>bar</metadata:Format>
+        <metadata:ConditionScript language="javascript">
+            <metadata:Script>input.getEntityID().equals("https://sp2.example.org/sp/shibboleth");</metadata:Script>
+        </metadata:ConditionScript>
+    </metadata:MetadataFilter>
+
+    <EntitiesDescriptor Name="ukgroup">
+    	<EntityDescriptor ID="uk001502"
+    		entityID="https://sp.example.org/sp/shibboleth">
+    
+    		<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">
+    
+            <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-schema/src/main/resources/schema/shibboleth-metadata.xsd b/idp-schema/src/main/resources/schema/shibboleth-metadata.xsd
index 7b274ae..f1ec60e 100644
--- a/idp-schema/src/main/resources/schema/shibboleth-metadata.xsd
+++ b/idp-schema/src/main/resources/schema/shibboleth-metadata.xsd
@@ -1221,6 +1221,14 @@
                             </documentation>
                         </annotation>
                     </element>
+                    <element name="ConditionScript" type="shibmd:ScriptType">
+                        <annotation>
+                            <documentation>
+                                A script implementing Predicate<EntityDescriptor> to identify one
+                                or more EntityDescriptors to add all the preceding Attribute elements to. 
+                            </documentation>
+                        </annotation>
+                    </element>
                 </choice>
             </extension>
         </complexContent>

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


More information about the commits mailing list