Security 小程序访问控制问题
我有一个小程序,它依次连接到服务器进行文件写入。当我尝试使用localhost连接到服务器时: 它在我的机器上工作(服务器在同一台机器上),但在其他机器上不工作 当我尝试使用IP地址时,它在哪里都不起作用 我的小程序代码:Security 小程序访问控制问题,security,applet,Security,Applet,我有一个小程序,它依次连接到服务器进行文件写入。当我尝试使用localhost连接到服务器时: 它在我的机器上工作(服务器在同一台机器上),但在其他机器上不工作 当我尝试使用IP地址时,它在哪里都不起作用 我的小程序代码: public class dynamicTreeApplet extends JPrefuseApplet { private static final long serialVersionUID = 1L; public static int i = 1;
public class dynamicTreeApplet extends JPrefuseApplet {
private static final long serialVersionUID = 1L;
public static int i = 1;
public String dieasenameencode;
public void init() {
System.out.println("the value of i is " + i);
URL url = null;
//Here dieasesname is important to make the page refresh happen
//String dencode = dieasenameencode.trim();
try {
//String dieasename = URLEncoder.encode(dencode, "UTF-8");
// i want this piece of the code to be called
url = new URL("http://localhost:8080/docRuleTool/appletRefreshAction.do?dieasename=");
URLConnection con = url.openConnection();
con.setDoOutput(true);
con.setDoInput(true);
con.setUseCaches(false);
InputStream ois = con.getInputStream();
this.setContentPane(dynamicView.demo(ois, "name"));
ois.close();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (FileNotFoundException f) {
f.printStackTrace();
} catch (IOException io) {
io.printStackTrace();
}
++i;
}
}
java策略文件:
grant {
permission java.net.SocketPermission "*", "accept";
permission java.net.SocketPermission "*", "connect";
};
我的jar没有签名,从维护的角度来看,我也不希望它们也被签名
它在我的机器上工作(服务器在同一台机器上),但在其他机器上不工作
是的,但只有从“另一台机器”提供服务的小程序写回“另一台机器”才有意义。上面的代码有
url = new URL("http://localhost:8080/docRuleTool/appletRefreshAction.do?dieasename=");
这意味着来自其他主机的小程序正试图将数据写回可能不存在的“localhost”。相反,您的小程序应该使用更多类似于..的内容来形成URL
url = new URL(getDocumentBase(), "/docRuleTool/appletRefreshAction.do?dieasename=");
如果代码这样做,它应该能够保持沙盒状态。
另外,策略文件实际上只用于开发目的。如果代码在实际部署中需要信任,则需要对其进行数字签名 它在我的机器上工作(服务器在同一台机器上),但在其他机器上不工作 是的,但只有从“另一台机器”提供服务的小程序写回“另一台机器”才有意义。上面的代码有
url = new URL("http://localhost:8080/docRuleTool/appletRefreshAction.do?dieasename=");
这意味着来自其他主机的小程序正试图将数据写回可能不存在的“localhost”。相反,您的小程序应该使用更多类似于..的内容来形成URL
url = new URL(getDocumentBase(), "/docRuleTool/appletRefreshAction.do?dieasename=");
如果代码这样做,它应该能够保持沙盒状态。
另外,策略文件实际上只用于开发目的。如果代码在实际部署中需要信任,则需要对其进行数字签名。我的问题没有任何意义吗不要担心,如果您的问题在30分钟内没有得到回答,它是免费的!别担心,如果你的问题在30分钟内没有得到回答,那是免费的!