Пример #1
0
        public List <Claim> GetAccessClaimList(AccountDto account, SignInMessage sgnMessage)
        {
            List <Claim> claimList = new List <Claim>();

            if (account != null)
            {
                SecurityUserBussiness userBussiness = new SecurityUserBussiness();
                var user = userBussiness.GetSingle(it => it.UserId == account.UserId);
                if (user != null)
                {
                }
            }


            return(claimList);
        }
Пример #2
0
        public void RegisterUserTest()
        {
            SecurityUserBussiness provider = new SecurityUserBussiness();
            UserDto user = new UserDto()
            {
                FirstName  = "test2",
                LastName   = "ftest2",
                NationalNo = "123457"
            };
            AccountDto acc = new AccountDto()
            {
                Username = "******",
                Password = "******"
            };

            user.Accounts.Add(acc);
            var result = provider.RegisterUser(user);
        }
Пример #3
0
        public List <Claim> GetIdentityClaimList(AccountDto account, SignInMessage sgnMessage)
        {
            List <Claim> claimList = new List <Claim>();

            if (account != null)
            {
                SecurityUserBussiness userBussiness = new SecurityUserBussiness();
                var user = userBussiness.GetSingle(it => it.UserId == account.UserId);
                if (user != null)
                {
                    Claim subjectClaim = new Claim()
                    {
                        Type  = ClaimTypes.Subject,
                        Value = user.UserId.ToString()
                    };
                    claimList.Add(subjectClaim);

                    Claim fnameClaim = new Claim()
                    {
                        Type  = ClaimTypes.Name,
                        Value = user.FirstName
                    };

                    claimList.Add(fnameClaim);
                    Claim perId = new Claim()
                    {
                        Type  = ClaimTypes.PersonId,
                        Value = user.PerId.ToString()
                    };
                    claimList.Add(perId);
                    Claim lnameClaim = new Claim()
                    {
                        Type  = ClaimTypes.FamilyName,
                        Value = user.LastName
                    };
                    claimList.Add(lnameClaim);

                    Claim unameClaim = new Claim()
                    {
                        Type  = ClaimTypes.PreferredUserName,
                        Value = account.Username
                    };
                    claimList.Add(unameClaim);

                    Claim clientIdClaim = new Claim()
                    {
                        Type  = ClaimTypes.ClientId,
                        Value = sgnMessage.ClientId
                    };
                    claimList.Add(clientIdClaim);


                    Claim expClaim = new Claim()
                    {
                        Type  = ClaimTypes.Expiration,
                        Value = string.Empty
                    };
                    if (account.ExpiredDate.HasValue)
                    {
                        expClaim.Value = account.ExpiredDate.Value.ToString("yyyy-MM-dd HH:mm tt");
                    }
                    claimList.Add(expClaim);
                    var roleIds = userBussiness.GetUserRoleIds(user.UserId);
                    foreach (var roleId in roleIds)
                    {
                        Claim roleClaim = new Claim()
                        {
                            Type  = ClaimTypes.Role,
                            Value = roleId.ToString()
                        };
                        claimList.Add(roleClaim);
                    }
                    var groupIds = userBussiness.GetUserGroupIds(user.UserId);
                    foreach (var groupId in groupIds)
                    {
                        Claim groupClaim = new Claim()
                        {
                            Type  = ClaimTypes.Group,
                            Value = groupId.ToString()
                        };
                        claimList.Add(groupClaim);
                    }
                }
            }


            return(claimList);
        }