Howto configure a JDBC realm for container managed security with tomcat?
我想将 tomcat / 我的 Web 应用程序配置为使用 JDBC 领域来实现容器管理的安全性。我在 tomcat 的 server.xml 文件中指定了这样的领域:
1 | <Realm className="org.apache.catalina.realm.JDBCRealm" driverName="net.sourceforge.jtds.jdbc.Driver" connectionURL="jdbc:jtds:sqlserver://hostname:1433/intranet;user=sa;password=sa04jT14;instance=instanceName" userTable="users" userNameCol="username" userCredCol="password" userRoleTable="roles" roleNameCol="role" /> |
我创建了数据库和表。我创建了一个登录页面并将以下代码添加到 web.xml:
1 2 3 4 5 6 7 | <login-config> FORM</auth-method> <form-login-config> <form-login-page>/login.xhtml</form-login-page> <form-error-page>/login.xhtml</form-error-page> </form-login-config> </login-config> |
但是 Tomcat 是如何知道他必须使用哪个领域进行身份验证的呢?
我必须向元素添加元素吗?但那应该是什么价值呢?
提前致谢。
这样很好。这取决于
The
element can be nested
inside any one of of the following
Container elements. The location of
the Realm element has a direct impact
on the"scope" of that Realm (i.e.
which web applications will share the
same authentication information):
Inside an
element - This Realm will be shared across ALL
web applications on ALL virtual hosts,
UNLESS it is overridden by a Realm
element nested inside a subordinate
or element. Inside a
element - This Realm will be shared across ALL web
applications for THIS virtual host,
UNLESS it is overridden by a Realm
element nested inside a subordinate
element. Inside a
element - This Realm will be used ONLY for THIS
web application.
希望这会有所帮助。