我可以从客户端检测当前用户有权使用哪些 EJB 吗?

发布于 2024-07-15 17:44:40 字数 416 浏览 7 评论 0原文

我的 J2EE 服务器上有各种 EJB,它们具有不同的安全角色。

现在,在 Java Swing 客户端应用程序中,当我将用户登录到服务器时,我想发现用户可以访问哪些 EJB,而无需实际尝试创建或调用它们。

我想要这样做的原因是根据可用的 EJB 来调整用户界面。

例如,如果当前用户可以使用“AdministerMetadata”EJB,我想显示一个用于管理元数据等的菜单选项。

我可以从客户端内已知 EJB 的预定义列表中进行查询,因此我不需要这样它就完全动态了。

我不想创建一个特殊的 EJB 来仅返回此访问信息,并且我想避免必须尝试调用方法并捕获异常来进行发现。

我计划在 JBoss 上使用该解决方案,但如果可能的话更喜欢标准解决方案。

这可能吗? 如果是这样怎么办?

I have various EJBs on a J2EE-server, with different security roles.

Now, from a Java Swing client application, when I log the user on to the server, I would like to discover which of these EJBs that are accessible to the user, without actually trying to create them or invoke them.

The reason I want to do this is to adjust the user interface depending on which EJBs are available.

For instance, if the "AdministerMetadata" EJB is usable by the current user, I want to display a menu option for administering metadata etc.

It is acceptable for me to query from a predefined list of known EJBs within the client, so I dont need it to be totally dynamic that way.

I dont want to create a special EJB to just return this access-information, and I want to avoid having to try to call methods and catch Exceptions to do the discovery.

I am planning on using the solution on JBoss, but would prefer a standard solution if possible.

Is this possible? If so how?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

So尛奶瓶 2024-07-22 17:44:40

据我所知,J2EE 中没有任何内容可以在客户端为您提供此信息。 即使在服务器端 EJBContext只会为您提供调用者拥有的角色以及调用者的主体(例如登录名)。

我认为除了拥有一个额外的会话 Bean 之外别无他法,您可以在客户端查询该会话 Bean,并检查服务器端的 EJBContext 以告诉客户端当前用户拥有哪些角色。

As far as I know there is nothing in J2EE which would provide you this information at the client side. Even at the server side EJBContext will give you just the roles the caller owns as well as the caller's principal (e.g. login name).

I see no other way than to have an extra Session Bean which you can query on the client side and which will inspect the EJBContext on the server side to tell the client which roles the current user owns.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文