/// <summary>
        /// Verifies the specified session-id.
        /// </summary>
        /// <param name="stanza">The original IQ stanza.</param>
        /// <param name="sid">The session-id to verify.</param>
        /// <returns>true if the specified session-id is valid; Otherwise
        /// false.</returns>
        private bool VerifySession(Iq stanza, string sid)
        {
            if (String.IsNullOrEmpty(sid))
            {
                return(false);
            }
            var session = siFileTransfer.GetSession(sid, stanza.From, im.Jid);

            return(session != null);
        }
Example #2
0
        /// <summary>
        /// Processes an IBB 'open' request.
        /// </summary>
        /// <param name="sessionId">The mandatory session id attribute of the 'open'
        /// element.</param>
        /// <param name="stanza">The IQ stanza containing the request.</param>
        /// <exception cref="ArgumentNullException">The sessionId parameter or the
        /// stanza parameter is null.</exception>
        /// <exception cref="ArgumentException">The specified session id is not
        /// valid, or the initiator requested a data-transfer other than IQ
        /// stanzas (i.e. message stanzas).</exception>
        private void Open(string sessionId, Iq stanza)
        {
            sessionId.ThrowIfNull("sessionId");
            stanza.ThrowIfNull("stanza");
            if (siFileTransfer.GetSession(sessionId, stanza.From, im.Jid) == null)
            {
                throw new XmppException("Invalid session-id.");
            }
            string s = stanza.Data["open"].GetAttribute("stanza");

            if (!String.IsNullOrEmpty(s) && s != "iq")
            {
                throw new XmppException("Only IQ stanzas are supported.");
            }
        }