开发者

Seam Drool Security Rules - Additional Facts in Working Memory?

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?


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜