Rhino
Overview
The Rhino plugin provides support for the Mozilla Rhino JavaScript engine for IdPs of version 4.1 and beyond. This is the old scripting engine that existed in Java 7 and earlier and was commonly used with IdP V2. It has always worked with some manual effort, but now that Nashorn has been removed from future Java versions, and the fact that it is somewhat simpler to use for some people, we have chosen to package a distribution of it that can be officially supported.
Note that at present, most of the examples in the documentation all use Nashorn and will usually NOT work unmodified with Rhino. There are significant differences in how Java classes are imported and new objects created between the two languages.
Installation
Starting with IdP 4.2 you can the install the latest plugin version supported on your IdP version with./idp/bin/plugin.sh -I net.shibboleth.idp.plugin.rhino
PluginId |
---|
net.shibboleth.idp.plugin.rhino |
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:
rhino
Rhino
js
JS
JavaScript
javascript
ECMAScript
ecmascript
Note that the IdP will look for other JSR-223 implementations prior to consulting the plugin. So (for instance) specifying lang="js"
on a JVM prior to JDK15 specifies the native Nashorn implementation, not this one. It's a good idea to be more specific so as to avoid surprises during upgrades.
Example of a Rhino Scripted Matcher
<PermitValueRule xsi:type="Script" language="rhino">
<Script>
CDATA[
importPackage(Packages.java.util);
x = new HashSet();
x.add(attribute.getValues().iterator().next());
x;
]]>
</Script>
</PermitValueRule>