Example #1
0
        public static void ShowIdentity(Identity id)
        {
            Console.WriteLine("Principal: {0}", id.PrincipalType);
            Console.WriteLine("Identity: {0}", id.IdentityType);

            id.Claims.ForEach(c => ShowClaim(c));
        }
Example #2
0
        public Identity GetIdentity()
        {
            "\n\nRequest message:".ConsoleYellow();
            Console.WriteLine(OperationContext.Current.RequestContext.RequestMessage.ToString());

            var principal = ClaimsPrincipal.Current;

            var result = ClaimsAuthorization.CheckAccess(
                "Read",
                "Claims",
                "IdentityType",
                "PrincipalType");

            var id = new Identity
            {
                PrincipalType = principal.GetType().FullName,
                IdentityType = principal.Identity.GetType().FullName,

                Claims = new List<ClaimDto>(
                    from claim in principal.Claims
                    select new ClaimDto
                    {
                        Type = claim.Type,
                        Value = claim.Value,
                        Issuer = claim.Issuer,
                        OriginalIssuer = claim.OriginalIssuer,
                    })
            };

            return id;
        }