Exemplo n.º 1
0
        public static IPolicyContainerConfiguration DelegatePolicy(this IPolicyContainerConfiguration policyContainer, string uniqueName, Func <DelegateSecurityContext, bool> policyDelegate, Func <PolicyViolationException, ActionResult> violationHandlerDelegate = null, string failureMessage = "Access denied")
        {
            Func <DelegateSecurityContext, PolicyResult> booleanPolicyDelegate =
                context => policyDelegate.Invoke(context)
                                        ? PolicyResult.CreateSuccessResult(context.Policy)
                                        : PolicyResult.CreateFailureResult(context.Policy, failureMessage);

            policyContainer.AddPolicy(new DelegatePolicy(uniqueName, booleanPolicyDelegate, violationHandlerDelegate));
            return(policyContainer);
        }
Exemplo n.º 2
0
 public static IPolicyContainerConfiguration <RequireAllRolesPolicy> RequireAllRoles(this IPolicyContainerConfiguration policyContainer, params object[] roles)
 {
     policyContainer.AddPolicy(new RequireAllRolesPolicy(roles));
     return(new PolicyContainerConfigurationWrapper <RequireAllRolesPolicy>(policyContainer));
 }
Exemplo n.º 3
0
 public static IPolicyContainerConfiguration Ignore(this IPolicyContainerConfiguration policyContainer)
 {
     policyContainer.AddPolicy(new IgnorePolicy());
     return(policyContainer);
 }
Exemplo n.º 4
0
 public static IPolicyContainerConfiguration <DenyAuthenticatedAccessPolicy> DenyAuthenticatedAccess(this IPolicyContainerConfiguration policyContainer)
 {
     policyContainer.AddPolicy(new DenyAuthenticatedAccessPolicy());
     return(new PolicyContainerConfigurationWrapper <DenyAuthenticatedAccessPolicy>(policyContainer));
 }
Exemplo n.º 5
0
 public static IPolicyContainerConfiguration DelegatePolicy(this IPolicyContainerConfiguration policyContainer, string uniqueName, Func <DelegateSecurityContext, PolicyResult> policyDelegate, Func <PolicyViolationException, ActionResult> violationHandlerDelegate = null)
 {
     policyContainer.AddPolicy(new DelegatePolicy(uniqueName, policyDelegate, violationHandlerDelegate));
     return(policyContainer);
 }
 public static IPolicyContainerConfiguration GroupPolicy(this IPolicyContainerConfiguration policyContainer, params PermissionGroupEntity[] groups)
 {
     return(policyContainer.AddPolicy(EngineContext.Current.Resolve <PermissionGroupPolicy>(new PositionalParameter(1, groups))));
 }
 public static IPolicyContainerConfiguration RolePolicy(this IPolicyContainerConfiguration policyContainer, params RoleEntity[] roles)
 {
     return(policyContainer.AddPolicy(EngineContext.Current.Resolve <RolePolicy>(new PositionalParameter(1, roles))));
 }
 public IPolicyContainerConfiguration AddPolicy(ISecurityPolicy securityPolicy)
 {
     return(_inner.AddPolicy(securityPolicy));
 }