Beispiel #1
0
        internal SecuritySpecificationInfo Clone()
        {
            SecuritySpecificationInfo result = new SecuritySpecificationInfo();

            foreach (var claimSpecification in _claimValues)
            {
                var clonedClaimSpecification = new ConcurrentDictionary <string, string>();
                foreach (var claimValue in claimSpecification.Value)
                {
                    clonedClaimSpecification[claimValue.Key] = null;
                }

                result._claimValues[claimSpecification.Key] = clonedClaimSpecification;
            }

            return(result);
        }
Beispiel #2
0
        private void Merge(SecuritySpecificationInfo securitySpecificationInfo, Expression <Func <ResourceSecurityInfo, object> > mergingDelegate)
        {
            var method = ((MethodCallExpression)mergingDelegate.Body).Method;

            foreach (var claimType in securitySpecificationInfo)
            {
                if (!securitySpecificationInfo[claimType].Any())
                {
                    method.Invoke(this, new object[] { claimType, null });
                }
                else
                {
                    foreach (var claimValue in securitySpecificationInfo[claimType])
                    {
                        method.Invoke(this, new object[] { claimType, claimValue });
                    }
                }
            }
        }
Beispiel #3
0
        internal static bool Matches(this SecuritySpecificationInfo securitySpecificationInfo, IClaimBasedIdentity identity)
        {
            foreach (var claimType in securitySpecificationInfo)
            {
                IEnumerable <string> claims;
                if ((claims = identity[claimType]) == null)
                {
                    continue;
                }

                var claimValues    = securitySpecificationInfo[claimType];
                var anyValues      = claimValues.Any();
                var matchingClaims = from value in claimValues join claim in claims on value equals claim select claim;
                if ((!anyValues) || (matchingClaims.Any()))
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #4
0
 private ResourceSecurityInfo(SecuritySpecificationInfo allowed, SecuritySpecificationInfo denied)
 {
     Allowed = allowed;
     Denied  = denied;
 }