如何在代码中添加角色,Java EE

发布于 2024-07-16 10:02:56 字数 323 浏览 2 评论 0原文

我正在使用 jboss 4.2.3 和 jaas org.jboss.security.auth.spi.DatabaseServerLoginModule。

用户登录后,我想为其添加角色。 我该怎么做?

例如,用户单击按钮并添加角色...

澄清: 我有 1 个应用程序,用户可以在其中登录。 在登录中,用户获得一些角色(来自数据库)。 之后,我想在代码中向用户添加另一个角色。 我的示例是:用户登录后,他可以单击一个按钮,然后在我的 servlet 中向该用户添加一个新角色。

看来Jboss不允许这样做,角色只能在登录模块中访问。

I'm using jboss 4.2.3 and jaas org.jboss.security.auth.spi.DatabaseServerLoginModule.

After a user is logged in I want to add a role to it. How can I do it?

For example, the user clicks in a button and a role is added...

Clarification:
I have 1 app where a user does the login. In the login the users gets some roles (from the db). After that I want to add another roles to the user in my code. My example is: after the user is logged in, he can click a button and in my servlet a new role is added to the user.

It seems Jboss doesn't allow this, roles can be accessed only in the login module.

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

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

发布评论

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

评论(1

掩饰不了的爱 2024-07-23 10:02:56

我一直在寻找这个问题的答案,我发现 JBoss 允许您以编程方式以及使用 MBean 刷新凭证缓存:

http://community.jboss.org/wiki/CachingLoginCredentials

您可以将角色添加到用户,然后刷新该用户的凭据。 据我所知,他们必须注销然后重新登录到您的应用程序; 发生这种情况后,他们将拥有您赋予他们的新角色。

如果有一种方法可以分配角色而不需要用户注销并重新登录,我想听听。

I've been looking for an answer to this problem, and I found that JBoss lets you flush the Credential Cache, programmatically and also by using a MBean:

http://community.jboss.org/wiki/CachingLoginCredentials

You can add the role to the user and then cause that user's credentials to be flushed. As far as I can tell, they have to log out and then log back in to your application; after that happens, they'll have the new role that you gave them.

If there is a way to assign the role without requiring the user to log out and back in, I'd like to hear about it.

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