Versions Compared

Key

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

...

Code Block
languagexml
titleA trivial implementation of Predicate<EntityDescriptor>
<ConditionScript>
    <Script>
    <![CDATA[
        "use strict";

        // A trivial implementation of Predicate<EntityDescriptor>
        // applied to the input argument
        //
        // The input argument is of type:
        // org.opensaml.saml.saml2.metadata.EntityDescriptor
        //
        (function (entity) { return false; }(input));
    ]]>
    </Script>
</ConditionScript>

The formal parameter name is arbitrary. In the previous example, the parameter name entity is used for clarity. A nontrivial script would depend on the formal parameter entity.

If the customObjectRef attribute is present on the <ConditionScript> element, the script operates on a pair of arguments arguments called custom and input. The following script implements a function that always returns the same trivial implementation of Predicate<EntityDescriptor> regardless of the custom argument. The resulting predicate is then applied to the input argument, which always returns false.

Code Block
languagexml
titleA trivial implementation of Function<T, Predicate<EntityDescriptor>>
<ConditionScript customObjectRef="BeanID">
    <Script>
    <![CDATA[
        "use strict";


        // A trivial implementation of Function<T, Predicate<EntityDescriptor>>,
        // that is, a function that takes an argument of some unspecified type T
        // and returns an implementation of Predicate<EntityDescriptor>.
        // The latter is ultimately applied to the input object.
        //
        // The type of the custom argument depends on the application.
        //
        // The input argument is of type:
        // org.opensaml.saml.saml2.metadata.EntityDescriptor
        //
        (function (t) { return function (entity) { return false; }; }(custom))(input);
    ]]>
    </Script>
</ConditionScript>

...