Hi,
Using Tomcat 6.0.14, I need some help. I have left the default server.xml
mostly unchanged, except for the configuration of a global datasource. For my
application, I have created a Realm in its context.xml which is suppose to be
used for authentication, but Tomcat continues to use the default Realm and
ignores the extra one I have configured. I know I somehow have to configure the
<login-config> to use my new Realm, but how? There is a tag <realm-name> which
looked to be my answer, but I couldn't find an example anywhere of how to
identify the Realm and the <realm-name> seems more like a comment than a
meaningful parameter.
Can someone help please? Maybe post an working example of a configuration using
more than one Realm?
Extract from my server.xml:
<GlobalNamingResources>
<Resource name="UserDatabase"
auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
<Resource name="jdbc/rankings"
auth="Container"
type="javax.sql.DataSource"
maxActive="16"
maxIdle="8"
maxWait="10000"
username="myUser"
password="myPass"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/rankings?autoReconnect=true" />
</GlobalNamingResources>
The datasource works and can be tested from within the application, so it is
set up correctly.
The application's context.xml:
<Context path="/rankings"
docBase="path.to.file/rankings.war"
debug="0"
reloadable="false"
antiJARLocking="true"
antiResourceLocking="true"
crossContext="true">
<ResourceLink name="jdbc/rankings"
global="jdbc/rankings"
type="javax.sql.DataSource" />
<Realm className="org.apache.catalina.realm.DataSourceRealm"
debug="99"
dataSourceName="jdbc/rankings"
userTable="users"
userNameCol="email"
userCredCol="password"
userRoleTable="user_roles"
roleNameCol="role_name" />
</Context>
Extract from the application's web.xml:
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/rankings</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<security-constraint>
<display-name>Default</display-name>
<web-resource-collection>
<web-resource-name>Default secured domain</web-resource-name>
<url-pattern>*.do</url-pattern>
<url-pattern>*.jsp</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>Default</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<display-name>Public</display-name>
<web-resource-collection>
<web-resource-name>Public accessible</web-resource-name>
<url-pattern>/public/*</url-pattern>
</web-resource-collection>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>Datasource Realm</realm-name>
</login-config>
<security-role>
<role-name>Default</role-name>
</security-role>
Thanks in advance!
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]