ISAM JavaScript – Making Multi value Attributes

Received a question related to the ‘art’ of making an attribute that is multivalued for the purpose of a SAML Mapping rule, but this is still relevant when using Infomap, OAuth or even the AuthSvcCred mapping rules.

When we are writing the JavaScript mapping rules, the engine wants to make JavaScript objects, this is useful some of the time, but when we are interfacing with a number of our JavaScript incarnations of objects, this can be hazardous.

Take Attribute for example:


Constructor List for Attribute

We have ways to make the Attribute that includes single valued attributes as well as multi-valued attributes by way of a “List”, a “String Array” and “DOM Nodes”.

Assuming you had some groups:

  • group1
  • group2

That you wanted to put into an STSUU, you might think you can do this:

var groups = ["group1", "group2"];
var attr = new Attribute("groups", "", groups);

This will result in an error, not unlike this:

Caused by: org.mozilla.javascript.EvaluatorException: 
The choice of Java method
matching JavaScript argument types (string,string,object) is ambiguous; candidate methods are:


In order to do this correctly, follow the steps below:

1)  Source or create a Java String Array, and in JavaScript an easy way to do this, is using the following line of code:

var javaStringArray = java.lang.reflect.Array.newInstance(java.lang.String, 2);
This is sourced from here.
2) Now, we can use the javaStringArray – as we would the javascript one, to populate it with the desired values.
javaStringArray[0] = "group1";
javaStringArray[1] = "group2";
3) We should be able to add this to our new Attribute:
var rolesAttribute = new Attribute("group", "", javaStringArray);

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Up ↑

%d bloggers like this: