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

AbuseContactTest.java (1346B)


      1 package eu.siacs.compliance.tests;
      2 
      3 import eu.siacs.compliance.Result;
      4 import rocks.xmpp.addr.Jid;
      5 import rocks.xmpp.core.XmppException;
      6 import rocks.xmpp.core.session.XmppClient;
      7 import rocks.xmpp.extensions.data.model.DataForm;
      8 import rocks.xmpp.extensions.disco.ServiceDiscoveryManager;
      9 
     10 import java.util.List;
     11 
     12 public class AbuseContactTest extends AbstractTest {
     13     public AbuseContactTest(XmppClient client) {
     14         super(client);
     15     }
     16 
     17     @Override
     18     public Result run() {
     19         Jid target = Jid.of(client.getConnectedResource().getDomain());
     20         final ServiceDiscoveryManager serviceDiscoveryManager = client.getManager(ServiceDiscoveryManager.class);
     21         try {
     22             List<DataForm> extensions = serviceDiscoveryManager.discoverInformation(target).getResult().getExtensions();
     23             for(DataForm extension: extensions) {
     24                 final DataForm.Field addr = extension.findField("abuse-addresses");
     25                 if(addr != null && addr.getValues() != null && addr.getValues().size() > 0) {
     26                     return Result.PASSED;
     27                 }
     28             }
     29             return Result.FAILED;
     30         } catch (XmppException e) {
     31             return Result.FAILED;
     32         }
     33     }
     34     @Override
     35     public String getName() {
     36         return "XEP-0157: Contact Addresses for XMPP Services";
     37     }
     38 }