[rules-users] generalize a rule in "security.drl" file

Christian Spurk Christian.Spurk at dfki.de
Thu Nov 8 04:46:23 EST 2007


Hi Mohamed!

Mohamed Mhissen wrote:
> I use restrictions to control access to my pages.
> 
> [...]
> 
> rule RestrictAccessClientEdit
> 	when
> 		check: PermissionCheck(name == "/ClientEdit.xhtml", action == "render")
>   		Role(name == "admin")
> 	then
> 		check.grant
> ();
> 
> [...] I want to generalize this restriction so to apply it to all pages 
> publishing: *Edit.xhtml
> 
> I tried like that :
> 
> *Code:*
> check: PermissionCheck(name == "/*Edit.xhtml", action == "render")

You can do this with the "matches" operator (cf. Drools manual section 
6.5.2.1.1.3.1., "Matches Operator"), e.g., like this:

check: PermissionCheck(name matches "^\/.*Edit\.xhtml$", action == "render")

HTH,
Christian



More information about the rules-users mailing list