Win a copy of TDD for a Shopping Website LiveProject this week in the Testing 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

BASIC authentication not working

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've configured my webapp to use BASIC authentication.
When attempting to access http://localhost:8080/DBTest/ I do get a popup asking for user/pwd.
On submitting the user/pwd as role1/password, it is not accepted and the popup keeps reappearing.
Below are the web.xml and tomcat-users.xml

web.xml
-----------------


tomcat-users.xml
------------------------------
 
Ranch Hand
Posts: 470
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Amar Jee wrote:
On submitting the user/pwd as role1/password, it is not accepted and the popup keeps reappearing.

tomcat-users.xml
------------------------------



Should you submit username/password as role1/tomcat?
 
Amar Jee
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, typo in the post.
I'm trying role1/tomcat as user/pwd (this is not working ).
Using tomcat 6.0.20.
 
Misha Ver
Ranch Hand
Posts: 470
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It should work. Perhaps you could post complete web.xml and tomcat-users.xml files.
 
Saloon Keeper
Posts: 25455
178
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have to select a security Realm in your tomcat conf/server.xml file.

The sample that's provided for tomcat-users.xml is the MemoryRealm, and as shipped it's commented out.

You must uncomment the realm definition in server.xml to make it work.

Note that tomcat-users.xml is simply the (default) name of a file that the MemoryRealm uses. Most production Tomcat servers use a Realm that employs a database or LDAP/Active Directory server to maintain user account information.
 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess its too late to reply to this post , but since i figured out the problem I think its my duty to post the solution.
I was using a WTP enabled eclipse and running the tomcat through the eclipse. Eclipse had created a server directory and was using the tomcat-users.xml file from the location ~/MyWorkspace/MyProject/Servers/Tomcat v6.0 Server at localhost-config/tomcat-users.xml. I too had directly modified the $CATALINA_HOME/conf/tomcat-users.xml

After editing the right config file i was able to run the authentication as expected
 
Tim Holloway
Saloon Keeper
Posts: 25455
178
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

sksumit kumar wrote:I guess its too late to reply to this post , but since i figured out the problem I think its my duty to post the solution.
I was using a WTP enabled eclipse and running the tomcat through the eclipse. Eclipse had created a server directory and was using the tomcat-users.xml file from the location ~/MyWorkspace/MyProject/Servers/Tomcat v6.0 Server at localhost-config/tomcat-users.xml. I too had directly modified the $CATALINA_HOME/conf/tomcat-users.xml

After editing the right config file i was able to run the authentication as expected



This is why I loathe and despise WTP (and use sysdeo instead). In addition to the conditions you've noted, WTP's copying of the tomcat config is selective, based on what they think the Tomcat configuration is, and if you stray from that model, you'll discover - painfully - that your extended configurations are not supported.
 
"Don't believe every tiny ad you see on the internet. But this one is rock solid." - George Washington
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic