You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Mete Kural <me...@yahoo.com> on 2002/07/23 01:20:48 UTC

JDBCRealm Question

Hello,

My question is about how the user roles are
deterermined in JDBCRealm. In the basic XML file
configuration, the XML files has an element "roles".
All of the user's roles are provided in this element
as a comma-seperated list. It seems to me that in
JDBCRealm, this is not the case. User_role column of
the User_Roles table only stores one user role at a
time. For instance if somebody has both the roles
"user" and "admin", in the XML file this would be
specified as "user, admin" inside the roles element.
My understanding is that in JDBCRealm, you have to
enter multiple records relating to the same user, i.e.
username for each role that the user has. Is there a
way to tweak JDBCRealm to read one comma-seperated
list string from only one row instead of reading a row
for each role that the user has.

Why did I need this kind of functionality? Because I
want to keep my user data including the user role all
in one table and not deal with a seperate table for
user_roles. Is what I want possible? Or do you have a
suggestion on how to manage my user_roles data in the
relational database?

Thanks,
Mete Kural


__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: JDBCRealm Question

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Mon, 22 Jul 2002, Mete Kural wrote:

> Date: Mon, 22 Jul 2002 16:20:48 -0700 (PDT)
> From: Mete Kural <me...@yahoo.com>
> Reply-To: Tomcat Users List <to...@jakarta.apache.org>
> To: tomcat-user@jakarta.apache.org
> Subject: JDBCRealm Question
>
> Hello,
>
> My question is about how the user roles are
> deterermined in JDBCRealm. In the basic XML file
> configuration, the XML files has an element "roles".
> All of the user's roles are provided in this element
> as a comma-seperated list. It seems to me that in
> JDBCRealm, this is not the case. User_role column of
> the User_Roles table only stores one user role at a
> time. For instance if somebody has both the roles
> "user" and "admin", in the XML file this would be
> specified as "user, admin" inside the roles element.
> My understanding is that in JDBCRealm, you have to
> enter multiple records relating to the same user, i.e.
> username for each role that the user has. Is there a
> way to tweak JDBCRealm to read one comma-seperated
> list string from only one row instead of reading a row
> for each role that the user has.
>

You are correct about your reasoning that JDBCRealm wants a separate row
for each user+role combination.  That is very typical of the result of
"normalizing" data structures for storage in a DBMS, so you will see this
design pattern a lot as you work with different database-based
applications.

In fact, many XML purists would frown on the fact that we didn't normalize
the data structure in the XML file by having nested <role> elements inside
each <user> element :-).  But, given backwards compatibility requirements,
it's too late now.

> Why did I need this kind of functionality? Because I
> want to keep my user data including the user role all
> in one table and not deal with a seperate table for
> user_roles. Is what I want possible? Or do you have a
> suggestion on how to manage my user_roles data in the
> relational database?
>

You would seem to have the following choices:

* Bite the bullet and maintain a user_roles table as well.  (Even
  if you avoid learning how to deal with master/detail relationships
  for this app, you're definitely going to need to understand how
  to do this for other situations).

* Make a stored procedure (if your database supports them) that
  automatically updates the user_roles table whenever you
  update the user table.  That way, your administrative program
  doesn't need to worry about it, and JDBCRealm still gets what it needs.

* Make your own custom version of JDBCRealm that knows about
  a single comma-delmited column, and maintain it yourself.
  There is nothing in the standard version that does this.


> Thanks,
> Mete Kural
>

Craig


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>