Пример #1
0
        protected IQuickspatchPrincipal CreatePrincipalFromClaimsAndUser(User user, List <Claim> claims)
        {
            var firstOrDefault = claims.FirstOrDefault(x => x.Type == ClaimsDeclaration.AuthenticationTypeClaimType);

            if (firstOrDefault != null)
            {
                var providerClaim = firstOrDefault.Value;
                var orDefault     = claims.FirstOrDefault(x => x.Type == ClaimsDeclaration.NameClaimType);
                if (orDefault != null)
                {
                    var loginName = orDefault.Value;

                    var primaryIdentity = new QuickspatchIdentity(loginName, user.Id, providerClaim);

                    // create principal with primary identity
                    var returnPrincipal = new QuickspatchPrincipal(primaryIdentity)
                    {
                        AuthToken = SessionIdManager.CreateSessionID(null),
                        User      = user
                    };

                    return(returnPrincipal);
                }
            }
            return(null);
        }
Пример #2
0
        public QuickspatchPrincipal(QuickspatchIdentity identity)
            : base(identity)
        {
            if (identity == null)
            {
                throw new ArgumentNullException("identity");
            }

            _currentIdentity = identity;
            _identities      = new List <ClaimsIdentity> {
                _currentIdentity
            };
        }
Пример #3
0
        public QuickspatchPrincipal(ClaimsIdentity identity)
            : base(identity)
        {
            if (identity == null)
            {
                throw new ArgumentNullException("identity");
            }

            // Transform the ClaimsIndentity to an QuickspatchIdentity that extends
            // ClaimsIdentity with application-specific behavior.
            var advantageIdentity = new QuickspatchIdentity(identity.Claims);

            _currentIdentity = advantageIdentity;
            _identities      = new List <ClaimsIdentity> {
                advantageIdentity
            };
        }