Exemple #1
0
        internal IAzScope CreateScope(string name, string description = null)
        {
            var iaz = IAzScope.CreateScope(name);

            iaz.Description = description;
            iaz.Submit();
            return(iaz);
        }
Exemple #2
0
        internal IAzApplicationGroup CreateGroup(string name, string description = null)
        {
            var iaz = IAzScope.CreateApplicationGroup(name);

            iaz.Description = description;
            iaz.Submit();

            return(iaz);
        }
Exemple #3
0
 internal void DeleteOperation(AzOperation operation)
 {
     if (operation == null)
     {
         return;
     }
     Operations.Remove(operation);
     IAzScope.DeleteOperation(operation.Name);
     HasChanged = true;
 }
Exemple #4
0
 internal void DeleteRoleAssignment(AzRoleAssignment roleAssignment)
 {
     if (roleAssignment == null)
     {
         return;
     }
     RoleAssignments.Remove(roleAssignment);
     IAzScope.DeleteRole(roleAssignment.Name);
     HasChanged = true;
 }
Exemple #5
0
        internal IAzTask CreateRole(string name, string description = null)
        {
            var iaz = IAzScope.CreateTask(name);

            iaz.IsRoleDefinition = 1;
            iaz.Description      = description;
            iaz.Submit();

            return(iaz);
        }
Exemple #6
0
 internal void DeleteGroup(AzGroup group)
 {
     if (group == null)
     {
         return;
     }
     Groups.Remove(group);
     IAzScope.DeleteApplicationGroup(group.Name);
     HasChanged = true;
 }
Exemple #7
0
 internal void DeleteRole(AzRole role)
 {
     if (role == null)
     {
         return;
     }
     Roles.Remove(role);
     IAzScope.DeleteTask(role.Name);
     HasChanged = true;
 }
Exemple #8
0
 internal void DeleteScope(AzScope scope)
 {
     if (scope == null)
     {
         return;
     }
     Scopes.Remove(scope);
     IAzScope.DeleteScope(scope.Name);
     HasChanged = true;
 }
        private void SetHirearchy(IAzScope azScope, IAzApplication azApplication, string taskName, IAzManApplication application)
        {
            IAzTask azTask = null;

            if (azScope == null)
            {
                azTask = azApplication.OpenTask(taskName, null);
            }
            else
            {
                azTask = azScope.OpenTask(taskName, null);
            }

            if (azTask != null)
            {
                IAzManItem item = application.GetItem(taskName);
                //SubTasks
                object[] azSubTasks = azTask.Tasks as object[];
                if (azSubTasks != null)
                {
                    foreach (string azSubTask in azSubTasks)
                    {
                        IAzManItem subItem = application.GetItem(azSubTask);
                        var        members = item.GetMembers();
                        if (members == null || members.Where(t => t.ItemId == subItem.ItemId).Count() == 0)
                        {
                            item.AddMember(subItem);
                        }
                        this.SetHirearchy(azScope, azApplication, azSubTask, application);
                    }
                }
                //SubOperations
                object[] azSubOperations = azTask.Operations as object[];
                if (azSubOperations != null)
                {
                    foreach (string azSubOperation in azSubOperations)
                    {
                        IAzManItem subItem = application.GetItem(azSubOperation);
                        var        members = item.GetMembers();
                        if (members == null || members.Where(t => t.ItemId == subItem.ItemId).Count() == 0)
                        {
                            item.AddMember(subItem);
                        }
                    }
                }
            }
        }
Exemple #10
0
        protected override void OnSaving()
        {
            if (IsNew)
            {
                IAzItem = Application.CreateScope(Name, Description);
            }
            else
            {
                IAzScope.Name        = Name;
                IAzScope.Description = Description;
            }

            Roles.ForEach(r => r.Save());
            Groups.ForEach(g => g.Save());
            RoleAssignments.ForEach(r => r.Save());

            IAzScope.Submit();
        }
Exemple #11
0
        private object[] GetTaskOperations(AzManAuthorizationProviderData data, IAzApplication azApp, string[] tasks)
        {
            string[]         scopes     = new string[] { data.Scope };
            StringCollection operations = new StringCollection();

            foreach (String task in tasks)
            {
                IAzScope scope = null;
                if ((scopes != null) && (scopes[0].Length > 0))
                {
                    scope = azApp.OpenScope(scopes[0], null);
                }

                IAzTask azTask = null;
                if (scope != null)
                {
                    azTask = scope.OpenTask(task, null);
                }
                else
                {
                    azTask = azApp.OpenTask(task, null);
                }

                Array ops = azTask.Operations as Array;
                Debug.Assert(ops != null);
                foreach (String op in ops)
                {
                    operations.Add(op);
                }
            }

            if (operations.Count == 0)
            {
                throw new ConfigurationException(SR.NoOperations);
            }

            object[] operationIds = new object[operations.Count];
            for (int index = 0; index < operations.Count; index++)
            {
                operationIds[index] = azApp.OpenOperation(operations[index], null).OperationID;
            }

            return(operationIds);
        }
        private object[] GetTaskOperations(IAzApplication azApp, string[] tasks)
        {
            string[]         scopes     = new string[] { this.scopeName };
            StringCollection operations = new StringCollection();

            foreach (String task in tasks)
            {
                IAzScope scope = null;
                if ((scopes != null) && (scopes[0].Length > 0))
                {
                    scope = azApp.OpenScope(scopes[0], null);
                }

                IAzTask azTask = null;
                if (scope != null)
                {
                    azTask = scope.OpenTask(task, null);
                }
                else
                {
                    azTask = azApp.OpenTask(task, null);
                }

                Array ops = azTask.Operations as Array;
                foreach (String op in ops)
                {
                    operations.Add(op);
                }
            }

            if (operations.Count == 0)
            {
                throw new ConfigurationErrorsException(Properties.Resources.NoOperations);
            }

            object[] operationIds = new object[operations.Count];
            for (int index = 0; index < operations.Count; index++)
            {
                operationIds[index] = azApp.OpenOperation(operations[index], null).OperationID;
            }

            return(operationIds);
        }
Exemple #13
0
        internal AzRoleAssignment GetOrCreateAzRoleAssignment(string name)
        {
            var role = RoleAssignments[name];

            if (role != null)
            {
                return(role);
            }

            var azRole = IAzScope.CreateRole(name);

            azRole.Submit();

            role = new AzRoleAssignment {
                IAzItem = azRole
            };
            RoleAssignments.Add(role);

            HasChanged = true;
            return(role);
        }
Exemple #14
0
        private void SetHirearchy(IAzScope azScope, IAzApplication azApplication, string taskName, IAzManApplication application)
        {
            IAzTask azTask = null;

            if (azScope == null)
            {
                azTask = azApplication.OpenTask(taskName, null);
            }
            else
            {
                azTask = azScope.OpenTask(taskName, null);
            }

            IAzManItem item = application.GetItem(taskName);

            if (azTask != null)
            {
                //SubTasks
                object[] azSubTasks = azTask.Tasks as object[];
                if (azSubTasks != null)
                {
                    foreach (string azSubTask in azSubTasks)
                    {
                        IAzManItem subItem = application.GetItem(azSubTask);
                        item.AddMember(subItem);
                        //this.SetHirearchy(azScope, azApplication, azSubTask, application);
                    }
                }
                //SubOperations
                object[] azSubOperations = azTask.Operations as object[];
                if (azSubOperations != null)
                {
                    foreach (string azSubOperation in azSubOperations)
                    {
                        IAzManItem subItem = application.GetItem(azSubOperation);
                        item.AddMember(subItem);
                    }
                }
            }
        }
        private void SetHirearchy(IAzScope azScope, IAzApplication azApplication, string taskName, IAzManApplication application)
        {
            IAzTask azTask = null;
            if (azScope == null)
                azTask = azApplication.OpenTask(taskName, null);
            else
                azTask = azScope.OpenTask(taskName, null);

            IAzManItem item = application.GetItem(taskName);
            if (azTask != null)
            {
                //SubTasks
                object[] azSubTasks = azTask.Tasks as object[];
                if (azSubTasks != null)
                {
                    foreach (string azSubTask in azSubTasks)
                    {
                        IAzManItem subItem = application.GetItem(azSubTask);
                        item.AddMember(subItem);
                        //this.SetHirearchy(azScope, azApplication, azSubTask, application);
                    }
                }
                //SubOperations
                object[] azSubOperations = azTask.Operations as object[];
                if (azSubOperations != null)
                {
                    foreach (string azSubOperation in azSubOperations)
                    {
                        IAzManItem subItem = application.GetItem(azSubOperation);
                        item.AddMember(subItem);
                    }
                }
            }
        }
Exemple #16
0
 public AzApplicationScopeWrapper(IAzScope scope)
 {
     Guard.ArgumentIsNotNull(scope, nameof(scope));
     _scope = scope;
 }
        private void SetHirearchy(IAzScope azScope, IAzApplication azApplication, string taskName, IAzManApplication application)
        {
            IAzTask azTask = null;
            if (azScope == null)
                azTask = azApplication.OpenTask(taskName, null);
            else
                azTask = azScope.OpenTask(taskName, null);

            if (azTask != null)
            {
                IAzManItem item = application.GetItem(taskName);
                //SubTasks
                object[] azSubTasks = azTask.Tasks as object[];
                if (azSubTasks != null)
                {
                    foreach (string azSubTask in azSubTasks)
                    {
                        IAzManItem subItem = application.GetItem(azSubTask);
                        var members = item.GetMembers();
                        if (members == null || members.Where(t => t.ItemId == subItem.ItemId).Count() == 0)
                            item.AddMember(subItem);
                        this.SetHirearchy(azScope, azApplication, azSubTask, application);
                    }
                }
                //SubOperations
                object[] azSubOperations = azTask.Operations as object[];
                if (azSubOperations != null)
                {
                    foreach (string azSubOperation in azSubOperations)
                    {
                        IAzManItem subItem = application.GetItem(azSubOperation);
                        var members = item.GetMembers();
                        if (members == null || members.Where(t => t.ItemId == subItem.ItemId).Count() == 0)
                            item.AddMember(subItem);
                    }
                }
            }
        }