0

I am attempting to add a JAR to WSO2 IS 5.11.0 so that I can call the getSessionData function from the Script Based Adaptive Authentication console.

I cloned the identity-conditional-auth-functions repository and built the session module found here using maven. I then placed the created JAR in each of the following places and restarted WSO2 IS:

  • CARBON_HOME/repository/components/dropins
  • CARBON_HOME/lib
  • CARBON_HOME/repository/components/lib
  • CARBON_HOME/repository/components/extensions

From the Script Based Adaptive Authentication console I then call getSessionData which is a function registered inside of the JAR I added. When I login and trigger the script I get the following error:

eval>:9 ReferenceError: "getSessionData" is not defined
    at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ECMAErrors.error(ECMAErrors.java:57)
    at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:319)
    at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:291)
    at jdk.scripting.nashorn/jdk.nashorn.internal.objects.Global.__noSuchProperty__(Global.java:1616)
...

How can I get WSO2 IS to add custom functions that I am able to call from the Script Based Adaptive Authentication console?

Community
  • 1
  • 1
wearebob
  • 376
  • 2
  • 15
  • Copy the jar into CARBON_HOME/repository/components/dropins and start the server in OSGi debug mode (./wso2server.sh -DosgiConsole). Once the server starts press some enters and get the OSGI console. Issue the command "ss org.wso2.carbon.conditional.auth.functions.session" and check the whether the status of the component is ACTIVE. – Anuradha Karunarathna Jan 14 '21 at 02:32
  • I had to remove an Import from the pom, but it is now showing ACTIVE when I run `ss org.wso2.carbon.conditional.auth.functions.session`. However when I attempt to login I still get the same error that `"getSessionData" is not defined`. Do I need to do something in the Script Based Adaptive Authentication console to explicitly `require` this library? – wearebob Jan 14 '21 at 18:49
  • Does `diag ` (bundle id relevant to `org.wso2.carbon.conditional.auth.functions.session` )execution on OSGi console respond as `No resolution report for the bundle.`? – Anuradha Karunarathna Jan 14 '21 at 19:22
  • Yes, it does `org.wso2.carbon.conditional.auth.functions.session [187]` `No resolution report for the bundle.` – wearebob Jan 14 '21 at 20:09
  • Can you please add the output by executing `b ` on OSGi console? In order to use the "getSessionData" in adaptive auth scripts, proper activation of this bundle is sufficient. You don't need to explicitly import them in the script using "require" – Anuradha Karunarathna Jan 15 '21 at 03:45
  • 1
    Thanks for your help Anuradha. The bundle is now activated and I'm able to call the function from the JS console. For anyone else hitting a similar problem, I needed to provide a version for an import in the pom. `org.osgi.service.component` -> `org.osgi.service.component;version="[1.2,2.0)"` – wearebob Jan 15 '21 at 18:30

0 Answers0