Exemplo n.º 1
0
        public async Task <bool> Execute(string policyId)
        {
            _umaServerEventSource.StartToRemoveAuthorizationPolicy(policyId);
            if (string.IsNullOrWhiteSpace(policyId))
            {
                throw new ArgumentNullException(nameof(policyId));
            }

            var policy = await _repositoryExceptionHelper.HandleException(
                string.Format(ErrorDescriptions.TheAuthorizationPolicyCannotBeRetrieved, policyId),
                () => _policyRepository.Get(policyId));

            if (policy == null)
            {
                return(false);
            }

            await _repositoryExceptionHelper.HandleException(
                string.Format(ErrorDescriptions.TheAuthorizationPolicyCannotBeUpdated, policyId),
                () => _policyRepository.Delete(policyId));

            _umaServerEventSource.FinishToRemoveAuthorizationPolicy(policyId);
            return(true);
        }