Security Manager perm for loading a resource

Blaine Simpson <[email protected]>
Newsgroups gmane.comp.java.mx4j.devel
Message-ID <[email protected]>
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.

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.  Works fine until the security manager is
thrown in.  getResourceAsStream() just returns null-- no *Permission
exception is thrown.  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.  :(


There are a couple fallback strategies, both of which have
undesirable consequences which I won't discuss until the need
arises (or hopefully doesn't).  Could display this text in
another frame, so it'd be loaded by an independent GET.  Could
have a web.xml param specifying the HTML fragment file.  The
web.xml param would need to be set in step with a corresponding
FilePermission in the policy file.


-- 
Don't pray in my school, and I won't think in your church.
ICF:  703-934-3692       Cell:  703-944-9317


-------------------------------------------------------
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_id=1470&alloc_id=3638&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.