Bug 48589 - org.apache.catalina.realm.JNDIRealm User class should be accessible from sub-classes
org.apache.catalina.realm.JNDIRealm User class should be accessible from sub-...
Status: RESOLVED FIXED
Product: Tomcat 6
Classification: Unclassified
Component: Catalina
unspecified
All All
: P2 normal (vote)
: default
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2010-01-21 07:49 UTC by Candid Dauth
Modified: 2010-05-18 13:47 UTC (History)
0 users



Attachments
Patch to make JNDIRealm extendible by making the User class protected. (1.38 KB, application/octet-stream)
2010-01-21 07:49 UTC, Candid Dauth
Details
Patch to make JNDIRealm extendible by making the User class protected. (1.41 KB, patch)
2010-01-21 08:21 UTC, Candid Dauth
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Candid Dauth 2010-01-21 07:49:57 UTC
Created attachment 24878 [details]
Patch to make JNDIRealm extendible by making the User class protected.

Currently, JNDIRealm uses objects of a User class to pass information between several protected methods. The User class is only available inside the org.apache.catalina.realm package. If you want to extend JNDIRealm and overload some methods, you have two possibilities:
1. You put your class inside the org.apache.catalina.realm package. This is not a very proper solution.
2. You overload all methods that use User objects and eliminate the latter. This means that you have to copy a lot of logic from the JNDIRealm class.

I suggest to make an inner class out of the User class and make that protected so that sub-classes can access it to properly extend the Realm. See the patch I provided.
Comment 1 Candid Dauth 2010-01-21 08:21:34 UTC
Created attachment 24879 [details]
Patch to make JNDIRealm extendible by making the User class protected.

I forgot to make the members visible...
Comment 2 Mark Thomas 2010-02-16 11:44:03 UTC
Thanks for the patch. I didn't use it directly but used it as the basis for the fix I have applied to 7.0.x and proposed for 6.0.x

For future reference, please provide patches in diff -u format as this makes the patch easier to work with.

The main difference in the fix that I applied is that the User fields are now private with public accessors. I prefer this to allowing read/write access directly to the fields.
Comment 3 Mark Thomas 2010-05-18 13:47:36 UTC
The patch has been applied to 6.0.x and will be included in 6.0.27 onwards.