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

            _securityClient.CheckConstructorAccess(typeof(SecurableObject));

            _testHelper.VerifyAll();
        }
        public void Test_AccessGranted()
        {
            _testHelper.ExpectFunctionalSecurityStrategyHasAccess(GeneralAccessTypes.Create, true);
            _testHelper.ReplayAll();

            _securityClient.CheckConstructorAccess(typeof(SecurableObject));

            _testHelper.VerifyAll();
        }
Example #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));
            }
        }