View Full Version : JSR223 context issue?

02-11-2010, 07:11 PM
We're trying to use quercus as a JSR-223 compliant scripting language with Shibboleth (a java based web SSO package). In addition to being an SSO, Shibboleth provides "attribute" information about users for the purposes of making authorization decisions. Attribute values can be generated by JSR-223 compliant languages...


My php script can see the information passed into it..

But attribute data modified by the script doesn't make it back out of the script.

import edu.internet2.middleware.shibboleth.common.attribu te.provider.BasicAttribute;
$phpAttr = new BasicAttribute("phpAttr");
$phpAttr->getValues()->add("some value");

Other than invoking $attr->getValues()->add(), one shouldn't have to do anything to make the information available to the application. The equivalent script in ECMAscript would be..

importPackage(Packages.edu.internet2.middleware.sh ibboleth.common.attribute.provider);
jsAttr = new BasicAttribute("jsAttr");
jsAttr.getValues().add("some value");

I'm not that Java savvy, but the Shib developers suggested that it could be a "context" issue.
The JSR-223 APIs have you pass in a processing context in to the script execution engine. This context contains a map where the keys are the attribute IDs and the values are the created objects. The keys then get changed in to variables within the script.

Shibboleth can see the updated value in the other JSR-223 compliant languages I've tried (jython, jruby, ECMAscript, groovy). My example script is essentially the same across all languages.

I'd really like to be able to use PHP/Quercus for this purpose (PHP being my language of choice). I'm not sure if the behavior I'm seeing with Quercus is a bug or a configuration option.

I'm open to suggestions.
University of Michigan

02-12-2010, 10:59 AM
In PHP 5.3 / JavaBridge you can use:

use edu\internet2\middleware\shibboleth\common\attribu te\provider\BasicAttribute as ShibBasicAttribute;


And in Quercus you can use:

java_context()->getBindings(100)->add(someKey, someVal);

It may be some Quercus name space issue.


02-12-2010, 03:04 PM
I'm not sure I follow.

Wouldn't the combination of PHP5.3 + JavaBridge obviate the need for Quercus?

Should java_context() work in quercus? I get..

Exception in thread "main" com.caucho.quercus.QuercusErrorException: eval::14: Fatal Error: 'java_context' is an unknown function.

02-12-2010, 11:13 PM
Wouldn't the combination of PHP5.3 + JavaBridge obviate the need for Quercus?

I don't think so. Why do you ask?

Should java_context() work in quercus?

Ah, soirry. I have tested this in PHP 5.3 only. I guess Quercus exports the jsr223 context under a different name.

You can access the jsr script bindings directly. And you shouldn't call new and discard the created object at the end of the script.

02-17-2010, 06:17 PM
You can access the jsr script bindings directly.

Are there docs or examples showing how to do it?

Nothing context related jumped out of me in the Quercus docs I've seen (http://quercus.caucho.com/quercus-3.1/)

And you shouldn't call new and discard the created object at the end of the script.

I have to call new. If I don't, this fails...
$phpAttr->getValues()->add("some value")
...with a Fatal Error: Method call 'getValues' is not allowed for a null value

02-21-2010, 04:43 AM
I've filed a bug report for this at:


You may retrieve java classes with:

$sys = java_class("java.lang.System");
$time = $sys->nanoTime();

06-02-2010, 02:13 AM
functionShowFilespath : String : String;varclicked : Command;s, p, i : integer;files : String;beginShowFiles := ;repeatShowMenupath, CH_IMPLICIT;addCommandcmdOk;addCommandcmdSelect;if lengthpath<>0 then begini := menuAppendString..;files := jsr75.get_dirspath;files := filesjsr75.get_filespath;end elsefiles := jsr75.get_roots;p := posfiles, ;while p>0 do begini := menuAppendStringcopyfiles, 0, p;files := copyfiles, p1, lengthfiles;p := posfiles, ;end;repeat clicked := getClickedCommand; until clicked <> emptyCommand;path := path ui.list_get_stringmenuGetSelectedIndex; until clicked = cmdSelect;ShowFiles := path;end;нет хождения назад, но думаю это и сам можешь сделать.