We apologize for untranslated text, you can use the Google Translation button to get an automatic translation of the web page in the language of your choice.

Install and Configure an XMPP server with JCMS

WebChat Plugin

WebChat plugin add a bridge between JCMS and instant messaging server (using XMPP protocol).

In this article, we describes installation and configuration of Openfire server. Openfire is an open source XMPP server written in java. XMPP connector plugin is certified with this server and provided a Openfire plugin to add authentification mechanism with JCMS and triggering of chat between two JCMS users. Pidgin XMPP client will be used as example.

General architecture

Followinf schema describe the general architecture of the solution.

XMPP clients, installed on user computer, are connected to Openfire server. This server are in relation with JCMS.

JCMS is also a XMPP client. So it must have a XMPP account on Openfire server. The link between JCMS and Openfire has several roles :

  • Openfire notify JCMS user's presence state (XMPP protocol)
  • Openfire asks JCMS to validate user's authentication (OpenAPI via  HTTP protocol)
  • JCMS send message to Openfire for notification and web chat (XMPP protocol)

XMPP Authentication schema with JCMS

WebChat plugin provides a Openfire plugin. The schema display exhanges used to make authentication.

schema auth xmpp

Openfire server installation

Openfire installation from tar.gz archive

Openfire can be available via packet manager of your distribution.

When Openfire is installed with a package, you can safely ignore this step.

Download Openfire archive.

cd /opt
wget http://www.igniterealtime.org/downloadServlet?filename=openfire/openfire_3_7_1.tar.gz

unarchive in /opt/.

tar zxvf openfire_3_7_1.tar.gz

Configure openfire startup at boot:

ln -s /opt/openfire/bin/Openfire /etc/init.d/
chmod +x /etc/init.d/openfire
update-rc.d openfire

Configuration

Configure your firewall to authorize steam on ports 5222, 5223, 5269, 7777 and 9090.

For example, if you are using iptables, you can add the following lines to the configuration file /etc/network/iptables.rules.

...
# Ports de CHAT
-A INPUT -p tcp -m state --state NEW --dport 5222 -j ACCEPT
-A INPUT -p tcp -m state --state NEW --dport 5223 -j ACCEPT
-A INPUT -p tcp -m state --state NEW --dport 5269 -j ACCEPT

## Transfert de fichier

-A INPUT -p tcp -m state --state NEW --dport 7777 -j ACCEPT
## Port de configuration
-A INPUT -p tcp -m state --state NEW --dport 9090 -j ACCEPT
...

Create the user and the database openfire (with Postgresql for example):

su -l postgres
root@xmpp-server.example.com:/# su - postgres
postgres@xmpp-server.example.com:~$ createuser
Enter name of role to add: openfire
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) n
Shall the new role be allowed to create more new roles? (y/n) n
postgres@xmpp-server.example.com:~$ createdb -O openfire -E UNICODE openfire

Change the password:

postgres@xmpp-server.example.com:~$ psql
postgres=# alter user openfire password '123456';
postgres=# \q

WARNING : Do not use schema creation script provided by Openfire (/opt/openfire/resources/database/Openfire_postgresql.sql), otherwise database configuration via administration web page will failed.

Start configuration of openfire server via : http://xmpp-server.example.com:9090/ with the following data ( for an XMPP domain named example.com) :

WARNING : The domaine name to choose (by default the FDQN on the server) is the suffix of XMPP id: <login>@<domain XMPP>.

Serveur name : xmpp-server.example.com
 database URL : jdbc:postgresql://xmpp-server.example.com:5432/openfire
User : openfire
Password : 123456
Administrateur login : openfire
Administrator Email : openfire@example.com
Administrator password : 456789

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Using administrator account named admin is discouraged for Openfire because it will be conflicted with JCMS default admin accouont. A new administrator account (named openfire by example) must be create and declared as XMPP server administrator.

 

 

Creation of JCMS XMPP account in adminstration console of Openfire server :

login : jcms
password : 987654

WARNING : Openfire has a issue about logs management. Logs files are written in /logs (at system root)  and not in <Openfire>/logs as it should be. You must create the directory /logs like a symbolic link to <Openfire>/logs.

sudo ln -s /opt/openfire/logs /logs

JCMS Authentication component installation

An Authkey must be generated on JCMS platform to authorize Openfire to validate authentication elements.

TO do that, Go to Admin area in section "Authentication key generation".  Generate an new authkey with following parameters:

  • URL : http://<serveur-JCMS>:<port>/<contextRoot>/rest/data/Member
  • Mode : prefix d'URL
  • HTTP Method : GET
  • User : admin
  • Duration : illimité (10 years for example)
  • IP : If you want to restrict the use of this authkey to Openfire server IP

For more information about authKey generation, consult JCMS administrator manual.

Enable Open API feature on JCMS server. To do that, go to Admin aredu serveur JCMS. Pour cela, aller dans Admin area > Proprerties > Web Services > Open API.

Download archive JcmsAuthProvider.zip.
uncompress the archive in /opt/openfire/lib/.

Add in Openfire configuration file (openfire.xml) the following lines:

<jive>
...
  <!-- definition des administrateur Openfire -->
  <admin>
    <authorizedJIDs>admin@example.com,openfire@example.com</authorizedJIDs>
  </admin>
  <!--definition des processus d'authentification -->
  <provider>
    <auth>
      <className>com.jalios.jcms.openfire.JcmsAuthProvider</className>
    </auth>
    <user>
      <className>com.jalios.jcms.openfire.JcmsUserProvider</className>
    </user>
  </provider>
  <jcmsAuthProvider>
    <memberAuthKey>XXX-YYY-ZZZ</memberAuthKey>
    <url>https://jcmsServer.example.com/</url>
  </jcmsAuthProvider>
  <hybridAuthProvider>
    <primaryProvider/>
    <secondaryProvider/>
  </hybridAuthProvider>
  <hybridUserProvider>
    <primaryProvider>
      <className>org.jivesoftware.openfire.user.DefaultUserProvider</className>
    </primaryProvider>
    <secondaryProvider>
      <className>com.jalios.jcms.openfire.JcmsUserProvider</className>
    </secondaryProvider>
  </hybridUserProvider>
</jive>

Execute in Openfire database the script openfire_jcms_configuration.sql.

$ su -l postgresql
$ psql -h localhost -U openfire openfire
openfire=> \i /tmp/openfire_jcms.sql

Restart Openfire server.

Connector XMPP plugin configuration

In JCMS, Connector XMPP Plugin must be configured with parameters:

  • Bot Login : jcms
  • Bot Password : 987654
  • XMPP Server : xmpp-server.example.com
  • XMPP Domain: XMPP domain name (ex. example.com)

Test and validation

XMPP connector module provide a interface to check configuration.

Go to Admin Area > Technical Administration >WebChat

Click on Actions -> "Test XMPP configuration"

 

XMPP client configuration: Pidgin

Installation and configuration

Download setup from http://www.pidgin.im/download/.

Start setup by executing downloaded file.

 

 

Choose installation in english.

 

 

Click on "Next".

 

 

Click on "Next" to accept license.

 

 

Accept default options

 

 

Click on "Install".

 

 

Wait for the installation end.

 

 

Click on "Next".

 

 

Pidgin opens and a configuration is needed.

In this example, the configuration is done with an XMPP domain jalios.net. XMPP id are <login JCMS>@jalios.net.

 

 

Click on "Add".

 

 

Select XMPP protocol and enter in user field th XMPP login, in domain field, the XMPP domain.

Enter your password ans a local alias (used to display the pidgin account).

If the DNS configuration has not be done, select "Advanced" tab and precise the XMPP server in "Connection server"..

 

 

Click on "Add".

 

 

XMPP logo should be colored, as the connection is done.

Click on "Close".

You must now add a contact to start a chat.

Go to menu "Contacts" and click on "Add a contact".

 

 

Enter XMPP id of the contact (<nom>@<domaine XMPP>).

 

 

Click on "Add".

The contact should appear in roster list.

 

 

Test and validation

Add jcms@<domaine XMPP> contact as described in previous section and acception presence request received by pidgin.

Send a message to JCMS, it should answer a message indicating that it is a bot (ex. "Je suis un Robot JCMS" Vous avez dit: test"). 

The instant messaging solution is now correctly installed and configured. You can start chat with another JCMS user.

 

In brief...

This article describe installation and configuration of instant messaging (XMPP) solution for JCMS. it deal with Openfire XMPP server

Subject
Products
Published

3/16/16

Writer
  • Alexis Fiers