对于Java应用程序:
实际上,对于JDownloader案例,这是一个模块化设计。托盘图标是一个可从以下位置禁用的插件:
JDownloader→附加组件→附加组件管理器→扩展→取消选中JD Light Tray的激活框
对于一般的Java应用程序,可以通过编写自定义策略规则来使用Java安全管理器。
在以下位置创建java.policy
文件~/.jdownloader
:
grant codeBase "file:/home/user/.jdownloader/-" {
// full access
// permission java.security.AllPermission;
// AWTPermission full or only selected elements from it
// permission java.awt.AWTPermission "*";
permission java.awt.AWTPermission "accessClipboard";
permission java.awt.AWTPermission "accessEventQueue";
// permission java.awt.AWTPermission "accessSystemTray";
permission java.awt.AWTPermission "createRobot";
permission java.awt.AWTPermission "fullScreenExclusive";
permission java.awt.AWTPermission "listenToAllAWTEvents";
permission java.awt.AWTPermission "readDisplayPixels";
permission java.awt.AWTPermission "replaceKeyboardFocusManager";
permission java.awt.AWTPermission "setAppletStub";
permission java.awt.AWTPermission "setWindowAlwaysOnTop";
permission java.awt.AWTPermission "showWindowWithoutWarningBanner";
permission java.awt.AWTPermission "toolkitModality";
permission java.awt.AWTPermission "watchMousePointer";
// Added by try and learn
permission java.io.FilePermission "/-", "read,write,delete";
permission java.util.PropertyPermission "*", "read,write";
permission java.util.logging.LoggingPermission "control";
permission java.lang.RuntimePermission "*";
permission java.net.NetPermission "*";
permission java.security.SecurityPermission "*";
permission javax.net.ssl.SSLPermission "*";
permission java.net.SocketPermission "*", "connect,resolve";
permission java.lang.reflect.ReflectPermission "*";
};
修改jdownloader
启动脚本以使用自定义策略
sudo nano /usr/bin/jdownloader
添加:-Djava.security.manager -Djava.security.policy=java.policy
至java命令调用:
exec java ${JAVA_OPTIONS} -Djava.security.manager -Djava.security.policy=java.policy -jar JDownloader.jar $*
这些是允许我启动jdownloader的最低要求。您可能需要添加更多权限。因为没有deny
选择,所以您必须编写所有必需的grant
规则。
参考文献:
顺便说一句,尝试通过添加//
到行的开头来注释规则之一;这样您就可以看到拒绝权限错误的样子。它告诉您应该添加哪个权限。还要注意,在寻找快速解决方案时,我已经使用了很多-
&*
试图扩展规则(AllPermission
无论如何都是默认值),而且我也不想让应用程序入狱。
下面是一个模板,尝试授予所有可能的权限:
grant codeBase "file:/home/user/.jdownloader/-" {
// permission java.security.AllPermission;
// permission java.awt.AWTPermission "*";
permission java.awt.AWTPermission "accessClipboard";
permission java.awt.AWTPermission "accessEventQueue";
// permission java.awt.AWTPermission "accessSystemTray";
permission java.awt.AWTPermission "createRobot";
permission java.awt.AWTPermission "fullScreenExclusive";
permission java.awt.AWTPermission "listenToAllAWTEvents";
permission java.awt.AWTPermission "readDisplayPixels";
permission java.awt.AWTPermission "replaceKeyboardFocusManager";
permission java.awt.AWTPermission "setAppletStub";
permission java.awt.AWTPermission "setWindowAlwaysOnTop";
permission java.awt.AWTPermission "showWindowWithoutWarningBanner";
permission java.awt.AWTPermission "toolkitModality";
permission java.awt.AWTPermission "watchMousePointer";
permission javax.sound.sampled.AudioPermission "*";
permission javax.security.auth.AuthPermission "*";
// permission javax.security.auth.kerberos.DelegationPermission "";
permission javax.xml.bind.JAXBPermission "*";
permission java.nio.file.LinkPermission "hard";
permission java.nio.file.LinkPermission "symbolic";
permission java.util.logging.LoggingPermission "control";
// permission java.lang.management.ManagementPermission "*";
permission javax.management.MBeanServerPermission "*";
permission javax.management.MBeanTrustPermission "*";
permission java.net.NetPermission "*";
permission java.util.PropertyPermission "*", "read,write";
permission java.lang.reflect.ReflectPermission "*";
permission java.lang.RuntimePermission "*";
permission java.security.SecurityPermission "*";
permission java.io.SerializablePermission "*";
permission java.sql.SQLPermission "*";
permission javax.net.ssl.SSLPermission "*";
permission javax.management.remote.SubjectDelegationPermission "*";
permission javax.xml.ws.WebServicePermission "*";
// permission "*";
permission java.io.FilePermission "/-", "read,write,execute,delete,readlink";
permission javax.management.MBeanPermission "*", "*";
// permission javax.security.auth.PrivateCredentialPermission "", "read";
permission javax.security.auth.kerberos.ServicePermission "*", "initiate,accept";
permission java.net.SocketPermission "*", "accept,connect,listen,resolve";
permission java.net.URLPermission "*";
};
注意事项:
Java Policy Tools是用于编辑策略文件的GUI工具。它使从下拉框中找出所有可用选项更加容易。它应该已经与Java软件包一起安装。