powered by Jive Software

SASL authentication PLAIN failed: not-authorized

Hi,

I use smack to connect a java application to an openfire server. If I connect to our main production openfireserver as admin everthing is fine. When I do the same with my local development openfire server I can’t login. This is part of the stacktrace:

Caused by: SASL authentication PLAIN failed: not-authorized:

at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java: 337)

at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:203)

I created another user. With the same code but new username and password I am able to login.

When I try to login as admin with pidgin I can only do when I add the domain I gave openfire: admin@mydomain. When I try the same with smack it does not work. I still get the same Exception.

The production server uses openfire version 3.6.4. The develpment server uses 3.7.1. Does this difference has something to do with this version difference or do I have to configure something additionally to my development openfire instance?

If you think this issue is related to smack than openfire you may move this diskussion.

Thanks in advance

Facts:

Windows 7 32bit

Openfire 3.7.1

Smack 3.2.2

Java 7

Connection port: 5222

P.S.: Here is the code I wrote:

public List<String> getXmppIdsAvailibleForChat(List<String> candidateXmppIds) throws ChatServiceException {

if (candidateXmppIds == null) {

    throw new NullPointerException("candidateXmppIds = " + candidateXmppIds);

} else if (candidateXmppIds.isEmpty()) {

    throw new IllegalArgumentException("candidateXmppIds is emtpy. candidateXmppIds = " + candidateXmppIds);

}

final Logger logger = Logger.getLogger(getClass().getName());

String logMessage = String.format("Establishing XMPP Connection to chat with following properties: host: %s + port: %s user: %s resource: %s", XMPP_HOST, XMPP_PORT, XMPP_USER, XMPP_RESOURCE);

logger.log(Level.INFO, logMessage);

List<String> xmppIdsAvailibleForChat = new ArrayList<String>();

ConnectionConfiguration connectionConfiguration = new ConnectionConfiguration(XMPP_HOST, XMPP_PORT);

connectionConfiguration.setReconnectionAllowed(false);

// connectionConfiguration.setSASLAuthenticationEnabled(true);

XMPPConnection xmppConnection = new XMPPConnection(connectionConfiguration);

try {

    SASLAuthentication.supportSASLMechanism("PLAIN", 0);

    xmppConnection.connect();

    xmppConnection.login(XMPP_USER, XMPP_PASSWORD, XMPP_RESOURCE);

    Roster roster = xmppConnection.getRoster();

    //The presences of the users my not be availible at this time, because the connection has just been established. Therefore all entries are fetched before the presences will be fetched. In tests this made an overhead < 5 ms. Alternative strategies would be to wait with thread sleep or use a presence listener, which maybe needs a change in the algorithm and maybe a longer running connection.

    roster.getEntries();

    for (String currentXmppId : candidateXmppIds) {

    if (isUserAvailible(roster, currentXmppId)) {

        xmppIdsAvailibleForChat.add(currentXmppId);

    }

    }

} catch (XMPPException ex) {

    throw new ChatServiceException(ex);

} finally {

    if (xmppConnection != null && xmppConnection.isConnected()) {

    xmppConnection.disconnect();

    }

}

return xmppIdsAvailibleForChat;

}