public async Task <IEnumerable <IntrospectionResponse> > Execute(IEnumerable <string> rpts) { if (rpts == null || !rpts.Any()) { throw new ArgumentNullException(nameof(rpts)); } var concatenatedRpts = string.Join(",", rpts); _umaServerEventSource.StartToIntrospect(concatenatedRpts); var rptsInformation = await _rptRepository.Get(rpts); if (rptsInformation == null || !rptsInformation.Any()) { throw new BaseUmaException(ErrorCodes.InvalidRpt, string.Format(ErrorDescriptions.TheRptsDontExist, concatenatedRpts)); } var tickets = await _ticketRepository.Get(rptsInformation.Select(r => r.TicketId)); if (tickets == null || !tickets.Any() || tickets.Count() != rptsInformation.Count()) { throw new BaseUmaException(ErrorCodes.InternalError, ErrorDescriptions.AtLeastOneTicketDoesntExist); } var result = new List <IntrospectionResponse>(); foreach (var rptInformation in rptsInformation) { var record = new IntrospectionResponse { Expiration = rptInformation.ExpirationDateTime.ConvertToUnixTimestamp(), IssuedAt = rptInformation.CreateDateTime.ConvertToUnixTimestamp() }; var ticket = tickets.First(t => t.Id == rptInformation.TicketId); if (rptInformation.ExpirationDateTime < DateTime.UtcNow || ticket.ExpirationDateTime < DateTime.UtcNow) { _umaServerEventSource.RptHasExpired(rptInformation.Value); record.IsActive = false; } else { record.Permissions = new List <PermissionResponse> { new PermissionResponse { ResourceSetId = rptInformation.ResourceSetId, Scopes = ticket.Scopes, Expiration = ticket.ExpirationDateTime.ConvertToUnixTimestamp() } }; record.IsActive = true; } result.Add(record); } _umaServerEventSource.EndIntrospection(JsonConvert.SerializeObject(result)); return(result); }