Hi,
I am a newbie at JSecurity and try to explore how to use it in a web application. I am looking for an example of using JdbcRealm. I basically want to setup a sample webapp with security info (user/password/role) stored in a SQL db.
I have read the java doc for org.api.org.jsecurity.web.servlet.JSecurityFilter and scan through the sample config but haven't seen any reference to JdbcRealm configuration (or any other realm). Any pointer would be appreciated.
- Chi Nguyen
Re: JdbcRealm config example?
Hi Chi,
Sorry about the delayed reply - I was out of town for a few weeks and then was moving last week. This is the first time I was able to reply. Next time, please try using the mailing lists - they're often more responsive now that we've moved to the Apache Software Foundation.
To answer your question, you can configure the realm like any other pojo with getters and setters with our simplified configuration syntax. Define it before the [filters] section in your config.
For example:
dataSource = some.pkg.jdbc.DataSource
//other properties set
myJdbcRealm.class = some.domain.JdbcRealm
myJdbcRealm.property1 = foo
myJdbcRealm.property2 = bar
myJdbcRealm.dataSource = $dataSource
etc.
If this relatively simple mechanism isn't sufficient for your needs, you'll probably want to look into using Spring to back JSecurity (or other DI framework), as its configuration is more powerful than typical properties-based configuration.
I hope that helps!
Cheers,
Les