Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Security / February 2004

Tip: Looking for answers? Try searching our database.

Minimum permissions to load a class

Thread view: 
JK - 12 Feb 2004 12:58 GMT
Hi,

does anybody know what permissions I have to set to load a class using
the URLCLassLoader? The following code works without security manager

    String path = "file:///home/user/dir_of_class/";
    URLClassLoader loader = URLClassLoader.newInstance
      (new URL[] { new URL(path) });
    Class c = loader.loadClass("A");

but when I set a security manager it does not. I have already set the policy

grant codebase "file:///home/user/dir_of_loader_app/"
{
  permission java.io.FilePermission
"file:///home/user/dir_of_class/-","read";
  permission java.lang.RuntimePermission "*"
};

Unfortunately, the class loader just throws a ClassNotFoundException
instead of a SecurityException, so I can't figure out what is missing.
Or do I really have to set AllPermission?

Regards
JK.
JK - 12 Feb 2004 15:54 GMT
OK,I found it myself. I shouldn't set an URL in the FilePermission, so
    permission java.io.FilePermission
        "file:///home/user/dir_of_class/-","read";"file:///..."
should be
    permission java.io.FilePermission
        "/home/user/dir_of_class/-","read";"file:///..."

JK

> Hi,
>
[quoted text clipped - 22 lines]
> Regards
> JK.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.