blob: 875538becc99e9a68f3e148ad902fe76c686f3f7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
package eu.siacs.conversations.crypto.sasl;
import android.util.Base64;
import java.nio.charset.Charset;
import eu.siacs.conversations.entities.Account;
public class Plain extends SaslMechanism {
public static final String MECHANISM = "PLAIN";
public Plain(final Account account) {
super(account);
}
public static String getMessage(String username, String password) {
final String message = '\u0000' + username + '\u0000' + password;
return Base64.encodeToString(message.getBytes(Charset.defaultCharset()), Base64.NO_WRAP);
}
@Override
public int getPriority() {
return 10;
}
@Override
public String getMechanism() {
return MECHANISM;
}
@Override
public String getClientFirstMessage() {
return getMessage(account.getUsername(), account.getPassword());
}
}
|