my problem there selectedMechanism is equal to null I need to set mechanism to it
public void authenticate(String username, String password, String resource) | |
throws XMPPErrorException, SASLErrorException, IOException, | |
SmackException { | |
SASLMechanism selectedMechanism = selectMechanism(); | |
if (selectedMechanism != null) { | |
currentMechanism = selectedMechanism; |
synchronized (this) { | ||
currentMechanism.authenticate(username, connection.getHost(), | ||
connection.getServiceName(), password); | ||
try { | ||
// Wait until SASL negotiation finishes | ||
wait(connection.getPacketReplyTimeout()); | ||
} | ||
catch (InterruptedException e) { | ||
// Ignore | ||
} | ||
} |
maybeThrowException(); |
if (!authenticationSuccessful) { | |
throw new NoResponseException(); | |
} | |
} | |
else { | |
throw new SmackException( | |
"SASL Authentication failed. No known authentication mechanisims."); | |
} | |
} |