There is no need to extend JdbcRealm. If you just want to use your own table
schema you can define your own queries for the JdbcRealm. This is a sample
Spring configuration for this purpose:
<bean id="jdbcRealm" class="org.apache.shiro.realm.jdbc.JdbcRealm">
<property name="dataSource" ref="dataSource"/>
<property name="credentialsMatcher" ref="credentialsMatcher"/>
<property name="authenticationQuery" value="select password from
users where username = ?"/>
<property name="permissionsQuery" value="select permission from
roles_permissions where role_name = ?"/>
<property name="userRolesQuery" value="select role_name from
user_roles where username = ?"/>
</bean>
The queries above are the standard ones from Shiro. You can change them for
whatever query you need, considering the given parameter for each query. If
you are not using Spring, use setAuthenticationQuery, setPermissionsQuery
and setUserRolesQuery methods for that.
Hope it helps.
On Tue, Aug 25, 2009 at 9:09 AM, Neo Anderson
<[email protected]>wrote:
>
> I am not familiar with shiro as well. Just a user.
>
> At the moment the way how I use shiro with specific/ customized table
> (User,
> Roles, Permission) is by extending JdbcRealm. Then overriding the methods
> in
> JdbcRealm. For instance, I want to integrate hibernate instead of using
> jdbc
> call directly. So I subclass JpaRealm class which looks like
>
> public class JpaRealm extends JdbcRealm{
> ...
> // methods
> ... doGetAuthen....(){
> }
> ... getPermission ...(){
> }
> }
>
> When running the procedure like quick start, the necessary methods
> overridden will get called.
>
> Hope this helps.
>
>
> smaskar wrote:
> >
> > Is there a way to use application specific tables and not the one which
> > comes with shiro default.
> >
> > Our application already has user, role and permission tables and we
> wanted
> > to use the same using shiro framework, Is there any configuration file
> > where one can specify the custom tables instead of shiro defaults.
> >
> > -Santosh Maskar
> >
>
> --
> View this message in context:
> http://n2.nabble.com/JdbcRealm-Application-specific-table-instead-of-default-tp3509201p3509333.html
> Sent from the Shiro User mailing list archive at Nabble.com.
>