Java Web Start security permissions

19 views
Skip to first unread message

trongdinh

unread,
Nov 26, 2007, 7:57:00 PM11/26/07
to jsystemtrader-dev
I tried to run jsystemtrader application via JWS - Java Web Start
(http addressing) and got an access permission denied exception with
this line in ClassFinder.getClasses (used to find strategy classes and
display them on the main window)

URL[] classpath = ((URLClassLoader)
ClassLoader.getSystemClassLoader()).getURLs();

Are there any ways to find the names of the strategy classes without
using the getSystemClassLoader above? Once the names are known then
Class.forName can be used without troubles. It would be nice to run
the complete application via JWS. I am exploring the mechanism of
that. I will keep the list in touch.

nonlinear5

unread,
Nov 27, 2007, 12:13:51 AM11/27/07
to jsystemtrader-dev
Thanks, trongdinh. I wanted to enable JST for JWS, but never got to
it. It would be wonderful if that ClassLoader.getSystemClassLoader
(or its equivalent) works under 3 launch setups:

1. Loading classes from directory
2. Loading classes from JARs
3. JWS

Florent Guiliani

unread,
Nov 27, 2007, 4:09:35 AM11/27/07
to jsystemt...@googlegroups.com
trongdinh a écrit :

> It would be nice to run
> the complete application via JWS. I am exploring the mechanism of
> that. I will keep the list in touch.

Maybe we need a additionnal way to add strategy into JST. In addiction of adding
local strategy to a JST running by JWS, it would allow a user/developer to make
a checkout of the official SVN repository somewhere and a checkout of his
strategy from another SVN repository elsewhere.

Florent,

trongdinh

unread,
Nov 28, 2007, 9:30:20 PM11/28/07
to jsystemtrader-dev
I am trying various ways to list classes in a package, but for JWS,
these can work so far:

1. Have a list generated to a file or serialized
2. Have the classes put in a jar as a normal resource file (in the
resource hierarchy or in the http file system)

trongdinh

unread,
Nov 28, 2007, 10:41:21 PM11/28/07
to jsystemtrader-dev
When running with JWS the following code produces the http path to the
program's jar file like "http://host/path/JSystemTrader.jar":

String urlPath = getClass().getResource("/com/jsystemtrader/
strategy").getPath();
urlPath = urlPath.substring(0, path.indexOf('!'));

The path produced can be used to read the contents of the program's
jar file.
> > Florent,- Hide quoted text -
>
> - Show quoted text -

trongdinh

unread,
Nov 28, 2007, 10:42:28 PM11/28/07
to jsystemtrader-dev
FYI I only tested on Java 6.
> > - Show quoted text -- Hide quoted text -

trongdinh

unread,
Jun 4, 2008, 5:55:17 AM6/4/08
to jsystemtrader-dev
I had a little play on running the latest jsystemtrader with java web
start
today and got it to run. What I did are the followings:

+ added following 4 lines to the beginning of MainFrame.getImageURL
method (below the URL imgURL line)

ClassLoader cl = getClass().getClassLoader();
if (cl.getClass().getSimpleName().equals("JNLPClassLoader")) {
imgURL = cl.getResource(imageFileName.replaceAll("\\\\", "/"));
}

+ added following 10 lines to the end of ClassFinder.getClasses method
(above the Collections.sort line)

ClassLoader cl = getClass().getClassLoader();
if (cl.getClass().getSimpleName().equals("JNLPClassLoader")) {
BufferedReader strategies = new BufferedReader(new
InputStreamReader(cl.getResourceAsStream("strategies.txt")));
for (String strategy; (strategy = strategies.readLine()) !=
null;) {
String className = packageName + "." +
strategy.substring(0, strategy.lastIndexOf("."));
Class<?> clazz = Class.forName(className);
classes.add(clazz);
}
strategies.close();
}

+ generate a listing of source\com\jsystemtrader\strategy folder to a
strategies.txt file with dir /a:-d /b source\com\jsystemtrader
\strategy
\*.class > strategies.txt
+ create jsystemtrader application jar file containing binary classes
+ resources folder + strategies.txt file
+ sign jsystemtrader application jar file and library jar files with a
test/fake certificate. see
http://java.sun.com/javase/6/docs/technotes/guides/javaws/developersguide/development.html#signing
+ write a jnlp file with security set to all-permissions for example

<?xml version="1.0" encoding="utf-8"?>

<jnlp spec="1.0+" codebase="file:///c:/trader" href="trader.jnlp">
<information>
<title>Trader</title>
<vendor>Trader</vendor>
<homepage href="index.html" />
<description>Trader</description>
<offline-allowed />
</information>
<resources>
<jar href="trader.jar" main="true"/>
<jar href="liquidlnf.jar"/>
<jar href="commons-math-1.2.jar"/>
<jar href="API-9.4.jar"/>
<jar href="OTFeed.jar"/>
<jar href="jcalendar-1.3.2.jar"/>
<jar href="joda-time-1.5.jar"/>
<jar href="jfreechart-1.0.6.jar"/>
<jar href="mail.jar"/>
<jar href="jcommon-1.0.9.jar"/>
</resources>
<application-desc main-
class="com.jsystemtrader.platform.startup.JSystemTrader">
<argument>.</argument>
</application-desc>
<security>
<all-permissions/>
</security>
</jnlp>

Now I can run the application with the jnlp file and can do charts,
strategy run, optimizer like running on the desktop.

Eugene Kononov

unread,
Jun 4, 2008, 9:39:41 AM6/4/08
to jsystemt...@googlegroups.com, tron...@gmail.com
Thanks, trongdinh. I am not sure if you are aware of the JSystemTrader's "sister" project, which is JBookTrader. I've been actively working on JBookTrader for the last few months. I wonder if you have interest in making JBT web-start capable. Here is the project:
http://code.google.com/p/jbooktrader/

Trong Dinh

unread,
Jun 4, 2008, 10:06:57 PM6/4/08
to Eugene Kononov, jsystemt...@googlegroups.com
Yes, I was aware of JBookTrader's existence, even though was not thinking of it. I will look into JBookTrader soon, thanks. Anyway, here is temporary test page for anyone to run the JSystemTrader Web Start http://duc.codec.fr/trader/index.html & http://duc.codec.fr/trader/trader.jnlp . The security certificate is bogus of course. I have only tested the backtest functionalities of it, using the historical data stored locally.
 
Cheers,

Trong Dinh

unread,
Jun 5, 2008, 12:11:02 AM6/5/08
to Eugene Kononov, jsystemt...@googlegroups.com
JBookTrader can now also be run from the same page as above. (direct link: http://duc.codec.fr/trader/trader.jnlp). I also did the same number of configuration steps with it as with JSystemTrader. I have only tested the backtest functionality of it.

Reply all
Reply to author
Forward
0 new messages