views:

219

answers:

1

Hello,

I'm developing a web application and have created a war file. If I deploy it to my tomcat server, it is used without being unpacked (which is the setting I want to have for this server).

For unpacked web apps I have a policy file to grant AllPermission to my application. The file is served with the application and installed into e.g. /etc/tomcat5.5/policy.d/40tc.policy. It contains these lines:

grant codeBase "file:${catalina.base}/webapps/tc/-" {
    permission java.security.AllPermission;
};

But what has the codeBase to be for packed war files? The war file is located at ${catalina.base}/webapps/tc.war

I've tried the following:

grant codeBase "file:${catalina.base}/webapps/tc.war" {
    permission java.security.AllPermission;
};

and

grant codeBase "jar:file:${catalina.base}/webapps/tc.war" {
    permission java.security.AllPermission;
};

But nothings works. There are several permissions that must be granted, so AllPermission should be set for only the application. (Global changes in the server configuration are not allowed.)

Any suggestion what to do next?

Thanks, André

A: 
grant codeBase "file:${catalina.base}/webapps/tc.war" { 
permission java.security.AllPermission; 

};

Is this what you're looking for?

JoseK
I already tried this one. But it does not work. Result is the same:java.security.AccessControlException: access denied (java.util.PropertyPermission user.dir read)
André
Ah - you should post the complete stack trace as well in the post. Is your code trying to access the "user.dir" referred in the error?
JoseK
In catalina.policy, can you add this line within the ========== WEB APPLICATION PERMISSIONS ======== block permission java.util.PropertyPermission "user.dir", "read";
JoseK
"user.dir" is not the only Permission that shall work (FilePermission, ...). My installer provides a single .policy file for the application and that should be configured to grant AllPermission. The settings should not affect other applications of the tomcat server.
André
So you have tried putting the policy entry in the webapps individual policy file as well?grant codeBase "file:${catalina.base}/webapps/tc.war" { permission java.security.AllPermission; };
JoseK
Yes, I tried the code from your answer in the policy file. And I also changed the codeBase to "jar:file:${catalina.base}/webapps/tc.war" which didn't work either.
André
I suggest that you post the full path and name of the war file, as well as error stack trace so someone might be able to help
JoseK
K, I've edited my question. Hopefully there is someone out there that has the answer I'm looking for. Thanks for you help.
André
Okay one more option I've seen is with trailing !/- like grant codeBase "jar:file:${catalina.base}/webapps/tc.war!/-" {
JoseK
I tried this option but had no success. Seems that this is not possible.
André