本文整理汇总了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;
}
}
}
示例2: Adjust
public void Adjust(CheckAccessContext context)
{
if (context.User == null && !MembershipInitialized)
{
context.Granted = true;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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...
}
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
}
示例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);
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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;
}
示例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);
}