Update Java security policy at runtime?

北城以北 提交于 2020-01-12 18:43:50

问题


Is there a legal way to add/remove permissions to Java security policy at runtime?


回答1:


Javadoc says that Policy.refresh() for file-based policy would re-read the file. Thus, it is possible to modify system-wide policy at runtime by editing policy file and then calling Policy.refresh()




回答2:


From 1.4 dynamic ProtectionDomains can delegate to the Policy. Dynamically removing permissions from code is unlikely to make any sense. The two argument forms of AccessController.doPrivileged might also be useful.




回答3:


It is possible to set custom Policy implementation, using Policy.setPolicy() method. For example see JAAS in Action book.



来源:https://stackoverflow.com/questions/1011777/update-java-security-policy-at-runtime

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!