Tuesday, 15 June 2010

securitymanager - Java : Is there an API to find which class needs the permission in a Custom security manager class? -



securitymanager - Java : Is there an API to find which class needs the permission in a Custom security manager class? -

i'm trying find class has requested permission dynamically in custom security manager. not able find api helps me codebase location of invoking class. below i'm trying do,

i have testapp class tries write file,

package test.profilingsecuritymanager; import java.io.printwriter; public class testapp { public static void main(string [] args) throws exception { system.setsecuritymanager(new newprofilingsecuritymanger()); printwriter author = new printwriter("profile.txt"); writer.println("test line"); writer.close(); } }

the over-ridden method in custom security manager below,

public void checkpermission(final permission permission) { seek { // see parent security manager code says super.checkpermission(permission); } grab (exception e) { // find code base of operations requested permission // can phone call stack here class [] sourceclasses = getclasscontext(); class invokingclass = sourceclasses[sourceclasses.length - 1]; // can accesscontrol context here // using -accesscontroller.getcontext() // how find codebase location of class // needed permission here } }

i need find codebase location of testapp when exception thrown within checkpermission method. 1 help me out on how this?

thanks

java securitymanager

No comments:

Post a Comment