...
NOTE: This connector is only included since IdP 1.3.1 (see announcement e-mail). If you use an earlier IdP release, you may retrieve it from the source control system if you feel comfortable doing so.
This attribute definition allows Java code to be written in the definition and executed when the attribute is requested. This provides nearly limitless flexibility for creating or transforming attributes. The scripts are processed by the BeanShell interpreter.
Include Page |
---|
| SHIB:AttributeDefinitionBasicsSHIB: |
---|
| AttributeDefinitionBasics |
---|
|
Configuring the Definition
- Create a ScriptletAttributeDefinition element with its id attribute.
- Create a Scriptlet element, child of ScriptletAttributeDefinition, whose content is Java code that should be executed when this attribute is requested. You may wish to place this data in a CDATA section to ensure it does not interfere with the XML processing.
...
Code Block |
---|
|
<ScriptletAttributeDefinition id="urn:mace:dir:attribute-def:eduPersonAffiliation">
<DataConnectorDependency requires="directory"/>
<Scriptlet><![CDATA[
Attributes attributes = dependencies.getConnectorResolution("directory");
Attribute memberOf = attributes.get("memberOf");
// add values from directory
String value = "none";
boolean student = false;
boolean faculty = false;
boolean staff = false;
boolean member = false;
for (int i = 0; memberOf != null && i < memberOf.size(); i++)
{
value = memberOf.get(i);
if (value.indexOf("Stud") > 0){
student = true;
}
if (value.indexOf("Doz") > 0){
faculty = true;
}
if (value.indexOf("Lehr") > 0){
faculty = true;
}
}
if (!student && !faculty){
staff = true;
}
if (student){
resolverAttribute.addValue("student");
}
if (faculty){
resolverAttribute.addValue("faculty");
}
if (staff || faculty){
resolverAttribute.addValue("staff");
}
if (student || staff){
resolverAttribute.addValue("affiliate");
}
]]>
</Scriptlet>
</ScriptletAttributeDefinition>
|
Include Page |
---|
| SHIB:AttributeDefinitionDependenciesSHIB: |
---|
| AttributeDefinitionDependencies |
---|
|
Include Page |
---|
| SHIB:AttributeDefinitionErrorAndCacheSHIB: |
---|
| AttributeDefinitionErrorAndCache |
---|
|