• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

request.isUerInRole()

 
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

i changed my web.xml like above, still getting output as : false
 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic