本文整理汇总了C#中ISecurityManager.IsAuthorized方法的典型用法代码示例。如果您正苦于以下问题:C# ISecurityManager.IsAuthorized方法的具体用法?C# ISecurityManager.IsAuthorized怎么用?C# ISecurityManager.IsAuthorized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISecurityManager
的用法示例。
在下文中一共展示了ISecurityManager.IsAuthorized方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsPermitted
private static bool IsPermitted(ISecurityManager security, object possiblyPermittable, IPrincipal user, ContentItem item)
{
var permittable = possiblyPermittable as IPermittable;
if (permittable != null && permittable.RequiredPermission > Permission.Read && !security.IsAuthorized(user, item, permittable.RequiredPermission))
return false;
return true;
}
示例2: IsPermitted
private static bool IsPermitted(ISecurityManager security, object possiblyPermittable, IPrincipal user)
{
var permittable = possiblyPermittable as IPermittable;
if (permittable == null)
return true;
if (permittable.RequiredPermissions == null)
return true;
if (permittable.RequiredPermissions.Length == 0)
return true;
// only authenticated users can be permitted
if (!user.Identity.IsAuthenticated)
return false;
return permittable.RequiredPermissions.Any(permission => security.IsAuthorized(user, permission));
}
示例3: IsAuthorized
/// <summary>Find out whether a user has permission to view this plugin in the toolbar.</summary>
/// <param name="user">The user to check.</param>
/// <param name="security">The security manager used to check authorization.</param>
/// <returns>True if the user is null or no permissions are required or the user has permissions.</returns>
public bool IsAuthorized(IPrincipal user, ISecurityManager security)
{
if (user == null) return true;
return security.IsAuthorized(this, user, null);
}