Get() public méthode

public Get ( ) : List
Résultat List
Exemple #1
0
        public static bool IsStaticDomain(string domain = "")
        {
            if (string.IsNullOrWhiteSpace(domain))
            {
                domain = GetDomain();
            }

            Log.Verbose($"Checking if the domain \"{domain}\" is a static domain.");

            var approved        = new DomainSerializer("DomainsApproved.json");
            var approvedDomains = approved.Get();

            var tenant = approvedDomains.FirstOrDefault(x => x.GetSubtenants().Contains(domain.ToLowerInvariant()));

            if (tenant != null)
            {
                bool isStatic = domain.ToUpperInvariant().Equals(tenant.CdnDomain.ToUpperInvariant());

                Log.Verbose(isStatic
                    ? $"The domain \"{domain}\" is a static domain."
                    : $"The domain \"{domain}\" is not a static domain.");

                return(isStatic);
            }

            return(false);
        }
Exemple #2
0
        public static bool EnforceSsl(string domain = "")
        {
            if (string.IsNullOrWhiteSpace(domain))
            {
                domain = GetDomain();
            }

            Log.Verbose($"Getting SSL configuration for domain \"{domain}\".");

            var approved        = new DomainSerializer("DomainsApproved.json");
            var approvedDomains = approved.Get();

            var tenant = approvedDomains.FirstOrDefault(x => x.GetSubtenants().Contains(domain.ToLowerInvariant()));

            if (tenant != null)
            {
                Log.Verbose(tenant.EnforceSsl
                    ? $"SSL is enforced on domain \"{domain}\"."
                    : $"SSL is optional on domain \"{domain}\".");

                return(tenant.EnforceSsl);
            }

            Log.Verbose($"Cannot find SSL configuration because no approved domain entry found for \"{domain}\".");
            return(false);
        }
Exemple #3
0
        public void Register()
        {
            try
            {
                var installed = new DomainSerializer("DomainsInstalled.json");

                foreach (var repository in
                    from domain in installed.Get()
                    let catalog = DbConvention.GetDbNameByConvention(domain.DomainName)
                    select new AddInstalledDomainProcedure
                    {
                        DomainName = domain.DomainName,
                        AdminEmail = domain.AdminEmail,
                        SkipValidation = true,
                        _Catalog = catalog
                    })
                {
                    repository.Execute();
                }
            }
            catch (NpgsqlException ex)
            {
                Log.Error("Could not execute AddInstalledDomainProcedure. Exception: {Exception}", ex);
            }
        }
Exemple #4
0
        public static ApprovedDomain FindDomainByTenant(string tenant)
        {
            var    approved = new DomainSerializer("DomainsApproved.json");
            string domain   = approved.GetTenantMembers().FirstOrDefault(x => GetTenant(x) == tenant);
            var    instance = approved.Get().FirstOrDefault(x => domain != null && x.GetSubtenants().Contains(domain.ToLowerInvariant()));

            return(instance);
        }
Exemple #5
0
        public static bool IsValidCatalog(string catalog = "")
        {
            if (string.IsNullOrWhiteSpace(catalog))
            {
                catalog = GetDbNameByConvention(catalog);
            }

            var serializer = new DomainSerializer("domains-approved.json");

            return serializer.Get().Select(GetDbNameByConvention).Any(c => catalog.Equals(c));
        }
Exemple #6
0
        public static bool IsValidCatalog(string catalog = "")
        {
            if (string.IsNullOrWhiteSpace(catalog))
            {
                catalog = GetDbNameByConvention(catalog);
            }

            var serializer = new DomainSerializer("domains-approved.json");

            return(serializer.Get().Select(GetDbNameByConvention).Any(c => catalog.Equals(c)));
        }
Exemple #7
0
        public static bool IsValidCatalog(string catalog = "")
        {
            if (string.IsNullOrWhiteSpace(catalog))
            {
                catalog = GetDbNameByConvention(catalog);
            }

            var serializer = new DomainSerializer("DomainsApproved.json");

            return serializer.Get().Any(domain => GetDbNameByConvention(domain.DomainName) == catalog);
        }
Exemple #8
0
        public ActionResult Index()
        {
            string domain = DbConvention.GetDomain();

            var approved = new DomainSerializer("DomainsApproved.json");
            var installed = new DomainSerializer("DomainsInstalled.json");
           
            if (!approved.Get().Any(x => x.DomainName.Equals(domain)))
            {
                return this.HttpNotFound();
            }

            if (installed.Get().Any(x => x.DomainName.Equals(domain)))
            {
                return this.Redirect("/");
            }

            var setup = approved.Get().FirstOrDefault(x => x.DomainName.Equals(domain));
            InstallationFactory.Setup(setup); //Background job
            return this.Content("Installing frapid, please visit the site after a few minutes.");
        }
        private ActionResult RedirectToInstallationPage()
        {
            string domain = DbConvention.GetDomain();

            var approved = new DomainSerializer("DomainsApproved.json");
            var installed = new DomainSerializer("DomainsInstalled.json");

            bool isApproved = approved.Get().Any(x => x.DomainName.Equals(domain));
            bool isInstalled = installed.Get().Any(x => x.DomainName.Equals(domain));

            if (isApproved && !isInstalled)
            {
                return Redirect("/install");
            }

            return Content("Frapid cannot be installed due configuration errors. Please check application log for more information.");
        }
Exemple #10
0
        public static string GetDbNameByConvention(string domain = "")
        {
            if (string.IsNullOrWhiteSpace(domain))
            {
                domain = GetDomain();
            }

            Log.Verbose($"Getting tenant name for domain \"{domain}\"");

            var approved = new DomainSerializer("DomainsApproved.json");
            var tenant   = approved.Get().FirstOrDefault(x => x.GetSubtenants().Contains(domain.ToLowerInvariant()));

            if (tenant != null)
            {
                Log.Verbose($"Tenant found for domain \"{domain}\". Tenant domain: \"{tenant.DomainName}\".");
                return(ConvertToDbName(tenant.DomainName));
            }

            return(ConvertToDbName(domain));
        }
Exemple #11
0
        public ActionResult Index()
        {
            string domain = DbConvention.GetDomain();

            var approved = new DomainSerializer("domains-approved.json");
            var installed = new DomainSerializer("domains-installed.json");

            if (!approved.Get().Contains(domain))
            {
                return this.HttpNotFound();
            }

            if (installed.Get().Contains(domain))
            {
                return this.Redirect("/");
            }

            InstallationFactory.Setup(domain); //Background job
            return this.Content("Installing frapid, please visit the site after a few minutes.");
        }
Exemple #12
0
        public static string GetBaseDomain(HttpContextBase context, bool includeScheme)
        {
            string domain = context.Request.Url?.DnsSafeHost;

            if (string.IsNullOrWhiteSpace(domain))
            {
                return(string.Empty);
            }

            var    approved   = new DomainSerializer("DomainsApproved.json");
            var    tenant     = approved.Get().FirstOrDefault(x => x.GetSubtenants().Contains(domain.ToLowerInvariant()));
            string domainName = domain;

            if (tenant != null && includeScheme)
            {
                string scheme = context.Request.IsSecureConnection ? "https://" : "http://";
                domainName = scheme + tenant.DomainName;
            }

            return(domainName);
        }
Exemple #13
0
        public static bool IsValidTenant(string tenant = "")
        {
            if (string.IsNullOrWhiteSpace(tenant))
            {
                tenant = GetDbNameByConvention(tenant);
                Log.Verbose($"The tenant for empty domain was automatically resolved to \"{tenant}\".");
            }

            var serializer = new DomainSerializer("DomainsApproved.json");


            bool result = serializer.Get().Any(domain => GetDbNameByConvention(domain.DomainName) == tenant);

            if (!result)
            {
                Log.Information(
                    $"The tenant \"{tenant}\" was not found on list of approved domains. Please check your configuration");
            }

            return(result);
        }
Exemple #14
0
        public static List <string> GetTenants()
        {
            var serializer = new DomainSerializer("DomainsApproved.json");

            return(serializer.Get().Select(member => GetDbNameByConvention(member.DomainName)).ToList());
        }
Exemple #15
0
        public static List <ApprovedDomain> GetDomains()
        {
            var serializer = new DomainSerializer("DomainsApproved.json");

            return(serializer.Get());
        }
Exemple #16
0
 public bool IsWellKnownDb()
 {
     var serializer = new DomainSerializer("DomainsApproved.json");
     var domains = serializer.Get();
     return domains.Any(domain => DbConvention.GetCatalog(domain.DomainName) == this.Catalog);
 }