You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Pernica, Jan" <pe...@dcb.cz> on 2001/05/28 17:15:36 UTC

RE: RE: How to get Role and Password from JDBC Realme -using 3.2. 2

The username and the password is part of the request. you can get it from
	org.apache.catalina.util.Base64 base64Helper = new
org.apache.catalina.util.Base64();
	String unencoded = new
String(base64Helper.decode(request.getHeader("authorization").getBytes()));
	int colon = unencoded.indexOf(':');
	if (colon < 0)
	    return (null);
	String username = unencoded.substring(0, colon).trim();
	String password = unencoded.substring(colon + 1).trim();

I hope it helps

Jan

On Monday, May 28, 2001 4:56 PM, me@twrichter.de [SMTP:me@twrichter.de]
wrote:
> Thanks Jan,
> 
> I have to apologize not to have explained the intended usage:
> I need username, userpassword and userrole since I will use it for
> DB-Authorization (GRANT to group, and user to tables and so on, connecting
> DB with username,userpass). I intend to synchronize username, password and
> role with the authDB of the specific Datebase (Interbase and isc4.gdb). Is
> there a methode like org.apache.catalina.realm.GenericPrincipal principal
> = request.getUserPrincipal() for Tomcat 3.2.2 and is there an elegant
> method for attaching password, too?
> 
> Thank you for help
>    Thomas
> 
> "Pernica, Jan" wrote:
> >It depends what do you want:
> >to get user login = request.getRemoteUser()
> >to whether he/she have a role you can use
> >request.isUserInRole("myrole")
> >
> > Even you are able to get the list of roles
> > org.apache.catalina.realm.GenericPrincipal principal =
>  >request.getUserPrincipal();
>  >principal.getRoles()
> >
> >Regards
> >
>  >Jan
> 
> On Monday, May 28, 2001 4:22 PM, me@twrichter.de
>  [SMTP:me@twrichter.de]
>  wrote:
>  > Hello,
>  >
>  > I want to use the provided user_pass and user_role in the
>  > JDBCRealm-Database given in server.xml. What is the most
>  elegant way to do
>  > this? Of cource I would be able to get it via
>  request.getRemoteUser() and
>  > then make a select to the hardcoded database name with provided
>  auth user
>  > and pass like it is given in server.xml. But there must be a
>  better way
>  > since database name, username and driver url is already
>  included in the
>  > Realm section? How to use it? I read the JDBCRealm code but I
>  did not find
>  > out where it gets the connectionUrl a.s.o.
>  >
>  > Best Regards
>  >    Thomas


__________________________________________________________________
Tato komunikace je urcena vyhradne pro adresata a je duverna. 
This communication is intended solely for the addressee and is confidential.