On Mon, 13 Aug 2001 [EMAIL PROTECTED] wrote:

> Hi,
> 
> I am using JDBCRealm and need a convenient way to get the userRoles of the
> user. GetRemoteUser is not the right way. In the source code of JDBCRealm I
> found a getuserRoles method - how can I use it in my own servlets? Calling
> jedbcRealm = new JDBCRealm() and then jdbcRealm.getuserRoles do not work,
> of course...
> 
> Best thanks in advance
> 
> Thomas W. Richter
> 
> 

There is nothing in the servlet API that lets you (portably) ask for all
the roles assigned to the authenticated user.  However, you can ask "does
this user have role FOO" by calling request.isUserInRole("FOO").

If you need to do more than that (for example, you're writing a web app to
administer the set of valid users and roles), your best bet is to write a
database maintenance application in the usual way that happens to point at
the same database tables.  From the *application* developer's point of
view, JDBCRealm is not visible -- it just happens to be the gadget that
Tomcat uses internally to look up users and roles in a database.

Craig


Reply via email to