Red*_*mer 1 java applet signed securityexception self-signed
我有一个在tomcat 5.5上运行的java applet.签名(-selfcert).java.security.AccessControlException: access denied (java.lang.RuntimePermission createClassLoader)
当我的Applet尝试连接到webservice(已在此行中)时,我仍然遇到异常:
ws_locator = new My_WebserviceLocator(ws_adress + "?wsdl",
new javax.xml.namespace.QName("http://impl.webservice", "My_Webservice"));
Run Code Online (Sandbox Code Playgroud)
由于这里有一些类似的问题,我读了它们:
是的,小程序已签名.我用-verify检查了它.
可能是Tomcat安全异常,但我已经添加到catalina.policy:
grant codeBase "file:/home/me/apache-tomcat-5.5.27/webapps/myapplet/-" {
permission java.security.AllPermission; };
Run Code Online (Sandbox Code Playgroud)
grant codeBase "file:/home/me/apache-tomcat-5.5.27/webapps/myapplet/applet.jar" { permission java.security.AllPermission; };
通常的东西也在那里:
grant codeBase "file:${java.home}/jre/lib/ext/-" {
permission java.security.AllPermission;
};
Run Code Online (Sandbox Code Playgroud)
没有结果.
好的,快速更新,添加:
grant{
permission java.security.AllPermission;
};
Run Code Online (Sandbox Code Playgroud)
到本地java.policy文件修复了这个问题.但这不是我想要的,applet应该在avarage机器上运行,使用dafault java.policy文件.所以它必须从代码中修复.
你是从applet主线程调用你的WS还是从使用javascript调用applet的方法启动的线程?
见下面的例子.
希望能帮助到你.
public class MyApplet extends JApplet {
@Override
public void start() {
// It will work if your applet is signed
callWebService();
}
public void methodCalledFromJavascriptWrong() {
// It will NOT work even if your applet is signed
callWebService();
}
public void methodCalledFromJavascriptGood() {
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
// It will work if your applet is signed
callWebService();
return null;
}
});
}
private void callWebService() {
//Here you call your web service
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4275 次 |
最近记录: |