Esempio n. 1
0
        protected override AuthenticationResult OnAuthenticationRequest(ISIPExtension extension, RequestAuthenticationInfo authInfo)
        {
            Console.WriteLine("Authentication request received from: " + authInfo.From.UserName);

            var success = _sessionCache.VerifySession(authInfo.From.UserName, authInfo.AuthName);

            if (success)
            {
                Console.WriteLine("Authentication accepted. UserName: "******"Authentication denied. UserName: " + extension.ExtensionID);
            }

            return(new AuthenticationResult(success));
        }
Esempio n. 2
0
        protected override RegisterResult OnRegisterReceived(ISIPExtension extension, SIPAddress from, int expires)
        {
            Console.WriteLine("Register received from: " + extension.ExtensionID);
            //Save location to DB
            Dictionary <string, object> parameters = new Dictionary <string, object>();
            string   received   = "sip:" + extension.InstanceInfo.Transport.RemoteEndPoint.Address.ToString() + ":" + extension.InstanceInfo.Transport.RemoteEndPoint.Port.ToString();
            double   seconds    = expires;
            DateTime expiredate = DateTime.Now.AddSeconds(seconds);

            parameters.Add("@username", extension.AuthName);
            parameters.Add("@domain", from.Address);
            parameters.Add("@contact", extension.InstanceInfo.Contact.ToString());
            parameters.Add("@received", received);
            parameters.Add("@expires", expiredate);

            string command = "UPDATE registrar_table  SET domain = @domain, contact = @contact, received = @received, expires = @expires WHERE username = @username;"
                             + "insert into registrar_table (username, domain, contact, received, expires)"
                             + " select @username, @domain, @contact, @received, @expires where not exists (select from registrar_table where username = @username);";

            _database.WriteDataToDB(command, parameters);
            return(base.OnRegisterReceived(extension, from, expires));
        }
Esempio n. 3
0
 protected override void OnUnregisterReceived(ISIPExtension extension)
 {
     Console.WriteLine("Unregister received from: " + extension.ExtensionID);
     base.OnUnregisterReceived(extension);
 }