Seam Drool 安全规则 - 工作记忆中的其他事实?

发布于 2024-10-06 04:33:15 字数 539 浏览 4 评论 0原文

我创建了一个名为 ApplicationLoginContext 的类,其中包含用户经过身份验证后的信息(用户名、登录时间戳、远程 IP 地址等)。我正在使用 JBoss Seam 安全规则(基于流口水)在我的申请过程中的不同时间进行授权和权限检查。有没有办法将此登录上下文类永久添加到我的安全规则的工作内存中?例如,我有一个登录事件的侦听器。在这个侦听器中,我创建登录上下文对象,并将其添加到我的安全规则工作内存中。从那里,在我的安全规则文件中,我将能够执行以下操作:

rule MyRule
...
when
  c: PermissionCheck()
  loginContext:  ApplicationLoginContext()
  // do stuff with loginContext here
then
  ...

我尝试将 ApplicationLoginContext 对象添加到会话中,但这似乎没有帮助。还有什么我应该做的吗?我不想每次进行权限检查时都必须将其作为参数包含在内。理想情况下,我想每次注射一次并完成。

想法?

I've created a class called ApplicationLoginContext that contains information about a user once they've authenticated (username, login timestamp, remote IP address, etc.) I'm using JBoss Seam security rules (based on Drools) for authorization and permission checks at various times throughout my application. Is there any way to permanently add this login context class to the working memory of my security rules? For example, I have a listener for login events. Inside this listener, I create the login context object, and add that to my security rules working memory. From there, inside my security rules file, I would be able to do things like:

rule MyRule
...
when
  c: PermissionCheck()
  loginContext:  ApplicationLoginContext()
  // do stuff with loginContext here
then
  ...

I've tried just adding the ApplicationLoginContext object to the session, but that doesn't seem to help. Is there something else I should be doing? I don't want to have to include it as a parameter every time I do a permission check. Ideally, I'd like to inject it once per session and be done.

Thoughts?

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

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

发布评论

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

评论(1

萧瑟寒风 2024-10-13 04:33:15

希望我正确理解了这个问题,但似乎您应该只创建一个具有最高显着性的规则,每次首先运行,从而插入您每次想要使用的事实对象。

rule "insert logic"
salience 100
when 
eval(true)

then
insert fact object

Hope I'm understanding the question correctly, but it seems that you should just create one rule with the highest salience that runs first each time, that as a consequence inserts the fact object that you'd like to use each time.

rule "insert logic"
salience 100
when 
eval(true)

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