Creating Users and Passwords with Tomcat using tomcat-users.xml
By: Emiley J.
A very easy method of authenticating users with Tomcat involves creating usernames, passwords, and roles in the tomcat-users.xml file. This file is stored in <Tomcat-installation-directory>/conf.
Everyone is familiar with usernames and passwords, but what are roles? Roles are logical ways to describe groups of users who have similar responsibilities, such as manager or databaseAdmin. Example below shows a tomcat-users.xml file that creates two roles and two users with two aptly named XML elements: role and user.
The tomcat-users XML file
<?xml version='1.0' encoding='utf-8'?> <tomcat-users> <role rolename="dbadmin"/> <role rolename="manager"/> <user username="BruceP" password="bwperry" roles="dbadmin,manager"/> <user username="JillH" password="jhayward" roles="manager"/> </tomcat-users>
In above example, the user BruceP is associated with two roles (dbadmin and manager), while user JillH is associated only with the manager role. Tomcat uses this file when authenticating users with BASIC and form-based authentication
Comment on this tutorial
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Subscribe to Tutorials
Related Tutorials
Program using concept of byte long short and int in java
Update contents of a file within a jar file
Tomcat and httpd configured in port 8080 and 80
Count number of vowels, consonants and digits in a String in Java
Student marks calculation program in Java
Calculate gross salary in Java
Calculate average sale of the week in Java
Vector in Java - Sample Program
MultiLevel Inheritance sample in Java
Archived Comments
1. <tomcat-users>
<role rolename=&q
View Tutorial By: nc30 at 2012-04-18 10:13:10
2. Hi, these are the lines i added after i downloaded
View Tutorial By: sandeep,p at 2012-11-22 10:17:07
3. After edit tomcat-user file and restart sevice ..i
View Tutorial By: Rajesh Perumal at 2013-01-08 06:29:21
4. thank u.....
View Tutorial By: DiptaRanjan at 2013-02-02 14:56:45
5. thanks alot.
View Tutorial By: ZolTech at 2013-06-01 17:57:40
6. Servicerzo
View Tutorial By: Servicepke at 2017-06-29 06:10:11
7. autohitsrn
View Tutorial By: autohiteav at 2017-07-12 08:26:54
8. Wow, that's what I was exploring for, what a data!
View Tutorial By: what is list of forex companies in india at 2017-08-31 11:53:27