blob: df7278a05ae6a4a04596c3358b33ce1eb54c25a9 (
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
40
41
42
43
44
45
46
|
package net.java.sip.communicator.impl.neomedia;
import gnu.java.zrtp.ZrtpConfigure;
import gnu.java.zrtp.ZrtpConstants;
public class ZrtpConfigureUtils {
public static <T extends Enum<T>>String getPropertyID(T algo) {
Class<T> clazz = algo.getDeclaringClass();
return "net.java.sip.communicator." + clazz.getName().replace('$', '_');
}
public static ZrtpConfigure getZrtpConfiguration() {
ZrtpConfigure active = new ZrtpConfigure();
setupConfigure(ZrtpConstants.SupportedPubKeys.DH2K, active);
setupConfigure(ZrtpConstants.SupportedHashes.S256, active);
setupConfigure(ZrtpConstants.SupportedSymCiphers.AES1, active);
setupConfigure(ZrtpConstants.SupportedSASTypes.B32, active);
setupConfigure(ZrtpConstants.SupportedAuthLengths.HS32, active);
return active;
}
private static <T extends Enum<T>> void setupConfigure(T algo, ZrtpConfigure active) {
String id = ZrtpConfigureUtils.getPropertyID(algo);
String savedConf = NeomediaActivator.getConfigurationService().getString(id);
if (savedConf == null)
savedConf = "";
Class <T> clazz = algo.getDeclaringClass();
String savedAlgos[] = savedConf.split(";");
// Configure saved algorithms as active
for (String str : savedAlgos) {
try {
T algoEnum = Enum.valueOf(clazz, str);
if (algoEnum != null) {
active.addAlgo(algoEnum);
}
} catch (IllegalArgumentException e) {
continue;
}
}
}
}
|