public override void AddSIPProviderAsync(SIPProvider sipProvider)
 {
     if (AddSIPProviderComplete != null)
     {
         AddSIPProviderComplete(new AddSIPProviderCompletedEventArgs(new object[] { sipProvider }, null, false, null));
     }
 }
        public SIPProviderBinding(SIPProvider sipProvider)
        {
            SetProviderFields(sipProvider);

            m_id = Guid.NewGuid();

            // All set, let the Registration Agent know the binding is ready to be processed.
            NextRegistrationTime = DateTimeOffset.UtcNow;
        }
        //public Dictionary<Guid, object> Load(XmlDocument dom)
        //{
        //    return SIPAssetXMLPersistor<SIPProviderBinding>.LoadAssetsFromXMLRecordSet(dom);
        //}
#endif

        public void SetProviderFields(SIPProvider sipProvider)
        {
            m_providerId          = sipProvider.Id;
            m_owner               = sipProvider.Owner;
            AdminMemberId         = sipProvider.AdminMemberId;
            ProviderName          = sipProvider.ProviderName;
            ProviderAuthUsername  = (!sipProvider.ProviderAuthUsername.IsNullOrBlank()) ? sipProvider.ProviderAuthUsername : sipProvider.ProviderUsername;
            ProviderPassword      = sipProvider.ProviderPassword;
            RegistrarServer       = sipProvider.Registrar.CopyOf();
            RegistrarRealm        = (!sipProvider.RegisterRealm.IsNullOrBlank()) ? sipProvider.RegisterRealm : RegistrarServer.Host;
            ProviderOutboundProxy = sipProvider.ProviderOutboundProxy;
            SendMWISubscribe      = sipProvider.SendMWISubscribe;

            if (sipProvider.RegisterEnabled)
            {
                BindingExpiry = sipProvider.RegisterExpiry;
            }
            else
            {
                BindingExpiry = 0;
            }

            string bindingId = null;

            if (m_bindingURI != null && m_bindingURI.Parameters.Has(REGAGENT_CONTACT_ID_KEY))
            {
                bindingId = m_bindingURI.Parameters.Get(REGAGENT_CONTACT_ID_KEY);
            }

            if (!sipProvider.RegisterContact.IsNullOrBlank())
            {
                m_bindingURI = SIPURI.ParseSIPURI(sipProvider.RegisterContact);
                if (!bindingId.IsNullOrBlank())
                {
                    m_bindingURI.Parameters.Set(REGAGENT_CONTACT_ID_KEY, bindingId);
                }
            }
            else
            {
                // The register contact field on the SIP Provider is empty.
                // This condition needs to be trearted as the binding being disabled and it needs to be removed.
                BindingExpiry = 0;
            }
        }
 public override void AddSIPProviderAsync(SIPProvider sipProvider)
 {
     m_provisioningServiceProxy.AddSIPProviderAsync(sipProvider);
 }
 public override void UpdateSIPProviderAsync(SIPProvider sipProvider)
 {
     m_provisioningServiceProxy.UpdateSIPProviderAsync(sipProvider);
 }
Exemplo n.º 6
0
        public static string ValidateAndClean(SIPProvider sipProvider)
        {
            if (sipProvider.ProviderName.IsNullOrBlank())
            {
                return("A value for Provider Name must be specified.");
            }
            else if (sipProvider.ProviderName.Contains("."))
            {
                return("The Provider Name cannot contain a full stop '.' in order to avoid ambiguity with DNS host names, please remove the '.'.");
            }

            if (sipProvider.ProviderType == ProviderTypes.SIP)
            {
                if (sipProvider.ProviderServer.IsNullOrBlank())
                {
                    return("A value for Server must be specified.");
                }
                if (sipProvider.RegisterEnabled && sipProvider.m_registerContact == null)
                {
                    return("A valid contact must be supplied to enable a provider registration.");
                }
                else if (sipProvider.m_providerServer.Host.IndexOf('.') == -1)
                {
                    return("Your provider server entry appears to be invalid. A valid hostname or IP address should contain at least one '.'.");
                }
                else if (sipProvider.m_registerServer != null && sipProvider.m_registerServer.Host.IndexOf('.') == -1)
                {
                    return("Your register server entry appears to be invalid. A valid hostname or IP address should contain at least one '.'.");
                }
                else if (sipProvider.m_registerContact != null && sipProvider.m_registerContact.Host.IndexOf('.') == -1)
                {
                    return("Your register contact entry appears to be invalid. A valid hostname or IP address should contain at least one '.'.");
                }
                else if (sipProvider.m_registerContact != null && sipProvider.m_registerContact.User.IsNullOrBlank())
                {
                    return("Your register contact entry appears to be invalid, the user portion was missing. Contacts must be of the form [email protected], e.g. [email protected].");
                }
                else if (DisallowedServerPatterns != null && Regex.Match(sipProvider.m_providerServer.Host, DisallowedServerPatterns).Success)
                {
                    return("The Provider Server contains a disallowed string. If you are trying to create a Provider entry pointing to sipsorcery.com it is not permitted.");
                }
                else if (DisallowedServerPatterns != null && sipProvider.m_registerServer != null && Regex.Match(sipProvider.m_registerServer.Host, DisallowedServerPatterns).Success)
                {
                    return("The Provider Register Server contains a disallowed string. If you are trying to create a Provider entry pointing to sipsorcery.com it is not permitted.");
                }
            }
            else
            {
                if (sipProvider.ProviderUsername.IsNullOrBlank())
                {
                    return("A username is required for Google Voice entries.");
                }
                else if (sipProvider.ProviderPassword.IsNullOrBlank())
                {
                    return("A password is required for Google Voice entries.");
                }
                else if (sipProvider.GVCallbackNumber.IsNullOrBlank())
                {
                    return("A callback number is required for Google Voice entries.");
                }
                else if (Regex.Match(sipProvider.GVCallbackNumber, @"\D").Success)
                {
                    return("The callback number contains an invalid character. Only digits are permitted.");
                }
            }

            return(null);
        }
Exemplo n.º 7
0
 public abstract void AddSIPProviderAsync(SIPProvider sipProvider);
Exemplo n.º 8
0
 public abstract void UpdateSIPProviderAsync(SIPProvider sipProvider);
Exemplo n.º 9
0
 public abstract void DeleteSIPProviderAsync(SIPProvider sipProvider);