public async Task <ValidationResult> ValidateCreate(string policyJson, ClaimsPrincipal currentUser) { var policyJsonParsed = new DelegationPolicyJsonParser(policyJson); var newPolicyIssuer = policyJsonParsed.PolicyIssuer; var newAccessSubject = policyJsonParsed.AccessSubject; var validationResult = ValidateIssuer(currentUser.GetPartyId(), newPolicyIssuer, newAccessSubject); if (!validationResult.Success) { return(validationResult); } if (await _delegationService.DelegationExists(newPolicyIssuer, newAccessSubject)) { return(ValidationResult.Invalid("The combination policyIssuer - accessSubject already exists.")); } return(ValidationResult.Valid()); }
public async Task <ValidationResult> ValidateCreate(string policyJson, ClaimsPrincipal currentUser) { var policyJsonParsed = new DelegationPolicyJsonParser(policyJson); var newPolicyIssuer = policyJsonParsed.PolicyIssuer; var newAccessSubject = policyJsonParsed.AccessSubject; if (String.IsNullOrEmpty(newPolicyIssuer) || String.IsNullOrEmpty(newAccessSubject)) { return(ValidationResult.Invalid("Policy issuer and access subject are required.")); } if (currentUser.IsInRole(Constants.Roles.EntitledPartyCreator) && currentUser.GetPartyId() != newPolicyIssuer) { return(ValidationResult.Invalid("Policy issuer must be equal to your party id.")); } if (await _delegationService.DelegationExists(newPolicyIssuer, newAccessSubject).ConfigureAwait(false)) { return(ValidationResult.Invalid("The combination policyIssuer - accessSubject already exists.")); } return(ValidationResult.Valid()); }