Versions Compared

Key

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

...

This attribute definition allows Java code to be written in the definition and executed when the attribute is requested. This provides nearly limitless flexability for creating or tansforming attributes. The scripts are processed by the BeanShell interpreter.

Include Page
SHIB:AttributeDefinitionBasics
SHIB:AttributeDefinitionBasics

...

Code Block
<ScriptletAttributeDefinition id="urn:mace:dir:attribute-def:eduPersonAffiliation">
    <DataConnectorDependency requires="directory"/>
        <Scriptlet><![CDATA[
            Attributes attributes = dependencies.getConnectorResolution("directory");
            Attribute affiliation = attributes.get("eduPersonAffiliation");
            if (affiliation.size() > 0) {
                resolverAttribute.addValue("affiliate");
            }
        ]]></Scriptlet>
</ScriptletAttributeDefinition>

Example Configuration for common-lib-terms

This example sets the eduPersonEntitlement to the common-lib-terms URN for a principal with affiliation staff or student while keeping any entitlement values retrieved from the directory.

For the definition of common-lib-terms, refer to http://middleware.internet2.edu/urn-mace/urn-mace-dir-entitlement.html.

Code Block

<ScriptletAttributeDefinition id="urn:mace:dir:attribute-def:eduPersonEntitlement">
   <DataConnectorDependency requires="directory"/>
   <AttributeDependency requires="urn:mace:dir:attribute-def:eduPersonAffiliation" />
   <Scriptlet><![CDATA[
Attributes attributes = dependencies.getConnectorResolution("directory");

Attribute entitlement = attributes.get("eduPersonEntitlement");

// add values from directory
for (int i = 0; entitlement != null && i < entitlement.size(); i++)
{
    resolverAttribute.addValue(entitlement.get(i));
}

// add common-lib-terms for staff and student
Attribute attribute = attributes.get("eduPersonAffiliation");
if (attribute.contains("staff") ||
    attribute.contains("student"))
{
    resolverAttribute.addValue("urn:mace:dir:entitlement:common-lib-terms");
}
      ]]>
   </Scriptlet>
</ScriptletAttributeDefinition>

...