-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Vince,

On 11/26/14 7:26 AM, vince.w...@thomsonreuters.com wrote:
>> -----Original Message----- From: Christopher Schultz
>> [mailto:ch...@christopherschultz.net] Sent: 26 November 2014
>> 04:17 To: Tomcat Users List Subject: Re: How can code in a Realm
>> gain access to a Globally Named Resource
>> 
> Vince,
> 
> On 11/25/14 9:00 PM, vince.w...@thomsonreuters.com wrote:
>>>> Web applications gain access to Globally Named JDBC
>>>> Resources <GlobalNamingResources> by adding a <ResourceLink>
>>>> to context.xml
>>>> 
>>>> Then using code like:
>>>> 
>>>> Context initContext = new InitialContext(); dbLookupStr =
>>>> "java:comp/env/" + dbResourceName; ds =
>>>> (DataSource)initContext.lookup(dbLookupStr);
>>>> 
>>>> HOW CAN code in a custom Realm gain access to one of those
>>>> same Globally named database connection pools ?
> 
> What's wrong with the code above?
> 
>> I don't know if there is nothing wrong with the code above, if it
>> can be used in a Realm, then what I'm missing is the Realm
>> equivalent of adding a <ResourceLink> to an application's
>> context.xml As a result I fail to get a DataSource
> 
>> I have the Realm defined in the <Engine> section of server.xml

I'm not sure, but I would guess you can't define a Realm in server.xml
and use a DataSource defined in context.xml. If the Realm is in
server.xml, then you should be able to grab the globally-accessible
DataSources by using their existing (global) names.

>>>> Extra info included here for background: I have a custom
>>>> realm that I created by extending JDBCRealm it does its own
>>>> authentication and uses JDBCRealm's getRoles() to do the
>>>> authorization. Although it works much of the time, the
>>>> inherited getRoles method causes problems. I've decided to
>>>> re-write my realm without extending JDBCRealm, thus I need to
>>>> write my own JDBC authorization code, hence the above
>>>> question.
> 
> JDBCRealm should probably die, and you probably shouldn't be using
> it.
> 
> Why not extend DataSourceRealm instead? You'll get DataSource
> access for free ;)
> 
>> I've never looked at DataSourceRealm, perhaps it's time I did. I
>> used JDBCRealm because having used it years ago I understand what
>> it aims to do

DataSourceRealm will use a DataSource you have configured instead of
having the connection information directly-specified in the Realm
configuration. JDBCRealm maintains only a single JDBC connection so if
you have lots of login operations, it will slow down to a crawl. You
are better off in almost all cases using DataSourceRealm.

I'm curious about what you have added in your custom Realm.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org

iQIcBAEBCAAGBQJUdf6MAAoJEBzwKT+lPKRY5nMQALBY0XlR4bOEiR20bjK0NQd+
sfI8S/vZG7g+/fyGJFcPUIwlDz6Pqv4ZGqF/OalW87O+6Yj/aKVATAqdqXzcaDuH
AmIrJaW7Qk2eTsERC71EA/ZallSFenjhJkRxovsMg6QNbwp8QNWyriSfeU6HOiUv
ishq3eo5q3oByZ+TyOkC9zdIUbf/icFypafj5ptn/+65niKZFUUbHSqw/P04bmw9
KYwkPKfI0UpROCqEaxJ0nlo5/8jaqonxeclfTk8yR452GEb/puSLG1NXAjXR0zkG
HT6DXdk6mJJdB2R8bmVUHXrq0YsroK61Uw78jUyijxkD/RqCdcD48zcXpC0K1uu/
jvDTtBjmWG7TYQgaIQbHGT/udwxoZa1LsVRmQUWhxxlzsMzJ5oEpvV5IWdCjBMa4
7xABF022pLT0AMes7qB3KtSG0djcSiOBq77LgRcctVVrHMS0HPx3VEsNJcilLk45
76Mxu6rfXmp2/WhV+qFPfm9t7vW68E8RkXIwto+fQM2rrwoUhriqQBIZYV7YNlNL
bTNDCN1vE0c3tUhiZtETW/ISkidz5AgSZ/8OTBZ/lWbeJd3RBzpvYqxF6Y0G+rGl
XRdmHLJQq6wvd0D1h5S2Jf7Gxgz/GX/lY0ICnw1wO9ioV9MwV8HXkbZMlt/cnRL2
oKkez8NOhc4lGUezx40u
=t5yq
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to