GSF.Security.SecurityProviderUtility.IsResourceAccessible C# (CSharp) Method

IsResourceAccessible() public static method

Determines if the current user, as defined by the Thread.CurrentPrincipal, has permission to access the specified resource based on settings in the config file.
public static IsResourceAccessible ( string resource ) : bool
resource string Name of the resource to be checked.
return bool
        public static bool IsResourceAccessible(string resource)
        {
            // Check if the resource has a role-based access restriction on it.
            foreach (KeyValuePair<string, string> inclusion in s_includedResources)
            {
                foreach (string item in inclusion.Key.Split(','))
                {
                    if (IsRegexMatch(item.Trim(), resource))
                    {
                        // Allow security to be implemented inside the resource.
                        if (string.IsNullOrEmpty(inclusion.Value))
                            return true;

                        // Check resource role requirements against user's role subscription.
                        return Thread.CurrentPrincipal.IsInRole(inclusion.Value);
                    }
                }
            }

            return false;
        }