Calling Java code from Javascript in the Script Mapper in RH-SSO

Solution Verified - Updated -

Environment

  • Red Hat Single Sign-On 7

Issue

  • I want call java code from an external jar to create claims data in a script mapper.
  • Calling java code from scripts using Java Scripting API (JSR 223)

Resolution

  1. You first need to make the code available in a global module in Red Hat Single Sign-On. See solution:

    Creating Custom Modules in JBoss EAP

  2. The script mapper uses the Java Scripting Api, so once the classes are accessible, it's trivial to call them from Javascript.

Root Cause

The java code needs to be available to Red Hat Single Sign-On, so a module is necessary, then, since the script mapper uses the Java Scripting Api, it can call the java code directly.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.