With refer to the xep document below:
XEP-0070: Verifying HTTP Requests via XMPP#4.6 XMPP Client Confirms Request via XMPP
Example 8. XMPP Client Denies Request via IQ
If the user wishes to deny the request, the <iq/> response stanza MUST be of type "error", MAY contain the original <confirm/> child element (although this is not necessary since the XMPP 'id' attribute can be used for tracking purposes), and MUST specify an error, which SHOULD be <not-authorized/>:
Although the inclusion of the <confirm/> element received from the requester is optional, it is found that some server require the <confirm/> element to work properly e.g. ‘auth.agayon.be’.
However in smack IQ class method appendInnerXml(), it is being disabled by designed (see attached source comment); also the IQ source does not allow @override these in sub-class.
/**
* Append the sub-element XML section of the IQ stanza.
*
* @param xml the XmlStringBuilder to append to.
*/
private void appendInnerXml(XmlStringBuilder xml) {
if (type == Type.error) {
// Add the error sub-packet, if there is one.
appendErrorIfExists(xml);
// *** cmeng; must comment out below 'return' to include <confirm/> in error response ***/
return;
}
if (childElementName == null) {
return;
}
// Add the query section if there is one.
IQChildElementXmlStringBuilder iqChildElement = getIQChildElementBuilder(
new IQChildElementXmlStringBuilder(getChildElementName(), getChildElementNamespace(), null, xml.getXmlEnvironment()));
// TOOD: Document the cases where iqChildElement is null but childElementName not. And if there are none, change
// the logic.
if (iqChildElement == null) {
return;
}
xml.append(iqChildElement);
List<ExtensionElement> extensionsXml = getExtensions();
if (iqChildElement.isEmptyElement) {
if (extensionsXml.isEmpty()) {
xml.closeEmptyElement();
return;
}
xml.rightAngleBracket();
}
xml.append(extensionsXml);
xml.closeElement(iqChildElement.element);
}
aTalk generated IQ error stanza when ‘return’ is commented out:
2023-03-01 06:58:19.923 1725-2177/org.atalk.android D/SMACK: RECV (0):
<iq xml:lang='en' to='swordfish@atalk.sytes.net/atalk' from='proxy.atalk.sytes.net' type='result' id='IVIGU-27'>
<query xmlns='http://jabber.org/protocol/bytestreams'>
<streamhost port='7777' host='42.60.99.32' jid='proxy.atalk.sytes.net/55238004'/>
</query>
</iq>
2023-03-01 06:58:20.287 1725-2176/org.atalk.android D/SMACK: SENT (0):
<iq to='auth.agayon.be' id='54' type='error'>
<error type='auth'>
<not-authorized xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
</error>
<confirm xmlns='http://jabber.org/protocol/http-auth' id='36FCSc' method='POST' url='demo.agayon.be'/>
</iq>