Anonymous Login in Openfire with Strophe

5.9k Views Asked by At

I am running openfire 3.6.4 and connecting with Strophe library. The setup is working fine. Now i want to do one thing i want a anonymous login for my application and that login should also get subscribed to a room and receive the notification of that room. I have enabled the anonymous setting in openfire.

2

There are 2 best solutions below

1
On BEST ANSWER

I did it by changing strophe.js

find:
if (Strophe.getNodeFromJid(this.jid) === null && do_sasl_anonymous) {

Change to :
if (Strophe.getNodeFromJid(this.jid) === '' && do_sasl_anonymous) {

By changing the comparison of the Jid node from null to empty, I was able to authenticate anonymously when only submitting the domain part of the Jid, and still was able to authenticate with DIGEST when sumitting the full Jid and the password.

3
On

First, enable SASL ANONYMOUS in Strophe by passing in null for username and password to connect():

connection.connect(null,
                   null,
                   onConnect);

Next, just send presence to room@conference_service/nick:

var pres = $pres({to: 'room@conference_service/nick'});
connection.send(pres);