Пример #1
0
        public bool AllowCreateApplication(string application)
        {
            if (string.IsNullOrWhiteSpace(application))
            {
                return(false);
            }

            return(User.IsInRole(SecurityRoles.RoleCreateApplication()) || IsMasterKey);
        }
Пример #2
0
        public bool AllowCreateDirectories(string application, string directoryName)
        {
            if (string.IsNullOrWhiteSpace(application) || string.IsNullOrWhiteSpace(directoryName))
            {
                return(false);
            }

            return(User.IsInRole(SecurityRoles.RoleCreateDirectory(application)) || IsMasterKey);
        }
Пример #3
0
        public bool AllowReadApiKeys(string applicationName)
        {
            if (string.IsNullOrWhiteSpace(applicationName))
            {
                return(false);
            }

            return(User.IsInRole(SecurityRoles.RoleReadApiKeys(applicationName)) || IsMasterKey);
        }
Пример #4
0
        public bool AllowDeleteSetting(string application, string directoryName)
        {
            if (string.IsNullOrWhiteSpace(application) || string.IsNullOrWhiteSpace(directoryName))
            {
                return(false);
            }

            return(User.IsInRole(SecurityRoles.RoleDeleteSetting(application, directoryName)) || IsMasterKey);
        }
Пример #5
0
        public bool AllowDeleteApplication(string application)
        {
            if (string.IsNullOrWhiteSpace(application) || string.Equals(application, Constants.SYSTEM_APPLICATION_NAME, System.StringComparison.CurrentCultureIgnoreCase))
            {
                return(false);
            }

            return(User.IsInRole(SecurityRoles.RoleDeleteApplication(application)) || IsMasterKey);
        }
        public static string[] ConstructRoles(string strKey)
        {
            List <string> roles = new List <string>();

            using (ValidationRepository repository = new ValidationRepository())
            {
                ApiKeyData data = repository.GetApiKey(strKey);

                if (data != null && data.Active)
                {
                    bool allowAdministration = data.AdminKey || data.Id == Constants.SYSTEM_MASTER_KEY_ID;

                    roles.Add(SecurityRoles.RoleReadDirectories(data.Application.Name));
                    roles.Add(SecurityRoles.RoleReadVersions(data.Application.Name));

                    if (data.Id == Constants.SYSTEM_MASTER_KEY_ID)
                    {
                        roles.Add(SecurityRoles.RoleCreateApplication());
                        roles.Add(SecurityRoles.RoleDeleteApplication(data.Application.Name));
                        roles.Add(SecurityRoles.RoleReadApiKeys());
                    }

                    foreach (var item in data.Access)
                    {
                        if (allowAdministration)
                        {
                            AddRoles(SecurityRoles.RoleDeleteDirectory(item.Directory.Application.Name, item.Directory.Name), roles);
                            AddRoles(SecurityRoles.RoleCreateDirectory(item.Directory.Application.Name), roles);
                            AddRoles(SecurityRoles.RoleDeleteDirectories(item.Directory.Application.Name), roles);
                            AddRoles(SecurityRoles.RoleCreateVersion(item.Directory.Application.Name), roles);
                            AddRoles(SecurityRoles.RoleDeleteVersion(item.Directory.Application.Name), roles);
                            AddRoles(SecurityRoles.RoleEditApiKey(item.Directory.Application.Name), roles);
                            AddRoles(SecurityRoles.RoleReadApiKeys(item.Directory.Application.Name), roles);
                        }

                        AddRoles(SecurityRoles.RoleReadDirectory(item.Directory.Application.Name, item.Directory.Name), roles);

                        if (item.AllowCreate)
                        {
                            AddRoles(SecurityRoles.RoleCreateSetting(item.Directory.Application.Name, item.Directory.Name), roles);
                        }

                        if (item.AllowDelete)
                        {
                            AddRoles(SecurityRoles.RoleDeleteSetting(item.Directory.Application.Name, item.Directory.Name), roles);
                        }

                        if (item.AllowWrite)
                        {
                            AddRoles(SecurityRoles.RoleWriteSetting(item.Directory.Application.Name, item.Directory.Name), roles);
                        }
                    }
                }

                return(roles.ToArray());
            }
        }
Пример #7
0
        public bool AllowCreateDirectory(string application, string directoryName)
        {
            if (string.IsNullOrWhiteSpace(application) || string.IsNullOrWhiteSpace(directoryName))
            {
                return(false);
            }

            if (!string.IsNullOrWhiteSpace(directoryName))
            {
                if (string.Equals(directoryName, Constants.DEAULT_DIRECTORY_NAME, System.StringComparison.CurrentCultureIgnoreCase))
                {
                    return(false);
                }
                return(User.IsInRole(SecurityRoles.RoleCreateDirectory(application)));
            }

            return(false);
        }
Пример #8
0
        public bool AllowDeleteDirectory(string application, string directoryName)
        {
            if (string.IsNullOrWhiteSpace(application) || string.IsNullOrWhiteSpace(directoryName))
            {
                return(false);
            }

            if (!IsMasterKey && string.Equals(directoryName, Constants.DEAULT_DIRECTORY_NAME, System.StringComparison.CurrentCultureIgnoreCase))
            {
                return(false);
            }

            if (string.Equals(application, Constants.SYSTEM_APPLICATION_NAME, System.StringComparison.CurrentCultureIgnoreCase) && string.Equals(directoryName, Constants.DEAULT_DIRECTORY_NAME, System.StringComparison.CurrentCultureIgnoreCase))
            {
                return(false);
            }

            return(User.IsInRole(SecurityRoles.RoleDeleteDirectory(application, directoryName)) || IsMasterKey);
        }