2

I've digged the internet for the guide about how to set tomcat authentication,and yes,it really has a pop-up window,which allows me to input username/password,but it seems that my username/password is wrong. I add fraction of my tomcat-user.xml here:

enter code here
<!--
  <role rolename="tomcat"/>
  <role rolename="role1"/>
  <user username="tomcat" password="tomcat" roles="tomcat"/>
  <user username="both" password="tomcat" roles="tomcat,role1"/>
  <user username="role1" password="tomcat" roles="role1"/>
-->

and fraction of web.xml here:

enter code here
<auth-constraint>
  <role-name>tomcat</role-name>
  <role-name>both</role-name>
  <role-name>role1</role-name>
</auth-constraint>

All these "tomcat/tomcat,both/tomcat,role1/tomcat" don't work. What's problem?

lujun
  • 23
  • 1
  • 1
  • 3

3 Answers3

3

depending on your tomcat version, this should work:

<role rolename="manager"/>
<role rolename="admin"/>
<user username="admin" password="admin" roles="admin,manager"/>

EDIT: and please read this ;-) What is the default username and password in Tomcat?

Community
  • 1
  • 1
k-deux
  • 493
  • 3
  • 13
3

Lujun

The file after update should look like this

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<!--
<role rolename="tomcat"/>
<role rolename="role1"/>
<user username="tomcat" password="tomcat" roles="tomcat"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
<user username="role1" password="tomcat" roles="role1"/>
-->
<role rolename="manager"/>
<role rolename="admin"/>
<user username="admin" password="admin" roles="admin,manager"/>
</tomcat-users>

Restart tomcat and use admin/admin

DarthVader
  • 98
  • 8
2

You need to change the file "tomcat-users.xml"

File path C:\Users\suman\Documents\Software\apache-tomcat-7.0.55\conf

File Name tomcat-users.xml

<tomcat-users>
<!--
<role rolename="tomcat"/>
<role rolename="role1"/>
<user username="tomcat" password="tomcat" roles="tomcat"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
<user username="role1" password="tomcat" roles="role1"/>
-->
<role rolename="manager"/>
<role rolename="admin"/>
<role rolename="manager-gui"/>
<role rolename="admin-gui"/>
<role rolename="manager-script"/>
<role rolename="admin-script"/>
<user username="admin" password="admin" roles="admin,manager,manager-gui"/>
</tomcat-users>
Dan Lenski
  • 76,929
  • 13
  • 76
  • 124
Suman
  • 476
  • 5
  • 7