No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

xep-0079.xml 67KB

  1. <?xml version='1.0' encoding='UTF-8'?>
  2. <!DOCTYPE xep SYSTEM 'xep.dtd' [
  3. <!ENTITY % ents SYSTEM 'xep.ent'>
  4. %ents;
  5. ]>
  6. <?xml-stylesheet type='text/xsl' href='xep.xsl'?>
  7. <xep>
  8. <header>
  9. <title>Advanced Message Processing</title>
  10. <abstract>This specification defines an XMPP protocol extension that enables entities to request, and servers to perform, advanced processing of XMPP message stanzas, including reliable data transport, time-sensitive delivery, and expiration of transient messages.</abstract>
  12. <number>0079</number>
  13. <status>Draft</status>
  14. <type>Standards Track</type>
  15. <sig>Standards</sig>
  16. <dependencies>
  17. <spec>XMPP Core</spec>
  18. <spec>XEP-0030</spec>
  19. <spec>XEP-0082</spec>
  20. </dependencies>
  21. <supersedes>
  22. <spec>XEP-0023</spec>
  23. </supersedes>
  24. <supersededby/>
  25. <shortname>amp</shortname>
  26. <schemaloc>
  27. <ns>amp</ns>
  28. <url></url>
  29. </schemaloc>
  30. <schemaloc>
  31. <ns>amp#errors</ns>
  32. <url></url>
  33. </schemaloc>
  34. <schemaloc>
  35. <ns>feature</ns>
  36. <url></url>
  37. </schemaloc>
  38. <registry/>
  39. &linuxwolf;
  40. &stpeter;
  41. <revision>
  42. <version>1.2</version>
  43. <date>2005-11-30</date>
  44. <initials>psa</initials>
  45. <remark>Consolidated and generalized security considerations.</remark>
  46. </revision>
  47. <revision>
  48. <version>1.1</version>
  49. <date>2005-10-19</date>
  50. <initials>psa</initials>
  51. <remark>Reversed the meaning of conditions other than expire-at (per list discussion); correctly specified stream feature.</remark>
  52. </revision>
  53. <revision>
  54. <version>1.0</version>
  55. <date>2004-10-11</date>
  56. <initials>psa</initials>
  57. <remark>Per a vote of the Jabber Council, advanced to a status of Draft.</remark>
  58. </revision>
  59. <revision>
  60. <version>0.12</version>
  61. <date>2004-09-09</date>
  62. <initials>lw</initials>
  63. <remark>Relaxed server-to-server requirements; clarified discovery rules; removed expire-in condition.</remark>
  64. </revision>
  65. <revision>
  66. <version>0.11</version>
  67. <date>2004-08-25</date>
  68. <initials>lw/psa</initials>
  69. <remark>Specified that the timestamp for an expire-at condition must be a UTC DateTime per XEP-0082; provided further explanation regarding expire-at and expire-in conditions.</remark>
  70. </revision>
  71. <revision>
  72. <version>0.10</version>
  73. <date>2004-07-14</date>
  74. <initials>lw/psa</initials>
  75. <remark>Changes to address Council feedback: clarified error handling and provided error examples; specified that server should validate all rule semantics before returning an error; specified that service discovery information can be cached (not necessary to send disco query before dispatching each message); added "forward" and "gateway" to values of "deliver" condition to handle redirection of messages to alternate XMPP addresses and non-XMPP systems respectively; more clearly specified processing rules for "expire-in" condition; changed milliseconds to seconds for "expire-in"; made explicit that partial JID-matching is not included for "match-resource" condition; added clarifying note to security consideration regarding "deliver" condition; corrected values of per-hop from [yes|no] to [true|false]; changed "standard" conditions to "defined" conditions and mandated that they should be supported; changed "" namespace to "".</remark>
  76. </revision>
  77. <revision>
  78. <version>0.9</version>
  79. <date>2004-04-25</date>
  80. <initials>psa</initials>
  81. <remark>Editorial review: clarified some matters in the text; fully defined the XMPP Registrar Considerations.</remark>
  82. </revision>
  83. <revision>
  84. <version>0.8</version>
  85. <date>2004-01-20</date>
  86. <initials>lw</initials>
  87. <remark>Reorganized for Editorial preferences; revised error conditions to properly align with XMPP-Core</remark>
  88. </revision>
  89. <revision>
  90. <version>0.7</version>
  91. <date>2003-12-10</date>
  92. <initials>lw</initials>
  93. <remark>Incorported changes requested from Standards list discussions: Changed entity-to-server discovery behavior; s2s discovery behavior; Expanded application-specific error conditions; Reorganized for better presentation; Changed "per-hop" to apply to the entire ruleset; Fixed minor typos and missteps</remark>
  94. </revision>
  95. <revision>
  96. <version>0.6</version>
  97. <date>2003-10-15</date>
  98. <initials>lw</initials>
  99. <remark>Changed disco behavior; Changed schema to reflect customizations</remark>
  100. </revision>
  101. <revision>
  102. <version>0.5.1</version>
  103. <date>2003-09-20</date>
  104. <initials>lw</initials>
  105. <remark>Fixed many typos</remark>
  106. </revision>
  107. <revision>
  108. <version>0.5</version>
  109. <date>2003-08-28</date>
  110. <initials>lw</initials>
  111. <remark>Renamed to "amp" (thanks stpeter!); Added information about the original addressing; Added requirement for id attribute in &MESSAGE;; Restricted behavior within the "Security Considerations";</remark>
  112. </revision>
  113. <revision>
  114. <version>0.4</version>
  115. <date>2003-06-23</date>
  116. <initials>lw</initials>
  117. <remark>Completely rewritten to better account for various suggested usage details and requirements; Completely reorganized to better codify the protocol(s) and their possible uses; Added more conditions; Added more actions; Added common usage scenarios</remark>
  118. </revision>
  119. <revision>
  120. <version>0.3</version>
  121. <date>2003-04-21</date>
  122. <initials>lw</initials>
  123. <remark>Clarified client-side processing; Removed semantics scope; Clarified "fail" action; Moved existing "use-cases" into "Usage" section in "Overview"; Added more relevant use cases; Added XMPP-style error conditions</remark>
  124. </revision>
  125. <revision>
  126. <version>0.2</version>
  127. <date>2003-04-15</date>
  128. <initials>psa</initials>
  129. <remark>Added XML Schema (with author's assistance).</remark>
  130. </revision>
  131. <revision>
  132. <version>0.1</version>
  133. <date>2003-04-15</date>
  134. <initials>lw</initials>
  135. <remark>Initial version.</remark>
  136. </revision>
  137. </header>
  138. <section1 topic='Introduction' anchor='intro'>
  139. <p>This document defines a protocol that enables an end-point entity to specify additional delivery semantics for an XMPP &lt;message/&gt; stanza. This protocol is typically used by clients to inform the receiving server how to deliver a particular stanza, such as providing an expiration time or a resource-matching strategy.</p>
  140. <section2 topic='Motivation' anchor='intro-motivation'>
  141. <p>The built-in delivery semantics for &lt;message/&gt; stanzas (defined in &xmppcore; and, for instant messaging applications, also in &xmppim;) are adequate for most current applications. However, there are various cases where more stringent delivery semantics are necessary. The most common cases discussed in this document are:</p>
  142. <ul>
  143. <li>Reliable data transport -- the sender requires notification (positive and/or negative) of message delivery.</li>
  144. <li>Time-sensitive messages -- the message is valid only until a certain date and time.</li>
  145. <li>Transient messages -- the message should not be stored offline for later delivery.</li>
  146. </ul>
  147. </section2>
  148. <section2 topic='Concepts' anchor='intro-concepts'>
  149. <p>This protocol is mostly handled by the server or servers processing the &lt;message/&gt;. The protocol consists of a list of rules, with conditions and actions for each rule. Upon receipt of an appropriately marked message, the server interprets the rules in the order they are received, looking for met conditions. When a condition is met, the action for that rule is executed, and message processing stops.</p>
  150. <p>Each rule is flagged for the scope it applies to, whether it be the overall route, or for each hop in the route. Additionally, while this document defines a default set of conditions and actions, the protocol is extensible enough to allow for more to be defined in the future.</p>
  151. <p>The namespace for the protocol is "".</p>
  152. </section2>
  153. <section2 topic='Prerequisites' anchor='intro-prereq'>
  154. <p>In order for this protocol to function properly, the containing &MESSAGE; stanza MUST possess an 'id' attribute, and the value of the 'id' attribute MUST NOT be an empty string. The server MUST include this 'id' attribute value with any response back to the sender; this enables servers and clients to properly relate the initial request with any subsequent alert, error, or notification.</p>
  155. </section2>
  156. </section1>
  157. <section1 topic='Process Flows' anchor='process'>
  158. <section2 topic='Sender-to-Server' anchor='process-s2s'>
  159. <p>The following use case flow describes the interaction between the sender and a server. As illustrated below, this interaction is actually rather simple:</p>
  160. <ol>
  161. <li>Sender determines support (E1)</li>
  162. <li>Sender specifies appropriate rules and sends message to server (E1,E2)</li>
  163. <li>Sender awaits any protocol-specific responses (UCE)</li>
  164. </ol>
  165. <ul>
  166. <li><cite>E1:</cite> The server does not support this protocol (UCE unsuccessfully)</li>
  167. <li><cite>E2:</cite> The server does not support one or more specified rule conditions/actions (UCE unsuccessfully)</li>
  168. </ul>
  169. <section3 topic='Discovery' anchor='process-s2s-disco'>
  170. <p>Sending entities that wish to use AMP SHOULD discover support for this protocol (using &xep0030;) along the intended path. Typically, this would involve sending disco#info queries to the sending entity's own server and the server of the intended recipient. The results of these queries MAY be cached for up to 24 hours, unless otherwise expired.</p>
  171. <p>If a server supports Advanced Message Processing, it MUST report that by including a service discovery feature of "" in the service discovery information result that it returns to the requesting entity.</p>
  172. <example caption="Initial Service Discovery information request"><![CDATA[
  173. <iq from='northumberland@shakespeare.lit/westminster'
  174. to='shakespeare.lit'
  175. type='get'>
  176. <query xmlns=''/>
  177. </iq>
  178. ]]></example>
  179. <example caption="Service Discovery information response"><![CDATA[
  180. <iq from='shakespeare.lit'
  181. to='northumberland@shakespeare.lit/westminster'
  182. type='result'>
  183. <query xmlns=''>
  184. <identity name='Shakespeare IM' category='im' type='server'/>
  185. ...
  186. <feature var=''/>
  187. ...
  188. </query>
  189. </iq>
  190. ]]></example>
  191. <p>A server SHOULD also maintain a service discovery node named "", at which it advertises the individual actions and conditions it supports. If an entity needs to determine whether the server supports individual actions and conditions, it SHOULD send a service discovery information request to that node; the server then MUST either return the list of supported actions and conditions or return an error such as &feature;. (Note: If the server does not provide information for this disco node, the requesting entity MUST assume that all actions and conditons are supported for each reported action set or condition set.)</p>
  192. <p>Each supported action shall be reported as a feature using the following format:</p>
  193. <code>{action}</code>
  194. <p>Each supported condition shall be reported as a feature using the following format:</p>
  195. <code>{condition}</code>
  196. <p>The following examples show the request-response flow for information about individual actions and conditions (note the inclusion of the 'node' attribute).</p>
  197. <example caption="Request for information about individual actions and conditions"><![CDATA[
  198. <iq from='northumberland@shakespeare.lit/westminster'
  199. to='shakespeare.lit'
  200. type='get'>
  201. <query xmlns=''
  202. node=''/>
  203. </iq>
  204. ]]></example>
  205. <example caption="Response for individual actions and conditions"><![CDATA[
  206. <iq from='shakespeare.lit'
  207. to='northumberland@shakespeare.lit/westminster'
  208. type='result'>
  209. <query xmlns=''
  210. node=''>
  211. <identity name='Shakespeare IM AMP Support' category='im' type='server'/>
  212. ...
  213. <feature var=''/>
  214. <feature var=''/>
  215. <feature var=''/>
  216. <feature var=''/>
  217. <feature var=''/>
  218. <feature var=''/>
  219. <feature var=''/>
  220. ...
  221. </query>
  222. </iq>
  223. ]]></example>
  224. </section3>
  225. <section3 topic='Specifying Semantics' anchor='process-s2s-semantics'>
  226. <p>Once support is determined, the sender can attach the desired delivery semantics to the message:</p>
  227. <example caption='A message with AMP semantics'><![CDATA[
  228. <message
  229. from='northumberland@shakespeare.lit'
  230. id='richard2-4.1.247'
  231. to='kingrichard@royalty.england.lit'>
  232. <body>My lord, dispatch; read o'er these articles.</body>
  233. <amp xmlns=''>
  234. <rule condition='expire-at'
  235. action='drop'
  236. value='2004-01-01T00:00:00Z'/>
  237. </amp>
  238. </message>
  239. ]]></example>
  240. <p>The semantics are defined as a set of &lt;rule/&gt; elements within the &lt;amp/&gt; root element. Each &lt;rule/&gt; declares the condition to trigger on and the action to execute if triggered.</p>
  241. <p>By default, the ruleset applies only to the "edge servers": those servers to which the sending and receiving entities are connected. (Note: For the purposes of Advanced Message Processing, "server" is defined as in <cite>XMPP Core</cite> and does not include any internal components, such as connection managers, that may provide functionality within a server implementation or installation.)</p>
  242. <p>The ruleset MAY be applied to all server-to-server "hops" along the route from the sending and receiving entities by adding the "per-hop' attribute to the &lt;amp/&gt; element. The value of this attribute is either "true" (apply rules to all hops) or "false" (follow default behavior, i.e., apply rules at the edge servers only).</p>
  243. <example caption='Another message with AMP semantics'><![CDATA[
  244. <message
  245. from='northumberland@shakespeare.lit'
  246. id='richard2-4.1.247'
  247. to='kingrichard@royalty.england.lit'>
  248. <body>My lord, dispatch; read o'er these articles.</body>
  249. <amp xmlns=''
  250. per-hop='true'>
  251. <rule condition='expire-at'
  252. action='drop'
  253. value='2004-01-01T00:00:00Z'/>
  254. </amp>
  255. </message>
  256. ]]></example>
  257. <p>For examples of validation failure, refer to the <link url="#errors">Error Handling</link> section of this document.</p>
  258. <p>Note: Even if "per-hop" processing is requested, each server in the route MUST ignore rules that cannot apply to it; the <link url="#conditions-def">Defined Conditions</link> outline if they can be applied per-hop.</p>
  259. </section3>
  260. </section2>
  261. <section2 topic='Server Processing' anchor='process-server'>
  262. <p>Server operation is where the bulk of the work is performed. Upon receiving a message with an AMP extension, the server performs the following flow:</p>
  263. <ol>
  264. <li>Validate the semantics (E1, E2).</li>
  265. <li>Determine the default behavior.</li>
  266. <li>Process rules until condition is met.
  267. <ul>
  268. <li>If a condition is met, execute that rule's action</li>
  269. <li>If no conditions are met, perform "default" behavior for message</li>
  270. </ul>
  271. </li>
  272. <li>Execute determined action (UCE) (E3).</li>
  273. </ol>
  274. <ul>
  275. <li><cite>E1:</cite> The provided semantics (condition and/or action) are not supported or valid (UCE unsuccessfully)</li>
  276. <li><cite>E2:</cite> The requested semantics are not acceptable (UCE unsuccessfully)</li>
  277. <li><cite>E3:</cite> The next server does not support this protocol (UCE unsuccessfully)</li>
  278. </ul>
  279. <section3 topic='Validating Semantics' anchor='process-server-semantics'>
  280. <p>Validation can take many forms, but at the very least the server MUST verify that it understands each of the rule conditions and actions, and that the condition contents are appropriate. The server MAY also refuse to accept certain combinations of conditions and actions, for example if they present a risk of violating security policies. If the semantics are not valid, supported, or acceptable, the server MUST reply with an error specifying the rule(s) that are at issue. The server SHOULD validate all the semantics before returning an error. For syntax and examples of error handling related to validation failure, refer to the <link url="#errors">Error Handling</link> section of this document.</p>
  281. </section3>
  282. <section3 topic='Determine Default Action' anchor='process-server-default'>
  283. <p>This step is essentially what a server normally does, except that it does not actually perform the action. This determines what would happen to the message if there were no semantics attached (such as dispatch to another server or store offline). At this point, the server SHOULD also calculate any timing or calendar requirements (if applicable).</p>
  284. </section3>
  285. <section3 topic='Process Rules' anchor='process-server-rules'>
  286. <p>At this step, the server processes the attached semantics. The server MUST process the rules serially, and in the order they are presented within the &lt;amp/&gt; element. As soon as a rule's condition is met, processing ends with that action overriding the default action determined earlier (unless the action permits continued processing).</p>
  287. </section3>
  288. <section3 topic='Execute Determined Action' anchor='process-server-execute'>
  289. <p>Once all rules have been processed or otherwise accounted for, the server executes the action determined at this point.</p>
  290. <p>A server SHOULD NOT dispatch a &MESSAGE; stanza with AMP semantics to another server unless it knows that the next server supports AMP (this SHOULD be discovered via <cite>Service Discovery</cite> and MAY be cached to avoid delivery delays). If the next server does not support AMP, the current server replies to the original sender with a &e503; error condition. Otherwise this flow starts again for the server to which the message has been dispatched.</p>
  291. </section3>
  292. <section3 topic='Return Event' anchor='process-server-event'>
  293. <p>If the determined action involves returning an event (alert, error, or notification) to the sender, a server MUST send a &MESSAGE; stanza to the sender containing the rule that was met. This &MESSAGE; stanza MUST include the original value of the 'id' attribute and SHOULD NOT contain the non-AMP contents (e.g., &BODY; child) originally included by the sender.</p>
  294. </section3>
  295. </section2>
  296. </section1>
  297. <section1 topic='Conditions and Actions' anchor='conditionsactions'>
  298. <p>The preceding sections of this document define the general behavior regarding AMP. This section outlines how &lt;rule/&gt; action and condition sets are specified. It also provides defined action and condition sets; these action and condition sets SHOULD be supported by any implementation of Advanced Message Processing, but support for any given action or condition set it not required. (Note: The action and condition sets defined herein may be supplemented in the future via registration of additional action and condition sets with the XMPP Registrar.)</p>
  299. <section2 topic='Rule Condition Guidelines' anchor='conditions-guide'>
  300. <p>The definition of a &lt;rule/&gt; condition MUST provide the following information:</p>
  301. <ul>
  302. <li>Define a namespace governing the condition set</li>
  303. <li>Define the condition:
  304. <ul>
  305. <li>Define the 'condition' attribute value</li>
  306. <li>Specify if the "per-hop" flag applies</li>
  307. <li>Define the syntax/format of the 'value' attribute value</li>
  308. <li>Define how the "value" is interpreted to meet a condition</li>
  309. </ul>
  310. </li>
  311. </ul>
  312. </section2>
  313. <section2 topic='Rule Action Guidelines' anchor='actions-guide'>
  314. <p>The definition of a &lt;rule/&gt; action MUST provide the following information:</p>
  315. <ul>
  316. <li>Define a namespace governing the action set</li>
  317. <li>Define the action:
  318. <ul>
  319. <li>Define each 'action' attribute value</li>
  320. <li>Define the expected behavior if the &lt;rule/&gt; is triggered</li>
  321. </ul>
  322. </li>
  323. </ul>
  324. </section2>
  325. <section2 topic='Defined Conditions' anchor='conditions-def'>
  326. <p>The condition defines how or when a particular rule is triggered. The value of the condition attribute determines what the contents of the &lt;rule/&gt; mean.</p>
  327. <p>The following conditions are defined by this document and SHOULD be supported by any implementation.</p>
  328. <p>In the following sections, the terms "content" and "contents" refers to the XML character data contained by the &lt;rule/&gt; element.</p>
  329. <section3 topic='deliver' anchor='conditions-def-deliver'>
  330. <p>The "deliver" condition is used to ensure delivery (or non-delivery) in one of five ways:</p>
  331. <ol>
  332. <li>Directly to the specified address or account over XMPP</li>
  333. <li>Delayed to offline storage (for later delivery via XMPP)</li>
  334. <li>Forwarded to an alternate address or account over XMPP</li>
  335. <li>Indirectly to an alternate address or account through a gateway to a non-XMPP system</li>
  336. </ol>
  337. <p>This condition is met based on what the processor would do with the message at the moment of receipt, as follows:</p>
  338. <table caption='"deliver" values'>
  339. <tr>
  340. <th>Value</th>
  341. <th>Description</th>
  342. </tr>
  343. <tr>
  344. <td>direct</td>
  345. <td>The message would be immediately delivered to the intended recipient or routed to the next hop.</td>
  346. </tr>
  347. <tr>
  348. <td>forward</td>
  349. <td>The message would be forwarded to another XMPP address or account.</td>
  350. </tr>
  351. <tr>
  352. <td>gateway</td>
  353. <td>The message would be sent through a gateway to an address or account on a non-XMPP system.</td>
  354. </tr>
  355. <tr>
  356. <td>none</td>
  357. <td>The message would not be delivered at all (e.g., because the intended recipient is offline and message storage is not enabled).</td>
  358. </tr>
  359. <tr>
  360. <td>stored</td>
  361. <td>The message would be stored offline for later delivery to the intended recipient.</td>
  362. </tr>
  363. </table>
  364. <p>This condition MAY be applied to each "hop" in the server route.</p>
  365. </section3>
  366. <section3 topic='expire-at' anchor='conditions-def-expireat'>
  367. <p>The "expire-at" condition is used to ensure delivery before an absolute point in time. Naturally, this does not <em>guarantee</em> <note>Guarantee is a strong word. This document defines methods for making message delivery more reliable within certain bounds, but does not pretend that such methods provide any form of guaranteed delivery.</note> that the message will not be delivered after that time from the sender's perspective, since this document does not assume that all machine clocks (e.g., for all servers along the delivery route) are synchronized. However, in order to help ensure that this condition is met correctly, servers that implement this document (or the machines that host such servers) SHOULD use the Network Time Protocol (&rfc1305;) to keep in sync with established time authorities. Note also that expire-at functionality becomes less reliable the closer the expire-at time is to the present (e.g., the sender will receive less reliable delivery of a message speciifying an expire-at time two seconds in the future than of a message specifying an expire-at time two hours or two days in the future).</p>
  368. <p>The content of the 'value' attribute specifies some point after the exact moment the message is sent; the content MUST be a DateTime as specified in &xep0082;, and the timezone MUST be UTC.</p>
  369. <p>The condition is met if the message would be delivered to the recipient after the specified datetime. To determine the datetime to compare to, the processor first determines if and when a message can be dispatched (e.g. not stored offline). The processor then records this datetime, and compares it with the specified datetime. If the current datetime is on or after that specified, the condition is met.</p>
  370. <p>This condition MAY be applied to each "hop" in the server route.</p>
  371. </section3>
  372. <section3 topic='match-resource' anchor='conditions-def-match'>
  373. <p>The "match-resource" condition is used to restrict delivery based on the resource identifier of the recipient JID.</p>
  374. <p>The defined values for this condition are:</p>
  375. <table caption='"match-resource" values'>
  376. <tr>
  377. <th>Value</th>
  378. <th>Description</th>
  379. <th>Example</th>
  380. </tr>
  381. <tr>
  382. <td>any</td>
  383. <td>Destination resource matches any value, effectively ignoring the intended resource.</td>
  384. <td>"home/laptop" matches "home", "home/desktop" or "work/desktop"</td>
  385. </tr>
  386. <tr>
  387. <td>exact</td>
  388. <td>Destination resource exactly matches the intended resource.</td>
  389. <td>"home/laptop" only matches "home/laptop" and not "home/desktop" or "work/desktop"</td>
  390. </tr>
  391. <tr>
  392. <td>other</td>
  393. <td>Destination resource matches any value except for the intended resource.</td>
  394. <td>"home/laptop" matches "work/desktop", "home" or "home/desktop", but not "home/laptop"</td>
  395. </tr>
  396. </table>
  397. <p>The condition is met if the resource for the actual destination JID matches the intended JID using the above rules. For instance, if a message is intended for "" with the "match-resource" condition of "exact", the condition is met if the message can be immediately delivered only to "".</p>
  398. <p>For purposes of this condition, an intended JID with no resource has the following behavior:</p>
  399. <ul>
  400. <li>If the value is "exact", the condition is met only if the server would deliver to a destination JID without a resource identifier (e.g., a &xep0045; room or offline storage).</li>
  401. <li>If the value is "other", the condition is met only if the server would not deliver to a destination JID without a resource identifier.</li>
  402. </ul>
  403. <p>This condition MUST NOT be applied to each "hop" in the server route, only at the edge servers. If an &lt;amp/&gt; element includes this condition and also indicates that it should be processed per hop, this &lt;rule/&gt; shall be ignored.</p>
  404. <p>Note: By design, this protocol does not include support for partial resource matching (which would stipulate, for example, that the resource identifiers "home/laptop" and "homeboy" both match "home").</p>
  405. </section3>
  406. </section2>
  407. <section2 topic='Defined Actions' anchor='actions-def'>
  408. <p>The action defines what occurs when a particular rule is triggered. The value of the action attribute determines the behavior if the rule's condition is met.</p>
  409. <p>The following actions are defined by this document.</p>
  410. <section3 topic='alert' anchor='actions-def-alert'>
  411. <p>The "alert" action triggers a reply &MESSAGE; stanza to the sending entity. This &MESSAGE; stanza MUST contain the element &lt;amp status='alert'/&gt;, which itself contains the &lt;rule/&gt; that triggered this action. In all other respects, this action behaves as "drop".</p>
  412. <example caption='Alert Response'><![CDATA[
  413. <message from='hamlet.lit'
  414. to='bernardo@hamlet.lit/elsinore'
  415. id='chatty2'>
  416. <amp xmlns=''
  417. status='alert'
  418. from='bernardo@hamlet.lit/elsinore'
  419. to='francisco@hamlet.lit'>
  420. <rule action='alert' condition='deliver' value='stored'/>
  421. </amp>
  422. </message>
  423. ]]></example>
  424. </section3>
  425. <section3 topic='drop' anchor='actions-def-drop'>
  426. <p>The "drop" action silently discards the message from any further delivery attempts and ensures that it is not placed into offline storage. The drop MUST NOT result in other responses.</p>
  427. </section3>
  428. <section3 topic='error' anchor='actions-def-error'>
  429. <p>The "error" action triggers a reply &MESSAGE; stanza of type "error" to the sending entity. The &MESSAGE; stanza's &lt;error/&gt; child MUST contain a &lt;failed-rules xmlns=''/&gt; error condition, which itself contains the rules that triggered this action.</p>
  430. <example caption='Error Response'><![CDATA[
  431. <message from='hamlet.lit'
  432. to='bernardo@hamlet.lit/elsinore'
  433. type='error'
  434. id='chatty2'>
  435. <amp xmlns=''
  436. status='error'
  437. to='bernardo@hamlet.lit/elsinore'
  438. from='francisco@hamlet.lit'>
  439. <rule action='error' condition='deliver' value='stored'/>
  440. </amp>
  441. <error type='modify' code='500'>
  442. <undefined-condition xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  443. <failed-rules xmlns=''>
  444. <rule action='error' condition='deliver' value='stored'/>
  445. </failed-rules>
  446. </error>
  447. </message>
  448. ]]></example>
  449. <p>Note that the error SHOULD be of type "modify", and the general error condition SHOULD be &lt;undefined-condition xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;.</p>
  450. </section3>
  451. <section3 topic='notify' anchor='actions-def-notify'>
  452. <p>The "notify" action triggers a reply &MESSAGE; stanza to the sending entity. This &MESSAGE; stanza MUST contain the element &lt;amp status='notify'/&gt;, which itself contains the &lt;rule/&gt; that triggered this action. Unlike the other actions, this action does not override the default behavior for a server. Instead, the server then executes its default behavior after sending the notify.</p>
  453. <example caption='Notify Response'><![CDATA[
  454. <message from='hamlet.lit'
  455. to='bernardo@hamlet.lit/elsinore'
  456. id='chatty2'>
  457. <amp xmlns=''
  458. status='notify'
  459. to='bernardo@hamlet.lit/elsinore'
  460. from='francisco@hamlet.lit'>
  461. <rule action='notify' condition='deliver' value='stored'/>
  462. </amp>
  463. </message>
  464. ]]></example>
  465. </section3>
  466. </section2>
  467. <section2 topic='Description of Condition/Action Combinations' anchor='description'>
  468. <p>In general, a rule can be read as "do {action} if {condition} is true for {value}"; however, to facilitate understanding, this section describes the various condition/action combinations in plain English.</p>
  469. <section3 topic='Deliver Rules' anchor='description-deliver'>
  470. <p>When the condition is "deliver", the rules can be described as follows:</p>
  471. <table caption='Deliver Rules'>
  472. <tr>
  473. <th>Action</th>
  474. <th>Value</th>
  475. <th>Description</th>
  476. </tr>
  477. <tr>
  478. <td>alert</td>
  479. <td>direct</td>
  480. <td>Return an alert if the message would be delivered directly.</td>
  481. </tr>
  482. <tr>
  483. <td>alert</td>
  484. <td>forward</td>
  485. <td>Return an alert if the message would be forwarded to another XMPP address.</td>
  486. </tr>
  487. <tr>
  488. <td>alert</td>
  489. <td>gateway</td>
  490. <td>Return an alert if the message would be delivered to a non-XMPP address through a gateway.</td>
  491. </tr>
  492. <tr>
  493. <td>alert</td>
  494. <td>none</td>
  495. <td>Return an alert if no delivery is possible.</td>
  496. </tr>
  497. <tr>
  498. <td>alert</td>
  499. <td>stored</td>
  500. <td>Return an alert if the message would be stored offline for later delivery via XMPP.</td>
  501. </tr>
  502. <tr>
  503. <td>drop</td>
  504. <td>direct</td>
  505. <td>Drop the message if it would be delivered directly.</td>
  506. </tr>
  507. <tr>
  508. <td>drop</td>
  509. <td>forward</td>
  510. <td>Drop the message if it would be forwarded to another XMPP address.</td>
  511. </tr>
  512. <tr>
  513. <td>drop</td>
  514. <td>gateway</td>
  515. <td>Drop the message if it would be delivered to a non-XMPP address through a gateway.</td>
  516. </tr>
  517. <tr>
  518. <td>drop</td>
  519. <td>none</td>
  520. <td>Drop the message if no delivery is possible.</td>
  521. </tr>
  522. <tr>
  523. <td>drop</td>
  524. <td>stored</td>
  525. <td>Drop the message if it would be stored offline for later delivery via XMPP.</td>
  526. </tr>
  527. <tr>
  528. <td>error</td>
  529. <td>direct</td>
  530. <td>Return an error if the message would be delivered directly.</td>
  531. </tr>
  532. <tr>
  533. <td>error</td>
  534. <td>forward</td>
  535. <td>Return an error if the message would be forwarded to another XMPP address.</td>
  536. </tr>
  537. <tr>
  538. <td>error</td>
  539. <td>gateway</td>
  540. <td>Return an error if the message would be delivered to a non-XMPP address through a gateway.</td>
  541. </tr>
  542. <tr>
  543. <td>error</td>
  544. <td>none</td>
  545. <td>Return an error if no delivery is possible.</td>
  546. </tr>
  547. <tr>
  548. <td>error</td>
  549. <td>stored</td>
  550. <td>Return an error if the message would be stored offline for later delivery via XMPP.</td>
  551. </tr>
  552. <tr>
  553. <td>notify</td>
  554. <td>direct</td>
  555. <td>Return a notification if the message would be delivered directly.</td>
  556. </tr>
  557. <tr>
  558. <td>notify</td>
  559. <td>forward</td>
  560. <td>Return a notification if the message would be forwarded to another XMPP address.</td>
  561. </tr>
  562. <tr>
  563. <td>notify</td>
  564. <td>gateway</td>
  565. <td>Return a notification if the message would be delivered to a non-XMPP address through a gateway.</td>
  566. </tr>
  567. <tr>
  568. <td>notify</td>
  569. <td>none</td>
  570. <td>Return a notification if no delivery is possible.</td>
  571. </tr>
  572. <tr>
  573. <td>notify</td>
  574. <td>stored</td>
  575. <td>Return a notification if the message would be stored offline for later delivery via XMPP.</td>
  576. </tr>
  577. </table>
  578. </section3>
  579. <section3 topic='Expire-at Rules' anchor='description-expire-at'>
  580. <p>When the condition is "expire-at", the rules can be described as follows:</p>
  581. <table caption='Expiration Rules'>
  582. <tr>
  583. <th>Action</th>
  584. <th>Description</th>
  585. </tr>
  586. <tr>
  587. <td>alert</td>
  588. <td>Return an alert if the message would be delivered after the specified timestamp.</td>
  589. </tr>
  590. <tr>
  591. <td>drop</td>
  592. <td>Drop the message if it would be delivered after the specified timestamp.</td>
  593. </tr>
  594. <tr>
  595. <td>error</td>
  596. <td>Return an error if the message would be delivered after the specified timestamp.</td>
  597. </tr>
  598. <tr>
  599. <td>notify</td>
  600. <td>Return a notification if the message would be delivered after the specified timestamp.</td>
  601. </tr>
  602. </table>
  603. </section3>
  604. <section3 topic='Match-resource Rules' anchor='description-match-resource'>
  605. <p>When the condition is "match-resource", the rules can be described as follows:</p>
  606. <table caption='Resource Matching Rules'>
  607. <tr>
  608. <th>Action</th>
  609. <th>Value</th>
  610. <th>Description</th>
  611. </tr>
  612. <tr>
  613. <td>alert</td>
  614. <td>any</td>
  615. <td>Return an alert if the message would be delivered to any resource.</td>
  616. </tr>
  617. <tr>
  618. <td>alert</td>
  619. <td>exact</td>
  620. <td>Return an alert if the message would be delivered to the exact resource.</td>
  621. </tr>
  622. <tr>
  623. <td>alert</td>
  624. <td>other</td>
  625. <td>Return an alert if the message would be delivered to a resource other than that specified.</td>
  626. </tr>
  627. <tr>
  628. <td>drop</td>
  629. <td>any</td>
  630. <td>Drop the message if it would be delivered to any resource.</td>
  631. </tr>
  632. <tr>
  633. <td>drop</td>
  634. <td>exact</td>
  635. <td>Drop the message if it would be delivered to the exact resource.</td>
  636. </tr>
  637. <tr>
  638. <td>drop</td>
  639. <td>other</td>
  640. <td>Drop the message if it would be delivered to a resource other than that specified.</td>
  641. </tr>
  642. <tr>
  643. <td>error</td>
  644. <td>any</td>
  645. <td>Return an error if the message would be delivered to any resource.</td>
  646. </tr>
  647. <tr>
  648. <td>error</td>
  649. <td>exact</td>
  650. <td>Return an error if the message would be delivered to the exact resource.</td>
  651. </tr>
  652. <tr>
  653. <td>error</td>
  654. <td>other</td>
  655. <td>Return an error if the message would be delivered to a resource other than that specified.</td>
  656. </tr>
  657. <tr>
  658. <td>notify</td>
  659. <td>any</td>
  660. <td>Return a notification if the message would be delivered to any resource.</td>
  661. </tr>
  662. <tr>
  663. <td>notify</td>
  664. <td>exact</td>
  665. <td>Return a notification if the message would be delivered to the exact resource.</td>
  666. </tr>
  667. <tr>
  668. <td>notify</td>
  669. <td>other</td>
  670. <td>Return a notification if the message would be delivered to a resource other than that specified.</td>
  671. </tr>
  672. </table>
  673. </section3>
  674. </section2>
  675. </section1>
  676. <section1 topic='Formal Description' anchor='formal'>
  677. <section2 topic='&lt;amp/&gt; Root Element' anchor='formal-root'>
  678. <p>All delivery semantics are encapsulated in the &lt;amp/&gt; element. This element contains one or more &lt;rule/&gt; elements specifying the specific rules to process. It can optionally possess attributes about the current status, the original sender and recipient, and route applicability.</p>
  679. <p>The 'status' attribute specifies the reason for this &lt;amp/&gt; element. When specifying semantics to be applied (client to server), this attribute MUST NOT be present. When replying to a sending entity regarding a met condition, this attribute MUST be present and SHOULD be the value of the 'action' attribute for the triggered rule. (Note: Individual action definitions MAY provide their own requirements.)</p>
  680. <p>The 'from' attribute specifies the original sender of the containing &MESSAGE; stanza. This attribute MUST be specified for any &MESSAGE; stanza sent from a supporting server, regardless of the recipient. It SHOULD NOT be specified otherwise. The value of the 'from' attribute MUST be the full JID (node@domain/resource) of the sender for the original &MESSAGE; stanza.</p>
  681. <p>The 'to' attribute specifies the original (intended) recipient of the containing &MESSAGE; stanza. This attribute MUST be specified for any &MESSAGE; stanza sent from a supporting server, regardless of the recipient. It SHOULD NOT be specified otherwise. The value of the 'to' attribute MUST be the full JID (node@domain/resource) of the intended recipient for the original &MESSAGE; stanza.</p>
  682. <p>The 'per-hop' attribute flags the contained ruleset for processing at each server in the route between the original sender and original intended recipient. This attribute MAY be present, and MUST be either "true" or "false". If not present, the default is "false".</p>
  683. </section2>
  684. <section2 topic='&lt;rule/&gt; Element' anchor='formal-rule'>
  685. <p>Each semantic rule is specified with a &lt;rule/&gt; element. This element possesses attributes for the condition, value, and action.</p>
  686. <p>The 'action' attribute defines the result for this rule. This attribute MUST be present, and MUST be either a value defined in the <link url="#actions-def">Defined Actions</link> section, or one registered with the XMPP Registrar.</p>
  687. <p>The 'condition' attribute defines the overall condition this rule applies to. This attribute MUST be present, and MUST be either a value defined in the <link url="#conditions-def">Defined Conditions</link> section, or one registered with the XMPP Registrar.</p>
  688. <p>The 'value' attribute defines how the condition is matched. This attribute MUST be present, and MUST NOT be an empty string (""). The interpretation of this attribute's value is determined by the 'condition' attribute.</p>
  689. </section2>
  690. </section1>
  691. <section1 topic='Example Scenarios' anchor='examples'>
  692. <section2 topic='Reliable Data Transport' anchor='examples-reliabledata'>
  693. <p>The &MESSAGE; stanza is nearly ideal for data transport, but to ensure reliability it is often desirable that such messages not be delivered to any resource but that specified. To facilitate this, the sending entity includes a &lt;rule action='drop' condition='match-resource' value='other'/&gt; (if failure notification is unnecessary) or &lt;rule action='error' condition='match-resource' value='other'/&gt; (if failure notification is required). The following example illustrates this using &xep0047;:</p>
  694. <example caption='Sending a message for reliable data transport'><![CDATA[
  695. <message to='francisco@hamlet.lit/pda'
  696. from='bernardo@hamlet.lit/elsinore'
  697. id='ibb1'>
  698. <data xmlns='' sid='mySID' seq='0'>
  699. qANQR1DBwU4DX7jmYZnncmUQB/9KuKBddzQH+tZ1ZywKK0yHKnq57kWq+RFtQdCJ
  700. WpdWpR0uQsuJe7+vh3NWn59/gTc5MDlX8dS9p0ovStmNcyLhxVgmqS8ZKhsblVeu
  701. IpQ0JgavABqibJolc3BKrVtVV1igKiX/N7Pi8RtY1K18toaMDhdEfhBRzO/XB0+P
  702. AQhYlRjNacGcslkhXqNjK5Va4tuOAPy2n1Q8UUrHbUd0g+xJ9Bm0G0LZXyvCWyKH
  703. kuNEHFQiLuCY6Iv0myq6iX6tjuHehZlFSh80b5BVV9tNLwNR5Eqz1klxMhoghJOA
  704. </data>
  705. <amp xmlns='' per-hop='true'>
  706. <rule action='error' condition='expire-at' value='2004-09-10T08:33:14Z'/>
  707. <rule action='error' condition='match-resource' value='other'/>
  708. </amp>
  709. </message>
  710. ]]></example>
  711. <p>In the above case, the sender would receive an error reply if the message could not be delivered specifically to "francisco@hamlet.lit/pda" by the specified time. For example, if the intended resource went offline before the message could be delivered, the processing server would return the following error:</p>
  712. <example caption='Failed reliable data transport message'><![CDATA[
  713. <message from='hamlet.lit'
  714. to='bernardo@hamlet.lit/elsinore'
  715. id='ibb1'>
  716. <amp xmlns=''
  717. from='bernardo@hamlet.lit/elsinore'
  718. to='francisco@hamlet.lit/pda'>
  719. <rule action='error' condition='match-resource' value='other'/>
  720. </amp>
  721. <error type='modify' code='500'>
  722. <undefined-condition xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  723. <failed-rules xmlns=''>
  724. <rule action='error' condition='match-resource' value='other'/>
  725. </failed-rules>
  726. </error>
  727. </message>
  728. ]]></example>
  729. </section2>
  730. <section2 topic='Time-Sensitive Messages' anchor='examples-time'>
  731. <p>Time-sensitive messages are a frequent occurrence in some environments (e.g., front-office personnel routinely notify others of "events" such as guests, unexpected refreshments, and ad-hoc gatherings). To send a time-sensitive message, the sending entity includes a &lt;rule action='drop' condition='expire-at'/&gt; with the time when the event is to occur:</p>
  732. <example caption='Sending a time-sensitive message'><![CDATA[
  733. <message to=''
  734. from=''
  735. id='alert849'>
  736. <subject>Guest Alert!</subject>
  737. <body>
  738. There will be clients in the conference room today around 1 PM!
  739. As always, be courteous and quiet nearby...
  740. </body>
  741. <amp xmlns=''>
  742. <rule action='drop' condition='expire-at' value='2003-06-23T23:00:00Z'/>
  743. </amp>
  744. </message>
  745. ]]></example>
  746. <p>In the above case, the server for "" would not deliver the message once 23:00 UTC (3:00 PM Pacific Daylight Time) has passed.</p>
  747. </section2>
  748. <section2 topic='Transient Messages' anchor='examples-transient'>
  749. <p>Transient messages are messages that should never be stored offline. To send a transient message, the sending entity includes a &lt;rule action='drop' condition='deliver' value='stored'/&gt;:</p>
  750. <example caption='Sending a transient message'><![CDATA[
  751. <message to='francisco@hamlet.lit'
  752. from='bernardo@hamlet.lit/elsinore'
  753. type='chat'
  754. id='chatty1'>
  755. <body>Who&apos;s there?</body>
  756. <amp xmlns=''>
  757. <rule action='drop' condition='deliver' value='stored'/>
  758. </amp>
  759. </message>
  760. ]]></example>
  761. <p>Alternatively, the sending entity includes a &lt;rule action='alert' condition='deliver' value='stored'/&gt; to be alerted instead of having the message silently dropped:</p>
  762. <example caption='Sending a transient message (requesting alert)'><![CDATA[
  763. <message to='francisco@hamlet.lit'
  764. from='bernardo@hamlet.lit/elsinore'
  765. type='chat'
  766. id='chatty2'>
  767. <body>Who&apos;s there?</body>
  768. <amp xmlns=''>
  769. <rule action='alert' condition='deliver' value='stored'/>
  770. </amp>
  771. </message>
  772. ]]></example>
  773. <example caption='Sender alerted regarding transient message'><![CDATA[
  774. <message from='hamlet.lit'
  775. to='bernardo@hamlet.lit/elsinore'
  776. id='chatty2'>
  777. <amp xmlns=''
  778. status='alert'
  779. from='bernardo@hamlet.lit/elsinore'
  780. to='francisco@hamlet.lit'>
  781. <rule action='alert' condition='deliver' value='stored'/>
  782. </amp>
  783. </message>
  784. ]]></example>
  785. </section2>
  786. </section1>
  787. <section1 topic='Error Handling' anchor='errors'>
  788. <section2 topic='Conditions' anchor='errors-conditions'>
  789. <p>To simplify the discussion of error conditions, this document uses the following mappings between namespace URIs and namespace prefixes (note: this mapping is provided only for the purpose of simplifying the discussion and is not intended for use within the protocol itself).</p>
  790. <table caption='Namespace Mappings'>
  791. <tr>
  792. <th>Prefix</th>
  793. <th>URI</th>
  794. </tr>
  795. <tr>
  796. <td>xmpp</td>
  797. <td>urn:ietf:params:xml:ns:xmpp-stanzas</td>
  798. </tr>
  799. <tr>
  800. <td>msg</td>
  801. <td></td>
  802. </tr>
  803. <tr>
  804. <td>err</td>
  805. <td></td>
  806. </tr>
  807. </table>
  808. <p>The following table shows the possible error conditions in relation to general AMP rules and conditions as well as the <link url="#actions-def">Defined Actions</link>.</p>
  809. <table caption='Error conditions'>
  810. <tr>
  811. <th>General Condition</th>
  812. <th>Error Type</th>
  813. <th>Specific Condition</th>
  814. <th>Description</th>
  815. </tr>
  816. <tr>
  817. <td>&lt;xmpp:bad-request/&gt;</td>
  818. <td>modify</td>
  819. <td>&lt;msg:unsupported-actions/&gt;</td>
  820. <td>One or more rule's specified actions are not supported. The element &lt;msg:unsupported-actions/&gt; contains the &lt;rule/&gt; elements that specify the unsupported actions.</td>
  821. </tr>
  822. <tr>
  823. <td>&lt;xmpp:bad-request/&gt;</td>
  824. <td>modify</td>
  825. <td>&lt;msg:unsupported-conditions/&gt;</td>
  826. <td>One or more rule's specified conditions are not supported. The element &lt;msg:unsupported-conditions/&gt; contains the &lt;rule/&gt; elements that specify the unsupported conditions.</td>
  827. </tr>
  828. <tr>
  829. <td>&lt;xmpp:not-acceptable/&gt;</td>
  830. <td>modify</td>
  831. <td>&lt;msg:invalid-rules/&gt;</td>
  832. <td>One or more rules are not acceptable by this server, usually because the condition/action combination is restricted. The element &lt;msg:invalid-rules/&gt; contains the &lt;rule/&gt; elements that are not acceptable.</td>
  833. </tr>
  834. <tr>
  835. <td>&lt;xmpp:service-unavailable/&gt;</td>
  836. <td>cancel</td>
  837. <td>NONE</td>
  838. <td>This protocol is not supported. This error is returned to the sending entity if a server along the route to the recipient does not implement this protocol.</td>
  839. </tr>
  840. <tr>
  841. <td>&lt;xmpp:undefined-condition/&gt;</td>
  842. <td>modify</td>
  843. <td>&lt;err:failed-rules/&gt;</td>
  844. <td>One or more &lt;rule/&gt; elements triggered the "error" action. This condition contains the triggered &lt;rule/&gt; elements.</td>
  845. </tr>
  846. </table>
  847. </section2>
  848. <section2 topic='Examples' anchor='errors-examples'>
  849. <p>This section shows examples of the error conditions described in the previous section (for information regarding mapping of XMPP error conditions to Jabber error codes, refer to &xep0086;).</p>
  850. <section3 topic='Unsupported Action' anchor='errors-action'>
  851. <example caption='A message with AMP semantics'><![CDATA[
  852. <message
  853. from='northumberland@shakespeare.lit'
  854. id='richard2-4.1.247'
  855. to='kingrichard@royalty.england.lit'>
  856. <body>My lord, dispatch; read o'er these articles.</body>
  857. <amp xmlns=''>
  858. <rule action='drop' condition='expire-at' value='2004-01-01T00:00:00Z'/>
  859. </amp>
  860. </message>
  861. ]]></example>
  862. <example caption='Server does not support action'><![CDATA[
  863. <message
  864. from='shakespeare.lit'
  865. id='richard2-4.1.247'
  866. to='northumberland@shakespeare.lit'
  867. type='error'>
  868. <amp xmlns=''>
  869. <rule action='drop' condition='expire-at' value='2004-01-01T00:00:00Z'/>
  870. </amp>
  871. <error type='modify' code='400'>
  872. <bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  873. <unsupported-actions xmlns=''>
  874. <rule condition='expire-at'
  875. action='drop'
  876. value='2004-01-01T00:00:00Z'/>
  877. </unsupported-actions>
  878. </error>
  879. </message>
  880. ]]></example>
  881. </section3>
  882. <section3 topic='Unsupported Condition' anchor='errors-condition'>
  883. <example caption='A message with AMP semantics'><![CDATA[
  884. <message
  885. from='shakespeare.lit'
  886. id='richard2-4.1.247'
  887. to='kingrichard@royalty.england.lit'>
  888. <body>My lord, dispatch; read o'er these articles.</body>
  889. <amp xmlns=''>
  890. <rule action='drop' condition='expire-at' value='2004-01-01T00:00:00Z'/>
  891. </amp>
  892. </message>
  893. ]]></example>
  894. <example caption='Server does not support condition'><![CDATA[
  895. <message
  896. from='shakespeare.lit'
  897. id='richard2-4.1.247'
  898. to='northumberland@shakespeare.lit'
  899. type='error'>
  900. <amp xmlns=''>
  901. <rule action='drop' condition='expire-at' value='2004-01-01T00:00:00Z'/>
  902. </amp>
  903. <error type='modify' code='400'>
  904. <bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  905. <unsupported-conditions xmlns=''>
  906. <rule action='drop' condition='expire-at' value='2004-01-01T00:00:00Z'/>
  907. </unsupported-conditions>
  908. </error>
  909. </message>
  910. ]]></example>
  911. </section3>
  912. <section3 topic='Not Acceptable' anchor='errors-notacceptable'>
  913. <example caption='A message with AMP semantics'><![CDATA[
  914. <message
  915. from='northumberland@shakespeare.lit'
  916. id='richard2-4.1.247'
  917. to='kingrichard@royalty.england.lit'>
  918. <body>My lord, dispatch; read o'er these articles.</body>
  919. <amp xmlns=''>
  920. <rule action='drop' condition='expire-at' value='2004-01-01T00:00:00Z'/>
  921. </amp>
  922. </message>
  923. ]]></example>
  924. <example caption='The rule is not acceptable to the server'><![CDATA[
  925. <message
  926. from='shakespeare.lit'
  927. id='richard2-4.1.247'
  928. to='northumberland@shakespeare.lit'
  929. type='error'>
  930. <amp xmlns=''>
  931. <rule action='drop' condition='expire-at' value='2004-01-01T00:00:00Z'/>
  932. </amp>
  933. <error type='modify' code='405'>
  934. <not-acceptable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  935. <invalid-rules xmlns=''>
  936. <rule action='drop' condition='expire-at' value='2004-01-01T00:00:00Z'/>
  937. </invalid-rules>
  938. </error>
  939. </message>
  940. ]]></example>
  941. </section3>
  942. <section3 topic='Service Unavailable' anchor='errors-unavail'>
  943. <example caption='A message with AMP semantics'><![CDATA[
  944. <message
  945. from='northumberland@shakespeare.lit'
  946. id='richard2-4.1.247'
  947. to='kingrichard@royalty.england.lit'>
  948. <body>My lord, dispatch; read o'er these articles.</body>
  949. <amp xmlns=''>
  950. <rule action='drop' condition='expire-at' value='2004-01-01T00:00:00Z'/>
  951. </amp>
  952. </message>
  953. ]]></example>
  954. <example caption='AMP service is unavailable'><![CDATA[
  955. <message
  956. from='royalty.england.lit'
  957. id='richard2-4.1.247'
  958. to='northumberland@shakespeare.lit'
  959. type='error'>
  960. <amp xmlns=''>
  961. <rule action='drop' condition='expire-at' value='2004-01-01T00:00:00Z'/>
  962. </amp>
  963. <error type='cancel' code='503'>
  964. <service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  965. </error>
  966. </message>
  967. ]]></example>
  968. </section3>
  969. <section3 topic='Undefined Condition' anchor='errors-undefined'>
  970. <example caption='A message with AMP semantics'><![CDATA[
  971. <message from='hamlet.lit'
  972. to='bernardo@hamlet.lit/elsinore'
  973. id='chatty2'>
  974. <body>Who&apos;s there?</body>
  975. <amp xmlns=''
  976. status='error'
  977. from='francisco@hamlet.lit'
  978. to='bernardo@hamlet.lit/elsinore'>
  979. <rule action='error' condition='deliver' value='stored'/>
  980. </amp>
  981. </message>
  982. ]]></example>
  983. <example caption='Failed rules'><![CDATA[
  984. <message from='hamlet.lit'
  985. to='bernardo@hamlet.lit/elsinore'
  986. type='error'
  987. id='chatty2'>
  988. <amp xmlns=''
  989. status='error'
  990. from='francisco@hamlet.lit'
  991. to='bernardo@hamlet.lit/elsinore'>
  992. <rule action='error' condition='deliver' value='stored'/>
  993. </amp>
  994. <error type='modify' code='500'>
  995. <undefined-condition xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  996. <failed-rules xmlns=''>
  997. <rule action='error' condition='deliver' value='stored'/>
  998. </failed-rules>
  999. </error>
  1000. </message>
  1001. ]]></example>
  1002. </section3>
  1003. </section2>
  1004. </section1>
  1005. <section1 topic='Implementation Notes' anchor='impl'>
  1006. <p>If the recipient's server implements "offline storage", it will need to keep track of which offline messages are subject to expiration and not deliver those which have expired. Exactly how to do so is a matter of implementation. One possible implementation is for the server to maintain a separate database of expirable messages and periodically scan it; upon discovering an expired message, it could flag the message as eligible for discarding and inform the sender, but not discard the message until the intended recipient next becomes available.</p>
  1007. </section1>
  1008. <section1 topic='Stream Feature' anchor='streamfeature'>
  1009. <p>&xmppcore; defines methods for advertising feature support during stream negotiation. For the sake of efficiency, it may be desirable for a server to advertise support for Advanced Message Processing as a stream feature. The namespace for reporting support within &lt;stream:features/&gt; is "". Upon receiving a stream header from the initiating entity, the receiving entity (usually a server) returns a stream header to initiating entity and MAY announce support for Advanced Message Processing registration by including the relevant stream feature:</p>
  1010. <example caption='Advertising Advanced Message Processing as a stream feature'><![CDATA[
  1011. <stream:features>
  1012. <amp xmlns=''/>
  1013. </stream:features>
  1014. ]]></example>
  1015. </section1>
  1016. <section1 topic='Security Considerations' anchor='security'>
  1017. <p>Most AMP conditions could be used by unauthorized individuals to gain access to presence information about users of IM servers and other presence-based messaging systems. For example, consider the following scenario: the user &lt;; is not an authorized subscriber to the presence of the user &lt;;, but sends a &MESSAGE; stanza with a "deliver" rule of "stored" and an action of "alert" to that address; if the Nurse is not online, Romeo would receive an AMP alert that the message has been stored offline, in the process discovering that the Nurse is offline. Similar scenarios are possible with the "match-resource" rule (send to the user's usual resource) and the "expire-at" rule (send messages every minute to poll for presence). If a server implements presence subscriptions as specified in &rfc3921;, it SHOULD NOT return alerts, errors, or other AMP notifications to senders who are not authorized to view the recipient's presence information (via a subscription of "both" or "from") if the notification would reveal the recipient's status as online or offline. <note>An exception might be fully-trusted or closed networks.</note>
  1018. ).</p>
  1019. <p>There are several directions server implementors can follow in this regard:</p>
  1020. <ul>
  1021. <li><p>Do not implement the relevant condition, as a result of which the server MUST reply with a &feature; error condition if the condition is specified; however, this is unduly restricts the supported conditions and effectively cripples the AMP functionality, so is NOT RECOMMENDED.</p></li>
  1022. <li><p>Accept the relevant condition only if the action is "drop", as a result of which the server MUST reply with a &notacceptable; error condition if the action is "alert", "error", or "notify"; this is slightly less restrictive but still unnecessarily restricts the functionality of the system, so is NOT RECOMMENDED.</p></li>
  1023. <li><p>Accept the relevant condition only if the sender is authorized to receive the receiver's presence, as a result of which the server MUST reply with a &notacceptable; error condition if the sender is not so authorized; this is the RECOMMENDED behavior.</p></li>
  1024. </ul>
  1025. </section1>
  1026. <section1 topic='IANA Considerations' anchor='iana'>
  1027. <p>No interaction with &IANA; is necessary as a result of this document.</p>
  1028. </section1>
  1029. <section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  1030. <section2 topic='Protocol Namespaces' anchor='registrar-ns'>
  1031. <p>The &REGISTRAR; includes '' and '' in its registry of protocol namespaces.</p>
  1032. </section2>
  1033. <section2 topic='Stream Features' anchor='registrar-stream'>
  1034. <p>The XMPP Registrar includes the '' namespace in its registry of stream feature namespaces.</p>
  1035. </section2>
  1036. <section2 topic='Well-Known Service Discovery Nodes' anchor='registrar-nodes'>
  1037. <p>The XMPP Registrar includes '' in its registry of well-known Service Discovery nodes.</p>
  1038. </section2>
  1039. <section2 topic='Registries' anchor='registrar-reg'>
  1040. <section3 topic='Rule Conditions Registry' anchor='registrar-reg-conditions'>
  1041. <p>The XMPP Registrar maintains a registry of AMP &lt;rule/&gt; conditions at &AMPCONDITIONS;.</p>
  1042. <section4 topic='Process' anchor='registrar-reg-conditions-process'>
  1043. &REGPROCESS;
  1044. <code><![CDATA[
  1045. <condition>
  1046. <name>the value of the 'condition' attribute</name>
  1047. <ns>the namespace to be used as a service discovery feature</ns>
  1048. <per-hop>does the "per-hop" flag apply? [true|false]</per-hop>
  1049. <value>
  1050. The syntax (e.g., datatype or allowable values) of the
  1051. 'value' attribute.
  1052. </value>
  1053. <processing>values that result in message processing</processing>
  1054. <doc>the document (e.g., XEP) in which this condition is specified</doc>
  1055. </condition>
  1056. ]]></code>
  1057. <p>The registrant may register more than one condition at a time, each contained in a separate &lt;condition/&gt; element.</p>
  1058. <p>Note: The namespace for the condition set shall be included in the Service Discovery features registry.</p>
  1059. </section4>
  1060. <section4 topic='Initial Submission' anchor='registrar-reg-conditions-initial'>
  1061. <code><![CDATA[
  1062. <condition>
  1063. <name>deliver</name>
  1064. <ns></ns>
  1065. <per-hop>true</per-hop>
  1066. <value>[direct|forward|gateway|none|stored]</value>
  1067. <processing>
  1068. The condition is met if (1) the value is "direct" and the message
  1069. can be immediately delivered or further dispatched, (2) the value
  1070. is "forward" and the message can be forwarded to another XMPP
  1071. address, (3) the value is "gateway" and the message can be sent
  1072. to a non-XMPP address via a gateway, (4) the value is "none" and
  1073. the message cannot be delivered at all, or (5) the value is
  1074. "stored" and the message can be stored for later delivery.
  1075. </processing>
  1076. <doc>XEP-0079</doc>
  1077. </condition>
  1078. <condition>
  1079. <name>expire-at</name>
  1080. <ns></ns>
  1081. <per-hop>true</per-hop>
  1082. <value>DateTime per XEP-0082</value>
  1083. <processing>
  1084. The condition is met if the message would be delivered after
  1085. the specified DateTime.
  1086. </processing>
  1087. <doc>XEP-0079</doc>
  1088. </condition>
  1089. <condition>
  1090. <name>match-resource</name>
  1091. <ns></ns>
  1092. <per-hop>false</per-hop>
  1093. <value>[any|exact|other]</value>
  1094. <processing>
  1095. The condition is met if (1) the value is "any" and the intended
  1096. recipient has at least one available resource (as defined in the
  1097. XMPP IM specification); (2) the value "exact" and the intended
  1098. recipient has an available resource that exactly matches the JID
  1099. specified in the 'to' address; (3) the value is "other" and the
  1100. intended recipient has an available resource whose full JID is
  1101. other than that specified in the 'to' address.
  1102. </processing>
  1103. <doc>XEP-0079</doc>
  1104. </condition>
  1105. ]]></code>
  1106. </section4>
  1107. </section3>
  1108. <section3 topic='Rule Actions Registry' anchor='registrar-reg-actions'>
  1109. <p>The XMPP Registrar maintains a registry of AMP &lt;rule/&gt; actions at &AMPACTIONS;.</p>
  1110. <section4 topic='Process' anchor='registrar-reg-actions-process'>
  1111. &REGPROCESS;
  1112. <code><![CDATA[
  1113. <action>
  1114. <name>the value of the 'action' attribute</name>
  1115. <ns>the namespace to be used as a service discovery feature</ns>
  1116. <behavior>the expected behavior if the rule is triggered</behavior>
  1117. <doc>the document (e.g., XEP) in which this action is specified</doc>
  1118. </action>
  1119. ]]></code>
  1120. <p>The registrant may register more than one action at a time, each contained in a separate &lt;action/&gt; element.</p>
  1121. <p>Note: The namespace for the action set shall be included in the Service Discovery features registry.</p>
  1122. </section4>
  1123. <section4 topic='Initial Submission' anchor='registrar-reg-actions-initial'>
  1124. <code><![CDATA[
  1125. <action>
  1126. <name>alert</name>
  1127. <ns></ns>
  1128. <behavior>
  1129. The message is silently discarded but an alert is returned to the
  1130. sender.
  1131. </behavior>
  1132. <doc>XEP-0079</doc>
  1133. </action>
  1134. <action>
  1135. <name>drop</name>
  1136. <ns></ns>
  1137. <behavior>
  1138. The message is silently discarded.
  1139. </behavior>
  1140. <doc>XEP-0079</doc>
  1141. </action>
  1142. <action>
  1143. <name>error</name>
  1144. <ns></ns>
  1145. <behavior>
  1146. The message is not processed and an error is returned to the sender,
  1147. specifying which rule resulted in failed processing.
  1148. </behavior>
  1149. <doc>XEP-0079</doc>
  1150. </action>
  1151. <action>
  1152. <name>notify</name>
  1153. <ns></ns>
  1154. <behavior>
  1155. The message is processed and a notification message is returned to
  1156. the sender, specifying which rule was processed.
  1157. </behavior>
  1158. <doc>XEP-0079</doc>
  1159. </action>
  1160. ]]></code>
  1161. </section4>
  1162. </section3>
  1163. </section2>
  1164. </section1>
  1165. <section1 topic='XML Schemas' anchor='schemas'>
  1166. <section2 topic='AMP' anchor='schemas-amp'>
  1167. <code><![CDATA[
  1168. <?xml version='1.0' encoding='UTF-8'?>
  1169. <xs:schema
  1170. xmlns:xs=''
  1171. targetNamespace=''
  1172. xmlns=''
  1173. elementFormDefault='qualified'>
  1174. <xs:annotation>
  1175. <xs:documentation>
  1176. The protocol documented by this schema is defined in
  1177. XEP-0079:
  1178. </xs:documentation>
  1179. </xs:annotation>
  1180. <xs:element name='amp'>
  1181. <xs:complexType>
  1182. <xs:sequence>
  1183. <xs:element ref='rule' minOccurs='1' maxOccurs='unbounded'/>
  1184. </xs:sequence>
  1185. <xs:attribute name='from' use='optional' type='xs:string'/>
  1186. <xs:attribute name='per-hop' use='optional' type='xs:boolean' default='false'/>
  1187. <xs:attribute name='status' use='optional' type='xs:NCName'/>
  1188. <xs:attribute name='to' use='optional' type='xs:string'/>
  1189. </xs:complexType>
  1190. </xs:element>
  1191. <xs:element name='invalid-rules'>
  1192. <xs:complexType>
  1193. <xs:sequence>
  1194. <xs:element ref='rule' minOccurs='1' maxOccurs='unbounded'/>
  1195. </xs:sequence>
  1196. </xs:complexType>
  1197. </xs:element>
  1198. <xs:element name='unsupported-actions'>
  1199. <xs:complexType>
  1200. <xs:sequence>
  1201. <xs:element ref='rule' minOccurs='1' maxOccurs='unbounded'/>
  1202. </xs:sequence>
  1203. </xs:complexType>
  1204. </xs:element>
  1205. <xs:element name='unsupported-conditions'>
  1206. <xs:complexType>
  1207. <xs:sequence>
  1208. <xs:element ref='rule' minOccurs='1' maxOccurs='unbounded'/>
  1209. </xs:sequence>
  1210. </xs:complexType>
  1211. </xs:element>
  1212. <xs:element name='rule'>
  1213. <xs:complexType>
  1214. <xs:attribute name='action' use='required' type='xs:NCName'/>
  1215. <xs:attribute name='condition' use='required' type='xs:NCName'/>
  1216. <xs:attribute name='value' use='required' type='xs:string'/>
  1217. </xs:complexType>
  1218. </xs:element>
  1219. </xs:schema>
  1220. ]]></code>
  1221. </section2>
  1222. <section2 topic='Errors' anchor='schemas-err'>
  1223. <code><![CDATA[
  1224. <?xml version='1.0' encoding='UTF-8'?>
  1225. <xs:schema
  1226. xmlns:xs=''
  1227. targetNamespace=''
  1228. xmlns=''
  1229. elementFormDefault='qualified'>
  1230. <xs:annotation>
  1231. <xs:documentation>
  1232. The protocol documented by this schema is defined in
  1233. XEP-0079:
  1234. </xs:documentation>
  1235. </xs:annotation>
  1236. <xs:element name='failed-rules'>
  1237. <xs:complexType>
  1238. <xs:sequence>
  1239. <xs:element ref='rule' minOccurs='1' maxOccurs='unbounded'/>
  1240. </xs:sequence>
  1241. </xs:complexType>
  1242. </xs:element>
  1243. <xs:element name='rule'>
  1244. <xs:complexType>
  1245. <xs:attribute name='action' use='required' type='xs:NCName'/>
  1246. <xs:attribute name='condition' use='required' type='xs:NCName'/>
  1247. <xs:attribute name='value' use='required' type='xs:string'/>
  1248. </xs:complexType>
  1249. </xs:element>
  1250. </xs:schema>
  1251. ]]></code>
  1252. </section2>
  1253. <section2 topic='Stream Feature' anchor='schemas-streams'>
  1254. <code><![CDATA[
  1255. <?xml version='1.0' encoding='UTF-8'?>
  1256. <xs:schema
  1257. xmlns:xs=''
  1258. targetNamespace=''
  1259. xmlns=''
  1260. elementFormDefault='qualified'>
  1261. <xs:annotation>
  1262. <xs:documentation>
  1263. The protocol documented by this schema is defined in
  1264. XEP-0079:
  1265. </xs:documentation>
  1266. </xs:annotation>
  1267. <xs:element name='amp' type='empty'/>
  1268. <xs:simpleType name='empty'>
  1269. <xs:restriction base='xs:string'>
  1270. <xs:enumeration value=''/>
  1271. </xs:restriction>
  1272. </xs:simpleType>
  1273. </xs:schema>
  1274. ]]></code>
  1275. </section2>
  1276. </section1>
  1277. <section1 topic='Acknowledgements' anchor='acks'>
  1278. <p>Thanks to Marshall Rose and Craig Kaes for their comments.</p>
  1279. </section1>
  1280. </xep>