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


C# Security.CheckAccessContext类代码示例

本文整理汇总了C#中Orchard.Security.CheckAccessContext的典型用法代码示例。如果您正苦于以下问题:C# CheckAccessContext类的具体用法?C# CheckAccessContext怎么用?C# CheckAccessContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CheckAccessContext类属于Orchard.Security命名空间,在下文中一共展示了CheckAccessContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Adjust

 public void Adjust(CheckAccessContext context)
 {
     if (context.Content.Is<OrderPart>()) {
         if (context.Permission.Name == Orchard.Core.Contents.Permissions.PublishContent.Name || context.Permission.Name == Orchard.Core.Contents.Permissions.PublishOwnContent.Name) {
             context.Granted = false;
             context.Adjusted = true;
             context.Permission = OrdersPermissions.CreateOrders;
         }
         else if (context.Permission.Name == Orchard.Core.Contents.Permissions.EditContent.Name || context.Permission.Name == Orchard.Core.Contents.Permissions.EditOwnContent.Name) {
             context.Granted = false;
             context.Adjusted = true;
             context.Permission = OrdersPermissions.ManageOrders;
         }
         else if (context.Permission.Name == Orchard.Core.Contents.Permissions.DeleteContent.Name || context.Permission.Name == Orchard.Core.Contents.Permissions.DeleteOwnContent.Name) {
             context.Granted = false;
             context.Adjusted = true;
             context.Permission = OrdersPermissions.ManageOrders;
         }
         else if (context.Permission.Name == Orchard.Core.Contents.Permissions.ViewContent.Name || context.Permission.Name == Orchard.Core.Contents.Permissions.ViewOwnContent.Name) {
             context.Granted = false;
             context.Adjusted = true;
             context.Permission = OrdersPermissions.ViewOrders;
         }
     }
 }
开发者ID:rtpHarry,项目名称:OShop,代码行数:25,代码来源:OrdersAuthorizationEventHandler.cs

示例2: Adjust

 public void Adjust(CheckAccessContext context)
 {
     if (context.User == null && !MembershipInitialized)
     {
         context.Granted = true;
     }
 }
开发者ID:githubzwj,项目名称:Orchard.Platform,代码行数:7,代码来源:AuthorizationServiceEventHandler.cs

示例3: TryCheckAccess

        public bool TryCheckAccess(Permission permission, IUser user, IContent content) {
            var context = new CheckAccessContext { Permission = permission, User = user, Content = content };
            _authorizationServiceEventHandler.Checking(context);

            for (var adjustmentLimiter = 0; adjustmentLimiter != 3; ++adjustmentLimiter) {
                if (!context.Granted && context.User != null) {
                    if (String.Equals(context.User.UserName, "Administrator", StringComparison.OrdinalIgnoreCase) ||
                        ((!String.IsNullOrEmpty(CurrentSite.SuperUser) &&
                           String.Equals(context.User.UserName, CurrentSite.SuperUser, StringComparison.OrdinalIgnoreCase)))) {
                        context.Granted = true;
                    }
                }

                if (!context.Granted) {

                    // determine which set of permissions would satisfy the access check
                    var grantingNames = PermissionNames(context.Permission, Enumerable.Empty<string>()).ToArray();

                    // determine what set of roles should be examined by the access check
                    IEnumerable<string> rolesToExamine;
                    if (context.User == null) {
                        rolesToExamine = AnonymousRole;
                    }
                    else if (context.User.Has<IUserRoles>()) {
                        rolesToExamine = context.User.As<IUserRoles>().Roles.Concat(AuthenticatedRole);
                    }
                    else {
                        rolesToExamine = AuthenticatedRole;
                    }

                    foreach (var role in rolesToExamine) {
                        RoleRecord roleRecord = _roleService.GetRoleByName(role);
                        if ( roleRecord == null )
                            continue;
                        foreach (var permissionName in _roleService.GetPermissionsForRole(roleRecord.Id)) {
                            string possessedName = permissionName;
                            if (grantingNames.Any(grantingName => String.Equals(possessedName, grantingName, StringComparison.OrdinalIgnoreCase))) {
                                context.Granted = true;
                            }

                            if (context.Granted)
                                break;
                        }

                        if (context.Granted)
                            break;
                    }
                }

                context.Adjusted = false;
                _authorizationServiceEventHandler.Adjust(context);
                if (!context.Adjusted)
                    break;
            }

            _authorizationServiceEventHandler.Complete(context);

            return context.Granted;
        }
开发者ID:mofashi2011,项目名称:orchardcms,代码行数:59,代码来源:RolesBasedAuthorizationService.cs

示例4: TryCheckAccess

        public bool TryCheckAccess(Permission permission, IUser user, IContent content) {
            var context = new CheckAccessContext { Permission = permission, User = user, Content = content };
            _authorizationServiceEventHandler.Checking(context);

            for (var adjustmentLimiter = 0; adjustmentLimiter != 3; ++adjustmentLimiter) {
                if (!context.Granted && context.User != null) {
                    if (!String.IsNullOrEmpty(_workContextAccessor.GetContext().CurrentSite.SuperUser) &&
                           String.Equals(context.User.UserName, _workContextAccessor.GetContext().CurrentSite.SuperUser, StringComparison.Ordinal)) {
                        context.Granted = true;
                    }
                }

                if (!context.Granted) {

                    // determine which set of permissions would satisfy the access check
                    var grantingNames = PermissionNames(context.Permission, Enumerable.Empty<string>()).Distinct().ToArray();

                    // determine what set of roles should be examined by the access check
                    IEnumerable<string> rolesToExamine;
                    if (context.User == null) {
                        rolesToExamine = AnonymousRole;
                    } 
                    else if (user.As<IUserRoles>().Roles.Any()) {
                        

                        // the current user is not null, so get his roles and add "Authenticated" to it
                        rolesToExamine = user.As<IUserRoles>().Roles.Union(AuthenticatedRole);

                    } else {
                        // the user is not null and has no specific role, then it's just "Authenticated"
                        rolesToExamine = AuthenticatedRole;
                    }

                    foreach (var role in rolesToExamine) {
                        foreach (var permissionName in _roleService.GetPermissionsForRoleByName(role)) {
                            string possessedName = permissionName;
                            if (grantingNames.Any(grantingName => String.Equals(possessedName, grantingName, StringComparison.OrdinalIgnoreCase))) {
                                context.Granted = true;
                            }

                            if (context.Granted)
                                break;
                        }

                        if (context.Granted)
                            break;
                    }
                }

                context.Adjusted = false;
                _authorizationServiceEventHandler.Adjust(context);
                if (!context.Adjusted)
                    break;
            }

            _authorizationServiceEventHandler.Complete(context);

            return context.Granted;
        }
开发者ID:NIKASoftwareDevs,项目名称:Orchard,代码行数:59,代码来源:CASAuthorizationService.cs

示例5: Adjust

        public void Adjust(CheckAccessContext context) {
            if (context.Granted || context.Permission != Permissions.ViewProfiles || context.Content != context.User) {
                return;
            }

            context.Adjusted = true;
            context.Permission = Permissions.ViewOwnProfile;
        }
开发者ID:kyletowb,项目名称:InfusionDocs,代码行数:8,代码来源:AuthorizationEventHandler.cs

示例6: Adjust

 public void Adjust(CheckAccessContext context)
 {
     if (!context.Granted) {
         // Are we checking for a "PublishOwn" type permission?
         if (context.Permission.Name.StartsWith("PublishOwn_"))
         {
             // Hmmm...
         }
     }
 }
开发者ID:akhurst,项目名称:ricealumni,代码行数:10,代码来源:SingletonContentAuthorizationEventHandler.cs

示例7: Adjust

        public void Adjust(CheckAccessContext context) {
            if (!context.Granted 
                && context.Permission.Name == Orchard.Core.Contents.Permissions.EditContent.Name 
                && context.Content != null
                && context.Content.ContentItem.ContentType == "CustomForm") {

                context.Adjusted = true;
                context.Permission = Permissions.CreateSubmitPermission(context.Content.ContentItem.As<CustomFormPart>().ContentType);
            }
        }
开发者ID:anycall,项目名称:Orchard,代码行数:10,代码来源:AuthorizationEventHandler.cs

示例8: Adjust

        public void Adjust(CheckAccessContext context) {
            if (context.Granted == false && 
                context.Content.Is<Page>() && 
                OwnerVariationExists(context.Permission) &&
                HasOwnership(context.User, context.Content)) {

                context.Adjusted = true;
                context.Permission = GetOwnerVariation(context.Permission);
            }
        }
开发者ID:mofashi2011,项目名称:orchardcms,代码行数:10,代码来源:AuthorizationEventHandler.cs

示例9: Adjust

 public void Adjust(CheckAccessContext context) {
     if (!context.Granted &&
         context.Content.Is<ICommonPart>()) {
         if (OwnerVariationExists(context.Permission) &&
             HasOwnership(context.User, context.Content)) {
             context.Adjusted = true;
             context.Permission = GetOwnerVariation(context.Permission);
         }
     }
 }
开发者ID:richinoz,项目名称:Orchard1.6,代码行数:10,代码来源:BlogAuthorizationEventHandler.cs

示例10: Adjust

        public void Adjust(CheckAccessContext context) {
            if (!context.Granted && context.Permission.Name == Permissions.ManageMenus.Name && context.Content != null) {
                
                var menuAsContentItem = context.Content.As<ContentItem>();
                if (menuAsContentItem == null || menuAsContentItem.Id <= 0) {
                    return;
                }

                context.Adjusted = true;
                context.Permission = DynamicPermissions.CreateMenuPermission(menuAsContentItem, _contentManager);
            }
        }
开发者ID:SunRobin2015,项目名称:RobinWithOrchard,代码行数:12,代码来源:AuthorizationEventHandler.cs

示例11: Complete

        public void Complete(CheckAccessContext context)
        {
            if (context.Content == null) return;

            var pageContext = context.PageContext();

            if (pageContext.Group != FrontendsPageConfigs.Group) return;

            context.Granted = _frontendAuthorizationService.IsAuthorizedToView(
                _workContextAccessor.GetContext().CurrentUser,
                pageContext.Page.As<IEngineConfigurationAspect>().GraphDescriptor.MaximalContext());
        }
开发者ID:Lombiq,项目名称:Associativy-Frontend-Engines-Administration,代码行数:12,代码来源:AuthorizationFrontendEnginePageHandler.cs

示例12: Adjust

        public void Adjust(CheckAccessContext context) {
            var mediaPart = context.Content.As<MediaPart>();
            if (mediaPart != null) {
                if(_authorizer.Authorize(Permissions.ManageMediaContent)) {
                    context.Granted = true;
                    return;
                }

                if(_authorizer.Authorize(Permissions.ManageOwnMedia)) {
                    context.Granted = _mediaLibraryService.CanManageMediaFolder(mediaPart.FolderPath);
                }
            }
        }
开发者ID:SunRobin2015,项目名称:RobinWithOrchard,代码行数:13,代码来源:MediaAuthorizationEventHandler.cs

示例13: Adjust

        public void Adjust(CheckAccessContext context) {
            if (!context.Granted &&
                context.Content.Is<ICommonPart>()) {

                if (context.Permission.Name == Orchard.Core.Contents.Permissions.PublishContent.Name && context.Content.ContentItem.ContentType == "BlogPost") {
                    context.Adjusted = true;
                    context.Permission = Permissions.PublishBlogPost;
                }
                else if (OwnerVariationExists(context.Permission) &&
                    HasOwnership(context.User, context.Content)) {
                    context.Adjusted = true;
                    context.Permission = GetOwnerVariation(context.Permission);
                }
            }
        }
开发者ID:anycall,项目名称:Orchard,代码行数:15,代码来源:BlogAuthorizationEventHandler.cs

示例14: Complete

        public void Complete(CheckAccessContext context) {
            if (context.Content == null) {
                return;
            }

            var part = context.Content.As<ContentMenuItemPart>();

            // if the content item has no right attached, check on the container
            if (part == null) {
                return;
            }

            context.Granted = _authorizationService.TryCheckAccess(context.Permission, context.User, part.Content);
            context.Adjusted = true;
        }
开发者ID:akhurst,项目名称:ricealumni,代码行数:15,代码来源:ContentMenuItemAuthorizationEventHandler.cs

示例15: Adjust

        public void Adjust(CheckAccessContext context)
        {
            if (context.Granted || context.Content == null || context.Content.ContentItem.ContentType != "Menu") {
                return;
            }

            // replace permission if a menu-specific version exists
            var permission = GetMenuVariation(context.Permission);

            if (permission == null) {
                return;
            }

            context.Adjusted = true;
            context.Permission = MenuPermissions.CreateDynamicPermission(permission, context.Content);
        }
开发者ID:Timbioz,项目名称:SciGitAzure,代码行数:16,代码来源:AuthorizationEventHandler.cs


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