package net.java.sip.communicator.impl.neomedia; import gnu.java.zrtp.ZrtpConfigure; import gnu.java.zrtp.ZrtpConstants; public class ZrtpConfigureUtils { public static >String getPropertyID(T algo) { Class 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 > void setupConfigure(T algo, ZrtpConfigure active) { String id = ZrtpConfigureUtils.getPropertyID(algo); String savedConf = NeomediaActivator.getConfigurationService().getString(id); if (savedConf == null) savedConf = ""; Class 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; } } } }