tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <...@directbox.com>
Subject [SOLVED] :) user authetication on MySql db issue need some help!
Date Tue, 13 Sep 2005 12:54:49 GMT
hello everyone,

i found out what was the problem:)

okay the problem is that my jdbc driver was to old and could not comunicate with my mysql
 and after finding that out using a java  based  mysql administartion tool (dbvisualzer) 
i could not login and i was wondering the whole tiome what could be the source of the problem
and i find out that yesterday as i was debuggin (seeking the problem i setted the passwords
without md5 no digest and  my passwords was as a MD5 crypted   so the request

050913 14:40:12       5 Execute     [1] SELECT user_pass FROM users WHERE user_name = ?
                      5 Execute     [2] SELECT role_name FROM user_roles WHERE user_name =
?


did not match the "e115d589186390dd1405e7034d897"  not i added the digest="MD5" to my server
xml again and thing works fine 


one thing iam now dealing with is how to lets tomcat manager grab the user  and roles data
from the db 

okay have a great time everyone!

regards and dont give up :)


yassine
ps: Wade thanks again!



-------- directBOX Reply ---------------
From: WadeChandler (hwadechandler-apache@yahoo.com) 
To: TomcatUsersList (tomcat-user@jakarta.apache.org) 
Date: 12.09.2005 18:41:54

--- Yassine ELassad <yel@directbox.com> wrote:

> hi list,
> 
> iam about to set my user to a database instead of
> file and i am now trying  to get that done on a
> mysql rdbms
> i created the following tables :
> mysql> use authority;
> Database changed
> mysql> show tables;
> +---------------------+
> | Tables_in_authority |
> +---------------------+
> | user_roles          |
> | users               |
> +---------------------+
> 2 rows in set (0.00 sec)
> 
> mysql> describe user_roles;
>
+-----------+-------------+------+-----+---------+-------+
> | Field     | Type        | Null | Key | Default |
> Extra |
>
+-----------+-------------+------+-----+---------+-------+
> | user_name | varchar(15) |      | PRI |         |  
>     |
> | role_name | varchar(10) |      |     |         |  
>     |
>
+-----------+-------------+------+-----+---------+-------+
> 2 rows in set (0.00 sec)
> 
> mysql> describe users;
>
+-----------+-------------+------+-----+---------+-------+
> | Field     | Type        | Null | Key | Default |
> Extra |
>
+-----------+-------------+------+-----+---------+-------+
> | user_name | varchar(15) |      | PRI |         |  
>     |
> | user_pass | varchar(32) |      |     |         |  
>     |
>
+-----------+-------------+------+-----+---------+-------+
> 2 rows in set (0.00 sec)
> 
> 
> and this  this is my server.xml:
> 
> 
> =================================
> <Server port="8005" shutdown="SHUTDOWN">
>  <GlobalNamingResources>
>     <!-- Used by Manager webapp -->
>     <Resource name="UserDatabase" auth="Container"
>              
> type="org.apache.catalina.UserDatabase"
>       description="User database that can be updated
> and saved">
> 
>    </Resource>
> 
> 
>    <ResourceParams name="UserDatabase">
>      <parameter>
>         <name>factory</name>
>        
>
<value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
>      </parameter>
>      <parameter>
>         <name>pathname</name>
>         <value>conf/tomcat-users.xml</value>
>       </parameter>
>    </ResourceParams>
>   </GlobalNamingResources>
> 
> 
>   <Service name="Catalina">
>     <Connector port="8080" />
> 
>     <!-- This is here for compatibility only, not
> required -->
>     <Connector port="8009" protocol="AJP/1.3" />
> 
>     <Engine name="Catalina" defaultHost="localhost">
>       <Logger
> className="org.apache.catalina.logger.FileLogger" />
> 
>       <Realm
>
className="org.apache.catalina.realm.UserDatabaseRealm"
>              resourceName="UserDatabase" />
> 
>        <realm
> className="org.apache.catalina.realm.JDBCRealm"
> debug="99"
>       		driverName="org.gjt.mm.mysql.Driver"
>       	
> connectionURL="jdbc:mysql://dekold4711/authority"
>       		connectionName="tomcat"
> connectionPassword="tomcat"
>       		userTable="users" userNameCol="user_name"
> userCredCol="user_pass"
>       		userRoleTable="user_roles"
> roleNameCol="role_name"
>       		digest="md5" />
> 
>       <Host name="localhost" appBase="webapps" />
>     </Engine>
>   </Service>
> </Server>
> ================================
> 
> each time iam trying to login i gets an error
> message telling me wrong username or wrong password 
> catalina.out dont show any susspecious errors any
> idea what i could be doing wrong please!!
> 
> regards Yassine ELassad

I'm using mysql fine.  I use a context.xml file for my
web app in META-INF and this is it:
<?xml version="1.0" encoding="UTF-8"?>
<Context path="" reloadable="true">
  <Resource auth="Container"
driverClassName="com.mysql.jdbc.Driver"
maxActive="100" maxIdle="30" maxWait="10000"
name="jdbc/caro462" password="xxxxxxxx"
removeAbandoned="true" type="javax.sql.DataSource"
url="jdbc:mysql://localhost:3306/caro462?autoReconnect=true"
username="caro462"/>
  <Realm
className="org.apache.catalina.realm.DataSourceRealm"
dataSourceName="jdbc/caro462" debug="99"
localDataSource="true" roleNameCol="role"
userCredCol="password" userNameCol="userid"
userRoleTable="USERROLELINKS" userTable="USERS"/>
</Context>

I then have my web.xml file setup with different
security constraints like this one:
   <security-constraint>
      <display-name>Agent security
constraint</display-name>
      <web-resource-collection>
         <web-resource-name>Agents</web-resource-name>
         <!-- Define the context-relative URL(s) to be
protected -->
         <url-pattern>/agents/secure/*</url-pattern>
      </web-resource-collection>
      <auth-constraint>
         <!-- Anyone with one of the listed roles may
access this area -->
         <role-name>Administrator</role-name>
         <role-name>AgencyAdministrator</role-name>
         <role-name>Agent</role-name>
      </auth-constraint>
    </security-constraint>


I can login fine.  You certainly have to make sure you
have your roles linking to your user name.

Wade

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


__________________________________________________
Verpassen Sie keine eBay-Auktion und bieten Sie bequem
und schnell ├╝ber das Telefon mit http://www.telefonbieten.de

Ihre eMails auf dem Handy lesen - ohne Zeitverlust - 24h/Tag
eMail, FAX, SMS, VoiceMail mit http://www.directbox.com



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message