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 / General / May 2005

Tip: Looking for answers? Try searching our database.

Java security problem

Thread view: 
DeMarcus - 15 May 2005 23:42 GMT
Hi,

I want to do a simple plugin interface so programmers
can easily write their own plugins to my software.
However, when I use URLClassLoader to load a class
that shall represent the plugin it seems that there
are a lot of security constraints that makes the
plugin limited.

For instance I can't have inner classes in the plugin,
because that gives me an IllegalAccessError. I tried
to avoid that by calling the methods of the plugins
with means of doPrivileged(), but it didn't help.

How can I be back to normal programming again despite
I'm using URLClassLoader?

Thanks
Daniel
Lāʻie Techie - 17 May 2005 08:25 GMT
> Hi,
>
> I want to do a simple plugin interface so programmers can easily write
> their own plugins to my software. However, when I use URLClassLoader to
> load a class that shall represent the plugin it seems that there are a lot
> of security constraints that makes the plugin limited.

Most plugins are defined by a certain Interface or extend an abstract
class.  It is convenient to place all plugins within a specific directory
(often referenced by a property).  You must also somehow tell your program
which plugin(s) to load using a ClassLoader which knows where to look.

Class clazz = Class.forName("com.mycompany.MyPlugin", true, loader);
Plugin plugin = (Plugin) clazz.newInstance();

From there, only access the methods defined in your Plugin interface.

HTH,
La'ie Techie
DeMarcus - 17 May 2005 08:32 GMT
>>Hi,
>>
[quoted text clipped - 15 lines]
> HTH,
> La'ie Techie

Actually I'm doing exactly as you propose, but instead of
Class.forName() I use clazz = loader.findClass( "MyPlugin" )
where loader is a URLClassLoader.

Is there a difference in Class.forName() and loader.findClass()?


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.