Bug 48589

Summary: org.apache.catalina.realm.JNDIRealm User class should be accessible from sub-classes
Product: Tomcat 6 Reporter: Candid Dauth <cdauth+issues.apache.org>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: unspecified   
Target Milestone: default   
Hardware: All   
OS: All   
Attachments: Patch to make JNDIRealm extendible by making the User class protected.
Patch to make JNDIRealm extendible by making the User class protected.

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.