Example #1
0
        internal List <UserRole> GetUserRoles(string resource)
        {
            var userRoles = new List <UserRole>();

            if (RealmAccess != null && RealmAccess.Roles != null && RealmAccess.Roles.Length > 0)
            {
                var realmRoles = RealmAccess.Roles;
                foreach (var realmRole in realmRoles)
                {
                    userRoles.Add(new UserRole(realmRole, RoleType.REALM, null));
                }
            }

            if (ResourceAccess != null && ResourceAccess.ContainsKey(resource) && ResourceAccess[resource].Roles != null && ResourceAccess[resource].Roles.Length > 0)
            {
                var resourceRoles = ResourceAccess[resource].Roles;
                foreach (var resourceRole in resourceRoles)
                {
                    userRoles.Add(new UserRole(resourceRole, RoleType.RESOURCE, resource));
                }
            }

            return(userRoles);
        }