Mochamad Gufron Efendi
Mochamad Gufron Efendi

Reputation: 1076

iOS Swift XMPPFramework, how to force authentication mechanism?

My jabber server gives response with 3 supported methods: DigestMD5, SCRAM-SHA-1, and Plain. Is there any way to force authentication mechanism of XMPP to, for example, XMPPPlainAuthentication? Well, in android we can blacklist the mechanisms and unblock the only mechanism we need to use. Like this code in android:

    SASLAuthentication.blacklistSASLMechanism("SCRAM-SHA-1");
    SASLAuthentication.blacklistSASLMechanism(SASLMechanism.DIGESTMD5);
    SASLAuthentication.blacklistSASLMechanism(SASLMechanism.EXTERNAL);
    SASLAuthentication.blacklistSASLMechanism(SASLMechanism.GSSAPI);
    SASLAuthentication.unBlacklistSASLMechanism(SASLMechanism.PLAIN);

Any thoughts?

Upvotes: 1

Views: 757

Answers (1)

Mochamad Gufron Efendi
Mochamad Gufron Efendi

Reputation: 1076

When i was trying to look for it, i tried to find it out inside the XMPPFramework code about how they use authentication when they already have received lists of supported mechanisms. And then it is dead simple, for example if you want to use XMPPPlainAuthentication with password, instead of using this code

xmppStream!.authenticatWithPassword(passwordString, error: &error)

try to use this one

let auth = XMPPPlainAuthentication(stream: xmppStream, password: passwordString) xmppStream!.authenticate(auth, error: &error)

that's what i did.

Upvotes: 4

Related Questions