Exemplo n.º 1
0
        private async Task <ActionResult <DelegationTranslationTestResponse> > TranslateDelegation(DelegationMask delegationMask)
        {
            var stepsValidation = await _previousStepsValdiationService.Validate(delegationMask);

            if (!stepsValidation.Succeeded)
            {
                return(BadRequest(stepsValidation.Errors));
            }

            var validationResult = _delegationMaskValidationService.Validate(delegationMask);

            if (!validationResult.Success)
            {
                return(BadRequest(new { error = validationResult.Error }));
            }

            var delegation = await _delegationService
                             .GetBySubject(delegationMask.DelegationRequest.Target.AccessSubject, delegationMask.DelegationRequest.PolicyIssuer)
            ;

            if (delegation == null)
            {
                return(NotFound());
            }

            var delegationResponse = _delegationTranslateService.Translate(delegationMask, delegation.Policy);

            return(delegationResponse);
        }
        public async Task <ActionResult <DelegationTranslationTestResponse> > TestDelegationTranslation([FromBody] DelegationMask delegationMask)
        {
            var validationResult = _delegationMaskValidationService.Validate(delegationMask);

            if (!validationResult.Success)
            {
                return(BadRequest(new { error = validationResult.Error }));
            }
            var delegation = await _delegationService
                             .GetBySubject(delegationMask.DelegationRequest.Target.AccessSubject, delegationMask.DelegationRequest.PolicyIssuer)
                             .ConfigureAwait(false);

            if (delegation == null)
            {
                return(NotFound());
            }
            var delegationResponse = _delegationTranslateService.Translate(delegationMask, delegation.Policy);

            return(delegationResponse);
        }