How to Encrypt passwords specified in tomcat-user.xml in EWS?

Solution Unverified - Updated -


  • Red Hat JBoss Enterprise WebServer (EWS)
    • 2.0.1
    • 3.x
    • 5.x


  • There are users specified with their passwords in $TOMCAT_HOME/conf/tomcat-users.xml, these users are part of authentication for accessing the web applications. How to Encrypt these passwords specified tomcat-user.xml in EWS 2.0.1?
  • How to mask Clear text password in Tomcat configuration file like tomcat-users.xml ?


  • There is a file named within the bin directory as follows, that can be used to mask passwords:-
  • The following steps were taken to encrypt the password:-

    • Encrypt using $TOMCAT_HOME/bin/ as follows1:-
    [krathod@dhcp223-150 bin]$ ./ -a SHA1 password
    • Add the SHA1 algorithm in $TOMCAT_HOME/conf/server.xml as follows:-
    <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
        digest="SHA1" resourceName="UserDatabase"/>
    • The $TOMCAT_HOME/conf/tomcat-users.xml should have the following:-
    <role rolename="TomcatAdmin"/>
    <user username="jboss" password="5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8" roles="TomcatAdmin"/>
    • The web.xml(in FormBasedSecurity web application uploaded in usually looks like follows:-
  • With this when hitting http://localhost:8080/FormBasedSecurity/secured/showPrivateData.jsp you will be successfully able to access the page with username as jboss and password as password.

  • The following files have been uploaded in the file for your reference:-

    • testcase/FormBasedSecurity (web application)

  1. Note that you can also use SHA instead of SHA1, however then you will need to specify the command as ./ -a SHA password and you will need to specify SHA also in $TOMCAT_HOME/conf/server.xml


This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.