On 3. September 2014 04:31:45 MESZ, "Dalecki, Janusz" <jdale...@tycoint.com> wrote: > > >-----Original Message----- >From: Mark Eggers [mailto:its_toas...@yahoo.com.INVALID] >Sent: Wednesday, 3 September 2014 1:21 AM >To: Tomcat Users List >Subject: Re: Configured JDBCRealm > >-----BEGIN PGP SIGNED MESSAGE----- >Hash: SHA1 > >On 9/2/2014 5:04 AM, Daniel Mikusa wrote: >> On Tue, Sep 2, 2014 at 7:00 AM, Dalecki, Janusz ><jdale...@tycoint.com> >> wrote: >> >>> Hi, I have configured JDBCRealm Tomcat with the following: >>> >>> <Context> >>> >>> <Realm className="org.apache.catalina.realm.JDBCRealm" >>> driverName="org.postgresql.Driver" >>> >connectionURL="jdbc:postgresql://localhost:5432/df_Scheduler?user=postgres&password=admin" >>> >>> >userTable="users" userNameCol="userName" userCredCol="password" >>> userRoleTable="user_roles" roleNameCol="roleName"/> >>> >>> </Context> I have a few questions: >>> >>> 1) How can I get hold of this realm object within my Java >>> app? 2) Even if I get the instance of the JDBCRealm - how do >>> I get the list of all roles available? >>> >> >> What's the purpose of doing this? >> >> This is just me, but if I wanted to get a list of my users or roles, >I >> would use JDBC and pull them from the database. Then I don't have to >> tie my application to Tomcat's internal classes. >> >> Dan >> >> >> >>> Regards, Janusz > >Janusz, > >If you want internal access to your users and roles, might I suggest >the DataSource Realm? It has the advantage of using JNDI and a JDBC >datasource, so it uses a pool of database connections. This will >perform better as your application load increases. > >You'll also be able to use normal JNDI access to query your database >for the users and roles. > >. . . . just my two cents >/mde/ > ... > >Hi, >I have just started reading on DataSource realm. >But I think I am facing the same problem as with JDBCRealm: >1) How can I get hold of an instance of this DataSourceRealm >object within my Java app? >2) How do I get the list of all roles available?
The realm ist used for authentication and authorization. But there is no official servlet api to get the list of roles for a given user. The only method you have is to check wether a user is in a given role. Same thing for getting a realm. There is no servlet api to get a realm. For both tasks you have to rely on tomcat api. If you have want more, you could look at apache shiro or spring security (or cast the principal to an tomcat only class. Note you will be tied to tomcat and there is no garantee that it will not be changed!) Regards Felix PS Don't place your answer below the mail signature. I had to look really hard for it, before I found it. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org