コード例 #1
0
        private bool FilterByPolicies(OperationInspector inspector, ODataOperationMethodDescriptor action, Content content)
        {
            if (action.OperationInfo.Policies.Length == 0)
            {
                return(true);
            }

            //TODO:~ set HttpContext in OperationCallingContext
            var context = new OperationCallingContext(content, action.OperationInfo);

            switch (inspector.CheckPolicies(action.OperationInfo.Policies, context))
            {
            case OperationMethodVisibility.Invisible:
                return(false);

            case OperationMethodVisibility.Disabled:
                // according to the policy this action is visible to the user but cannot be executed
                action.Forbidden = true;
                break;

            case OperationMethodVisibility.Enabled:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(true);
        }
コード例 #2
0
 private bool FilterByRoles(OperationInspector inspector, string[] expectedRoles, IEnumerable <string> actualRoles)
 {
     if (expectedRoles.Length == 0)
     {
         return(true);
     }
     return(inspector.CheckByRoles(expectedRoles, actualRoles));
 }
コード例 #3
0
 private bool IsPermitted(OperationInspector inspector, Content content, string[] permissionNames)
 {
     if (permissionNames == null || permissionNames.Length == 0)
     {
         return(true);
     }
     return(inspector.CheckByPermissions(content, permissionNames));
 }
コード例 #4
0
ファイル: OperationCenter.cs プロジェクト: jcallinan/sensenet
 private static bool FilterByContentTypes(OperationInspector inspector, Content content, string[] allowedContentTypes)
 {
     if (allowedContentTypes.Length == 0)
     {
         return(true);
     }
     return(inspector.CheckByContentType(content, allowedContentTypes));
 }
コード例 #5
0
ファイル: OperationCenter.cs プロジェクト: jcallinan/sensenet
 private static bool FilterByRolesAndPermissions(OperationInspector inspector, string[] roles, string[] permissions, Content content)
 {
     if (roles.Length > 0 && !inspector.CheckByRoles(roles))
     {
         return(false);
     }
     if (permissions.Length > 0 && !inspector.CheckByPermissions(content, permissions))
     {
         return(false);
     }
     return(true);
 }
コード例 #6
0
        private bool FilterByPermissions(OperationInspector inspector, ODataOperationMethodDescriptor action, Content content)
        {
            action.Forbidden |= !IsPermitted(inspector, content, action.OperationInfo.Permissions);

            return(true);
        }