hi Kris.<br><br>Well, you can't bind a variable to a new instance on the LHS - on the LHS you have no control over when conditions are evaluated, so the value of "now" would not necessarily be what you think.
<br><br>Nevertheless, I can see what you want:<br><br><br>rule CanDoHisStuff<br> activation-group "permissions"<br>when<br> c: PermissionCheck(name == "stuff", action == "do", granted = false)
<br><br><div id="mb_0"> ap: AppProps(startDate < ( now() ), endDate > ( now() ) )<br> Role(name == "A Role")<br><br>then<br> c.grant();<br>end;</div><br>this assumes you have a function :<br><br>function Date now()
<br> return new Date();<br>end<br><br>(I havent' tested this, just a suggestion).<br><br><br><div><span class="gmail_quote">On 3/8/07, <b class="gmail_sendername">Rented User</b> <<a href="mailto:rented@gmail.com">
rented@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi,<br><br>I'm mew to this rules stuff, and although I've looked at rules engines such as Corticon before, I got introduced to JBoss Rules through JBoss Seam's security mechanism.
<br><br>I'm trying to expand on Seam's built in functionality to assess a user's permissions. My use case is that a user of the system may or may not have permission to a resource based on the user's role AND the current date. The system accepts certain actions only if "now" is between a certain start and end date. What I'd like to do is something like this:
<br><br>rule CanDoHisStuff<br> activation-group "permissions"<br>when<br> c: PermissionCheck(name == "stuff", action == "do", granted = false)<br> now: new Date() <--------------------------------------------------------------How can I accomplish this?
<br> ap: AppProps()<br> Role(name == "A Role")<br> eval(now >= ap.startDate, now <= ap.endDate) <br>then<br> c.grant();<br>end;<br><br>Now, I understand that in my code, I could assert an object "now". However, a lot of the security is hidden behind the scenes in Seam. For example, this rules will be fired from an XML definition file.
E.g.<br><br> <page view-id="/restricted/doStuff.xhtml"><br> <restrict>#{s:hasPermission('stuff', 'do', null)}</restrict><br> <navigation from-action="#{
createStuffManager.yesConfirmSave}"><br> <end-conversation/><br> <redirect view-id="/restricted/viewStuff.xhtml"/><br> </navigation><br> </page><br>
<br>While I could start extending Seam's security model, that seems a bit invasive for such a simple task.<br><br>Thanks<br><br>/Kris<br><br><br><br>
<br>_______________________________________________<br>rules-users mailing list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br><a onclick="return top.js.OpenExtLink(window,event,this)" href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">
https://lists.jboss.org/mailman/listinfo/rules-users</a><br><br></blockquote></div><br>