[OPENAM-16140] Groovy / Javascript capabilities and limitations in scripted decision node Created: 14/Apr/20  Updated: 18/May/20  Resolved: 18/May/20

Status: Resolved
Project: OpenAM
Component/s: documentation, scripting
Affects Version/s: None
Fix Version/s: 7.0.0, 6.5.3

Type: Improvement Priority: Minor
Reporter: Julien Chausse Assignee: Chris Lee
Resolution: Fixed Votes: 7
Labels: AME
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Document
is documented by OPENAM-16122 Include commons Javadoc in the AM ser... Open
Rank: 1|i00mhz:
Support Ticket IDs:

 Description   

Hello

The scripted decision node offers the possibility to either script in Groovy or JavaScript language.

The AM documentation illustrates some of the scripted decision node functionalities with a sample code in Groovy language only, for instance "using callbacks" , 

https://backstage.forgerock.com/docs/am/6.5/authentication-guide/#scripting-api-node-callbacks.

We are receiving some requests from customers asking whether it is possible to achieve the same in JavaScript. So far, we are struggling to answer to that question from a technical perspective and AFAIK the documentation does not seem to cover that.

As a broader issue, it would be very valuable to enrich the documentation with a note on whether both languages are capable of achieving the same functionalities and to add some illustrations in both languages.

In the negative, enriching the documentation with a comparative table of the capabilities and limitations of each language, in the context of the scripted decision node use.

Therefore the customer will have to clear understanding of whether both languages can achieve the same or not, and in the negative, for which use case one language is more suitable than the other.

Thank you

 



 Comments   
Comment by Mark Craig [ 14/Apr/20 ]

Unassigning for triage

Comment by Chris Lee [ 14/Apr/20 ]

Hi Julien Chausse - do you have the source material that you wanted adding to the documentation, or is this a request for the docs team to try and obtain said information?
If the first option, please let us have the information, and examples of where the languages differ.
If its the second, the docs team are unlikely to be able to get all the information you have requested. We can try, but it may not be a quick or easy process.

Comment by Julien Chausse [ 14/Apr/20 ]

Hi Chris Lee

This is the second option. The product team may help out on that ?

Comment by Chris Lee [ 14/Apr/20 ]

Pushing this one that came direct to us through triage. Does sound a reasonable request but it's not one Cristina or I can tackle.
Could we get some information from the devs on this perhaps, if neccessary?

Comment by Chris Lee [ 20/Apr/20 ]

This is the part we could use some help with, even if it's just a sentence we can add one way or the other to say if they are equal or not. Cheers!

We are receiving some requests from customers asking whether it is possible to achieve the same in JavaScript. So far, we are struggling to answer to that question from a technical perspective and AFAIK the documentation does not seem to cover that.

Comment by Andy Hall [ 20/Apr/20 ]

The same variables and bindings are delivered to scripts of both types.

Comment by Andy Hall [ 20/Apr/20 ]

Chris Lee maybe just include the previous comment?

Comment by Chris Lee [ 13/May/20 ]

Added a note that we treat JS and Groovy equally. Will be in the next 6.5.x and 7.x docs releases.

Comment by Wolf Pietsch [ 15/May/20 ]

Hi Chris,

but it is not treated equally, thats the issue here. For example there is no way to include classes need for the AM callbacks in JS. How is this done with JS.

Take the section  https://backstage.forgerock.com/docs/am/6.5/authentication-guide/#scripting-api-node-callbacks 

It is not clear how to do it JS, if it contains the same functionality. It is totally clear and well documented how to trigger rest calls in JS, but how to use the AM callbacks. Is it a rest call as well? is there any library support in JS? How can I handle the same example in JS given in the "using callback" section?

 

Kinds

Wolf

Comment by Chris Lee [ 15/May/20 ]

The following is a JavaScript version of the callbacks example:

var fr = JavaImporter(
  org.forgerock.openam.auth.node.api,
  javax.security.auth.callback.NameCallback
);
with (fr) {
  if (callbacks.isEmpty()) {
  	action = Action.send(new NameCallback("Enter Your Nickname")).build();
  } else {
    sharedState = sharedState.put("Nickname", callbacks.get(0).getName());
    action = Action.goTo("true").build();
  }
}
outcome = "true";

I can add this to the documentation, but woulnd't have time to provide examples for ALL of the existing ones, in both languages.

Generated at Mon Mar 08 13:21:08 UTC 2021 using Jira 7.13.12#713012-sha1:6e07c38070d5191bbf7353952ed38f111754533a.