tsunpo
asked on
Tomcat issue: How to get a realm stored in a database rather than from a file
hi all,
how to get a realm stored in a database rather than from a file
i m using struts 1.1, tomcat 5.0.28, mysql...
1. so far this works fine for me (with basic j_security_check)
<Resource name="MyUsers" auth="Container"
type="org.apache.catalina. UserDataba se"
description="User database that can be updated and saved">
</Resource>
<ResourceParams name="MyUsers">
<parameter>
<name>factory</name>
<value>org.apache.catalina .users.Mem oryUserDat abaseFacto ry</value>
</parameter>
<parameter>
<name>pathname</name>
<value>conf/my-users.xml</ value>
</parameter>
</ResourceParams>
2. but i prefer to get the username and password from the datebase,
after refer to the document, i did sth like this in serverl.xml (but it doesnt work)... please help
<!-- (Comment out!!)
<Realm className="org.apache.cata lina.realm .UserDatab aseRealm"
debug="0" resourceName="UserDatabase "/>
-->
<Realm className="org.apache.cata lina.realm .JDBCRealm " debug="0"
driverName="org.gjt.mm.mys ql.Driver"
connectionURL="jdbc:mysql: //xxx.xxx. xxx.xxx/xx x"
connectionName="xxx" connectionPassword="xxx"
userTable="user" userNameCol="username" userCredCol="password"
userRoleTable="user" roleNameCol="depname" />
cheers,
george
how to get a realm stored in a database rather than from a file
i m using struts 1.1, tomcat 5.0.28, mysql...
1. so far this works fine for me (with basic j_security_check)
<Resource name="MyUsers" auth="Container"
type="org.apache.catalina.
description="User database that can be updated and saved">
</Resource>
<ResourceParams name="MyUsers">
<parameter>
<name>factory</name>
<value>org.apache.catalina
</parameter>
<parameter>
<name>pathname</name>
<value>conf/my-users.xml</
</parameter>
</ResourceParams>
2. but i prefer to get the username and password from the datebase,
after refer to the document, i did sth like this in serverl.xml (but it doesnt work)... please help
<!-- (Comment out!!)
<Realm className="org.apache.cata
debug="0" resourceName="UserDatabase
-->
<Realm className="org.apache.cata
driverName="org.gjt.mm.mys
connectionURL="jdbc:mysql:
connectionName="xxx" connectionPassword="xxx"
userTable="user" userNameCol="username" userCredCol="password"
userRoleTable="user" roleNameCol="depname" />
cheers,
george
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi TimYates,
Thats what I refered to... but doesnt work... :p
Accidentally found the solution by wild guess... knackered
<Context path="/bioinfo" docBase="bioinfo" debug="0" reloadable="true">
<Realm className="org.apache.cata lina.realm .JDBCRealm " debug="0"
driverName="com.mysql.jdbc .Driver"
connectionURL="jdbc:mysql: //xxx.xxx. xxx.xxx:33 06/xxx"
connectionName="xxx" connectionPassword="xxx"
userTable="users" userNameCol="user_name" userCredCol="user_pass"
userRoleTable="user_roles" roleNameCol="role_name"/>
</Context>
Me is doing bioinfomatics as well, hope to ask you other questions somedays.
Thanks anyway,
George
Thats what I refered to... but doesnt work... :p
Accidentally found the solution by wild guess... knackered
<Context path="/bioinfo" docBase="bioinfo" debug="0" reloadable="true">
<Realm className="org.apache.cata
driverName="com.mysql.jdbc
connectionURL="jdbc:mysql:
connectionName="xxx" connectionPassword="xxx"
userTable="users" userNameCol="user_name" userCredCol="user_pass"
userRoleTable="user_roles"
</Context>
Me is doing bioinfomatics as well, hope to ask you other questions somedays.
Thanks anyway,
George
Ahhh...wrong driver class eh? Yeah, it's confusing as there are 2 out there... and it's hard to tell which one you have (I have even seen them combined) ;-)
Yay! Bioinformatics :-) whereabouts are you doing it?
Yay! Bioinformatics :-) whereabouts are you doing it?
Oooooh! Thanks for the points too!!
I'll have to help extra hard with your next question ;-)
Tim
I'll have to help extra hard with your next question ;-)
Tim
ASKER
Hi Tim,
no no no no... did u see the <Context> part, thats the right place to put <Realm> :p
it seems either port number or driver is not the main issue of this problem...
i don know if it is the proper way to do with Struts. Say, what will u do to cope with
the login logout via a database rather than MemoryUserDatabaseFactory :)
my company is doing genotyping, mapping and all the SNP things
george
no no no no... did u see the <Context> part, thats the right place to put <Realm> :p
it seems either port number or driver is not the main issue of this problem...
i don know if it is the proper way to do with Struts. Say, what will u do to cope with
the login logout via a database rather than MemoryUserDatabaseFactory :)
my company is doing genotyping, mapping and all the SNP things
george
Ooooh, SNP :-)
Ahhh, the way I do it is with my own classes and table of users and encrypted passwords (then using the session to store the user's details), and not via the Tomcat realm...
Your way would work just as well (afaik)
Ahhh, the way I do it is with my own classes and table of users and encrypted passwords (then using the session to store the user's details), and not via the Tomcat realm...
Your way would work just as well (afaik)
ASKER
any step-by-step articles?? :p thanks in advance
SNP, microarray, AoD, Sequencing, FP...
SNP, microarray, AoD, Sequencing, FP...
I do my login "kinda" like this:
http://www.onjava.com/pub/a/onjava/2001/11/14/jsp_servlets.html?page=2
Heh, as you can see, I currently use Struts (though I am now looking into JSF, which seems like an immprovement, but I'll know more after I read my 200 page book I just bought) ;-)
I store the passwords as MD5 hashes in the database, so they cannot be extracted if anyone just views the table...
Basically, take username, encrypt password, send to business layer, if that returns a user, then add that user object to the session (so I can then display information like fullname, address, etc ;-)
But as I said, your way is cool too :-)
> SNP, microarray, AoD, Sequencing, FP...
We do similar stuff to you from the sound of it :-)
http://www.onjava.com/pub/a/onjava/2001/11/14/jsp_servlets.html?page=2
Heh, as you can see, I currently use Struts (though I am now looking into JSF, which seems like an immprovement, but I'll know more after I read my 200 page book I just bought) ;-)
I store the passwords as MD5 hashes in the database, so they cannot be extracted if anyone just views the table...
Basically, take username, encrypt password, send to business layer, if that returns a user, then add that user object to the session (so I can then display information like fullname, address, etc ;-)
But as I said, your way is cool too :-)
> SNP, microarray, AoD, Sequencing, FP...
We do similar stuff to you from the sound of it :-)
jdbc:mysql://localhost:330
And check catalina.out for JDBC errors on startup...