This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
I had a look at that documentation first. Only problem was i was developing a custom implementation of the RealmBase class as our authentication structure is a little different and did not find my answer there.
I'm trying to write my own Realm to authenticate my users. I have written a class extending org.apache.catalina.realm.RealmBase, compiled to a .jar file and put it in the /lib directory. Then I added this to server.xml:
Tomcat does not have a "/lib" directory, so where did you put the jar file? If you meant the WEB-INF/lib directory of a web app, then be aware that Realm implementations need to go into Tomcat's classpath, not your web app's classpath. Try the "common" or "shared" directories instead.
Ulf, you're thinking Tomcat 5 and earlier. They got rid of all that common/shared lib stuff in Tomcat6. now it's just TOMCAT_HOME/lib.
For the benefit of anyone wondering, by the way, it's easy to subclass the Tomcat database realm class. I did it because I needed Windows-style authentication (case-insensitive user name, case-sensitive password). My subclass folds the userid to lower case before querying the database.
Customer surveys are for companies who didn't pay proper attention to begin with.
Thanks guys for this thread! I had to extend the DataSourceRealm just to change one line in the digest() method because my organisation uses a very obscure encoding method. I followed all the instructions on the manual (and in this thread), but was stuck for days due to a ClassNotFoundError. But, alas it's my own stupid mistake. I added this to my context.xml:
I'm a newbie and never had to create a jar before. So, what I did was jar -cvf CustomDataSourceRealm.jar CustomDataSourceRealm.class. This didn't capture the class package information, hence the class not found. So what resolved the issue was simply to jar -cvf CustomDataSourceRealm com, where com is the package folder such that the class is in com/mycompany/CustomDataSource.class. Yes, a very basic mistake, I'm putting it out here so other people won't repeat my mistake.
Next, up I'm trying to configure the container in such a way that it takes in a third parameter for authentication. I know I need to mess with mbeans-descriptor.xml abit, I'm not to sure if I need to extend GenericPrincipal. But that's another question for another thread. Any pointers would help too.