• Post Reply Bookmark Topic Watch Topic
  • New Topic

Multiple roles in securit-role-ref

 
Anna Madhusudhanan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
In my applcation Some of the users belongs to manager1 and some of the users belongs manager2.

The following is the existing code.

if (request.isUserInRole("manager1")) {
//do the process1
}

Now i want to change the code to do the process1 for manager2 also.

so i need to add the following condition in my code:

if (request.isUserInRole("manager2")) {
//do the process1
}

it works fine. But i don't want to change my code frequenlty. Becuase tomorrows i need to add the for managerXYZ for the same process.

so i changed in my servlet code as:

if (request.isUserInRole("MANAGER")) {
//do the process1
}

in the web.xml i changed as follows:

<security-role-ref>
<role-name>MANGAER</role-name>
<role-link>manager1</role-link>
</security-role-ref>

<security-role-ref>
<role-name>MANAGER</role-name>
<role-link>manager2</role-link>
</security-role-ref>

but it is not working as expected way. only manager2 users is successful, not for manager1. I think the manager2 is override the manager1.
How can i make multiple role links pointed to a single role_name.

Please help me.

Thanks
Anna Madhusudhanan
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35743
412
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anna,
As you've noticed, you can't map different roles to the same role name. Why can't you just assign everyone the manager role directly? You could assign them another role if they need other privileges too.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35743
412
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anna,
As you've noticed, you can't map different roles to the same role name. Why can't you just assign everyone the manager role directly? You could assign them another role if they need other privileges too.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!