如何为此线程而不是系统设置 SecurityManager?
我有一个程序在其所有线程中运行基本的 RMISecurityManager。 但我想对多个线程进行更多控制,并专门为这些线程设置另一个 SecurityManager。
我怎样才能做到这一点 ? ...如果这可能的话!?
提前谢谢你。
编辑:我找到了我的解决方案。 请参阅此处了解更多详细信息。
I have a program that is running a basic RMISecurityManager in all its threads. But I would like to do more control to several threads and set another SecurityManager specially for these threads.
How can I do that ? ...if this is possible !?
thank you by advance.
Edit : I have found my solution. See here for more details.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这没有多大意义。 如果代码(无论是否恶意)导致在不同的线程上执行怎么办? 这甚至可能发生在 Java 库中,传输安全上下文(可能使用 java.security.AccessController.getContext/doPrivileged)。
Applet 确实使用了涉及 ThreadGroup 的稍微困难的系统,但我不推荐它。 JAAS 允许将
Subject
添加到AccessControlContext
中,但我个人建议不要使用这种编程风格。为下载的代码(如果有)提供适当的权限,并且不要将敏感对象提供给您不信任的代码。
It doesn't make a great deal of sense. What if code (malicious or not) causes execution on a different thread? This can even happen within the Java library, with security context transferred (which may use
java.security.AccessController.getContext
/doPrivileged
).Applets do use a slightly difficult system involving
ThreadGroup
s, but I wouldn't recommend it. JAAS allows aSubject
to be added to theAccessControlContext
, but personally I'd suggest not using this style of programming.Give downloaded code (if any) appropriate permissions, and don't give sensitive objects to code you don't trust with them.
SecurityManager 根据正在运行的线程的安全上下文执行检查,也许您想让您的 SecurityManager 根据它在上下文中找到的内容表现出不同的行为?
或者,您可能想使用策略模式来实现 SecurityManager 。
yc
The SecurityManager performs checks based on the security context of the running thread, perhaps you want to make your SecurityManager to behave differently based on whatever it finds in the context?
Or maybe, you want to implement your SecurityManager using the strategy pattern.
yc