public SecurityOptionsPasswordProvider(PasswordPathOption options)
 {
     this.configowner   = GetSecureString(options.OwnerPassword);
     this.configuser    = GetSecureString(options.UserPassword);
     this.restrictions  = options.Permissions;
     this.allowoverride = options.AllowOverrides;
 }
Beispiel #2
0
 public ChangePermissionRequirement(int environmentId, int environmentOwnerId, int permissionsUserId, PermissionFlags permission)
 {
     EnvironmentId      = environmentId;
     EnvironmentOwnerId = environmentOwnerId;
     PermissionsUserId  = permissionsUserId;
     Permission         = permission;
 }
Beispiel #3
0
        /// <summary>无权访问</summary>
        /// <param name="filterContext"></param>
        /// <param name="pm"></param>
        /// <returns></returns>
        public static ActionResult NoPermission(AuthorizationContext filterContext, PermissionFlags pm)
        {
            var act  = filterContext.ActionDescriptor;
            var ctrl = act.ControllerDescriptor;

            var ctx = filterContext.HttpContext;

            var res = "[{0}/{1}]".F(ctrl.ControllerName, act.ActionName);
            var msg = "访问资源 {0} 需要 {1} 权限".F(res, pm.GetDescription());

            LogProvider.Provider.WriteLog("访问", "拒绝", false, msg, ip: ctx.GetUserHost());

            var menu = ctx.Items["CurrentMenu"] as IMenu;

            var vr = new ViewResult()
            {
                ViewName = "NoPermission"
            };

            vr.ViewBag.Context    = filterContext;
            vr.ViewBag.Resource   = res;
            vr.ViewBag.Permission = pm;
            vr.ViewBag.Menu       = menu;
            return(vr);
        }
Beispiel #4
0
 public PermissionOverwrite(Snowflake id, string type, PermissionFlags allowFlags, PermissionFlags denyFlags)
 {
     Id         = id;
     Type       = type;
     AllowFlags = allowFlags;
     DenyFlags  = denyFlags;
 }
Beispiel #5
0
        /// <summary>申请指定操作的权限</summary>
        /// <param name="flag"></param>
        /// <returns></returns>
        public virtual Boolean Acquire(PermissionFlags flag)
        {
            // 当前管理员
            var admin = Current;

            if (admin == null)
            {
                return(false);
            }

            var menu = MyMenu;

            //if (menu == null)
            //{
            //    String name = PermissionName;
            //    if (String.IsNullOrEmpty(name)) return false;

            //    // 当前权限菜单
            //    menu = admin.FindPermissionMenu(name);
            //}

            if (menu == null)
            {
                return(false);
            }

            return(admin.Role.Has(menu.ID, flag));
        }
Beispiel #6
0
        /// <summary>无权访问</summary>
        /// <param name="actionContext"></param>
        /// <param name="pm"></param>
        /// <returns></returns>
        public static ActionResult NoPermission(this ActionContext actionContext, PermissionFlags pm)
        {
            var act = (ControllerActionDescriptor)actionContext.ActionDescriptor;
            //var ctrl = (ControllerActionDescriptor)act;

            var res = "[{0}/{1}]".F(act.ControllerName, act.ActionName);
            var msg = "访问资源 {0} 需要 {1} 权限".F(res, pm.GetDescription());

            LogProvider.Provider.WriteLog("访问", "拒绝", msg);

            var ctx  = actionContext.HttpContext;
            var menu = ctx.Items["CurrentMenu"] as IMenu;

            var vr = new ViewResult()
            {
                ViewName = "NoPermission"
            };

            //vr.Context = filterContext;//不需要赋值Context,执行的时候会自己获取Context

            vr.ViewData =
                new Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary(new EmptyModelMetadataProvider(),
                                                                             actionContext.ModelState)
            {
                ["Resource"]   = res,
                ["Permission"] = pm,
                ["Menu"]       = menu
            };

            return(vr);
        }
		public static void UploadFile(this SkyDoxUploader skyDoxUploader,
			string filePath,
			string skydoxFolderDescription,
			PermissionFlags permissionFlags,
			bool useTestDisplayName = false)
		{
			var infos = new List<SendLinkInfo>
			{
				new SendLinkInfo
				{
					ContentId = "1",
					DisplayName = useTestDisplayName ? "test file 1" : Path.GetFileNameWithoutExtension(filePath),
					FilePath = filePath
				}
			};

			// Create a (fairly) unique folder name.
			string folderName = string.Format("An upload test ({0:dd-MMM-yyyy, HH.mm.ss})", DateTime.Now);

			DateTime expiry = DateTime.UtcNow.AddMonths(1);

			string folderLink;
			bool result = skyDoxUploader.UploadFiles(
				folderName, skydoxFolderDescription, expiry, false,
				new[] { "*****@*****.**" }, permissionFlags, infos,
				false, out folderLink);

			Assert.IsTrue(result, "Failed to upload the file.");
		}
Beispiel #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DetailedComponentModel" /> class.
 /// </summary>
 /// <param name="permissions">Contains an optional permissions value for the detailed component model.</param>
 public DetailedComponentModel(PermissionFlags permissions)
     : base(permissions)
 {
     this.Tags         = new List <TagModel>();
     this.Properties   = new List <ComponentPropertyModel>();
     this.Dependencies = new List <ComponentDependencyModel>();
 }
Beispiel #9
0
 /// <summary>重置该角色指定的权限</summary>
 /// <param name="resid"></param>
 /// <param name="flag"></param>
 public void Reset(Int32 resid, PermissionFlags flag)
 {
     if (Permissions.TryGetValue(resid, out var pf))
     {
         Permissions[resid] = pf & ~flag;
     }
 }
 public ConfigPasswordProvider(PasswordPathElement element)
 {
     configowner   = GetSecureString(element.DefaultOwnerPassword);
     configuser    = GetSecureString(element.DefaultUserPassword);
     restrictions  = (PermissionFlags)element.DocumentRestrictions;
     allowoverride = element.AllowOverrides;
     securityType  = SecurityType.Standard128Bit;
 }
Beispiel #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MinimalComponentModel" /> class.
 /// </summary>
 /// <param name="permissions">Contains an optional permissions value for the minimal component model.</param>
 public MinimalComponentModel(PermissionFlags permissions)
 {
     this.ComponentType = new MinimalComponentTypeModel();
     this.itemType = ProjectFolderItemType.Component;
     this.State = ComponentStateType.Draft;
     this.Permissions = new PermissionModel(permissions);
     this.FollowedByUsers = new List<MinimalUserModel>();
 }
Beispiel #12
0
        /*
            FUNCTION: SetVersionGUID()

            PURPOSE: Sets the version GUID of your application. 

            This function must be called on every start of your program before
            any other functions are called, with the exception of SetProductFile()
            function.

            PARAMETERS:
            * versionGUID - the unique version GUID of your application as mentioned
              on the product version page of your application in the dashboard.

            * flags - depending upon whether your application requires admin/root 
              permissions to run or not, this parameter can have one of the following
              values: LA_SYSTEM, LA_USER

            RETURN CODES: LA_OK, LA_E_WMIC, LA_E_PFILE, LA_E_GUID, LA_E_PERMISSION

            NOTE: If this function fails to set the version GUID, none of the other
            functions will work.
        */

        public static int SetVersionGUID(string versionGUID, PermissionFlags flags)
        {
#if LA_ANY_CPU
            return IntPtr.Size == 8 ? Native.SetVersionGUID_x64(versionGUID, flags) : Native.SetVersionGUID(versionGUID, flags);
#else
            return Native.SetVersionGUID(versionGUID, flags);
#endif

        }
Beispiel #13
0
        /// <summary>实例化实体授权特性</summary>
        /// <param name="permission"></param>
        public EntityAuthorizeAttribute(PermissionFlags permission)
        {
            if (permission <= PermissionFlags.None)
            {
                throw new ArgumentNullException(nameof(permission));
            }

            Permission = permission;
        }
Beispiel #14
0
    protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row == null)
        {
            return;
        }

        IMenu entity = e.Row.DataItem as IMenu;

        if (entity == null)
        {
            return;
        }

        CheckBox     cb     = e.Row.FindControl("CheckBox1") as CheckBox;
        CheckBoxList cblist = e.Row.FindControl("CheckBoxList1") as CheckBoxList;

        // 检查权限
        PermissionFlags pf = FindByRoleAndMenu(RoleID, entity.ID);
        //cb.Checked = (pf != PermissionFlags.None);
        Role role = Role.FindByID(RoleID);

        cb.Checked = role.Permissions.ContainsKey(entity.ID);
        cb.ToolTip = pf.ToString();

        // 如果有子节点,则不显示
        if (entity.Childs != null && entity.Childs.Count > 0)
        {
            //cb.Visible = false;
            cblist.Visible = false;
            return;
        }

        // 检查权限
        Dictionary <PermissionFlags, String> flags = EnumHelper.GetDescriptions <PermissionFlags>();

        cblist.Items.Clear();
        foreach (PermissionFlags item in flags.Keys)
        {
            if (item == PermissionFlags.None)
            {
                continue;
            }
            if (!IsFullPermission && item > PermissionFlags.Delete)
            {
                continue;
            }

            ListItem li = new ListItem(flags[item], ((Int32)item).ToString());
            if ((pf & item) == item)
            {
                li.Selected = true;
            }
            cblist.Items.Add(li);
        }
    }
Beispiel #15
0
 public static DoxFolderPermissions Convert(PermissionFlags flags)
 {
     return new DoxFolderPermissions
         {
             CanComment = (flags & PermissionFlags.CanComment) != 0,
             CanAccessAnonymously = (flags & PermissionFlags.CanOnlyAccessIfLoggedIn) == 0,
             CanInviteWithLink = (flags & PermissionFlags.CanInviteOthers) != 0,
             CanDownloadOriginal = (flags & PermissionFlags.CanDownloadOriginal) != 0
         };
 }
Beispiel #16
0
        /// <summary>
        /// 删除权限
        /// </summary>
        /// <param name="flag"></param>
        /// <returns></returns>
        public RoleMenu <TEntity> Remove(PermissionFlags flag)
        {
            // 必须先检查是否包含这个标识位,因为异或的操作仅仅是取反
            if ((PermissionFlag & flag) == flag)
            {
                PermissionFlag ^= flag;
            }

            return(this);
        }
Beispiel #17
0
        /// <summary>是否拥有指定资源的指定权限</summary>
        /// <param name="resid"></param>
        /// <param name="flag"></param>
        /// <returns></returns>
        public Boolean Has(Int32 resid, PermissionFlags flag = PermissionFlags.None)
        {
            var pf = PermissionFlags.None;

            if (!Permissions.TryGetValue(resid, out pf))
            {
                return(false);
            }

            return(pf.Has(flag));
        }
Beispiel #18
0
        /// <summary>申请指定菜单指定操作的权限</summary>
        /// <param name="name">名称</param>
        /// <param name="flag"></param>
        /// <returns></returns>
        public virtual Boolean Acquire(String name, PermissionFlags flag)
        {
            var menu = FindPermissionMenu(name);

            if (menu == null)
            {
                return(false);
            }

            return(Acquire(menu.ID, flag));
        }
        //
        // .ctor(s)
        //


        internal PDFEncryter(int version, int revision, int keysizebytes,
                             byte[] owner, byte[] user, byte[] keystem,
                             PermissionFlags protection)
        {
            this.EncryptionVersion      = version;
            this.EncryptionRevision     = revision;
            this.EncryptionKeySizeBytes = keysizebytes;
            this.OwnerHash       = owner;
            this.UserHash        = user;
            this.KeyStem         = keystem;
            this.ProtectionFlags = protection;
        }
Beispiel #20
0
        /// <summary>设置该角色拥有指定资源的指定权限</summary>
        /// <param name="resid"></param>
        /// <param name="flag"></param>
        public void Set(Int32 resid, PermissionFlags flag = PermissionFlags.All)
        {
            var pf = PermissionFlags.None;

            if (!Permissions.TryGetValue(resid, out pf))
            {
                Permissions.Add(resid, flag);
            }
            else
            {
                Permissions[resid] = pf | flag;
            }
        }
Beispiel #21
0
        /// <summary>
        /// 检查是否有指定权限
        /// </summary>
        /// <param name="flag"></param>
        /// <returns></returns>
        public Boolean Acquire(PermissionFlags flag)
        {
            if (PermissionFlag == PermissionFlags.None)
            {
                return(false);
            }
            //if (PermissionFlag == PermissionFlags.All) return true;
            if ((PermissionFlag & PermissionFlags.All) == PermissionFlags.All)
            {
                return(true);
            }

            return((PermissionFlag & flag) == flag);
        }
Beispiel #22
0
 /// <summary>设置该角色拥有指定资源的指定权限</summary>
 /// <param name="resid"></param>
 /// <param name="flag"></param>
 public void Set(Int32 resid, PermissionFlags flag = PermissionFlags.All)
 {
     if (Permissions.TryGetValue(resid, out var pf))
     {
         Permissions[resid] = pf | flag;
     }
     else
     {
         if (flag != PermissionFlags.None)
         {
             Permissions.Add(resid, flag);
         }
     }
 }
        public void OnAuthorization(AuthorizationFilterContext filterContext)
        {
            /*
             * 验证范围:
             * 1,区域下的所有控制器
             * 2,所有带有EntityAuthorize特性的控制器或动作
             */
            var act  = filterContext.ActionDescriptor;
            var ctrl = (ControllerActionDescriptor)act;



            // 允许匿名访问时,直接跳过检查
            if (
                ctrl.MethodInfo.IsDefined(typeof(AllowAnonymousAttribute)) ||
                ctrl.ControllerTypeInfo.IsDefined(typeof(AllowAnonymousAttribute)))
            {
                return;
            }

            // 如果控制器或者Action放有该特性,则跳过全局
            var hasAtt =
                ctrl.MethodInfo.IsDefined(typeof(EntityAuthorizeAttribute), true) ||
                ctrl.ControllerTypeInfo.IsDefined(typeof(EntityAuthorizeAttribute));

            if (!hasAtt)
            {
                return;
            }
            Permission = ctrl.MethodInfo.GetCustomAttribute <EntityAuthorizeAttribute>().Permission;
            var per = Permission.ToInt();

            //记录执行过的增删改权限
            if ((per & 2 | per & 4 | per & 8) > 0)
            {
                //TODO:获取操作人信息
                var user = "******";
                _loggerHelper.Trace("Authorization", string.Format("{0}执行了{1}操作", user, Permission), "Authorization", "记录操作");
            }
            // 如果已经处理过,就不处理了
            if (filterContext.Result != null)
            {
                return;
            }

            if (!AuthorizeCore(filterContext.HttpContext))
            {
                HandleUnauthorizedRequest(filterContext);
            }
        }
		public static void UploadFiles(this SkyDoxUploader skyDoxUploader,
			string fromFolder,
			string skydoxFolderDescription,
			PermissionFlags permissionFlags,
			int howMany = 0,
			bool useTestDisplayName = false)
		{
			// Get all the file names.
			var rand = new Random();
			var filenames =
				(from f in new DirectoryInfo(fromFolder).EnumerateFiles()
				 where !f.Attributes.HasFlag(FileAttributes.Hidden)
					   && !f.Attributes.HasFlag(FileAttributes.System)
				 orderby rand.Next()
				 select new { Path = f.FullName, Ext = f.Extension }
				).ToArray();

			if (howMany <= 0)
			{
				howMany = filenames.Length;
			}

			var infos = new List<SendLinkInfo>();
			for (int i = 1; i <= howMany; i++)
			{
				var file = filenames[i % filenames.Length];
				var sli = new SendLinkInfo
				{
					ContentId = i.ToString(CultureInfo.InvariantCulture),
					DisplayName = useTestDisplayName ? "test file " + i : Path.GetFileNameWithoutExtension(file.Path),
					FilePath = file.Path
				};
				infos.Add(sli);
			}

			// Create a (fairly) unique folder name.
			string folderName = string.Format("An upload test ({0:dd-MMM-yyyy, HH.mm.ss})", DateTime.Now);

			DateTime expiry = DateTime.UtcNow.AddMonths(1);

			string folderLink;
			bool result = skyDoxUploader.UploadFiles(
				folderName, skydoxFolderDescription, expiry, false,
				new[] { "*****@*****.**" }, permissionFlags, infos,
				false, out folderLink);

			Assert.IsTrue(result, "Failed to upload files.");
		}
        /// <summary>
        /// Sets the product id of your application.
        ///
        /// This function must be called on every start of your program before
        /// any other functions are called, with the exception of SetProductFile()
        /// or SetProductData() function.
        /// </summary>
        /// <param name="productId">the unique product id of your application as mentioned on the product page in the dashboard</param>
        /// <param name="flags">depending upon whether your application requires admin/root permissions to run or not, this parameter can have one of the following values: LA_SYSTEM, LA_USER, LA_IN_MEMORY</param>
        public static void SetProductId(string productId, PermissionFlags flags)
        {
            int status;

            if (LexActivatorNative.IsWindows())
            {
                status = IntPtr.Size == 4 ? LexActivatorNative.SetProductId_x86(productId, flags) : LexActivatorNative.SetProductId(productId, flags);
            }
            else
            {
                status = LexActivatorNative.SetProductIdA(productId, flags);
            }
            if (LexStatusCodes.LA_OK != status)
            {
                throw new LexActivatorException(status);
            }
        }
Beispiel #26
0
        /// <summary>申请指定菜单指定操作的权限</summary>
        /// <param name="menuID"></param>
        /// <param name="flag"></param>
        /// <returns></returns>
        public virtual Boolean Acquire(Int32 menuID, PermissionFlags flag)
        {
            if (menuID <= 0)
            {
                throw new ArgumentNullException("menuID");
            }

            var entity = (this as IAdministrator).Role;

            if (entity == null)
            {
                return(false);
            }

            // 申请权限
            //return entity.Acquire(menuID, flag);
            return(true);
        }
        private PermissionFlags GetEmptyRestrictions(int revision)
        {
            uint def = (uint)ushort.MaxValue;

            def = def << 16;

            //These are defined but must be one.
            PermissionFlags empty = PermissionFlags.Reserved7
                                    | PermissionFlags.Reserved8
                                    | PermissionFlags.Reserved13
                                    | PermissionFlags.Reserved14
                                    | PermissionFlags.Reserved15
                                    | PermissionFlags.Reserved16;

            empty |= (PermissionFlags)def;

            return(empty);
        }
Beispiel #28
0
        /// <summary>申请指定操作的权限</summary>
        /// <param name="name">名称</param>
        /// <param name="flag"></param>
        /// <returns></returns>
        public virtual Boolean Acquire(String name, PermissionFlags flag)
        {
            // 当前管理员
            var admin = CurrentAdmin;

            if (admin == null)
            {
                return(false);
            }

            var mi = ManageProvider.Menu.Root.FindByPath(name);

            if (mi == null)
            {
                return(false);
            }

            return(admin.Role.Has(mi.ID, flag));
        }
Beispiel #29
0
        /// <summary>申请指定操作的权限</summary>
        /// <param name="flag"></param>
        /// <returns></returns>
        public virtual Boolean Acquire(PermissionFlags flag)
        {
            // 当前管理员
            var admin = CurrentAdmin;

            if (admin == null)
            {
                return(false);
            }

            var menu = CurrentMenu;

            if (menu == null)
            {
                return(false);
            }

            return(admin.Role.Has(menu.ID, flag));
        }
Beispiel #30
0
        ///// <summary>
        ///// 拥有指定菜单的权限,支持路径查找
        ///// </summary>
        ///// <param name="name"></param>
        ///// <returns></returns>
        //public override Boolean HasMenu(String name)
        //{
        //    if (String.IsNullOrEmpty(name) || MenuList == null || MenuList.Count < 1) return false;

        //    //TMenuEntity entity = Menu<TMenuEntity>.FindByPath(MenuList, name, Menu<TMenuEntity>._.Permission);
        //    TMenuEntity entity = Menu<TMenuEntity>.FindForPerssion(name);

        //    // 找不到的时候,修改当前页面
        //    if (entity == null && Menu<TMenuEntity>.Current != null)
        //    {
        //        if (Menu<TMenuEntity>.Current.ResetName(name)) entity = Menu<TMenuEntity>.Current;
        //    }

        //    //return entity != null;

        //    if (entity == null) return false;

        //    return HasMenu(entity.ID);
        //}

        ///// <summary>
        ///// 拥有指定菜单的权限
        ///// </summary>
        ///// <param name="menuID"></param>
        ///// <returns></returns>
        //public override Boolean HasMenu(Int32 menuID)
        //{
        //    //if (menu == null || MenuList == null || MenuList.Count < 1) return false;
        //    if (menuID <= 0) return false;

        //    TMenuEntity menu = Menu<TMenuEntity>.FindByID(menuID);

        //    // 当前菜单
        //    Boolean b = false;
        //    foreach (TMenuEntity item in MenuList)
        //    {
        //        if (item.ID == menu.ID)
        //        {
        //            b = true;
        //            break;
        //        }
        //    }
        //    if (!b) return false;

        //    // 判断父菜单
        //    if (menu.ParentID <= 0) return true;

        //    return HasMenu(menu.ParentID);
        //}

        /// <summary>
        /// 申请指定菜单指定操作的权限
        /// </summary>
        /// <param name="menuID"></param>
        /// <param name="flag"></param>
        /// <returns></returns>
        public override Boolean Acquire(Int32 menuID, PermissionFlags flag)
        {
            //if (String.IsNullOrEmpty(name) || MenuList == null || MenuList.Count < 1) return false;
            if (menuID <= 0 || MenuList == null || MenuList.Count < 1)
            {
                return(false);
            }

            // 找到菜单。自下而上递归查找,任意一级没有权限即视为无权限
            Int32 id = menuID;

            while (id > 0)
            {
                TMenuEntity entity = MenuList.Find(Menu <TMenuEntity> ._.ID, id);
                if (entity == null)
                {
                    return(false);
                }

                if (entity.Parent == null)
                {
                    break;
                }

                id = entity.ParentID;
            }

            // 申请权限
            if (flag == PermissionFlags.None)
            {
                return(true);
            }

            TRoleMenuEntity rm = Menus.Find(RoleMenu <TRoleMenuEntity> ._.MenuID, menuID);

            if (rm == null)
            {
                return(false);
            }

            return(rm.Acquire(flag));
        }
        private PermissionFlags GetRestrictionsV3()
        {
            PermissionFlags restrict = GetEmptyRestrictions(this.Revision);

            if (AllowPrinting)
            {
                restrict |= PermissionFlags.AllowPrinting;
            }
            if (AllowModification)
            {
                restrict |= PermissionFlags.AllowOtherModification;
            }
            if (AllowCopying)
            {
                restrict |= PermissionFlags.AllowCopyingOfTextAndGraphics;
            }
            if (AllowAnnotations)
            {
                restrict |= PermissionFlags.AllowR2AnnotationsAndForms;
            }

            if (AllowFormFilling)
            {
                restrict |= PermissionFlags.AllowR2AnnotationsAndForms;
                restrict |= PermissionFlags.AllowFormFilling;
            }
            if (AllowAccessiblity)
            {
                restrict |= PermissionFlags.AllowAccessibleTextAndGraphics;
            }
            if (AllowDocumentAssembly)
            {
                restrict -= PermissionFlags.AllowDocumentAssembly;
            }
            if (AllowHighQualityPrinting)
            {
                restrict |= PermissionFlags.AllowPrinting;
                restrict |= PermissionFlags.AllowHighQualityPrinting;
            }
            return(restrict);
        }
Beispiel #32
0
        /// <summary>自动从实体类拿到显示名</summary>
        /// <param name="menu"></param>
        /// <returns></returns>
        protected override IDictionary <MethodInfo, Int32> ScanActionMenu(IMenu menu)
        {
            // 设置显示名
            if (menu.DisplayName.IsNullOrEmpty())
            {
                menu.DisplayName = Entity <TEntity> .Meta.Table.DataTable.DisplayName;
                menu.Visible     = true;
                //menu.Save();
            }

            var dic = base.ScanActionMenu(menu);

            // 只写实体类过滤掉添删改权限
            if (Factory.Table.DataTable.InsertOnly)
            {
                var arr = new PermissionFlags[] { PermissionFlags.Insert, PermissionFlags.Update, PermissionFlags.Delete }.Select(e => (Int32)e).ToArray();
                dic = dic.Where(e => !arr.Contains(e.Value)).ToDictionary(e => e.Key, e => e.Value);
            }

            return(dic);
        }
        private PermissionFlags GetRestrictionsV2()
        {
            PermissionFlags restrict = GetEmptyRestrictions(this.Revision);

            if (AllowPrinting)
            {
                restrict |= PermissionFlags.AllowPrinting;
            }
            if (AllowModification)
            {
                restrict |= PermissionFlags.AllowOtherModification;
            }
            if (AllowCopying)
            {
                restrict |= PermissionFlags.AllowCopyingOfTextAndGraphics;
            }
            if (AllowAnnotations)
            {
                restrict |= PermissionFlags.AllowR2AnnotationsAndForms;
            }

            return(restrict);
        }
Beispiel #34
0
		public void SetFolderPermissions(long folderId, PermissionFlags flags)
		{
			if (string.IsNullOrEmpty(_deviceToken))
			{
				throw new Exception("Device token is blank.");
			}

			// Applying permissions to folder.
			Logger.LogDebug(string.Format("Applying permissions to folder ID {0}.", folderId));

			string uri = string.Format("{0}/folders/{1}/permission.xml", m_hostServer, folderId);

			Func<PermissionFlags, string> isFlagSet = f => flags.HasFlag(f) ? "true" : "false";
			Func<PermissionFlags, string> isFlagUnset = f => !flags.HasFlag(f) ? "true" : "false";

			var parameters = new List<NamedData>
			    {
			        new NamedData("permission[can_comment]", isFlagSet(PermissionFlags.CanComment)),
			        new NamedData("permission[can_access_anonymously]", isFlagUnset(PermissionFlags.CanOnlyAccessIfLoggedIn)),
			        new NamedData("permission[can_invite_with_link]", isFlagSet(PermissionFlags.CanInviteOthers)),

			        // These two permissions relate to the same policy option.
			        new NamedData("permission[can_download_original]", isFlagSet(PermissionFlags.CanDownloadOriginal)), 
			        new NamedData("permission[can_download_pdf]", "false")
			    };

			// Specify a schema to ensure the response is as expected.
			string xmlSchema = Resources.DeckPermissionXmlSchema;
			MultipartFormDataPut(uri, parameters, xmlSchema);
		}
Beispiel #35
0
        /// <summary>
        /// 申请指定操作的权限
        /// </summary>
        /// <param name="flag"></param>
        /// <returns></returns>
        public virtual Boolean Acquire(PermissionFlags flag)
        {
            // 当前管理员
            IAdministrator admin = Current;
            if (admin == null) return false;

            IMenu menu = CurrentMenu;
            if (menu == null) return false;

            return admin.Acquire(menu.ID, flag);
        }
Beispiel #36
0
        /// <summary>
        /// 申请指定操作的权限
        /// </summary>
        /// <param name="name"></param>
        /// <param name="flag"></param>
        /// <returns></returns>
        public virtual Boolean Acquire(String name, PermissionFlags flag)
        {
            // 当前管理员
            IAdministrator admin = Current;
            if (admin == null) return false;

            return admin.Acquire(name, flag);
        }
Beispiel #37
0
        /// <summary>申请指定操作的权限</summary>
        /// <param name="flag"></param>
        /// <returns></returns>
        public virtual Boolean Acquire(PermissionFlags flag)
        {
            // 当前管理员
            var admin = Current;
            if (admin == null) return false;

            var menu = MyMenu;
            //if (menu == null)
            //{
            //    String name = PermissionName;
            //    if (String.IsNullOrEmpty(name)) return false;

            //    // 当前权限菜单
            //    menu = admin.FindPermissionMenu(name);
            //}

            if (menu == null) return false;

            return admin.Role.Has(menu.ID, flag);
        }
Beispiel #38
0
 public static bool IsSet(this PermissionFlags flags, PermissionFlags flag)
 {
     return ((flags & flag) == flag);
 }
Beispiel #39
0
		public static void SetFolderPermissions(long folderId, PermissionFlags flags, IApiHelper apiHelper)
		{
			try
			{
				// Applying permissions to folder.
				Logger.LogDebug("Applying permissions to folder.");

				apiHelper.SetFolderPermissions(folderId, flags);

				Logger.LogInfo(string.Format("Successfully applied permissions to folder {0}.", folderId));
			}
			catch( WebException ex)
			{
				Logger.LogError(string.Format("Failed to add recipients to the cloud storage folder (folder ID: {0}).", folderId));
				Logger.LogError(ex);
				throw;
			}
		}
Beispiel #40
0
 public void SetFolder(string folderLink, long folderId, PermissionFlags permissionFlags)
 {
     _jobInfo.SkydoxFolderLink = folderLink;
     _jobInfo.SkydoxFolderId = folderId;
     _jobInfo.CurrentStage = JobStage.UploadFiles;
     _jobInfo.PermissionFlags = permissionFlags;
     JobInfo.WriteJobInfo(_jobInfo, _jobXmlPath);
     JobInfo.WriteJobInfo(_jobInfo, _jobBackupXmlPath);
     File.WriteAllText(_signalFilePath, "GetFolderLink Successful");
 }
Beispiel #41
0
        private static void ExtractProperties(IList<IActionProperty> actionPropertySet, out DateTime? expiryUtc, out bool getReturnReceipt, out PermissionFlags flags)
        {
            // Get expiry *date* from the expiry *days* property.
            string expiryDaysProperty = GetPropertyValue(actionPropertySet, SendLinkActionStringTable.ExpiryDays);
            int expiryDays;
            expiryUtc =
                int.TryParse(expiryDaysProperty, out expiryDays)
                ? GetExpiryDaysAsFixedDateFromToday(expiryDays)
                : null;

            // Get the get return receipt property.
            string getReturnReceiptObject = GetPropertyValue(actionPropertySet, SendLinkActionStringTable.GetReturnReceipt);
            bool.TryParse(getReturnReceiptObject, out getReturnReceipt);

            flags = GetPermissionFlags(actionPropertySet);
        }
Beispiel #42
0
        /// <summary>申请指定操作的权限</summary>
        /// <param name="flag"></param>
        /// <returns></returns>
        public virtual Boolean Acquire(PermissionFlags flag)
        {
            // 当前管理员
            var admin = CurrentAdmin;
            if (admin == null) return false;

            var menu = CurrentMenu;
            if (menu == null) return false;

            return admin.Role.Has(menu.ID, flag);
        }
Beispiel #43
0
        /// <summary>申请指定操作的权限</summary>
        /// <param name="name">名称</param>
        /// <param name="flag"></param>
        /// <returns></returns>
        public virtual Boolean Acquire(String name, PermissionFlags flag)
        {
            // 当前管理员
            var admin = CurrentAdmin;
            if (admin == null) return false;

            var mi = ManageProvider.Menu.Root.FindByPath(name);
            if (mi == null) return false;

            return admin.Role.Has(mi.ID, flag);
        }