Setting up XMPP Openfire Server and expose via RESTful APIs

In my previous post I explained most of the fundamentals in XMPP. In this post I hope to explain how we can implement XMPP IoT sample.

First we need to setup a XMPP server(or Jabber server). There are many XMPP server implementations available based on different and competitive license and support models. In this example I have chosen Openfire which comes with Apache license which one of well-known corporate friendly open source license.

Installing Openfire Jabber Server


STEP 1:
Goto download link and download Openfire latest version.

STEP 2:
Extract the zip archive file(depends on the platform) and run the setup.

STEP 3:
Go through installation steps and complete the installation.


STEP 4:
In MAC-OSX; I had to do one more additional step since "openfire" ownership was "openfire:247". 

sudo chown -R <your_os_username>:admin /usr/local/openfire
chmod +x /usr/local/openfire/bin/*.sh

Then you can run the server using following command;

cd /usr/local/openfire/bin
./openfire

If everything ran smoothly, terminal should print the following;

Openfire 3.10.2 [Aug 12, 2015 11:13:20 PM]
Admin console listening at http://rasikas-macbook-pro.local:9090

Just copy and paste admin console url on the address bar of a web browser.
STEP 5:
Now setup wizard should be appeared on the web browser. Select "English" as the language and click "continue". On the second screen enter the following;

Domain -> 127.0.0.1 #or enter the IP assigned on ifconfig.
Admin Console Port -> 9090 #http login
Secure Admin Console Port -> 9091 #https login
Property Encryption via -> Blowfish


STEP 6:
On the next step select "Embedded Database" and click "Continue". This is will simplify the database connection process and make use of its HSQLDB internally embedded DB. On the production environment you must select "Standard Database Connection" and configure a separate database.

STEP 7:


For the profile settings; select "Default". this option will keep the user information on the connected database.

STEP 8:
On the next step; enter an "email" and a valid password for the admin account. Click "Continue".

STEP 9:
Once you are done, It will display "Setup Complete!" message. Then click on "Log to the admin console".

STEP 10:
Once you are redirected, enter the username as "admin" and the password will be the same you gave on the previous Step 8. If you are unable to login using provided credentials; please try restarting the server.


Creating a New User

On this step we will create a new user on the open fire using admin console.

STEP 1:
Navigate into "Users/Groups" tab. Select "Create New User" on the left menu pane.



Deploying REST-API plugin to manage users

When integrating with other servers, manually creating each user on the openfire is not scalable or feasible approach. Hence you can use Openfire plugins. REST-API plugin provides functionalities to manage users through HTTP calls. API documentation is available on here.

In order to install plugin, you can just copy "restApi.jar" file into $OPEN-FIRE-HOME/plugins folder. In  OS-X "/usr/local/openfire/plugins". You don't need to restart the server. It will automatically deployed.

To configure REST API, Go to Server -> Server Settings. Then REST API from the left menu pane.

SHARE

Anonymous

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment