The <AttributeFilterScript>
element contains a script (or a reference to a script) that implements that ultimately applies an implementation of Predicate<Attribute>
to a given entity attribute.
Note | ||
---|---|---|
| ||
This feature requires IdP V3.4 or later. |
The <AttributeFilterScript>
element implicitly iterates over all entity attributes in the input streammetadata pipeline. For each entity attribute, the entity attribute is removed from the input stream if (and only if) the predicate evaluates to false.
...
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|
Examples
The following examples assume the default JavaScript language.
...
Script Context
A script contained by an <AttributeFilterScript>
element has access to an object called input
by convention. The actual input
argument is an instance of a class that implements the Attribute
interface.
If the customObjectRef
attribute is present on the <AttributeFilterScript>
element, the result of the referenced Spring bean is made available to the script via a second object called custom
. The type of the custom
object is determined by the Spring bean.
Examples
If the customObjectRef
attribute is not present on the <AttributeFilterScript>
element, the script operates on a single input
argument. The following trivial implementation of Predicate<Attribute>
always returns false regardless of the input
argument:
Code Block | ||||
---|---|---|---|---|
| ||||
<AttributeFilterScript><ConditionScript> <Script> <![CDATA[ // An implementation of Predicate<Attribute>"use strict"; false; // applied]]> to the input argument </Script> </ConditionScript> |
A more complex example might use the custom
object to help the operation.
Code Block |
---|
<Script> <![CDATA[ // "use strict"; // The input argument is of type: var someCondition = function(attributeValueCount) { // org.opensaml.saml.saml2.core.Attribute // Good stuff (function (attribute) { } "use strict"; var result; // do not remove CustomObjectRef points to a <util:map> where the entity attribute key is a string and the value is an 'interesting bean' if (attribute === null) { return true; } (someCondition(input.getValues.size()) { result = custom["myAttributePredicate"].someFunction(input); } else { // implementresult the predicate here...= custom["myOtherAttributePredicate"].someOtherFunction(input); }(input)) result; ]]> </Script> </AttributeFilterScript> |
...
<
Script
>
<![CDATA[
"use strict";
var someCondition = function(entityID) {
// Good stuff
}
var result;
// CustomObjectRef points to a <util:map> where the key is a string and the value is an 'interesting bean'
if (someCondition(input.getEntityID())) {
result = custom["myFirstBean"].someFunction(input);
} else {
result = custom["mySecondBean"].someOtherFunction(input);
}
result;
]]>
</
Script
>
<
Script
>
<![CDATA[
"use strict";
var someCondition = function(entityID) {
// Good stuff
}
var result;
// CustomObjectRef points to a <util:map> where the key is a string and the value is an 'interesting bean'
if (someCondition(input.getEntityID())) {
result = custom["myFirstBean"].someFunction(input);
} else {
result = custom["mySecondBean"].someOtherFunction(input);
}
result;
]]>
</
Script
>