xmpp-compliance-tester

XMPP Compliance Tester, forked from github.com/iNPUTmice/ComplianceTester
git clone https://git.in0rdr.ch/xmpp-compliance-tester.git
Log | Files | Refs | Pull requests |Archive | README | LICENSE

OMEMO.java (2103B)


      1 package eu.siacs.compliance.tests;
      2 
      3 import eu.siacs.compliance.Result;
      4 import rocks.xmpp.core.session.XmppClient;
      5 import rocks.xmpp.extensions.disco.ServiceDiscoveryManager;
      6 import rocks.xmpp.extensions.disco.model.info.Identity;
      7 import rocks.xmpp.extensions.disco.model.info.InfoNode;
      8 import rocks.xmpp.util.concurrent.AsyncResult;
      9 
     10 import java.util.Arrays;
     11 import java.util.Set;
     12 import java.util.concurrent.TimeUnit;
     13 
     14 /**
     15  * This test checks for the availability of publish-options on the account’s PEP service.
     16  * publish-options allows a client to efficiently change the access model of the OMEMO key material
     17  * such that everyone can access it. Without publish-options OMEMO is only available to contacts with
     18  * mutual presence subscription.
     19  */
     20 public class OMEMO extends AbstractTest {
     21 
     22     private static final String PUBLISH_OPTIONS = "http://jabber.org/protocol/pubsub#publish-options";
     23     private static final String WHITELISTED = "eu.siacs.conversations.axolotl.whitelisted";
     24 
     25     public OMEMO(XmppClient client) {
     26         super(client);
     27     }
     28 
     29     @Override
     30     public Result run() {
     31         ServiceDiscoveryManager manager = client.getManager(ServiceDiscoveryManager.class);
     32         AsyncResult<InfoNode> result = manager.discoverInformation(client.getConnectedResource().asBareJid());
     33         try {
     34             final InfoNode infoNode = result.get(10, TimeUnit.SECONDS);
     35             final Set<String> features = infoNode.getFeatures();
     36             if (!features.contains(PUBLISH_OPTIONS) && !features.contains(WHITELISTED)) {
     37                 return Result.FAILED;
     38             }
     39             for (Identity identity : infoNode.getIdentities()) {
     40                 if ("pep".equalsIgnoreCase(identity.getType()) && "pubsub".equalsIgnoreCase(identity.getCategory())) {
     41                     return Result.PASSED;
     42                 }
     43             }
     44             return Result.FAILED;
     45         } catch (Exception e) {
     46             e.printStackTrace();
     47             return Result.FAILED;
     48         }
     49     }
     50 
     51     @Override
     52     public String getName() {
     53         return "XEP-0384: OMEMO Encryption";
     54     }
     55 }