Secure Mobile Script

pnuts.ext.PnutsClient class

pnuts.ext.PnutsClient class provides a high level interface to access remote scripts through the JDK1.2 security model. This class is useful to implement a secure script environment, in which Pnuts scripts can be executed safely like Java applet.

Also, pnuts.ext.PnutsClient class provides a command line interface to load a script from the specified URL.

Before using this API, pnuts.jar and pnuts-ext.jar should be in the $JRE/lib/ext directory, and -Djava.security.manager option should be given to the java command.

java -Djava.security.manager pnuts.ext.PnutsClient \
    http://www.etale.com/pnuts/examples/awt/hello.pnut

When the URL is behind a firewall, -Dhttp.proxyHost=host and -Dhttp.proxyPort=port should be specified.

Constructor

pnuts.ext.PnutsClient(URL codebase)

This constructor associates the specified codebase with the instance. The codebase is used to determine permissions for security sensitive actions of scripts.

Instance Methods

eval(String expr [, Context context ] )
load(InputStream in [, Context context ] )
load(Reader in [, Context context ] )
loadFile(String filename [, Context context ] )

These methods correspond to static methods of pnuts.lang.Pnuts class with the same names respectively.

import("pnuts.ext.*")
import("java.net.*")

client = PnutsClient(URL("http://202.32.138.49/pnuts/"))

client.eval("s = class java.net.URL(\"http://localhost/pnuts/examples/awt/hello.pnut\")")
client.eval("read(s.openStream())")
         ==> access denied

client.eval("s = class.java.net.URL(\"http://202.32.138.49/pnuts/examples/awt/hello.pnut\")")
client.eval("read(s.openStream())")
         ==> succeed

Back