Example #1
0
        private void SetInheritance(Content content, SetPermissionsRequest request)
        {
            if (request.r != null)
            {
                throw new InvalidOperationException("Cannot use 'r' and 'inheritance' parameters at the same time.");
            }
            switch (request.inheritance.ToLower())
            {
            default:
                throw new ArgumentException("The value of the 'inheritance' must be 'break' or 'unbreak'.");

            case "break":
                content.ContentHandler.Security.BreakInheritance();
                break;

            case "unbreak":
                content.ContentHandler.Security.RemoveBreakInheritance();
                break;
            }
        }
Example #2
0
        private void SetInheritance(Content content, SetPermissionsRequest request, SnAclEditor editor)
        {
            if (request.r != null)
            {
                throw new InvalidOperationException("Cannot use 'r' and 'inheritance' parameters at the same time.");
            }

            switch (request.inheritance.ToLower())
            {
            default:
                throw new ArgumentException("The value of the 'inheritance' must be 'break' or 'unbreak'.");

            case "break":
                editor.BreakInheritance(content.Id, new[] { EntryType.Normal });
                break;

            case "unbreak":
                editor.UnbreakInheritance(content.Id, new[] { EntryType.Normal });
                break;
            }
        }
Example #3
0
        private void SetPermissions(Content content, SetPermissionsRequest request, SnAclEditor editor)
        {
            var contentId = content.Id;

            foreach (var permReq in request.r)
            {
                var member    = LoadMember(permReq.identity);
                var localOnly = permReq.localOnly.HasValue ? permReq.localOnly.Value : false;

                if (permReq.See != null) /**/ ProcessPermission{
                        (editor, contentId, member.Id, localOnly, PermissionType.See, permReq.See);
                }
                if (permReq.Preview != null) /**/ ProcessPermission{
                        (editor, contentId, member.Id, localOnly, PermissionType.Preview, permReq.Preview);
                }
                if (permReq.PreviewWithoutWatermark != null) /**/ ProcessPermission{
                        (editor, contentId, member.Id, localOnly, PermissionType.PreviewWithoutWatermark, permReq.PreviewWithoutWatermark);
                }
                if (permReq.PreviewWithoutRedaction != null) /**/ ProcessPermission{
                        (editor, contentId, member.Id, localOnly, PermissionType.PreviewWithoutRedaction, permReq.PreviewWithoutRedaction);
                }
                if (permReq.Open != null) /**/ ProcessPermission{
                        (editor, contentId, member.Id, localOnly, PermissionType.Open, permReq.Open);
                }
                if (permReq.OpenMinor != null) /**/ ProcessPermission{
                        (editor, contentId, member.Id, localOnly, PermissionType.OpenMinor, permReq.OpenMinor);
                }
                if (permReq.Save != null) /**/ ProcessPermission{
                        (editor, contentId, member.Id, localOnly, PermissionType.Save, permReq.Save);
                }
                if (permReq.Publish != null) /**/ ProcessPermission{
                        (editor, contentId, member.Id, localOnly, PermissionType.Publish, permReq.Publish);
                }
                if (permReq.ForceCheckin != null) /**/ ProcessPermission{
                        (editor, contentId, member.Id, localOnly, PermissionType.ForceCheckin, permReq.ForceCheckin);
                }
                if (permReq.AddNew != null) /**/ ProcessPermission{
                        (editor, contentId, member.Id, localOnly, PermissionType.AddNew, permReq.AddNew);
                }
                if (permReq.Approve != null) /**/ ProcessPermission{
                        (editor, contentId, member.Id, localOnly, PermissionType.Approve, permReq.Approve);
                }
                if (permReq.Delete != null) /**/ ProcessPermission{
                        (editor, contentId, member.Id, localOnly, PermissionType.Delete, permReq.Delete);
                }
                if (permReq.RecallOldVersion != null) /**/ ProcessPermission{
                        (editor, contentId, member.Id, localOnly, PermissionType.RecallOldVersion, permReq.RecallOldVersion);
                }
                if (permReq.DeleteOldVersion != null) /**/ ProcessPermission{
                        (editor, contentId, member.Id, localOnly, PermissionType.DeleteOldVersion, permReq.DeleteOldVersion);
                }
                if (permReq.SeePermissions != null) /**/ ProcessPermission{
                        (editor, contentId, member.Id, localOnly, PermissionType.SeePermissions, permReq.SeePermissions);
                }
                if (permReq.SetPermissions != null) /**/ ProcessPermission{
                        (editor, contentId, member.Id, localOnly, PermissionType.SetPermissions, permReq.SetPermissions);
                }
                if (permReq.RunApplication != null) /**/ ProcessPermission{
                        (editor, contentId, member.Id, localOnly, PermissionType.RunApplication, permReq.RunApplication);
                }
                if (permReq.ManageListsAndWorkspaces != null) /**/ ProcessPermission{
                        (editor, contentId, member.Id, localOnly, PermissionType.ManageListsAndWorkspaces, permReq.ManageListsAndWorkspaces);
                }
                if (permReq.TakeOwnership != null) /**/ ProcessPermission{
                        (editor, contentId, member.Id, localOnly, PermissionType.TakeOwnership, permReq.TakeOwnership);
                }

                if (permReq.Custom01 != null)
                {
                    ProcessPermission(editor, contentId, member.Id, localOnly, PermissionType.Custom01, permReq.Custom01);
                }
                if (permReq.Custom02 != null)
                {
                    ProcessPermission(editor, contentId, member.Id, localOnly, PermissionType.Custom02, permReq.Custom02);
                }
                if (permReq.Custom03 != null)
                {
                    ProcessPermission(editor, contentId, member.Id, localOnly, PermissionType.Custom03, permReq.Custom03);
                }
                if (permReq.Custom04 != null)
                {
                    ProcessPermission(editor, contentId, member.Id, localOnly, PermissionType.Custom04, permReq.Custom04);
                }
                if (permReq.Custom05 != null)
                {
                    ProcessPermission(editor, contentId, member.Id, localOnly, PermissionType.Custom05, permReq.Custom05);
                }
                if (permReq.Custom06 != null)
                {
                    ProcessPermission(editor, contentId, member.Id, localOnly, PermissionType.Custom06, permReq.Custom06);
                }
                if (permReq.Custom07 != null)
                {
                    ProcessPermission(editor, contentId, member.Id, localOnly, PermissionType.Custom07, permReq.Custom07);
                }
                if (permReq.Custom08 != null)
                {
                    ProcessPermission(editor, contentId, member.Id, localOnly, PermissionType.Custom08, permReq.Custom08);
                }
                if (permReq.Custom09 != null)
                {
                    ProcessPermission(editor, contentId, member.Id, localOnly, PermissionType.Custom09, permReq.Custom09);
                }
                if (permReq.Custom10 != null)
                {
                    ProcessPermission(editor, contentId, member.Id, localOnly, PermissionType.Custom10, permReq.Custom10);
                }
                if (permReq.Custom11 != null)
                {
                    ProcessPermission(editor, contentId, member.Id, localOnly, PermissionType.Custom11, permReq.Custom11);
                }
                if (permReq.Custom12 != null)
                {
                    ProcessPermission(editor, contentId, member.Id, localOnly, PermissionType.Custom12, permReq.Custom12);
                }
                if (permReq.Custom13 != null)
                {
                    ProcessPermission(editor, contentId, member.Id, localOnly, PermissionType.Custom13, permReq.Custom13);
                }
                if (permReq.Custom14 != null)
                {
                    ProcessPermission(editor, contentId, member.Id, localOnly, PermissionType.Custom14, permReq.Custom14);
                }
                if (permReq.Custom15 != null)
                {
                    ProcessPermission(editor, contentId, member.Id, localOnly, PermissionType.Custom15, permReq.Custom15);
                }
                if (permReq.Custom16 != null)
                {
                    ProcessPermission(editor, contentId, member.Id, localOnly, PermissionType.Custom16, permReq.Custom16);
                }
                if (permReq.Custom17 != null)
                {
                    ProcessPermission(editor, contentId, member.Id, localOnly, PermissionType.Custom17, permReq.Custom17);
                }
                if (permReq.Custom18 != null)
                {
                    ProcessPermission(editor, contentId, member.Id, localOnly, PermissionType.Custom18, permReq.Custom18);
                }
                if (permReq.Custom19 != null)
                {
                    ProcessPermission(editor, contentId, member.Id, localOnly, PermissionType.Custom19, permReq.Custom19);
                }
                if (permReq.Custom20 != null)
                {
                    ProcessPermission(editor, contentId, member.Id, localOnly, PermissionType.Custom20, permReq.Custom20);
                }
                if (permReq.Custom21 != null)
                {
                    ProcessPermission(editor, contentId, member.Id, localOnly, PermissionType.Custom21, permReq.Custom21);
                }
                if (permReq.Custom22 != null)
                {
                    ProcessPermission(editor, contentId, member.Id, localOnly, PermissionType.Custom22, permReq.Custom22);
                }
                if (permReq.Custom23 != null)
                {
                    ProcessPermission(editor, contentId, member.Id, localOnly, PermissionType.Custom23, permReq.Custom23);
                }
                if (permReq.Custom24 != null)
                {
                    ProcessPermission(editor, contentId, member.Id, localOnly, PermissionType.Custom24, permReq.Custom24);
                }
                if (permReq.Custom25 != null)
                {
                    ProcessPermission(editor, contentId, member.Id, localOnly, PermissionType.Custom25, permReq.Custom25);
                }
                if (permReq.Custom26 != null)
                {
                    ProcessPermission(editor, contentId, member.Id, localOnly, PermissionType.Custom26, permReq.Custom26);
                }
                if (permReq.Custom27 != null)
                {
                    ProcessPermission(editor, contentId, member.Id, localOnly, PermissionType.Custom27, permReq.Custom27);
                }
                if (permReq.Custom28 != null)
                {
                    ProcessPermission(editor, contentId, member.Id, localOnly, PermissionType.Custom28, permReq.Custom28);
                }
                if (permReq.Custom29 != null)
                {
                    ProcessPermission(editor, contentId, member.Id, localOnly, PermissionType.Custom29, permReq.Custom29);
                }
                if (permReq.Custom30 != null)
                {
                    ProcessPermission(editor, contentId, member.Id, localOnly, PermissionType.Custom30, permReq.Custom30);
                }
                if (permReq.Custom31 != null)
                {
                    ProcessPermission(editor, contentId, member.Id, localOnly, PermissionType.Custom31, permReq.Custom31);
                }
                if (permReq.Custom32 != null)
                {
                    ProcessPermission(editor, contentId, member.Id, localOnly, PermissionType.Custom32, permReq.Custom32);
                }
            }
            editor.Apply();
        }
Example #4
0
        private void SetPermissions(Content content, SetPermissionsRequest request)
        {
            var editor = content.ContentHandler.Security.GetAclEditor();

            foreach (var permReq in request.r)
            {
                var member     = LoadMember(permReq.identity);
                var propagates = permReq.propagates.HasValue ? permReq.propagates.Value : true;

                if (permReq.See != null)
                {
                    editor.SetPermission(member, propagates, PermissionType.See, GetPermissionValue(permReq.See));
                }
                if (permReq.Open != null)
                {
                    editor.SetPermission(member, propagates, PermissionType.Open, GetPermissionValue(permReq.Open));
                }
                if (permReq.OpenMinor != null)
                {
                    editor.SetPermission(member, propagates, PermissionType.OpenMinor, GetPermissionValue(permReq.OpenMinor));
                }
                if (permReq.Save != null)
                {
                    editor.SetPermission(member, propagates, PermissionType.Save, GetPermissionValue(permReq.Save));
                }
                if (permReq.Publish != null)
                {
                    editor.SetPermission(member, propagates, PermissionType.Publish, GetPermissionValue(permReq.Publish));
                }
                if (permReq.ForceCheckin != null)
                {
                    editor.SetPermission(member, propagates, PermissionType.ForceCheckin, GetPermissionValue(permReq.ForceCheckin));
                }
                if (permReq.AddNew != null)
                {
                    editor.SetPermission(member, propagates, PermissionType.AddNew, GetPermissionValue(permReq.AddNew));
                }
                if (permReq.Approve != null)
                {
                    editor.SetPermission(member, propagates, PermissionType.Approve, GetPermissionValue(permReq.Approve));
                }
                if (permReq.Delete != null)
                {
                    editor.SetPermission(member, propagates, PermissionType.Delete, GetPermissionValue(permReq.Delete));
                }
                if (permReq.RecallOldVersion != null)
                {
                    editor.SetPermission(member, propagates, PermissionType.RecallOldVersion, GetPermissionValue(permReq.RecallOldVersion));
                }
                if (permReq.DeleteOldVersion != null)
                {
                    editor.SetPermission(member, propagates, PermissionType.DeleteOldVersion, GetPermissionValue(permReq.DeleteOldVersion));
                }
                if (permReq.SeePermissions != null)
                {
                    editor.SetPermission(member, propagates, PermissionType.SeePermissions, GetPermissionValue(permReq.SeePermissions));
                }
                if (permReq.SetPermissions != null)
                {
                    editor.SetPermission(member, propagates, PermissionType.SetPermissions, GetPermissionValue(permReq.SetPermissions));
                }
                if (permReq.RunApplication != null)
                {
                    editor.SetPermission(member, propagates, PermissionType.RunApplication, GetPermissionValue(permReq.RunApplication));
                }
                if (permReq.ManageListsAndWorkspaces != null)
                {
                    editor.SetPermission(member, propagates, PermissionType.ManageListsAndWorkspaces, GetPermissionValue(permReq.ManageListsAndWorkspaces));
                }

                if (permReq.Preview != null)
                {
                    editor.SetPermission(member, propagates, PermissionType.Preview, GetPermissionValue(permReq.Preview));
                }
                if (permReq.PreviewWithoutWatermark != null)
                {
                    editor.SetPermission(member, propagates, PermissionType.PreviewWithoutWatermark, GetPermissionValue(permReq.PreviewWithoutWatermark));
                }
                if (permReq.PreviewWithoutRedaction != null)
                {
                    editor.SetPermission(member, propagates, PermissionType.PreviewWithoutRedaction, GetPermissionValue(permReq.PreviewWithoutRedaction));
                }

                if (permReq.Custom01 != null)
                {
                    editor.SetPermission(member, propagates, PermissionType.Custom01, GetPermissionValue(permReq.Custom01));
                }
                if (permReq.Custom02 != null)
                {
                    editor.SetPermission(member, propagates, PermissionType.Custom02, GetPermissionValue(permReq.Custom02));
                }
                if (permReq.Custom03 != null)
                {
                    editor.SetPermission(member, propagates, PermissionType.Custom03, GetPermissionValue(permReq.Custom03));
                }
                if (permReq.Custom04 != null)
                {
                    editor.SetPermission(member, propagates, PermissionType.Custom04, GetPermissionValue(permReq.Custom04));
                }
                if (permReq.Custom05 != null)
                {
                    editor.SetPermission(member, propagates, PermissionType.Custom05, GetPermissionValue(permReq.Custom05));
                }
                if (permReq.Custom06 != null)
                {
                    editor.SetPermission(member, propagates, PermissionType.Custom06, GetPermissionValue(permReq.Custom06));
                }
                if (permReq.Custom07 != null)
                {
                    editor.SetPermission(member, propagates, PermissionType.Custom07, GetPermissionValue(permReq.Custom07));
                }
                if (permReq.Custom08 != null)
                {
                    editor.SetPermission(member, propagates, PermissionType.Custom08, GetPermissionValue(permReq.Custom08));
                }
                if (permReq.Custom09 != null)
                {
                    editor.SetPermission(member, propagates, PermissionType.Custom09, GetPermissionValue(permReq.Custom09));
                }
                if (permReq.Custom10 != null)
                {
                    editor.SetPermission(member, propagates, PermissionType.Custom10, GetPermissionValue(permReq.Custom10));
                }
                if (permReq.Custom11 != null)
                {
                    editor.SetPermission(member, propagates, PermissionType.Custom11, GetPermissionValue(permReq.Custom11));
                }
                if (permReq.Custom12 != null)
                {
                    editor.SetPermission(member, propagates, PermissionType.Custom12, GetPermissionValue(permReq.Custom12));
                }
                if (permReq.Custom13 != null)
                {
                    editor.SetPermission(member, propagates, PermissionType.Custom13, GetPermissionValue(permReq.Custom13));
                }
                if (permReq.Custom14 != null)
                {
                    editor.SetPermission(member, propagates, PermissionType.Custom14, GetPermissionValue(permReq.Custom14));
                }
            }
            editor.Apply();
        }