[java-identity-provider] branch master updated: Add contrived example to test customPObjectRef in the ScriptedPredicate
Rod Widdowson
rdw at steadingsoftware.com
Thu Aug 2 09:40:53 EDT 2018
This is an automated email from the git hooks/post-receive script.
rdw 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=340dad2b10217cddb230594eecbd75fc9c5c8edc
The following commit(s) were added to refs/heads/master by this push:
new 340dad2 Add contrived example to test customPObjectRef in the ScriptedPredicate
340dad2 is described below
commit 340dad2b10217cddb230594eecbd75fc9c5c8edc
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Thu Aug 2 14:40:20 2018 +0100
Add contrived example to test customPObjectRef in the ScriptedPredicate
---
.../metadata/filter/PredicateFilterParserTest.java | 21 +++++++++++++++++---
.../metadata/filter/entityTrueResolver.xml | 20 +++++++++++++++++++
.../metadata/filter/predicateCustomBean.xml | 23 ++++++++++++++++++++++
.../metadata/filter/predicateScriptCustom.xml | 12 +++++++++++
4 files changed, 73 insertions(+), 3 deletions(-)
diff --git a/idp-profile-spring/src/test/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/PredicateFilterParserTest.java b/idp-profile-spring/src/test/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/PredicateFilterParserTest.java
index 5f72790..2e75dfb 100644
--- a/idp-profile-spring/src/test/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/PredicateFilterParserTest.java
+++ b/idp-profile-spring/src/test/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/PredicateFilterParserTest.java
@@ -19,15 +19,15 @@ package net.shibboleth.idp.profile.spring.relyingparty.metadata.filter;
import java.io.IOException;
-import net.shibboleth.idp.profile.spring.relyingparty.metadata.AbstractMetadataParserTest;
-import net.shibboleth.utilities.java.support.logic.ScriptedPredicate;
-
+import org.opensaml.core.criterion.EntityIdCriterion;
import org.opensaml.saml.common.profile.logic.EntityAttributesPredicate;
import org.opensaml.saml.common.profile.logic.EntityAttributesPredicate.Candidate;
import org.opensaml.saml.common.profile.logic.EntityGroupNamePredicate;
import org.opensaml.saml.common.profile.logic.EntityIdPredicate;
+import org.opensaml.saml.metadata.resolver.MetadataResolver;
import org.opensaml.saml.metadata.resolver.filter.impl.PredicateFilter;
import org.opensaml.saml.metadata.resolver.filter.impl.PredicateFilter.Direction;
+import org.opensaml.saml.saml2.metadata.EntityDescriptor;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.testng.Assert;
@@ -35,6 +35,11 @@ import org.testng.annotations.Test;
import com.google.common.base.Predicates;
+import net.shibboleth.idp.profile.spring.relyingparty.metadata.AbstractMetadataParserTest;
+import net.shibboleth.utilities.java.support.logic.ScriptedPredicate;
+import net.shibboleth.utilities.java.support.resolver.CriteriaSet;
+import net.shibboleth.utilities.java.support.resolver.ResolverException;
+
/**
* Test for parser for PredicateFilter filter.
*/
@@ -123,4 +128,14 @@ public class PredicateFilterParserTest extends AbstractMetadataParserTest {
Assert.assertSame(filter.getCondition().getClass(), Predicates.or(Predicates.alwaysTrue()).getClass());
}
+ @Test
+ public void custom() throws IOException, ResolverException {
+ final PredicateFilter filter = getBean(PredicateFilter.class, "filter/predicateScriptCustom.xml", "filter/predicateCustomBean.xml");
+ Assert.assertNotNull(filter);
+ Assert.assertEquals(filter.getDirection(), Direction.INCLUDE);
+ // hack!
+ MetadataResolver resolver = getBean(MetadataResolver.class, "filter/entityTrueResolver.xml");
+ Iterable<EntityDescriptor> entities = resolver.resolve(new CriteriaSet(new EntityIdCriterion("https://sp.example.org/sp/TRUE")));
+ Assert.assertTrue(filter.getCondition().apply(entities.iterator().next()));
+ }
}
\ No newline at end of file
diff --git a/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/entityTrueResolver.xml b/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/entityTrueResolver.xml
new file mode 100644
index 0000000..e27adb7
--- /dev/null
+++ b/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/entityTrueResolver.xml
@@ -0,0 +1,20 @@
+<?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"
+
+ id="inLineEntity" xsi:type="metadata:InlineMetadataProvider" >
+
+ <EntityDescriptor ID="xyz" entityID="https://sp.example.org/sp/TRUE">
+
+ <SPSSODescriptor
+ protocolSupportEnumeration="urn:oasis:names:tc:SAML:1.1:protocol urn:oasis:names:tc:SAML:1.0: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>
+</metadata:MetadataProvider>
\ No newline at end of file
diff --git a/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/predicateCustomBean.xml b/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/predicateCustomBean.xml
new file mode 100644
index 0000000..c627186
--- /dev/null
+++ b/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/predicateCustomBean.xml
@@ -0,0 +1,23 @@
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:webflow="http://www.springframework.org/schema/webflow-config"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:p="http://www.springframework.org/schema/p"
+ xmlns:c="http://www.springframework.org/schema/c"
+ xmlns:util="http://www.springframework.org/schema/util"
+ 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">
+
+ <bean class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer"
+ p:placeholderPrefix="%{" p:placeholderSuffix="}" />
+
+ <util:constant id="myTRUE" static-field="java.lang.Boolean.TRUE" />
+ <util:constant id="myFALSE" static-field="java.lang.Boolean.FALSE" />
+
+
+ <util:map id="myCustomBean">
+ <entry key="https://sp.example.org/sp/TRUE" value-ref="myTRUE" />
+ <entry key="https://sp.example.org/sp/FALSE" value-ref="myFALSE" />
+ </util:map>
+</beans>
\ No newline at end of file
diff --git a/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/predicateScriptCustom.xml b/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/predicateScriptCustom.xml
new file mode 100644
index 0000000..d60a2fb
--- /dev/null
+++ b/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/predicateScriptCustom.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<MetadataFilter
+ xmlns="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"
+
+ xsi:type="Predicate" direction="include" removeEmptyEntitiesDescriptors="false">
+
+ <ConditionScript customObjectRef="myCustomBean">
+ <Script>custom[input.getEntityID()];</Script>
+ </ConditionScript>
+</MetadataFilter>
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list