RE: Security Manager perm for loading a resource

"Bordet, Simone" <[email protected]>
Newsgroups gmane.comp.java.mx4j.devel
Message-ID <[email protected]>
Hi,

> I think it would be very convenient to have some HTML text on 
> the demo site that can be changed at run-time.  That way, we 
> could modify the list of usable MBeans, or otherwise improve 
> instructions, without having to re-build and redeploy the war.

You mean like a Wiki ?
Wouldn't changing the list of MBeans require also the classes ?

> The problem with that is, I want to load it as a resource 
> (Class.getResourceAsStream()), not as a file.  I don't want 
> to load it as a file because current-working-directory is 
> very app-server dependent, but since getResourceAsStream() 
> will use the container's overridden ClassLoader, it can 
> always load files from .../WEB-INF/classes.  The idea is, 
> we'd just throw a HTML fragment file into that directory.  

So you're running with exploded war ?

> Works fine until the security manager is thrown in.  
> getResourceAsStream() just returns null-- no *Permission 
> exception is thrown.  

Yes, I find this very annoying as well.

> I can find nothing in the Java API nor 
> in the Policy File Syntax guide about granting permissions to 
> load files as resources, only about loading files from 
> filesystems or loading classes.  I tried granting 
> AllPermissions to a new codebase (corresponding to what 
> .../WEB-INF/classes will be eventually), but that doesn't 
> work.  I think that some privilege needs to be added to the 
> loading codebase, not the target codebase.  Anybody know of 
> something I can try in the policy file, or anything else?
> 
> If it just threw an exception on the getResourceAsStream, I 
> could find out what permission it is lacking.  :(

My tactic in the past was: granting AllPermission to every codebase and see if that works as I expect.
If yes, run it with -Djava.security.debug=access.failure and then spend time to find out which domain failed and for which reason.

I'm not sure what you mean by "HTML that can be changed". Can you expand on that ?

Simon


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.