没有 SecurityManager 的 Java RMI

标签 java security rmi

我有一些不使用 SecurityManager 但使用 RMI 的旧代码。据我所知,RMI 需要一个安全管理器,但代码似乎可以在同一台机器上和两台机器之间正常运行。我已经在 1.5 上测试过这些东西,但没有在 1.6 上测试过。

我找不到任何资源讨论什么时候需要 SecurityManager 什么时候不需要,或者该要求是否随 Java 版本而改变。

我打算更新代码使用一个,我只是想了解它背后的细节。

感谢任何反馈!

最佳答案

只有在 RMI 从远程机器下载代码时才需要安全管理器。如果客户端和服务器都使用相同的类,则不需要。

来自 RMI Tutorial :

A security manager determines whether downloaded code has access to the local file system or can perform any other privileged operations.

If an RMI program does not install a security manager, RMI will not download classes (other than from the local class path) for objects received as arguments or return values of remote method invocations. This restriction ensures that the operations performed by downloaded code are subject to a security policy.

关于没有 SecurityManager 的 Java RMI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2298853/

相关文章:

java - Java 1.8 中的 switch-case 与 Eclipse 不可能吗?

java - 如何将用户输入的数字添加到字符串的末尾以选择特定对象

iphone - iOS 中应用程序间通信的安全性如何?

c# - MVC 字段级安全

java - 停止 RMI 服务器 (Java)

java - 什么时候是使用应用服务器的合适时机?

java - 从 IntelliJ 中的 groovy 测试文件创建 Java 类

java - 反转数组的元素

c# - 阻止用于访问资源的危险 IP

java - 使用具有临时端口的 JMX 服务器时,如何获取服务器端口号?