背景
我偶然发现了我的一个旧小程序,它已经非常过时了(其中部分是 2001 年的),我真的很想让它起死回生!小程序应该在其 native 应用程序中打开一个文件(除其他外),但这不适用于最新的 Windows 版本(包括 Windows 7),它在 Windows XP.
try {
if (Class.forName("com.ms.security.PolicyEngine") != null) {
PolicyEngine.assertPermission(PermissionID.EXEC);
PolicyEngine.assertPermission(PermissionID.FILEIO);
PolicyEngine.assertPermission(PermissionID.NETIO);
PolicyEngine.assertPermission(PermissionID.UI);
PolicyEngine.assertPermission(PermissionID.USERFILEIO);
PolicyEngine.assertPermission(PermissionID.CLIENTSTORE);
}
else {
}
} catch (Throwable e) {
}
问题/解决方案
我很确定上面的代码与它有关。就像完全删除此代码然后重新签署小程序一样简单吗?或者我是否需要在签名之前使用 java.security 包重新实现它?如果我需要使用 java.security 重新实现它,仅使用类似的东西就足够了:
try {
if (Class.forName("java.security.Policy") != null) {
final Permissions permissions = new Permissions();
permissions.add( new java.security.AllPermission());
}
else {
}
} catch (Throwable e) {
}
我需要什么才能使其在 Windows 7 上运行?
该小程序使用Java 版本1.5.0 (J2SE 5.0)。
.
干杯。
更新
以下代码可以在 Windows XP 中运行,但似乎无法在 Windows 7 中执行。
String command = '"' + sDir + sFileName + '"';
Runtime myRuntime = Runtime.getRuntime();
try {
myRuntime.exec("rundll32 SHELL32.DLL,ShellExec_RunDLL " + command);
gGfx.setStatusText("File opened.");
gGfx.drawStatusBar(1);
} catch (IOException e) {
System.out.println("Error " + e.getMessage());
}
最佳答案
Is it as easy as just removing this code completely and then re-signing the applet?
这就是解决方案。
关于java - 过时的 com.ms.security 的等效安全功能是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10247760/