Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

web security not working as expected,

 
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have written two index.jsp files in /Beer/AddRecipe and /Beer/ReviewRecipe/ folders. And one index.html in the application context. And have done changes to the tomcat-usres.xml

tomcat-users.xml looks like as follows.



Line 3,4,5,6,7 were there previously. All other things I have done.

And the wrote web.xml which looks as follows



But the problem is when I type in http://localhost:8080/testauth1/Beer/AddRecipe/index.jsp or http://localhost:8080/testauth1/Beer/ReviewRecipe/index.jsp it is not doing any authentication or authorization. Is there any thing wrong with my xml files. and Another thing do I have to remove role name in tomcat-users.xml that were there previously.


It works for the first time. But next time it doesn't as for username and password
 
Ranch Hand
Posts: 437
Oracle Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Anil.

You have not made resouce '/Beer/ReviewRecipe/' as constrained. If you made, it will work.

It works for the first time. But next time it doesn't ask for username and password



For the first request, tomcat creates session object and sets the time period of 30 min's(default time period of tomcat) and adds it to the cookie object and sends it to the client. Next time client will communicate to the tomcat via. cookie(JSESSIONID cookie).

For the second request if we want authentication, delete cookie at the browser side and send request.

 
Anil Deshpande
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the clarification on why it doesn't work for next requests. Another thing , I have written security-constraint in line number 23 to 37. I worked fine.
 
Message for you sir! I think it is a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic