Пример #1
0
        /// <summary>
        /// Gets the actual type of the ISecurityPolicy. Takes care of checking for lazy policies.
        /// </summary>
        public static Type GetPolicyType(this ISecurityPolicy securityPolicy)
        {
            var lazySecurityPolicy = securityPolicy as ILazySecurityPolicy;

            return(lazySecurityPolicy != null
                                ? lazySecurityPolicy.PolicyType
                                : securityPolicy.GetType());
        }
Пример #2
0
 public static PolicyResult CreateSuccessResult(ISecurityPolicy policy)
 {
     return new PolicyResult
     {
         PolicyType = policy.GetType(),
         ViolationOccured = false,
         Message = null
     };
 }
Пример #3
0
 public static PolicyResult CreateSuccessResult(ISecurityPolicy policy)
 {
     return(new PolicyResult
     {
         PolicyType = policy.GetType(),
         ViolationOccured = false,
         Message = null
     });
 }
Пример #4
0
 public virtual ISecurityPolicy Merge(ISecurityPolicy next)
 {
     if (next == null)
     {
         throw new ArgumentNullException("next");
     }
     if (next.GetType() != this.GetType())
     {
         throw new ArgumentException("Merging of policies of different types not allowed");
     }
     return(next);
 }
Пример #5
0
        public static PolicyResult CreateFailureResult(ISecurityPolicy policy, string message)
        {
            if (policy == null) throw new ArgumentNullException("policy", "A policy must be provided.");
            if (String.IsNullOrEmpty(message)) throw new ArgumentNullException("message", "A failure message must be provided.");

            return new PolicyResult
            {
                PolicyType = policy.GetType(),
                ViolationOccured = true,
                Message = message
            };
        }
Пример #6
0
        public static PolicyResult CreateFailureResult(ISecurityPolicy policy, string message)
        {
            if (policy == null)
            {
                throw new ArgumentNullException("policy", "A policy must be provided.");
            }
            if (String.IsNullOrEmpty(message))
            {
                throw new ArgumentNullException("message", "A failure message must be provided.");
            }

            return(new PolicyResult
            {
                PolicyType = policy.GetType(),
                ViolationOccured = true,
                Message = message
            });
        }
Пример #7
0
        private PolicyResultCacheStrategy GetExecutionCacheStrategyForPolicy(ISecurityPolicy securityPolicy, Cache defaultResultsCacheLifecycle)
        {
            var existingStrategy = GetExistingCacheStrategyForPolicy(securityPolicy.GetType());

            return(existingStrategy ?? new PolicyResultCacheStrategy(ControllerName, ActionName, securityPolicy.GetType(), defaultResultsCacheLifecycle));
        }
Пример #8
0
 protected PolicyResult(string message, bool violationOccured, ISecurityPolicy policy)
     : this(message, violationOccured, policy.GetType())
 {
 }
Пример #9
0
 protected PolicyResult(string message, bool violationOccured, ISecurityPolicy policy)
     : this(message, violationOccured, policy.GetType())
 {
 }