Пример #1
0
        private IEnumerable <Claim> ConcatenateTransformation(ClaimTransformation claimTransformation, List <Claim> claims)
        {
            var transformedClaims      = new List <Claim>();
            var addTransformationClaim = false;
            var values = new string[claimTransformation.ClaimsIn.Count()];
            int i      = 0;

            foreach (var claimIn in claimTransformation.ClaimsIn)
            {
                var value = claims.Where(c => c.Type.Equals(claimIn, StringComparison.OrdinalIgnoreCase)).Select(c => c.Value).FirstOrDefault();
                if (value != null)
                {
                    addTransformationClaim = true;
                    values[i++]            = value;
                }
                else
                {
                    values[i++] = string.Empty;
                }
            }

            if (addTransformationClaim)
            {
                var transformationValue = string.Format(claimTransformation.Transformation, values);
                transformedClaims.Add(new Claim(claimTransformation.ClaimOut, transformationValue));
            }
            return(transformedClaims);
        }
Пример #2
0
        private IEnumerable <Claim> MatchTransformation(ClaimTransformation claimTransformation, List <Claim> claims)
        {
            var transformedClaims = new List <Claim>();

            foreach (var claim in claims)
            {
                if (claim.Type.Equals(claimTransformation.ClaimsIn.Single(), StringComparison.OrdinalIgnoreCase) && claim.Value.Equals(claimTransformation.Transformation, StringComparison.OrdinalIgnoreCase))
                {
                    transformedClaims.Add(new Claim(claimTransformation.ClaimOut, claimTransformation.TransformationExtension));
                }
            }
            return(transformedClaims);
        }
Пример #3
0
        private IEnumerable <Claim> RegexMatchTransformation(ClaimTransformation claimTransformation, List <Claim> claims)
        {
            var transformedClaims = new List <Claim>();
            var regex             = new Regex(claimTransformation.Transformation, RegexOptions.IgnoreCase);
            var claimIn           = claimTransformation.ClaimsIn.Single();

            foreach (var claim in claims)
            {
                if (claim.Type.Equals(claimIn, StringComparison.OrdinalIgnoreCase))
                {
                    var match = regex.Match(claim.Value);
                    if (match.Success)
                    {
                        transformedClaims.Add(new Claim(claimTransformation.ClaimOut, claimTransformation.TransformationExtension));
                    }
                }
            }
            return(transformedClaims);
        }
Пример #4
0
 private Claim ConstantTransformation(ClaimTransformation claimTransformation)
 {
     return(new Claim(claimTransformation.ClaimOut, claimTransformation.Transformation));
 }