For Programmers: Free Programming Magazines  


Home > Archive > Java Security > October 2004 > Policy file in a Jar









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Policy file in a Jar
James Poli

2004-10-13, 8:57 pm

Is there way to specify a policy file in a jar? I've tired different
url for this and can't seem to get it to work.

For example:

jar:file:c:\test.jar!\policy.file

doesn't work
Remi Bastide

2004-10-14, 4:00 pm

James Poli <James.Poli@sas.com> wrote:

>Is there way to specify a policy file in a jar? I've tired different
>url for this and can't seem to get it to work.
>
>For example:
>
>jar:file:c:\test.jar!\policy.file
>
>doesn't work


I've received (by email) the following answer to the same question a
while ago :

It is possible to include a policy file within a jar, and the
ClassLoader provides an elegant way to access it. Assuming a client
policy file with the name client.policy in a subdirectory of the jar
called "other" it is possible to obtain a URL to the policy by doing
the following:

ClassLoader cl = getClass().getClassLoader(); URL policyURL =
cl.getResource("other/client.policy");

then set the policy by doing:

System.setProperty("java.security.policy",policyURL.toString());

and finally set the security manager:

System.setSecurityManager(new RMISecurityManager());



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com