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.
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
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:
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.