public string Check([FromBody] PrivacyCheckingCommand command)
        {
            _logger.LogInformation(DateTime.Now.Millisecond.ToString());
            var subject     = _subjectRepository.GetUniqueUser("_id", command.UserID);
            var environment = string.IsNullOrEmpty(command.Environment) || command.Environment == "{}" ? null : JObject.Parse(command.Environment);
            var resource    = _resourceRepository.GetCollectionDataWithCustomFilter(command.ResourceName, null);
            var action      = command.Action;
            var result      = _securityService.ExecuteProcess(subject, resource, action, command.ResourceName, environment);

            //if (result.Effect == EffectResult.Deny)
            //    return "Deny";
            //if (result.Effect == EffectResult.NotApplicable)
            //    return "Not Applicable";
            _logger.LogInformation(DateTime.Now.Millisecond.ToString());
            return(result.Data == null ? "" : result.Data.ToString());
        }
Example #2
0
        public string Check([FromBody] PrivacyCheckingCommand command)
        {
            var userFilter = Builders <BsonDocument> .Filter.Eq("_id", ObjectId.Parse(command.UserID));

            var       subject     = _subjectRepository.GetUniqueUser(JsonAccessControlSetting.UserDefaultCollectionName, userFilter);
            var       environment = string.IsNullOrEmpty(command.Environment) || command.Environment == "{}" ? null : JObject.Parse(command.Environment);
            var       resource    = _resourceRepository.GetCollectionDataWithCustomFilter(command.ResourceName, null);
            var       action      = command.Action;
            Stopwatch s1          = Stopwatch.StartNew();
            var       result      = _securityService.ExecuteProcess(subject, resource, action, command.ResourceName, environment);

            s1.Stop();
            Console.WriteLine(s1.ElapsedMilliseconds);
            if (result.Effect == EffectResult.Deny)
            {
                return("Deny");
            }
            if (result.Effect == EffectResult.NotApplicable)
            {
                return("Not Applicable");
            }
            return(result.Data == null ? "" : result.Data.ToString());
        }