• Post Reply Bookmark Topic Watch Topic
  • New Topic

Stop singel class from accessing certain packages  RSS feed

 
Humpe Caballero
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.

I have a question I havn't been able to find the answer to. I have a dynamicly created, compiled and loaded class in my application. I want to limit that singel class possibility to use some specific packages (To prevent it from doing harmfull operations to my application like System.exit(0) and so on). I tried to use a implementation of the SecurityManager but I'm not able to detect (Atleast I don't know how) which class made the checkXXX(...). I don't want to stop my main application from using the specified packages, just one singel klass.

Help please.

/H
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

First, a bit of business: you may not have read our naming policy on the way in. It requires that you use a full, real (sounding) first and last name for your display name. Cute names and "handles" aren't acceptable here. You can change your display name here. Thanks!

Second: your SecurityManager implementation can call the inherited getClassContext() method to get an array of Class objects representing the code on the current call stack; just search this array for the classes you which to restrict.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!