예제 #1
0
 public override string[] Authenticate(UserAgent ua, Header header, SIPStack sipStack)
 {
     throw new NotImplementedException();
 }
예제 #2
0
 /// <summary>
 /// Authenticates through the associated SIP application.
 /// </summary>
 /// <param name="ua">The ua.</param>
 /// <param name="header">The header.</param>
 /// <returns>System.String[][].</returns>
 public string[] Authenticate(UserAgent ua, Header header)
 {
     return App.Authenticate(ua, header, this);
 }
예제 #3
0
 public override string[] Authenticate(UserAgent ua, Header header, SIPStack stack)
 {
     return new[] { Username + "@" + Realm, Password };
 }
예제 #4
0
 /// <summary>
 /// Stub to handle the authentication of the specified ua.
 /// </summary>
 /// <param name="ua">The ua.</param>
 /// <param name="header">The header.</param>
 /// <param name="sipStack">The sip stack.</param>
 /// <returns>System.String[].</returns>
 public abstract string[] Authenticate(UserAgent ua, Header header, SIPStack sipStack);
예제 #5
0
 /// <summary>
 /// Inserts a header into the SIP message by either replacing the existing header, appending it at the end of its own header list, or inserting at the front of its own header list depending on the method specified.
 /// </summary>
 /// <param name="header">The header to insert.</param>
 /// <param name="method">The method - "replace", "append" or "insert". "replace" is the default. </param>
 public void InsertHeader(Header header, string method = "replace")
 {
     string name = header.Name;
     if (Headers.ContainsKey(name))
     {
         switch (method)
         {
             case "append":
                 {
                     Headers[name].Add(header);
                     break;
                 }
             case "replace":
                 {
                     List<Header> headers = new List<Header> {header};
                     Headers[name] = headers;
                     break;
                 }
             case "insert":
                 {
                     Headers[name].Insert(0, header);
                     break;
                 }
         }
     }
     else
     {
         List<Header> headers = new List<Header> {header};
         Headers[name] = headers;
     }
 }
예제 #6
0
 /// <summary>
 /// Creates a SIP request message based on the passed in parameters.
 /// </summary>
 /// <param name="method">The SIP method to use.</param>
 /// <param name="uri">The destination URI used in the first line.</param>
 /// <param name="headers">The SIP headers.</param>
 /// <param name="content">The SIP body content.</param>
 /// <returns>Message.</returns>
 public static Message CreateRequest(string method, SIPURI uri, Dictionary<string, List<Header>> headers = null,
                                     string content = "")
 {
     Message m = new Message {Method = method, Uri = uri, Protocol = "SIP/2.0"};
     m = PopulateMessage(m, headers, content);
     if (m.Headers.ContainsKey("CSeq"))
     {
         Header cseq = new Header(m.First("CSeq").Number.ToString() + " " + method, "CSeq");
         List<Header> cseqHeaders = new List<Header> {cseq};
         m.Headers["CSeq"] = cseqHeaders;
     }
     return m;
 }
예제 #7
0
        /// <summary>
        /// Creates a SIP request.
        /// </summary>
        /// <param name="method">The SIP method (invite etc.)</param>
        /// <param name="content">The SIP body contents.</param>
        /// <param name="contentType">The type of the SIP body.</param>
        /// <returns>Message.</returns>
        public virtual Message CreateRequest(string method, string content = "", string contentType = "")
        {
            Server = false;
            if (RemoteParty == null)
            {
                Debug.Assert(false, String.Format("No remoteParty for UAC\n"));
            }
            if (LocalParty == null)
            {
                LocalParty = new Address("\"Anonymous\" <sip:[email protected]>");
            }
            //TODO: Use Remote Party instead of Remote Target?
            SIPURI uri;
            if (RemoteTarget != null)
            {
                uri = new SIPURI(RemoteTarget.ToString());
            }
            else
            {
                uri = new SIPURI(RemoteParty.ToString());
            }

            if (method == "REGISTER")
            {
                //TODO: Is this right ?
                //uri.User = "";
            }
            if ((method != "ACK") && (method != "CANCEL"))
            {
                LocalSeq = ++LocalSeq;
            }
            //TODO: Use Remote Party instead of Remote Target?
            Header to;
            if (RemoteTarget != null)
            {
                to = new Header(RemoteTarget.ToString(), "To");
            }
            else
            {
                to = new Header(RemoteParty.ToString(), "To");
            }

            Header from = new Header(LocalParty.ToString(), "From");
            from.Attributes["tag"] = LocalTag;
            Header cSeq = new Header(LocalSeq + " " + method, "CSeq");
            Header callId = new Header(CallID, "Call-ID");
            Header maxForwards = new Header(MaxForwards.ToString(), "Max-Forwards");
            Header via = Stack.CreateVia();
            Dictionary<string, object> branchParams = new Dictionary<string, object>
                {
                    {"To", to.Value},
                    {"From", @from.Value},
                    {"CallId", callId.Value},
                    {"CSeq", cSeq.Number}
                };
            via.Attributes["branch"] = Transaction.CreateBranch(branchParams, false);
            if (LocalTarget == null)
            {
                LocalTarget = Stack.Uri.Dup();
                LocalTarget.User = LocalParty.Uri.User;
            }
            Header contact = new Header(LocalTarget.ToString(), "Contact");
            Header[] headerList = {to, from, cSeq, callId, maxForwards, via, contact};
            List<Header> headers = headerList.ToList();
            // Check this TODO
            //
            if (RouteSet.Count != 0)
            {
                headers.AddRange(RouteSet);
            }

            //app adds other headers such as Supported, Require and Proxy-Require
            if (!string.IsNullOrEmpty(contentType))
            {
                headers.Add(new Header(contentType, "Content-Type"));
            }
            Dictionary<string, List<Header>> headerDict = new Dictionary<string, List<Header>>();
            foreach (Header h in headers)
            {
                if (headerDict.ContainsKey(h.Name))
                {
                    headerDict[h.Name].Add(h);
                }
                else
                {
                    List<Header> temp = new List<Header> {h};
                    headerDict.Add(h.Name, temp);
                }
            }
            Request = Message.CreateRequest(method, uri, headerDict, content);
            return Request;
        }
예제 #8
0
 /// <summary>
 /// Authenticates the specified ua, using the specified username and password.
 /// Your own method to retrieve the users username and password should be placed in this method.
 /// </summary>
 /// <param name="ua">The ua.</param>
 /// <param name="header">The header.</param>
 /// <param name="stack">The stack.</param>
 /// <returns>System.String[].</returns>
 public override string[] Authenticate(UserAgent ua, Header header, SIPStack stack)
 {
     string username = "******";
     string realm = "open-ims.test";
     string password = "******";
     return new string[] { username + "@" + realm, password };
 }