• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

request.isUerInRole()

 
Garlapati Ravi
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
web.xml

servlet

output:
false
false

My Question:
1)Continer will always returns false, if it is not been authenticated, how come contianer will come to know whether it was authenticated or not ?
2)I was expecting true and false as result for my code, inspite of guest exists in security-role-ref, it's returning false, what's going wrong with my code? is it anything related to my first point ?

This is all code i have to test isUserInRole() method
 
Andriy Fedotov
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
inside <security-role-ref> you link a user role name (for example, "admin") to another name (like "super_user"), used inside isUserInRole method of your servlet.

it's mainly used when you have 3rd party servlets or you decided to have an abstract role name in your servlet code

syntaxes of <security-role-ref> is

<security-role-ref>
<role-name>original_role_name</role-name>
<role-link>role_name_used_in_servlet</role-link>
</security-role-ref>

to activate authentification in your web application you should specify <login-config> in your DD
 
Garlapati Ravi
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

i changed my web.xml like above, still getting output as : false
 
Musab Al-Rawi
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you:
- create define users to the tomcat-users.xml document?
- did you define roles there as well?
- did you define roles in web.xml <security-role>
- did you enable login?
 
Garlapati Ravi
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No i didn't do any of the things you mentioned, just thought of trying with these two snippets, web.xml and servlet.
I think i have to do all those, Thank you for your comments.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic