Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagexml
titleJavascript Example
collapsetrue
<!-- A script that checks a Relying Party name -->
<bean id="MyCondition" parent="shibboleth.Conditions.Scripted" factory-method="inlineScript">
	<constructor-arg>
		<value>
        <![CDATA[

             (function (parentContext) {// an implementation of Predicate<ProfileRequestContext>
         const id = "https://sp.example.com/shibboleth";//
             const subcontextClass = "net.shibboleth.idp// if the predicate function returns true, the activation condition
            // is satisfied.
            //
            // the profileContext argument is of type:
            // org.opensaml.profile.context.ProfileRequestContext
            //
            (function (context) {
                "use strict";

                var id = "https://sp.example.com/shibboleth";  // an entityID

                // specify the child context of the root ProfileRequestContext
                var subcontextClass = "net.shibboleth.idp.profile.context.RelyingPartyContext";;
                var subcontext;

                // check the parameter
                if (context === null) { varreturn subcontextfalse; }

               if (parentContext == null) { return false; }
// check the entityID of the relying party
                subcontext = parentContextcontext.getSubcontext(subcontextClass);
                if (subcontext === null) { return false; }
                return subcontext.getRelyingPartyId().equals(id);
            }(profileContext));
        ]]>
		</value>
	</constructor-arg>
</bean>

...