Results 1 to 2 of 2
  1. #1
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default Preventing dynamically loaded classes from using reflection

    I'm writing a program that will allow the user to dynamically load and execute classes that extend a certain class. Plugins, basically. I want to prevent those classes (or the threads running them, if that's the way to do it) from using reflection to access parts of the program they shouldn't. I want to apply these restrictions to every class loaded by my custom ClassLoader.

    I found a thread on SO that suggests it might be possible. But I don't really know where to start reading. Everything I'm finding is about applet permissions. Any pointers?

    Edit: Here's a person with a similar question. But I don't understand or trust the solution. It seems kind of hackish. And this thread looks promising, but it's a lot to take in and the commenters were conflicted about the right way to do it.
    Last edited by kjkrum; 04-14-2012 at 04:46 AM.
    Get in the habit of using standard Java naming conventions!

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default Re: Preventing dynamically loaded classes from using reflection

    The last link: this thread using a SecurityManager and testing the Permissions looks like a good possibility.

    You're right about the details mention at that link. It does look complicated. It seems that "hackers" find ways around a lot of security barriers. You should be able to raise the security bar high enough to keep out most programmers.
    Last edited by Norm; 04-14-2012 at 01:58 PM.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Replies: 0
    Last Post: 06-30-2011, 04:46 PM
  2. Dynamically interpreting/importing code/classes
    By ~ in forum Advanced Java
    Replies: 1
    Last Post: 04-27-2011, 05:06 AM
  3. Preventing stack overflow?
    By bobocheez in forum New To Java
    Replies: 11
    Last Post: 01-05-2011, 06:50 PM
  4. Preventing exceptions
    By ieoj31 in forum New To Java
    Replies: 3
    Last Post: 11-15-2010, 02:33 PM
  5. Java reflection: find serializable classes in package
    By andrew222 in forum Advanced Java
    Replies: 2
    Last Post: 02-27-2010, 08:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •