本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}