What We Do
We provide top quality services and best solutions based on your requirements and needs.
Share

MXAE and Openfire (Instant Messenger Server from Ignite Realtime)

In one of the projects that I have been working on, required an instant messaging service to be offered to its portal community. With that in my mind, I went to search for a free and open source instant messenger that supports XMPP protocol, which is one of the most widely, used protocol for instant messaging. Gtalk and Jabber are some of the popular supporter for the XMPP protocol.
 
With some simple searches on Google, I came across with Openfire from Ignite Realtime. It seems to me that it was the natural choice for the project as it meets all the requirements for the project. The website (http://www.igniterealtime.org/projects/openfire/) has this to say about Openfire:
 
Openfire is a real time collaboration (RTC) server licensed under the Open Source GPL. It uses the only widely adopted open protocol for instant messaging, XMPP (also called Jabber). Openfire is incredibly easy to setup and administer, but offers rock-solid security and performance.
 
Since this article is not about Openfire, we will not dwell too much into it and for more information about Openfire, you can visit the website at http://www.igniterealtime.org/projects/openfire/.
 
As I followed the installation documentation provided by the Openfire’s website, I was able to install and setup the Openfire instant messenger server successfully. With the instant messenger server installed, it is normal to proceed with testing the instant messenger server with a few XMPP compliant clients such as Miranda and Pidgin. And as I have predicted, it worked!
 
Now that I have Openfire up and running, my next task will be integrating the membership system between MXAE and Openfire. Since all the membership database services (eg. Registration, Login, Profile Update, etc) are handled by MXAE, one issue immediately pop-up if I were to integrate Openfire into the portal.
 
The issue is I need to make sure all the changes in MXAE membership database is reflected in Openfire as well, so that the portal member does not need to manage his or her profile at two places, namely MXAE and Openfire. More importantly, the username and password between MXAE and Openfire needs to be synchronized, so that the same portal member’s credential can be used on our new instant messaging service.
 
Luckily for us, Openfire do provide a user integration option where I can configure Openfire to load the members’ data and authenticate its member against a custom SQL table. Since MXAE is running on a MySQL RDBMS, I figured this would be a straight forward task.
 
First, I start with MXAE and based on the Openfire’s documentation on the custom database integration, in order for the user integration to work, the user SQL table must contain the following fields:

  1. Username
  2. Password (Stored either in plain-text or SHA1 hash digest)
  3. Name
  4. Email
Since MXAE already has username, name and email fields as part of its standard membership formset, however, even though the membership formset contain the password field, the password stored is encrypted and it is not compatible with Openfire requirement, which is either in plain-text or SHA1 hash digest.
 
So, I created a new field into the MXAE membership formset and name it ‘ofpassword’. This new field will be used to store the password in SHA1 hash digest. The reason to store the password in SHA1 is purely due to the security reason, where storing the password in plain-text is a big NO-NO as this would expose all our portal member’s password, should the database is compromised.

Image 1.0: Creating the ‘ofpassword’ in MXAE

My next issue is how I can store the SHA1 version of the member’s password as MXAE will not do it for me automatically. This is where I get to know about a MXAE function, which called ‘member trigger’. This member trigger will trigger a custom function whenever there is a member process (eg. Registration, Profile Update, etc) called and with this, we can create a custom function to update the ‘ofpassword’ field automatically. To know more about this member trigger function, please read the article a http://www.digialliance.com/index.php?ch=mda&pg=feature&ac=194.
 
With this, the tasks on MXAE are now completed and it is time I move on to the Openfire side for the integration process and before I continue, I have asked myself, am I familiar with the MXAE and Openfire database structure as the next task involve at the database level? I answered, “Let’s get start with the SQLs.”
 
To start with the integration process on the Openfire, I have to stop the Openfire service first by issuing the stop command at the console, as I do not want any data inconsistency for Openfire. For the Openfire stop command for Windows or Linux server, please refer to the Openfire’s installation documentation. With the Openfire service stopped, I can now start to update the Openfire database using the phpMyAdmin tool.
 
The SQLs needed to enable Openfire to use the MXAE membership table only affect 1 table in the Openfire database, and the affected table is ‘ofProperty’. Based on the SQLs, I have categorized the SQLs into 3 categories:
  1. Database connection settings
  2. Authentication integration
  3. User integration
For the database connection settings, I have to provide Openfire with the JDBC driver and the full connection string to MXAE database. In this project, the JDBC driver is obviously the MySQL driver, which is bundled together with Openfire. As for the connection string, it is the full connection string, which consists of:
  1. MXAE database host
  2. MXAE database name
  3. MXAE database username
  4. MXAE database password
Here are the corresponding SQLs for the database connection settings:
  • insert into ofProperty (name, propValue) values ('jdbcProvider.driver', 'com.mysql.jdbc.Driver');
  • insert into ofProperty (name, propValue) values ('jdbcProvider.connectionString', 'jdbc:mysql://[mxae_db_host]/[mxae_db_name]?user=[user_name]&password=[password]');
Example:
  • insert into ofProperty (name, propValue) values ('jdbcProvider.driver', 'com.mysql.jdbc.Driver');
  • insert into ofProperty (name, propValue) values ('jdbcProvider.connectionString', 'jdbc:mysql://192.168.52.145/w00087?user=username&password=password');
Next on the line is the authentication integration. Because of not using the Openfire default membership table, I have to instruct Openfire to use the custom authentication class, which is provided by Openfire. Next, I have to specify the MXAE password field name and the password type. Since I’m using the MXAE membership, I have to specify which user has the administrator access to Openfire as well.
 
Here are the corresponding SQLs:
  • update ofProperty set propValue = 'org.jivesoftware.openfire.auth.JDBCAuthProvider' where name = 'provider.auth.className';
  • insert into ofProperty (name, propValue) values ('jdbcAuthProvider.passwordSQL', 'select [mxae_membership_new_password_field] from [mxae_membership_table] where [mxae_membership_username_field]=?');
  • insert into ofProperty (name, propValue) values ('jdbcAuthProvider.passwordType', 'sha1');
  • insert into ofProperty (name, propValue) values ('admin.authorizedJIDs', '[mxae_membership_username]@[openfire_jid], [mxae_membership_username]@[openfire_jid]');
Example:
  • update ofProperty set propValue = 'org.jivesoftware.openfire.auth.JDBCAuthProvider' where name = 'provider.auth.className';
  • insert into ofProperty (name, propValue) values ('jdbcAuthProvider.passwordSQL', 'select ofpassword from member where username=?');
  • insert into ofProperty (name, propValue) values ('jdbcAuthProvider.passwordType', 'sha1');
  • insert into ofProperty (name, propValue) values ('admin.authorizedJIDs', 'admin1@messenger.com, admin2@ messenger.com ');
And the last part is the user integration. Similar to the authentication integration, I have to instruct Openfire to use the custom user class as well to display the portal member’s username, name and email from the MXAE membership table. This custom user class is also provided by Openfire. As this is about user information, I have to specify the MXAE username field name, MXAE email field name and MXAE user name field name.
 
Here are the corresponding SQLs:
  • update ofProperty set propValue = 'org.jivesoftware.openfire.user.JDBCUserProvider' where name = 'provider.user.className';
  • insert into ofProperty (name, propValue) values ('jdbcUserProvider.loadUserSQL', 'select [mxae_membership_username_field], [mxae_membership_email_field] from [mxae_membership_table] where [mxae_username_field]=?');
  • insert into ofProperty (name, propValue) values ('jdbcUserProvider.userCountSQL', 'select count(*) from [mxae_membership_table] ');
  • insert into ofProperty (name, propValue) values ('jdbcUserProvider.allUsersSQL', 'select [mxae_membership_username_field] from [mxae_membership_table] ');
  • insert into ofProperty (name, propValue) values ('jdbcUserProvider.searchSQL', 'select [mxae_membership_username_field] from [mxae_membership_table] where');
  • insert into ofProperty (name, propValue) values ('jdbcUserProvider.usernameField', '[mxae_membership_username_field]');
  • insert into ofProperty (name, propValue) values ('jdbcUserProvider.nameField', '[mxae_membership_user_name_field]');
  • insert into ofProperty (name, propValue) values ('jdbcUserProvider.emailField', '[mxae_membership_email_field]');
Example:
  • update ofProperty set propValue = 'org.jivesoftware.openfire.user.JDBCUserProvider' where name = 'provider.user.className';
  • insert into ofProperty (name, propValue) values ('jdbcUserProvider.loadUserSQL', 'select username, email from member where username=?');
  • insert into ofProperty (name, propValue) values ('jdbcUserProvider.userCountSQL', 'select count(*) from member ');
  • insert into ofProperty (name, propValue) values ('jdbcUserProvider.allUsersSQL', 'select username from member ');
  • insert into ofProperty (name, propValue) values ('jdbcUserProvider.searchSQL', 'select username from member where');
  • insert into ofProperty (name, propValue) values ('jdbcUserProvider.usernameField', 'username');
  • insert into ofProperty (name, propValue) values ('jdbcUserProvider.nameField', 'name');
  • insert into ofProperty (name, propValue) values ('jdbcUserProvider.emailField', 'email');
By now, all the work has been done and it is time for me to test on the Openfire authentication as well as displaying the portal member’s details by logging in using MXAE membership access with Miranda as the instant messaging client. And as I have predicted, I was able to connect to the Openfire. It is a success!

Image 2.0: MXAE Integration with Openfire

What I have learned from this project is there are more to MXAE that I need to unravel to myself, to know more about the functionalities that MXAE has provided that will help the developers to develop or to integrate applications with ease.

MXAE Release News

MXAE 2.7.5 Released
We would like to announce the immediate availability of MXAE 2.7.5. This release focuses on...




Tips & Tricks

Custom Attributes
You can actually define your own custom attributes and access it via the MXAE API. This is good...




MXAE Free Hosting

We are offering FREE hosting on MXAE platform with no string attached. You can use it as a development or demo hosting for your company. You can also use it to build your own website or host your client website.