internal PolicyViolationException(PolicyResult policyResult, ISecurityContext securityContext) : base(policyResult.Message) { PolicyResult = policyResult; SecurityContext = securityContext; PolicyType = PolicyResult.PolicyType; }
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); }
private static string CreateMessageForResult(PolicyResult result, PolicyResultCacheStrategy strategy, string cacheKey) { return("Enforced policy {0} - {1}! \r\n{2}: {3} at {4} with key '{5}'".FormatWith( result.PolicyType.FullName, result.ViolationOccured ? "Violation occured" : "Success", result.Cached ? "Cached. Strategy" : "Strategy", strategy.CacheLifecycle, strategy.CacheLevel, cacheKey )); }
public PolicyViolationException(PolicyResult policyResult, ISecurityContext securityContext) : base(policyResult.Message) { PolicyResult = policyResult; SecurityContext = securityContext; PolicyType = PolicyResult.PolicyType; }
internal PolicyViolationException(PolicyResult policyResult) : base(policyResult.Message) { PolicyResult = policyResult; PolicyType = PolicyResult.PolicyType; }