commit e3c27710d946bb3bbfbdb2c0f4b6fd5dedc8a666 parent 1dce641ad8a975d05f2dd32c1f54e0ff414c389e Author: Daniel Gultsch <daniel@gultsch.de> Date: Wed, 28 Feb 2018 15:14:51 +0100 Merge branch 'master' of https://github.com/RishiRaj22/ComplianceTester into RishiRaj22-master Diffstat:
A | src/main/java/eu/siacs/compliance/tests/AbuseContactTest.java | | | 38 | ++++++++++++++++++++++++++++++++++++++ |
1 file changed, 38 insertions(+), 0 deletions(-)
diff --git a/src/main/java/eu/siacs/compliance/tests/AbuseContactTest.java b/src/main/java/eu/siacs/compliance/tests/AbuseContactTest.java @@ -0,0 +1,38 @@ +package eu.siacs.compliance.tests; + +import eu.siacs.compliance.Result; +import rocks.xmpp.addr.Jid; +import rocks.xmpp.core.XmppException; +import rocks.xmpp.core.session.XmppClient; +import rocks.xmpp.extensions.data.model.DataForm; +import rocks.xmpp.extensions.disco.ServiceDiscoveryManager; + +import java.util.List; + +public class AbuseContactTest extends AbstractTest { + public AbuseContactTest(XmppClient client) { + super(client); + } + + @Override + public Result run() { + Jid target = Jid.of(client.getConnectedResource().getDomain()); + final ServiceDiscoveryManager serviceDiscoveryManager = client.getManager(ServiceDiscoveryManager.class); + try { + List<DataForm> extensions = serviceDiscoveryManager.discoverInformation(target).getResult().getExtensions(); + for(DataForm extension: extensions) { + final DataForm.Field addr = extension.findField("abuse-addresses"); + if(addr != null && addr.getValues() != null && addr.getValues().size() > 0) { + return Result.PASSED; + } + } + return Result.FAILED; + } catch (XmppException e) { + return Result.FAILED; + } + } + @Override + public String getName() { + return "XEP-0157: Contact Addresses for XMPP Services"; + } +}