PEP.java (1350B)
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.Set; 11 import java.util.concurrent.TimeUnit; 12 13 public class PEP extends AbstractTest { 14 15 public PEP(XmppClient client) { 16 super(client); 17 } 18 19 @Override 20 public Result run() { 21 ServiceDiscoveryManager manager = client.getManager(ServiceDiscoveryManager.class); 22 AsyncResult<InfoNode> result = manager.discoverInformation(client.getConnectedResource().asBareJid()); 23 try { 24 Set<Identity> identies = result.getResult(10, TimeUnit.SECONDS).getIdentities(); 25 for(Identity identity : identies) { 26 if ("pep".equalsIgnoreCase(identity.getType()) && "pubsub".equalsIgnoreCase(identity.getCategory())) { 27 return Result.PASSED; 28 } 29 } 30 return Result.FAILED; 31 } catch (Exception e) { 32 e.printStackTrace(); 33 return Result.FAILED; 34 } 35 } 36 37 @Override 38 public String getName() { 39 return "XEP-0163: Personal Eventing Protocol"; 40 } 41 }