[英]Configuring a Context specific Tomcat Security Realm
I am trying to get a context specific security Realm in Tomcat 6.0, but when I start Tomcat I get the following error: 我试图在Tomcat 6.0中获取特定于上下文的安全领域,但是当我启动Tomcat时,我收到以下错误:
09-Dec-2010 16:12:40 org.apache.catalina.startup.ContextConfig validateSecurityRoles
INFO: WARNING: Security role name myrole used in an <auth-constraint> without being defined in a <security-role>
I have created the following context.xml file: 我创建了以下context.xml文件:
<Context debug="0" reloadable="true">
<Resource name="MyUserDatabase"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/my-users.xml" />
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="MyUserDatabase"/>
</Context>
Created a file: my-users.xml which I have placed under WEB-INF/conf which contains the following: 创建了一个文件:my-users.xml,它放在WEB-INF / conf下,其中包含以下内容:
<tomcat-users>
<role rolename="myrole"/>
<user username="test" password="changeit" roles="myrole" />
</tomcat-users>
Added the following lines to my web.xml file: 在我的web.xml文件中添加了以下行:
<web-app ...>
...
<security-constraint>
<web-resource-collection>
<web-resource-name>Entire Application</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>myrole</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
...
</web-app>
But seem to get the error wherever I put conf/my-users.xml. 但无论我把conf / my-users.xml放在哪里,似乎都会出错。 Do I have to specify an explicit PATH in the pathname or is it relative to somewhere? 我是否必须在路径名中指定显式PATH或者它是否相对于某个地方? Ideally I would like to have it packaged up as part of my WAR file. 理想情况下,我希望将其打包为WAR文件的一部分。
Any ideas? 有任何想法吗?
I believe you need the following in your web.xml 我相信你的web.xml需要以下内容
<security-role>
<role-name>myrole</role-name>
</security-role>
in order to define the role. 为了定义角色。 Also, I think that you will need to reference the realm in the login-config 另外,我认为你需要在login-config中引用这个领域
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>MyUserDatabase</realm-name>
</login-config>
or similar. 或类似的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.