Esempio n. 1
0
        private bool MatchesState(ISecurityContext context, State state)
        {
            if (!context.ContainsState(state.PropertyName))
            {
                throw CreateAccessControlException("The state '{0}' is missing in the security context.", state.PropertyName);
            }

            var enumWrapper = context.GetState(state.PropertyName);

            var validStates = _securityContextRepository.GetStatePropertyValues(state.PropertyHandle);

            if (!validStates.Contains(enumWrapper.Name))
            {
                throw CreateAccessControlException(
                          "The state '{0}' is not defined for the property '{1}' of the securable class '{2}' or its base classes.",
                          enumWrapper.Name,
                          state.PropertyName,
                          context.Class);
            }

            return(enumWrapper.Name.Equals(state.Value));
        }