tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John Gregg" <john.gr...@techarch.com>
Subject [PATCH] change JDBCRealm to add flexibility in table layout
Date Tue, 05 Mar 2002 00:27:07 GMT
Hi all.

I'd like to propose a change to JDBCRealm to allow a little more flexibility
in the layout of one's users and roles tables.  The current implementation
(1.20) assumes the roles table will have a column with the same name and
meaning as the username column in the users table.  In general, I like to
avoid using a column with domain meaning as a primary or foreign key.  In
particular, doing so makes it difficult to allow a user to change his or her
username because that change would then ripple through the db to any other
place that uses username as a key, such as the roles table.  Instead, my
change requires the specification of two additional attributes in
server.xml's Realm element when using a JDBCRealm, userPrimaryKeyCol and
userForeignKeyCol, but frees one from having to track and propagate username
changes.  userPrimaryKeyCol is whatever column contains the unique (at least
within the user table) identifier of a user; userForeignKeyCol is the column
in the roles table that joins to that column.  Applications built on the
existing implementation of JDBCRealm can continue without a database
reorganization.  They simply have to specify userPrimaryKeyCol and
userForeignKeyCol as having the same value as userNameCol.

I tested my changes using Tomcat 4.0.1 and PostgreSQL 7.1.x.  I first
changed my server.xml to explicitly state that the username column was to be
used to join the users and roles tables.  Things worked as expected.  Then I
changed the layout of my db to use different join columns.  Again, things
worked as expected.  Though Tomcat 4.0.1 comes with JDBCRealm 1.19, I didn't
have any trouble compiling and running my changes based on 1.20.  It appears
the only difference between 1.19 and 1.20 is the addition of accessors in
the newer version.

I generated the patchfile with "diff -u <version 1.20> <my version based on
1.20>."


thanks

john gregg
TechArch Consulting Group
Minneapolis, MN



Mime
View raw message