Conversations/src/main/java/eu/siacs/conversations/crypto/sasl/Plain.java

31 lines
708 B
Java
Raw Normal View History

2014-11-12 10:15:38 -05:00
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);
}
2014-11-12 10:15:38 -05:00
2014-11-15 09:42:40 -05:00
@Override
public int getPriority() {
return 10;
2014-11-15 09:42:40 -05:00
}
@Override
public String getMechanism() {
return "PLAIN";
}
2014-11-12 10:15:38 -05:00
@Override
public String getClientFirstMessage() {
final String sasl = '\u0000' + account.getUsername() + '\u0000' + account.getPassword();
return Base64.encodeToString(sasl.getBytes(Charset.defaultCharset()), Base64.NO_WRAP);
}
2014-11-12 10:15:38 -05:00
}