Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 15 Next »

Overview

The Nashorn plugin provides support for the Nashorn JavaScript engine for IdPs of version 4.1 and beyond. This the scripting engine that was shipped with Java between versions 8 to 14 (it is not present as of JDK15).  It is therefore targeted at IdP installations on JDK 15 and later.

Installation

Starting with IdP 4.2 you can the install the latest plugin version supported on your IdP version with
.\plugin.sh -I net.shibboleth.idp.plugin.nashorn

PluginId

Latest Version

net.shibboleth.idp.plugin.nashorn

2.0.0: download

Configuration

This plugin requires no configuration and does not expose any Modules. Its sole purpose is to add a new scripting language to the IdP. The plugin is actually a  JSR-223 implementation which works alongside the IdP to make these language strings available:

  • nashorn

  • Nashorn

  • js

  • JS

  • JavaScript

  • javascript

  • ECMAScript

  • ecmascript

Tips

This is a collection point for any “generic” scripting tips or examples that don’t pertain to specific use cases but just illustrate harder or non-obvious ways to use Javascript in the Java environment.

Accessing Classes or Static Methods

Many of the APIs in our software rely on class objects or static methods, which are simple to use in Java itself but less obvious in Javascript.

Calling a static method on a class looks like this. The method name in this example is bar and it takes no arguments.

var typ = Java.type("org.example.package.ClassName");
var foo = type.bar();

Accessing a class object is slightly different:

var claz = Java.type("org.example.package.ClassName").class;
var classname = claz.getName();

  • No labels