I'm putting a couple of pieces together here that weren't in one place. When introducing Rhino javascript engine into our code, we wanted to lock down its access. Java 6 hides the internal Rhino context well enough that I couldn't figure out how to get at it. So to restrict access to a given set of classes when running untrusted Javascript inside the JVM you need to start your own Rhino context up, then hook in the filter.
The useRhinoDirectly() method gives a Rhino context in which we can set up a class filter:
http://stackoverflow.com/questions/4639892/whats-the-difference-between-java-6s-built-in-version-of-rhino-and-the-rhino-pa
Building the class filter is easier standing on someone else's shoulders. This example blocks access to static methods:
http://riven8192.blogspot.com/2010/07/java-rhino-fine-grained-classshutter.html
(Not sure which Text class this was using, but String.split() seemed to do the job.)
title
fire chief's random developer tidbits
Thursday, February 24, 2011
Wednesday, February 9, 2011
Most awesome error message ever
Trying to list the contents of a keystore I got the most awesome error message ever:
$ keytool -list -keystore keystore.jks
$ keytool -list -keystore keystore.jks
keytool error: gnu.javax.crypto.keyring.MalformedKeyringException: incorrect magic
uh, what?
$ which keytool
/usr/bin/keytool
Also notice it has "gnu" in the class name. The path /usr/bin wins over the later path /opt/jdk1.6.0_21/bin which is the keytool I actually wanted since I'm using Sun and not GNU.
Friday, February 4, 2011
Wicket deployment vs. development mode with Maven build
pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
...
<webResources>
<webResource>
<directory>${basedir}/src/main/webapp/WEB-INF</directory>
<includes>
<include>web.xml</include>
</includes>
<targetPath>WEB-INF</targetPath>
<filtering>true</filtering>
</webResource>
</webResources>
</configuration>
</plugin>
...
<profiles>
<profile>
<id>dev</id>
<properties>
<wicketconfig>development</wicketconfig>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>release</id>
<properties>
<wicketconfig>deployment</wicketconfig> <!-- variable in web.xml -->
</properties>
</profile>
</profiles>
web.xml:
<filter>
<filter-name>WicketApplication</filter-name>
<filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
<init-param>
<param-name>applicationClassName</param-name>
<param-value>com.rootAppClassNameGoesHere</param-value>
</init-param>
<init-param>
<param-name>configuration</param-name>
<param-value>${wicketconfig}</param-value>
</init-param>
</filter>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
...
<webResources>
<webResource>
<directory>${basedir}/src/main/webapp/WEB-INF</directory>
<includes>
<include>web.xml</include>
</includes>
<targetPath>WEB-INF</targetPath>
<filtering>true</filtering>
</webResource>
</webResources>
</configuration>
</plugin>
...
<profiles>
<profile>
<id>dev</id>
<properties>
<wicketconfig>development</wicketconfig>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>release</id>
<properties>
<wicketconfig>deployment</wicketconfig> <!-- variable in web.xml -->
</properties>
</profile>
</profiles>
web.xml:
<filter>
<filter-name>WicketApplication</filter-name>
<filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
<init-param>
<param-name>applicationClassName</param-name>
<param-value>com.rootAppClassNameGoesHere</param-value>
</init-param>
<init-param>
<param-name>configuration</param-name>
<param-value>${wicketconfig}</param-value>
</init-param>
</filter>
Subscribe to:
Posts (Atom)