Tomcat的User信息可以存储到数据库中吗?

2020-12-11 12:45发布

问题:

<tomcat-users xmlns="http://tomcat.apache.org/xml"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
              version="1.0">
<!--
  NOTE:  By default, no user is included in the "manager-gui" role required
  to operate the "/manager/html" web application.  If you wish to use this app,
  you must define such a user - the username and password are arbitrary. It is
  strongly recommended that you do NOT use one of the users in the commented out
  section below since they are intended for use with the examples web
  application.
-->
<!--
  NOTE:  The sample user and role entries below are intended for use with the
  examples web application. They are wrapped in a comment and thus are ignored
  when reading this file. If you wish to configure these users for use with the
  examples web application, do not forget to remove the <!.. ..> that surrounds
  them. You will also need to set the passwords to something appropriate.
-->
<!--
  <role rolename="tomcat"/>
  <role rolename="role1"/>
  <user username="tomcat" password="<must-be-changed>" roles="tomcat"/>
  <user username="both" password="<must-be-changed>" roles="tomcat,role1"/>
  <user username="role1" password="<must-be-changed>" roles="role1"/>
-->
</tomcat-users>

例如这个信息,可以把用户名密码放到数据库中吗?

这种明文密码未免有点太不安全了吧

回答1:

 不能,tomcat配置用户名密码只能通过配置文件的方式。

 不过tomcat是开源的,也许可以通过修改源代码的方式,来满足自己的需求。



回答2:

从来没考虑过这种事情,这就像是把钱放在桌子上还是桌子底下一样,没什么区别,毕竟能拿桌子上的钱的人自然也能手伸到桌子底下拿



标签: tomcat java