AnsweredAssumed Answered

aSmack 4.1: SASL Authentication failed. No known authentication mechanisims.

Question asked by Bernard on Nov 6, 2014
Latest reply on Nov 7, 2014 by Bernard

I do not understand how to connect to my ejabberd server using aSmack 4.1 alpha. Every thing I try results in SASL errors. It appears that SASLAuthentication doesn't have any registered SASLMechanisms which doesn't make sense to me. The read me suggest calling SmackAndroid.init(context), but there is no such class in aSmack 4.1. I have the following jars included in my Android project:

android-support-v4.jar

jxmpp-core-0.4.0.jar

jxmpp-util-cache-0.4.0.jar

smack-android-4.1.0-alpha1.jar

smack-core-4.1.0-alpha1.jar

smack-tcp-4.1.0-alpha1.jar

 

The following is a simplified example of the code I am running.

String userName = "bob@localhost";

String password = "password";

 

 

config.setSecurityMode(SecurityMode.enabled);

config.setCompressionEnabled(true);

config.setDebuggerEnabled(true);

config.setSendPresence(true);

config.setReconnectionAllowed(true);

TrustManager[] trustAllCerts = new TrustManager[] {

     new X509TrustManager() {    

         public java.security.cert.X509Certificate[] getAcceptedIssuers() {

          return new X509Certificate[0];

         }

         public void checkClientTrusted(

        X509Certificate[] certs,

        String authType) {

         }

         public void checkServerTrusted(

        X509Certificate[] certs,

        String authType) {

         }

     }

  };

HostnameVerifier verifier = new HostnameVerifier() {

 

  @Override

  public boolean verify(String hostname, SSLSession session) {

  if (BuildConfig.DEBUG) {

  Log.d(ChatTranslator.APPLICATION_NAME, "Hostname: " + hostname);

  }

  return true;

  }

};

try {

  SSLContext context= SSLContext.getInstance("SSL");

  context.init(null, trustAllCerts, new java.security.SecureRandom());

  config.setCustomSSLContext(context);

  config.setHostnameVerifier(verifier);

} catch (Exception e) {

  if (BuildConfig.DEBUG) {

  Log.e(ChatTranslator.APPLICATION_NAME, "Dummy SSL", e);

  }

}

AbstractXMPPConnection connection = new XMPPTCPConnection(config);

if (!connection.isConnected()) {

  try {

  this.connection.connect();

  } catch (IOException e) {

  throw new NetworkFault(e);

  } catch (Exception e) {

  throw new ConfigurationFault(e);

  }

  try {

  connection.login(userName, password);

  } catch (IOException e) {

  throw new NetworkFault(e);

  } catch (Exception e) {

  throw new AuthenticationFault(e);

  }

  Roster roster = connection.getRoster();

}

 

I have tried to register my own SASLMechanisms but I must not have the implementation correct because those throw errors too.

 

How do I get aSmack 4.1 to authenticate? How do I register the necessary SASLMechanisms? Does 4.1 alpha not support SASL yet?

Outcomes