<remark><p>Initial published version approved by the XMPP Council.</p></remark>
</revision>
<revision>
<version>0.0.1</version>
<date>2012-12-07</date>
<initials>snd</initials>
<remark><p>First draft.</p></remark>
</revision>
</header>
<section1topic='Introduction'anchor='intro'>
<p>It's often desirable for some XMPP based services to make it possible to manage user's roster to provide some contacts there. The most obvious example of such kind of service is a gateway to some legacy IM system (see &xep0100;). The current way that's recommended by the &xep0100; is to use the &xep0144; to synchronize items that's not sutiable in certain situations.</p>
</section1>
<section1topic='Requirements'anchor='reqs'>
<p>This document addresses the following requirements:</p>
<ol>
<li>Make it possible for remote services or entities to manage user's roster by the same mechanisms that descibed in the &rfc6121;.</li>
<li>Provide a way for user to control which services have permission to manage his roster.</li>
</ol>
</section1>
<section1topic='Glossary'anchor='glossary'>
<ul>
<li><strong>Remote entity</strong> — the entity that wants to modify user's roster.</li>
<li><strong>User</strong> — the entity which roster the remote entity wants to have access to.</li>
<li><strong>User's server</strong> — the XMPP server User connected to.</li>
<li><strong>Roster</strong> — the list of User's contacts as defined in the &rfc6121;.</li>
</ul>
</section1>
<section1topic='Use Cases'anchor='usecases'>
<section2topic='Remote entity asks for permission to manage user's roster'anchor='ask_permission'>
<p>In order to be able to make any changes to the user's roster the remote entity MUST ask permission to do so first.</p>
<p>NOTE: in order to be able to perform the query, the remote entity MUST have a presence subscription to the User</p>
<examplecaption='Remote entity asks for permission'><![CDATA[
<textxmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>You must have a presence subscription to be able to request remote roster management service.</text>
</error>
</iq>]]></example>
<p>The user's server SHOULD then generate a form request using &xep0004; to client in order to ask user if he's OK with granting the permission to the remote entity. The "challenge" form field is generated by the server and is used to identify the client's response. The server also MUST immediatly answer to the request IQ.</p>
<p>NOTE: if the entity is already granted with the permission, the server SHOULD immediatly answer with a success response and skip querying the user.</p>
<examplecaption='Server asks user for the permission'><![CDATA[
<messagefrom='example.com'
to='juliet@example.com'>
<body>icq.example.com wants to be able to manage your roster with following reason:
Manage contacts in the ICQ contact list
Do you want to allow it? Send "yes 5439123" or "no 5439123" back, pleas.</body>
<p>If the presence subscription is restored then the permission is needed to be rerequested as defined above.</p>
</section3>
</section2>
<section2topic='The remote entity requests current user's roster'anchor='request_roster'>
<p>The remote entity being granted the permission to manage roster can request it from the User's server using usual jabber:iq:roster protocol to be able to edit it:</p>
<examplecaption='The remote entity requests current roster'><![CDATA[
<section2topic='The user updates roster'anchor='user_update'>
<p>If client updates roster and this update affects the remote entity's contacts (i.e. belongs to it's hostname) then the server MUST forward these items to the remote entity:</p>
<examplecaption='The user updates roster'><![CDATA[
<section2topic='The remote entity updates the user's roster'anchor='entity_update'>
<p>The remote entity can also send the push query to the roster with the same semantics as specified for the jabber:iq:roster protocol described in the &rfc6121;:</p>
<p>The server MUST then inform the remote entity of success or an error and in the case of success also forward the push request to all connected User's resources.</p>
<p>If the entity tries to make changes into the items it's not allowed to, the server MUST NOT do any changes in the User's roster but respond to the entity with an error:</p>
<examplecaption='The server responds with an error'><![CDATA[