You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by me...@twrichter.de on 2001/08/13 17:45:36 UTC

How to get userRole from Tomcat 3.2.3?

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


Re: How to get userRole from Tomcat 3.2.3?

Posted by Andrew Robson <an...@netscapeonline.co.uk>.
Why not use

HttpServletRequest 
boolean isUserInRole(java.lang.String role)

andrew


On Mon, 13 Aug 2001, you 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



RE: How to get userRole from Tomcat 3.2.3?

Posted by Filip Hanik <ma...@filip.net>.
javax.servlet.http.HttpServletRequest contains these methods

public boolean isUserInRole(java.lang.String role)
public java.security.Principal getUserPrincipal()


Filip

~
Namaste - I bow to the divine in you
~
Filip Hanik
Software Architect
filip@filip.net
www.filip.net

>-----Original Message-----
>From: me@twrichter.de [mailto:me@twrichter.de]
>Sent: Monday, August 13, 2001 8:46 AM
>To: tomcat-user@jakarta.apache.org
>Subject: How to get userRole from Tomcat 3.2.3?
>
>
>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
>
>


Re: How to get userRole from Tomcat 3.2.3?

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

On Mon, 13 Aug 2001 me@twrichter.de 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