I'm playing around with a custom class loader and granting permissions to the classes loaded (without a policy file)
I have the following class that sets up a custom permission and loads another class with that permission (The "getPermissions" override in my classloader adds this permission to the class being loaded).
Inside the loaded class I check for this permission but it always fails. I have overrided the "implies" method and it looks like the permissions are being checked and the function is returning true (meaning that the permission loaded does "imply" the one I am checking. Nevertheless, the call to AccessController.checkPermission throws an AccessControlException with "access denied".
Can someone kindly look through my code and tell me where I'm going wrong?
First my permission class
Now my loader class (and main entry point)
Here's the class that is loaded and checks the permission
And here's the console output - as you can see the permissions look ok and implies returns true, but an exception is still caught.
Permission granted: (testprotected.MyPermission fooby.runCode)
Permission to check: (testprotected.MyPermission fooby.runCode)
Inside the implies method
This - Name:fooby.runCode - Hash:-1934868025
That - Name:fooby.runCode - Hash:-1934868025
Return from implies - true
Sorry, you dont have permission access denied (testprotected.MyPermission fooby.runCode)
Details (testprotected.MyPermission fooby.runCode)
Any help would be great.>