Conversations/src/main/java/eu/siacs/conversations/crypto/sasl/Plain.java
Daniel Gultsch 8d2f454479 prefer PLAIN over DIGEST-MD5
DIGEST-MD5 seems to be broken for a lot of cases (OpenFire)
switched priority of PLAIN to not cause any security errors
2015-01-02 01:39:19 +01:00

31 lines
708 B
Java

package eu.siacs.conversations.crypto.sasl;
import android.util.Base64;
import java.nio.charset.Charset;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.xml.TagWriter;
public class Plain extends SaslMechanism {
public Plain(final TagWriter tagWriter, final Account account) {
super(tagWriter, account, null);
}
@Override
public int getPriority() {
return 10;
}
@Override
public String getMechanism() {
return "PLAIN";
}
@Override
public String getClientFirstMessage() {
final String sasl = '\u0000' + account.getUsername() + '\u0000' + account.getPassword();
return Base64.encodeToString(sasl.getBytes(Charset.defaultCharset()), Base64.NO_WRAP);
}
}