aspose file tools*
The moose likes Tomcat and the fly likes BASIC authentication not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "BASIC authentication not working" Watch "BASIC authentication not working" New topic
Author

BASIC authentication not working

Amar Jee
Greenhorn

Joined: Oct 22, 2010
Posts: 6
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
------------------------------
Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
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

Joined: Oct 22, 2010
Posts: 6
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

Joined: Mar 03, 2008
Posts: 470
It should work. Perhaps you could post complete web.xml and tomcat-users.xml files.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16305
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
sumit anand kumar
Ranch Hand

Joined: Apr 28, 2010
Posts: 83
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

Joined: Jun 25, 2001
Posts: 16305
    
  21

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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: BASIC authentication not working