-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
How can I list tomcat roles of the current user in a method that is declared in index.zul ? How can I write the method with in <zscript>?
Hi Renjithr
You can check if the user is in a role using:
Executions.getCurrent().isUserInRole("MyRole")
With this, you can apply the kind of logic shown here: http://stackoverflow.com/questions/344117/how-to-get-user-roles-in-a-jsp-servlet
A starting point could be as:
<zscript><![CDATA[
List allRoles = new ArrayList();
allRoles.add("1"); //your possible roles here
allRoles.add("2");
allRoles.add("3");
List userRoles = new ArrayList();
for (int i = 0; i < allRoles.size(); i++) {
if(Executions.getCurrent().isUserInRole((String)allRoles.get(i))) {
userRoles.add(allRoles.get(i));
}
}
]]>
</zscript>
Hello renjithr,
For future reference you could use spring security for your application as shown below:
https://www.zkoss.org/wiki/SmallTalks/2010/April/CustomizeYourZKPagesPerSpringSecurityAuthority_Roles
Best Regards,
Darksu
Asked: 2016-04-19 09:37:04 +0800
Seen: 26 times
Last updated: May 14 '16