/// <summary>
        /// Go and get all claims for this user.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <IEnumerable <Claim> > GetProfileDataAsync(ProfileDataRequest request)
        {
            var subject             = request.Subject;
            var requestedClaimTypes = request.RequestedClaimTypes;

            if (subject == null)
            {
                throw new ArgumentNullException("subject");
            }

            var acct = await manager.FindByIdAsync(subject.FindFirst(Core.Constants.ClaimTypes.Subject).Value);

            if (acct == null)
            {
                throw new ArgumentException("Invalid subject identifier");
            }

            var claims = await GetClaimsFromAccount(acct);

            if (requestedClaimTypes != null && requestedClaimTypes.Any())
            {
                claims = claims.Where(x => requestedClaimTypes.Contains(x.Type));
            }

            return(claims);
        }
Beispiel #2
0
        async Task <ProfileDataResponse> GetProfileDataAsync(ProfileDataRequest request)
        {
            var validationResult = this.Validate(request);

            if (!validationResult.IsValid)
            {
                await _logServiceClient.PostAsync(new LogRequest { Message = $"Failed to get Profile Data for {request.SupplyPoint}" });

                return(new ProfileDataResponse {
                    Success = false, Errors = validationResult.FormattedErrors
                });
            }

            var result = new ProfileDataResponse {
                Success = true, ProfileRows = GetProfileData(request.SupplyPoint)
            };
            await _logServiceClient.PostAsync(new LogRequest { Message = $"Retrieved Profile Data for {request.SupplyPoint}: {result.ProfileRows}" });

            return(result);
        }
        public Task <IEnumerable <Claim> > GetProfileDataAsync(ProfileDataRequest request)
        {
            var subject             = request.Subject;
            var requestedClaimTypes = request.RequestedClaimTypes;

            var acct = userAccountService.GetByID(subject.GetSubjectId().ToGuid());

            if (acct == null)
            {
                throw new ArgumentException("Invalid subject identifier");
            }

            var claims = GetClaimsFromAccount(acct);

            if (requestedClaimTypes != null && requestedClaimTypes.Any())
            {
                claims = claims.Where(x => requestedClaimTypes.Contains(x.Type));
            }

            return(Task.FromResult(claims));
        }
Beispiel #4
0
        public async Task <IEnumerable <Claim> > GetProfileDataAsync(ProfileDataRequest request)
        {
            var user = await directoryContext.FindUserByNameAsync(request.Subject.Identity.Name);

            return(GetClaimsForResult(user));
        }