当前位置: 首页>>代码示例>>C#>>正文


C# ContentItem.IsAuthorized方法代码示例

本文整理汇总了C#中ContentItem.IsAuthorized方法的典型用法代码示例。如果您正苦于以下问题:C# ContentItem.IsAuthorized方法的具体用法?C# ContentItem.IsAuthorized怎么用?C# ContentItem.IsAuthorized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ContentItem的用法示例。


在下文中一共展示了ContentItem.IsAuthorized方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Authorizes

        public virtual bool Authorizes(IPrincipal user, ContentItem item, Permission permission)
        {
            if(item != null && permission == Permission.Read && !item.IsAuthorized(user))
                return false;

            return MapsTo(permission) && Contains(user);
        }
开发者ID:Biswo,项目名称:n2cms,代码行数:7,代码来源:PermissionMap.cs

示例2: Authorizes

        public virtual bool Authorizes(IPrincipal user, ContentItem item, Permission permission)
        {
            if (item == null) throw new ArgumentNullException("item");

            if(permission == Permission.Read && !item.IsAuthorized(user))
                return false;

            return MapsTo(permission) && Contains(user);
        }
开发者ID:Jobu,项目名称:n2cms,代码行数:9,代码来源:PermissionMap.cs

示例3: IsAuthorized

        /// <summary>Find out if a principal is allowed to access an item.</summary>
        /// <param name="item">The item to check against.</param>
        /// <param name="user">The principal to check for authorization.</param>
        /// <param name="operation"></param>
        /// <returns>True if the item has public access or the principal is allowed to access it.</returns>
        public virtual bool IsAuthorized(ContentItem item, IPrincipal user, string operation)
        {
            if (user != null && IsAdmin(user))
                return true;

            if (!IsPublished(item) && operation == Operations.Read)
                operation = Operations.ReadUnpublished;

            return item.IsAuthorized(user, operation);
        }
开发者ID:dpawatts,项目名称:zeus,代码行数:15,代码来源:SecurityManager.cs

示例4: Authorizes

        public override bool Authorizes(IPrincipal user, ContentItem item, Permission permission)
        {
            if(permission == Permission.None)
                return true;
            if (!MapsTo(permission))
                return false;

            bool isContentAuthorized = false;

            foreach(Permission permissionLevel in SplitPermission(permission))
            {
                if(!MapsTo(permissionLevel))
                    continue;

                if ((item.AlteredPermissions & permissionLevel) == Permission.None)
                    continue;

                if(permissionLevel == Permission.Read)
                {
                    if(!item.IsAuthorized(user))
                        return false;
                    
                    isContentAuthorized = true;
                    continue;
                }

                DetailCollection details = item.GetDetailCollection(AuthorizedRolesPrefix + permissionLevel, false);
                if(details != null)
                {
                    string[] rolesAuthorizedByItem = details.ToArray<string>();
                    if (!IsInRoles(user, rolesAuthorizedByItem) && !IsInUsers(user.Identity.Name))
                        return false;

                    isContentAuthorized = true;
                }
            }

            return isContentAuthorized || base.Authorizes(user, item, permission);
        }
开发者ID:brianmatic,项目名称:n2cms,代码行数:39,代码来源:DynamicPermissionMap.cs

示例5: GetPermissions

 /// <summary>Gets the permissions for a certain user towards an item.</summary>
 /// <param name="user">The user whose permissoins to get.</param>
 /// <param name="item">The item for which permissions should be retrieved.</param>
 /// <returns>A permission flag.</returns>
 public virtual Permission GetPermissions(IPrincipal user, ContentItem item)
 {
     return GetPermiossions(user, item, Administrators)
         | GetPermiossions(user, item, Editors)
         | GetPermiossions(user, item, Writers)
         | (item.IsAuthorized(user) ? Permission.Read : Permission.None);
 }
开发者ID:EzyWebwerkstaden,项目名称:n2cms,代码行数:11,代码来源:SecurityManager.cs

示例6: IsAuthorized

 /// <summary>Find out if a principal is allowed to access an item.</summary>
 /// <param name="item">The item to check against.</param>
 /// <param name="user">The principal to check for allowance.</param>
 /// <returns>True if the item has public access or the principal is allowed to access it.</returns>
 public virtual bool IsAuthorized(ContentItem item, IPrincipal user)
 {
     if (!Enabled || !ScopeEnabled || IsAdmin(user))
     {
         // Disabled security manager or Editor means full access
         return true;
     }
     else if (!IsEditor(user) && !IsPublished(item))
     {
         // Non-editors cannot load unpublished items
         return false;
     }
     return item.IsAuthorized(user);
 }
开发者ID:EzyWebwerkstaden,项目名称:n2cms,代码行数:18,代码来源:SecurityManager.cs


注:本文中的ContentItem.IsAuthorized方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。