public void Test_AccessGranted()
        {
            _testHelper.ReplayAll();

            _securityClient.CheckStaticMethodAccess(typeof(SecurableObject), "IsValid");

            _testHelper.VerifyAll();
        }
Esempio n. 2
0
        public void Test_AccessGranted()
        {
            _testHelper.ExpectPermissionReflectorGetRequiredMethodPermissions(_methodInformation, TestAccessTypes.First);
            _testHelper.ExpectFunctionalSecurityStrategyHasAccess(TestAccessTypes.First, true);
            _testHelper.ReplayAll();

            _securityClient.CheckStaticMethodAccess(typeof(SecurableObject), _methodInformation);

            _testHelper.VerifyAll();
        }
Esempio n. 3
0
        // methods and properties

        public void CheckAccess(WxeFunction function)
        {
            ArgumentUtility.CheckNotNull("function", function);

            if (SecurityFreeSection.IsActive)
            {
                return;
            }

            WxeDemandTargetPermissionAttribute attribute = GetPermissionAttribute(function.GetType());

            if (attribute == null)
            {
                return;
            }

            WxeDemandMethodPermissionAttributeHelper helper = new WxeDemandMethodPermissionAttributeHelper(function.GetType(), attribute);
            SecurityClient securityClient = SecurityClient.CreateSecurityClientFromConfiguration();

            switch (helper.MethodType)
            {
            case MethodType.Instance:
                securityClient.CheckMethodAccess(helper.GetSecurableObject(function), helper.MethodName);
                break;

            case MethodType.Static:
                securityClient.CheckStaticMethodAccess(helper.SecurableClass, helper.MethodName);
                break;

            case MethodType.Constructor:
                securityClient.CheckConstructorAccess(helper.SecurableClass);
                break;

            default:
                throw new InvalidOperationException(string.Format(
                                                        "Value '{0}' is not supported by the MethodType property of the WxeDemandMethodPermissionAttribute.",
                                                        helper.MethodType));
            }
        }