0

Tomcat roles of the current user

asked 2016-04-19 09:37:04 +0800

renjithr gravatar image renjithr
1 1

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>?

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2016-05-13 08:10:25 +0800

MDuchemin gravatar image MDuchemin
1346 1 4
ZK Team

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>
link publish delete flag offensive edit
0

answered 2016-05-14 14:31:14 +0800

Darksu gravatar image Darksu
1991 1 4

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

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2016-04-19 09:37:04 +0800

Seen: 26 times

Last updated: May 14 '16

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More