blob: 81bd1270527b547a377c47432b8f2e0499976059 (
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
37
38
39
|
package eu.siacs.conversations.crypto.sasl;
import android.util.Log;
import com.google.common.base.CaseFormat;
import java.util.Collection;
import eu.siacs.conversations.Config;
public enum ChannelBinding {
NONE,
TLS_EXPORTER,
TLS_SERVER_END_POINT,
TLS_UNIQUE;
public static ChannelBinding of(final String type) {
if (type == null) {
return null;
}
try {
return valueOf(
CaseFormat.LOWER_HYPHEN.converterTo(CaseFormat.UPPER_UNDERSCORE).convert(type));
} catch (final IllegalArgumentException e) {
Log.d(Config.LOGTAG, type + " is not a known channel binding");
return null;
}
}
public static ChannelBinding best(final Collection<ChannelBinding> bindings) {
if (bindings.contains(TLS_EXPORTER)) {
return TLS_EXPORTER;
} else if (bindings.contains(TLS_UNIQUE)) {
return TLS_UNIQUE;
} else {
return null;
}
}
}
|