예제 #1
0
        internal static void AddRole(AddRoleParms parms)
        {
            var policies = new List <SecurityPolicyInfo>();

            if (parms.GrantPolicies?.Count > 0)
            {
                policies = parms.GrantPolicies.OfType <String>().Select(o => m_client.GetPolicies(r => r.Oid == o).CollectionItem.FirstOrDefault()).OfType <SecurityPolicy>().Select(o => new SecurityPolicyInfo(o)).ToList();
            }
            if (parms.DenyPolicies?.Count > 0)
            {
                policies = policies.Union(parms.DenyPolicies.OfType <String>().Select(o => m_client.GetPolicies(r => r.Oid == o).CollectionItem.FirstOrDefault()).OfType <SecurityPolicy>().Select(o => new SecurityPolicyInfo(o))).ToList();
            }

            policies.ForEach(o => o.Grant = parms.GrantPolicies?.Contains(o.Oid) == true ? Core.Model.Security.PolicyGrantType.Grant : PolicyGrantType.Deny);

            m_client.CreateRole(new Core.Model.AMI.Auth.SecurityRoleInfo()
            {
                Policies = policies,
                Entity   = new Core.Model.Security.SecurityRole()
                {
                    Name        = parms.RoleName,
                    Description = parms.Description
                }
            });
        }
예제 #2
0
        internal static void AddRole(AddRoleParms parms)
        {
            var policies = new List <SecurityPolicyInfo>();

            if (parms.Policies?.Count > 0)
            {
                policies = parms.Policies.OfType <String>().Select(o => m_client.GetPolicies(r => r.Name == o).CollectionItem.FirstOrDefault()).ToList();
                policies.ForEach(o => o.Grant = Core.Model.Security.PolicyGrantType.Grant);
            }

            m_client.CreateRole(new Core.Model.AMI.Auth.SecurityRoleInfo()
            {
                Name     = parms.RoleName,
                Policies = policies,
                Role     = new Core.Model.Security.SecurityRole()
                {
                    Name        = parms.RoleName,
                    Description = parms.Description
                }
            });
        }