How to programmatically grant AllPermissions
to an RMI application without using policy file?
UPDATE:
After some researching, I have written this custom Policy Class and installed it via Policy.setPolicy(new MyPolicy())
.
Now I get the following error:
invalid permission: (java.io.FilePermission \C:\eclipse\plugins\org.eclipse.osgi_3.7.0.v20110613.jar read
class MyPolicy extends Policy {
@Override
public PermissionCollection getPermissions(CodeSource codesource) {
return (new AllPermission()).newPermissionCollection();
}
}
Based on @EJP's advice, I have debugged using
-Djava.security.debug=access
and found all the needed permissions in a policy file :But because I didn't want to create a policy file, I found a way to replicate this programmatically by extending
java.security.Policy
class and setting the policy at the startup of my application usingPolicy.setPolicy(new MinimalPolicy());