As referenced in my previous post(Defining Schema for Managed Objects using Javascript), OpenIDM allows you to decide what goes in and what is visible outside. In this section we are going to write a groovy script to allow only a certain list of attributes to be entered. Below is the groovy script code:
def allowedAttributes = ["userName","givenName","mail","_id","password","sn","department","country","creator","startdate","status","designation","isManager"];
Map jvMap = object.asMap();
Set keys = jvMap.keySet();
for( key in keys)
{
if(!allowedAttributes.contains(key))
throw new Exception("Attribute "+key+" not allowed");
}
We can change the attributes list as per our requirement. We need to reference this in Managed.json as below:
Similarly, if we can reference this script on "onUpdate" to control the attributes while updating the managed object.
def allowedAttributes = ["userName","givenName","mail","_id","password","sn","department","country","creator","startdate","status","designation","isManager"];
Map jvMap = object.asMap();
Set keys = jvMap.keySet();
for( key in keys)
{
if(!allowedAttributes.contains(key))
throw new Exception("Attribute "+key+" not allowed");
}
We can change the attributes list as per our requirement. We need to reference this in Managed.json as below:
| managed.json |
Similarly, if we can reference this script on "onUpdate" to control the attributes while updating the managed object.