-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello,
I'd like to know if is there a way to verify if the user has the necessary roles from a zul file? Just like the spring security plugin for Grails: http://www.grails.org/AcegiSecurity+Plugin+-+Artifacts
It would be nice to do something like this:
<security:ifAllGranted role="ROLE_ADMIN,ROLE_SUPERVISOR">
<button label="Special Button"/>
</security:ifAllGranted>
If those tags doesn't exists, how do you do this kind of authorization? Hide parts of the page that the user doesn't have access.
Regards,
Felipe Cypriano
you could register a xel method which calls the method ifAllGranted on the taglib, then use if and unless as pointed by edgar
What is a xel method and how could I register it?
Regards,
Felipe Cypriano
Thank you Edgar and madruga.
Register this xel method:
<?xel-method prefix="sec" name="userHasAuthority" class="org.springframework.security.util.AuthorityUtils" signature="boolean userHasAuthority(java.lang.String)"?>
Then if you need to show a button only to a certain role, you can use it as following:
<zul:button label="EDIT" if="${sec:userHasAuthority('ROLE_SUPERVISOR')}"/>
Asked: 2009-07-03 17:38:51 +0800
Seen: 379 times
Last updated: Jul 15 '09