public PermissionsCheckResult CheckPermissions(IPrincipal currentPrincipal, User account, TEntity entity)
        {
            if (!PermissionsHelpers.IsRequirementSatisfied(AccountOnBehalfOfPermissionsRequirement, currentPrincipal, account))
            {
                return(PermissionsCheckResult.AccountFailure);
            }

            return(CheckPermissionsForEntity(account, entity));
        }
        protected override PermissionsCheckResult CheckPermissionsForEntity(User account, IReadOnlyCollection <ReservedNamespace> reservedNamespaces)
        {
            if (!reservedNamespaces.Any())
            {
                return(PermissionsCheckResult.Allowed);
            }

            // Permissions on only a single namespace are required to perform the action.
            return(reservedNamespaces.Any(rn => PermissionsHelpers.IsRequirementSatisfied(ReservedNamespacePermissionsRequirement, account, rn)) ?
                   PermissionsCheckResult.Allowed : PermissionsCheckResult.ReservedNamespaceFailure);
        }
 public bool IsAllowedOnBehalfOfAccount(IPrincipal currentPrincipal, User account)
 {
     return(PermissionsHelpers.IsRequirementSatisfied(AccountOnBehalfOfPermissionsRequirement, currentPrincipal, account));
 }
 /// <summary>
 /// Determines whether <paramref name="currentPrincipal"/> can perform this action on <paramref name="account"/>.
 /// </summary>
 public PermissionsCheckResult CheckPermissions(IPrincipal currentPrincipal, User account)
 {
     return(PermissionsHelpers.IsRequirementSatisfied(AccountPermissionsRequirement, currentPrincipal, account) ?
            PermissionsCheckResult.Allowed : PermissionsCheckResult.AccountFailure);
 }
 protected override PermissionsCheckResult CheckPermissionsForEntity(User account, PackageRegistration packageRegistration)
 {
     return(PermissionsHelpers.IsRequirementSatisfied(PackageRegistrationPermissionsRequirement, account, packageRegistration) ? PermissionsCheckResult.Allowed : PermissionsCheckResult.PackageRegistrationFailure);
 }