tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul Bothma" <p...@xtracker.co.za>
Subject JDBCRealm
Date Thu, 13 Feb 2003 15:01:51 GMT
Hi,

I'm trying to use a JDBC realm with Tomcat 4.1.12. I've been able to use the
XML based one in conf/tomcat-users.xml.

I have created all the tables and inserted the users. Also, I know that
Tomcat can connect to the database. The problem is that I'm not entirely
sure what has to be changed in server.xml and also the web.xml files.

Basically what happens is that the username and password get rejected, even
though they are correctly inserted into the database called 'Tomcat'. The
password is stored using plain text.

The <Realm> tag is nested in <Engine> so it ought to be picked up, etc.

This is the bit that I changed in server.xml:

	<!--

      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
debug="0" 	resourceName="UserDatabase" validate="true"/>

	-->

      <Realm
      	className="org.apache.catalina.realm.JDBCRealm"
      	debug="99"
      	driverName="org.gjt.mm.mysql.Driver"

connectionURL="jdbc:mysql://localhost/Tomcat?user=HP&amp;password=123456"
      	userTable="users"
      	usernameCol="user_name"
      	userCredCol="user_pass"
      	userRoleTable="user_roles"
      	roleNameCol="role_name"
      	resourceName="UserDatabase"
      	 />

Not sure what needs to be done to this bit:

<Server>
	<GlobalNamingResources>

	    <Resource auth="Container" description="User database"
name="UserDatabase" 			scope="Shareable"
type="org.apache.catalina.UserDatabase"/>


	    <ResourceParams name="UserDatabase">
      	<parameter>
	        <name>factory</name>
      	  <value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
	      </parameter>
		<parameter>
	        <name>pathname</name>
	        <value>conf/tomcat-users.xml</value>
      	</parameter>
	    </ResourceParams>
	</GlobalNamingResources>
	...
</Server>

And in web.xml I have the following:

    <security-constraint>
      <display-name>HP Admin Security Constraint</display-name>
      <web-resource-collection>
         <web-resource-name>Protected Area</web-resource-name>
         <url-pattern>/admin/*</url-pattern>
      </web-resource-collection>
      <auth-constraint>
         <role-name>HP_admin</role-name>
      </auth-constraint>
    </security-constraint>

    <login-config>
      <auth-method>FORM</auth-method>
      <realm-name>HP Admin</realm-name>
      <form-login-config>
        <form-login-page>/admin/login.jsp</form-login-page>
        <form-error-page>/error.html</form-error-page>
      </form-login-config>
    </login-config>


    <!-- Security roles referenced by this web application -->
    <security-role>
      <role-name>HP_admin</role-name>
    </security-role>

Please help,

Paul


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message