So, the focus of this post is to show you guys that I managed to integrate OpenID4Java (v 0.9.6) with JForum (v 2.1.8). Took me a really lot of time, but given that it was to a school assignment, was completely worth it and I thought sharing it would be helpful to someone else.
What I basically did was:
- Utilize SSO forum's configurations (Also, Anonymous are not allowed to access, neither typical login, i.e., login and password form are hidden. The only way to access the forum is utilizing OpenID).
- Implement an GlassFish Authentication Module called OpenID4JavaAuthModule. (PS.: based on http://www-02.imixs.com/roller/ralphsjavablog/entry/openid_serverauthmodule_jsr_196_with"" target="_new" rel="nofollow">Ralph's Java Blog)
- Implement Attribute Exchange with Google, myOpenID and Yahoo!.
- Update Attribute Exchange configurations (they were a bit outdated, which took me a while to realize(!)... )
Also, applied a few fixes:
- Users names will be their real names published when loggin in (obtained via Attribute Exchange)
- If a user's got the same name as someone else already registered, his nickname will be Name + (x), where x will be the number of users with the same name. (Example: Test, Test(1), Test(2), and so on)
- Fixed a problem when a user could not view someone else's posts through his profile page.
There are few settings that I was not able to get an easy fix, though. One of them is because of the default Admin Login. It is "Admin", but, due to access restrictions (remember that no one is able to access the forum through form), other users will not be able be given different groups (e.g. General, Administration etc.) neither the Administration Control Panel will be available. The workaround was: run jforum-2.1.9 (the original version!) available on JForum's official website, install it, and insert a login according to the name you will publish via OpenID. Next step is get the folder WEB-INF/database/hsqldb and copy it to my JForum's version.
For Example: My name is Abraham Lincoln (according to the information I have in my OpenID provider). So, I run jforum-2.1.9, install it, and there I register myself with the login "Abraham Lincoln". I Logout, Login with the login of Admin (password: a) and put Abraham Lincoln in the Administration Group. Next, I access jforum-2.1.9 WEB-INF/database/hsqldb folder and copy it to Jforum's (my version) same folder.
In order to setup glassfish 3.1.2 execution environment, again I utilized Ralph's Java Blog. Also, I had to use some others libraries. All of them will be listed in the image I'll attach to this post.
- The first step was to create an Provider, according to Ralph's Blog Post. The GlassFishSetup.jpg shows how I did it.
- Next, the libraries. In the domain's ext folder, I had to put a lot of libraries. Almost all of them are included on official OpenID4Java's download page. (Image DomainExtLib.jpg).
* There needs to be a .jar called jForumJar in the "glassfish-3.1.2\glassfish3\glassfish\lib" folder. Without it, the Provider created in the first step won't work.
In the project, there's a Build Path jar called javax.security.auth.message.jar missing, which is part of the GlassFish version you are using. Given that you'll use Eclipse to open the Project, in the build path you can pick this jar on (glassfish-3.1.2\glassfish3\glassfish\modules) folder.
- Once that is done, you're now free to generate the JforumJar mentioned above.
*Note: You cant setup proxy in the OpenIDAuthModule.java class. By default there is no proxy.
-> Once these things are done, you simply have to load the JForum's project folder into glassfish.