Example #1
0
 internal void DeleteRowFromAllowList(List <string> targetList)
 {
     foreach (var target in targetList)
     {
         AllowList.Remove(target);
     }
 }
Example #2
0
        public async Task <bool> AddUser(string serverId, string UserId)
        {
            var allowList = await GetInternalAllowList(serverId);

            if (!allowList.Enabled)
            {
                return(false);
            }

            UserId = UserId.Replace("<@!", "");
            UserId = UserId.Replace(">", "");

            if (allowList?.AllowedIds != null && allowList.AllowedIds.Contains(UserId) == false)
            {
                allowList.AllowedIds.Add(UserId);
            }
            else
            {
                allowList = new AllowList()
                {
                    AllowedIds = new List <string>()
                    {
                        UserId
                    }
                };
            }

            await File.WriteAllTextAsync(await GetAllowListLocation(serverId), JsonConvert.SerializeObject(allowList));

            return(true);
        }
Example #3
0
        public async Task <IAdGuardListService> FromFileAsync(Stream stream, FileProviderFormat inputFormat, FileProviderType inputType, string comment = "")
        {
            int currentElementInLists = AllowList.Count + BlockList.Count;

            using var fileStream = new StreamReader(stream);
            string currentLine;

            while ((currentLine = await fileStream.ReadLineAsync()) != null)
            {
                currentLine = FileLineTransform(currentLine, inputFormat, inputType);
                if (string.IsNullOrWhiteSpace(currentLine))
                {
                    continue;
                }

                switch (inputType)
                {
                case FileProviderType.ALLOW_LIST:
                    AllowList.Add(currentLine + comment);
                    break;

                case FileProviderType.BLOCK_LIST:
                    BlockList.Add(currentLine + comment);
                    break;
                }
            }

            _logger.LogInformation($"{AllowList.Count + BlockList.Count - currentElementInLists} element(s) added with file");
            return(this);
        }
        public void ToListReturnsReadOnlyCollectionContainingAllowListAfterListModification()
        {
            var allowList = new AllowList();

            allowList.Add("Scunthorpe");
            allowList.Add("Penistone");

            var readonlyList = allowList.ToList;

            Assert.IsNotNull(readonlyList);
            Assert.AreEqual(2, readonlyList.Count);

            Assert.AreEqual("scunthorpe", readonlyList[0]);
            Assert.AreEqual("penistone", readonlyList[1]);

            allowList.Add("Bugger");
            allowList.Add("Plonker");

            readonlyList = allowList.ToList;
            Assert.IsNotNull(readonlyList);
            Assert.AreEqual(4, readonlyList.Count);

            Assert.AreEqual("scunthorpe", readonlyList[0]);
            Assert.AreEqual("penistone", readonlyList[1]);
            Assert.AreEqual("bugger", readonlyList[2]);
            Assert.AreEqual("plonker", readonlyList[3]);
        }
        public void AddInsertsLowercaseItemIntoTheAllowList()
        {
            var allowList = new AllowList();

            allowList.Add("Scunthorpe");

            Assert.IsTrue(allowList.Contains("scunthorpe"));
        }
        public void CountReturnsTwoForTwoEntriesInTheList()
        {
            var allowList = new AllowList();

            allowList.Add("Scunthorpe");
            allowList.Add("Penistone");

            Assert.AreEqual(2, allowList.Count);
        }
Example #7
0
        internal void MoveToAllowListFromDenyList(List <string> targetList)
        {
            foreach (var target in targetList)
            {
                AllowList.Add(target);
            }

            DeleteRowFromDenyList(targetList);
        }
        public void ToListReturnsEmptyReadOnlyCollectionContaining()
        {
            var allowList = new AllowList();

            var readonlyList = allowList.ToList;

            Assert.IsNotNull(readonlyList);
            Assert.AreEqual(0, readonlyList.Count);
        }
        public void AddInsertsItemIntoTheAllowList()
        {
            var allowList = new AllowList();

            Assert.AreEqual(0, allowList.Count);

            allowList.Add("Scunthorpe");

            Assert.AreEqual(1, allowList.Count);
        }
        public void ContainsReturnsFalseForAllowListItemNotInTheList()
        {
            var allowList = new AllowList();

            allowList.Add("Scunthorpe");
            allowList.Add("Penistone");

            Assert.IsFalse(allowList.Contains("Wibble"));
            Assert.IsFalse(allowList.Contains("Gobble"));
        }
        public void ContainsReturnsTrueForAllowListItemInTheListWithMixedCase()
        {
            var allowList = new AllowList();

            allowList.Add("Scunthorpe");
            allowList.Add("Penistone");

            Assert.IsTrue(allowList.Contains("ScunThorpe"));
            Assert.IsTrue(allowList.Contains("PeniStone"));
        }
        /// <summary>
        /// Default constructor.
        /// </summary>
        public UserControlAllowListAssets(AllowList passedRule = null)
        {
            this.passedRule = passedRule;
            InitializeComponent();
            InitializeCustomComponents();
            TableUtility tableUtility = new TableUtility();

            tableUtility.CreateTable(Asset.GetDefaultValue());
            InitializePassedRule();
        }
        public void RemoveNonExistingEntryFromTheAllowListReturnsFalse()
        {
            var allowList = new AllowList();

            allowList.Add("Scunthorpe");
            allowList.Add("Penistone");

            Assert.AreEqual(2, allowList.Count);

            Assert.IsFalse(allowList.Remove("DoesNotExist"));
        }
        public void RemoveEntryFromTheAllowListReturnsTrue()
        {
            var allowList = new AllowList();

            allowList.Add("Scunthorpe");
            allowList.Add("Penistone");

            Assert.AreEqual(2, allowList.Count);

            Assert.IsTrue(allowList.Remove("Scunthorpe"));
        }
        public void ClearRemovesEntriesFromTheList()
        {
            var allowList = new AllowList();

            allowList.Add("Scunthorpe");
            allowList.Add("Penistone");

            Assert.AreEqual(2, allowList.Count);

            allowList.Clear();

            Assert.AreEqual(0, allowList.Count);
        }
 internal void __MarshalTo(ref __Native @ref)
 {
     @ref.AllowList = default(InfoQueueFilterDescription.__Native);
     if (AllowList != null)
     {
         AllowList.__MarshalTo(ref @ref.AllowList);
     }
     @ref.DenyList = default(InfoQueueFilterDescription.__Native);
     if (DenyList != null)
     {
         DenyList.__MarshalTo(ref @ref.DenyList);
     }
 }
 internal void __MarshalTo(ref __Native @ref)
 {
     @ref.AllowList = default;
     if (AllowList != null)
     {
         AllowList.__MarshalTo(ref @ref.AllowList);
     }
     @ref.DenyList = default;
     if (DenyList != null)
     {
         DenyList.__MarshalTo(ref @ref.DenyList);
     }
 }
Example #18
0
        public override string ToString()
        {
            var disAllowStr = "";
            var allowStr    = "";

            DisallowList.ForEach(x => disAllowStr += x + ";");
            AllowList.ForEach(x => allowStr       += x + ";");

            return($"搜索引擎:{UserAgent}\r\n" +
                   $"禁止抓取的目录:{disAllowStr}\r\n" +
                   $"允许抓取的目录:{allowStr}\r\n" +
                   $"网站地图:{Sitemap}\r\n\n");
        }
        public void AddDoesntAllowDuplicateEntries()
        {
            var allowList = new AllowList();

            Assert.AreEqual(0, allowList.Count);

            allowList.Add("Scunthorpe");

            Assert.AreEqual(1, allowList.Count);

            allowList.Add("Scunthorpe");

            Assert.AreEqual(1, allowList.Count);
        }
        public void RemoveMixedCaseEntryFromTheAllowList()
        {
            var allowList = new AllowList();

            allowList.Add("Scunthorpe");
            allowList.Add("Penistone");

            Assert.AreEqual(2, allowList.Count);

            allowList.Remove("ScUnThOrPe");

            Assert.AreEqual(1, allowList.Count);
            Assert.IsFalse(allowList.Contains("Scunthorpe"));
            Assert.IsTrue(allowList.Contains("Penistone"));
        }
        public void ToListReturnsReadOnlyCollectionContainingAllowList()
        {
            var allowList = new AllowList();

            allowList.Add("Scunthorpe");
            allowList.Add("Penistone");

            var readonlyList = allowList.ToList;

            Assert.IsNotNull(readonlyList);
            Assert.AreEqual(2, readonlyList.Count);

            Assert.AreEqual("scunthorpe", readonlyList[0]);
            Assert.AreEqual("penistone", readonlyList[1]);
        }
        /// <summary>
        /// Implementation of <see cref="IRuleUserControl"/>
        /// </summary>
        /// <param name="ruleKind">Selected <see cref="RuleKind"/></param>
        /// <returns>Newly created rule, in that case an <see cref="AllowList"/></returns>
        public Rule InvokeSubmission(RuleKind ruleKind)
        {
            if (passedRule != null)
            {
                passedRule.Name = ruleName.Text;
                BindingList <Asset> changedAllowList = (BindingList <Asset>)FormUtility.GetBindingSource(dataGridView).List;
                passedRule.Allowed = changedAllowList.ToList();
                return(passedRule);
            }
            AllowList newAllowList = new AllowList(RuleKind.RULE_EXCEPTION, ruleName.Text);

            foreach (DataGridViewRow row in dataGridView.Rows)
            {
                newAllowList.Allowed.Add(row.DataBoundItem as Asset);
            }
            TableUtility tableUtility = new TableUtility();

            tableUtility.CreateTable(newAllowList);
            tableUtility.InsertTableRow(newAllowList);
            return(newAllowList);
        }
Example #23
0
        /// <summary> Creates organization. </summary>
        /// <param name="organizationId"> The organization identifier. </param>
        /// <param name="sipDomain"> The sip domain. </param>
        /// <param name="enableConferencingVideo"> True - if conferencing video should be enabled.</param>
        /// <param name="maxConferenceSize"> The max conference size.</param>
        /// <param name="enabledFederation"> True - if federations should be enabled.</param>
        /// <param name="enabledEnterpriseVoice"> True - if enterprise voice should be enabled.</param>
        /// <returns> The tenant identifier. </returns>
        internal override string CreateOrganizationInternal(string organizationId, string sipDomain, bool enableConferencingVideo, int maxConferenceSize, bool enabledFederation, bool enabledEnterpriseVoice)
        {
            sipDomain = sipDomain.ToLower();
            HostedSolutionLog.LogStart("CreateOrganizationInternal");
            HostedSolutionLog.DebugInfo("organizationId: {0}", organizationId);
            HostedSolutionLog.DebugInfo("sipDomain: {0}", sipDomain);
            string         tenantId;
            SfBTransaction transaction = StartTransaction();
            Runspace       runspace    = null;

            try
            {
                runspace = OpenRunspace();
                var command = new Command("New-CsSipDomain");
                command.Parameters.Add("Identity", sipDomain);
                ExecuteShellCommand(runspace, command, false);
                transaction.RegisterNewSipDomain(sipDomain);
                Guid id = Guid.NewGuid();

                AddAdDomainName(organizationId, sipDomain);

                CreateSimpleUrl(runspace, id);
                transaction.RegisterNewSimpleUrl(sipDomain, id.ToString());

                command = new Command("New-CsConferencingPolicy");
                command.Parameters.Add("Identity", organizationId);
                command.Parameters.Add("MaxMeetingSize", ((maxConferenceSize == -1) | (maxConferenceSize > 250)) ? 250 : maxConferenceSize);
                command.Parameters.Add("AllowIPVideo", enableConferencingVideo);
                ExecuteShellCommand(runspace, command, false);
                transaction.RegisterNewConferencingPolicy(organizationId);

                command = new Command("New-CsExternalAccessPolicy");
                command.Parameters.Add("Identity", organizationId);
                command.Parameters.Add("EnableFederationAccess", true);
                command.Parameters.Add("EnableOutsideAccess", true);
                command.Parameters.Add("EnablePublicCloudAccess", false);
                command.Parameters.Add("EnablePublicCloudAudioVideoAccess", false);
                ExecuteShellCommand(runspace, command, false);
                transaction.RegisterNewCsExternalAccessPolicy(organizationId);

                var allowList = new AllowList();
                var domain    = new DomainPattern(sipDomain);
                allowList.AllowedDomain.Add(domain);

                AddFederationDomainInternal("", domain.Domain, PoolFQDN);

                command = new Command("New-CsMobilityPolicy");
                command.Parameters.Add("Identity", organizationId + " EnableOutSideVoice");
                command.Parameters.Add("EnableMobility", true);
                command.Parameters.Add("EnableOutsideVoice", true);
                ExecuteShellCommand(runspace, command, false);
                transaction.RegisterNewCsMobilityPolicy(organizationId + " EnableOutSideVoice");

                command = new Command("New-CsMobilityPolicy");
                command.Parameters.Add("Identity", organizationId + " DisableOutSideVoice");
                command.Parameters.Add("EnableMobility", true);
                command.Parameters.Add("EnableOutsideVoice", false);
                ExecuteShellCommand(runspace, command, false);
                transaction.RegisterNewCsMobilityPolicy(organizationId + " DisableOutSideVoice");

                command = new Command("Invoke-CsManagementStoreReplication");
                ExecuteShellCommand(runspace, command, false);

                tenantId = id.ToString();
            }
            catch (Exception ex)
            {
                HostedSolutionLog.LogError("CreateOrganizationInternal", ex);
                RollbackTransaction(transaction);
                throw;
            }
            finally
            {
                CloseRunspace(runspace);
            }

            HostedSolutionLog.LogEnd("CreateOrganizationInternal");

            return(tenantId);
        }
Example #24
0
 internal void AddAllowList(string domain)
 {
     AllowList.Add(domain);
 }
Example #25
0
 internal void ClearAllowList()
 {
     AllowList.Clear();
 }
Example #26
0
        private string CreateOrganizationInternal(string organizationId, string sipDomain, bool enableConferencing, bool enableConferencingVideo, int maxConferenceSize, bool enabledFederation, bool enabledEnterpriseVoice)
        {
            sipDomain = sipDomain.ToLower();
            HostedSolutionLog.LogStart("CreateOrganizationInternal");
            HostedSolutionLog.DebugInfo("organizationId: {0}", organizationId);
            HostedSolutionLog.DebugInfo("sipDomain: {0}", sipDomain);

            string TenantId = string.Empty;

            LyncTransaction transaction = StartTransaction();

            Runspace runSpace = null;
            try
            {
                runSpace = OpenRunspace();

                // create sip domain
                Command cmd = new Command("New-CsSipDomain");
                cmd.Parameters.Add("Identity", sipDomain);
                ExecuteShellCommand(runSpace, cmd, false);

                transaction.RegisterNewSipDomain(sipDomain);

                //set the msRTCSIP-Domains, TenantID, ObjectID
                Guid id = Guid.NewGuid();

                string path = AddADPrefix(GetOrganizationPath(organizationId));
                DirectoryEntry ou = ActiveDirectoryUtils.GetADObject(path);
                ActiveDirectoryUtils.SetADObjectPropertyValue(ou, "msRTCSIP-Domains", sipDomain);
                ActiveDirectoryUtils.SetADObjectPropertyValue(ou, "msRTCSIP-TenantId", id);
                ActiveDirectoryUtils.SetADObjectPropertyValue(ou, "msRTCSIP-ObjectId", id);
                ou.CommitChanges();

                //Create simpleurls
                CreateSimpleUrl(runSpace, sipDomain, id);
                transaction.RegisterNewSimpleUrl(sipDomain, id.ToString());

                //create conferencing policy
                cmd = new Command("New-CsConferencingPolicy");
                cmd.Parameters.Add("Identity", organizationId);

                cmd.Parameters.Add("MaxMeetingSize", ((maxConferenceSize == -1) | (maxConferenceSize > 250)) ? 250 : maxConferenceSize);
                cmd.Parameters.Add("AllowIPVideo", enableConferencingVideo);
                ExecuteShellCommand(runSpace, cmd, false);
                transaction.RegisterNewConferencingPolicy(organizationId);

                //create external access policy
                cmd = new Command("New-CsExternalAccessPolicy");
                cmd.Parameters.Add("Identity", organizationId);
                cmd.Parameters.Add("EnableFederationAccess", true);
                cmd.Parameters.Add("EnableOutsideAccess", true);
                cmd.Parameters.Add("EnablePublicCloudAccess", false);
                cmd.Parameters.Add("EnablePublicCloudAudioVideoAccess", false);
                ExecuteShellCommand(runSpace, cmd, false);
                transaction.RegisterNewCsExternalAccessPolicy(organizationId);

                //Enable for federation
                AllowList allowList = new AllowList();
                DomainPattern domain = new DomainPattern(sipDomain);
                allowList.AllowedDomain.Add(domain);

                cmd = new Command("Set-CsTenantFederationConfiguration");
                cmd.Parameters.Add("Tenant", id);
                cmd.Parameters.Add("AllowFederatedUsers", true);
                cmd.Parameters.Add("AllowedDomains", allowList);
                ExecuteShellCommand(runSpace, cmd, false);

                //create mobility policy
                cmd = new Command("New-CsMobilityPolicy");
                cmd.Parameters.Add("Identity", organizationId + " EnableOutSideVoice");
                cmd.Parameters.Add("EnableMobility", true);
                cmd.Parameters.Add("EnableOutsideVoice", true);
                ExecuteShellCommand(runSpace, cmd, false);
                transaction.RegisterNewCsMobilityPolicy(organizationId + " EnableOutSideVoice");

                cmd = new Command("New-CsMobilityPolicy");
                cmd.Parameters.Add("Identity", organizationId + " DisableOutSideVoice");
                cmd.Parameters.Add("EnableMobility", true);
                cmd.Parameters.Add("EnableOutsideVoice", false);
                ExecuteShellCommand(runSpace, cmd, false);
                transaction.RegisterNewCsMobilityPolicy(organizationId + " DisableOutSideVoice");

                cmd = new Command("Invoke-CsManagementStoreReplication");
                ExecuteShellCommand(runSpace, cmd, false);


                TenantId = id.ToString();
            }
            catch (Exception ex)
            {
                HostedSolutionLog.LogError("CreateOrganizationInternal", ex);
                RollbackTransaction(transaction);
                throw;
            }
            finally
            {

                CloseRunspace(runSpace);
            }

            HostedSolutionLog.LogEnd("CreateOrganizationInternal");

            return TenantId;
        }
Example #27
0
        private bool AddFederationDomainInternal(string organizationId, string domainName, string proxyFqdn)
        {
            HostedSolutionLog.LogStart("AddFederationDomainInternal");
            HostedSolutionLog.DebugInfo("organizationId: {0}", organizationId);
            HostedSolutionLog.DebugInfo("domainName: {0}", domainName);

            domainName = domainName.ToLower();
            proxyFqdn = proxyFqdn.ToLower();

            Runspace runSpace = null;
            try
            {
                runSpace = OpenRunspace();

                Guid tenantId = Guid.Empty;
                Command cmd = new Command("Get-CsTenant");
                cmd.Parameters.Add("Identity", GetOrganizationPath(organizationId));
                Collection<PSObject> result = ExecuteShellCommand(runSpace, cmd, false);
                if ((result != null) && (result.Count > 0))
                {
                    tenantId = (Guid)GetPSObjectProperty(result[0], "TenantId");

                    //Get-CSTenantFederationConfiguration (AllowedDomains)
                    cmd = new Command("Get-CsTenantFederationConfiguration");
                    cmd.Parameters.Add("Tenant", tenantId);
                    result = ExecuteShellCommand(runSpace, cmd, false);

                    if ((result != null) && (result.Count > 0))
                    {
                        AllowList allowList = null;

                        if (GetPSObjectProperty(result[0], "AllowedDomains").GetType().ToString() == "Microsoft.Rtc.Management.WritableConfig.Settings.Edge.AllowList")
                        {
                            allowList = (AllowList)GetPSObjectProperty(result[0], "AllowedDomains");
                            DomainPattern domain = new DomainPattern(domainName);
                            allowList.AllowedDomain.Add(domain);
                        }
                        else
                        {
                            allowList = new AllowList();
                            DomainPattern domain = new DomainPattern(domainName);
                            allowList.AllowedDomain.Add(domain);
                        }

                        cmd = new Command("Set-CsTenantFederationConfiguration");
                        cmd.Parameters.Add("Tenant", tenantId);
                        cmd.Parameters.Add("AllowedDomains", allowList);
                        ExecuteShellCommand(runSpace, cmd, false);
                    }
                }
            }
            catch (Exception ex)
            {
                HostedSolutionLog.LogError("AddFederationDomainInternal", ex);
                throw;
            }
            finally
            {

                CloseRunspace(runSpace);
            }
            HostedSolutionLog.LogEnd("AddFederationDomainInternal");

            return true;
        }
        public void ContainsThrowsArgumentNullExceptionIfInputStringIsNullOrEmpty()
        {
            var allowList = new AllowList();

            allowList.Contains("");
        }
        public void AddThrowsArgumentNullExceptionIfInputStringIsNullOrEmpty()
        {
            var allowList = new AllowList();

            allowList.Add("");
        }
        public void ConstructorSetsAllowListToEmpty()
        {
            IAllowList filter = new AllowList();

            Assert.AreEqual(0, filter.Count);
        }
Example #31
0
 //メソッド
 //AllowListの操作
 internal bool IsContainAllowList(string domain)
 {
     return(AllowList.Contains(domain));
 }