private async Task OnEditSamlUpPartyValidSubmitAsync(GeneralSamlUpPartyViewModel generalSamlUpParty, EditContext editContext) { try { if (generalSamlUpParty.Form.Model.ClaimTransforms?.Count() > 0) { foreach (var claimTransform in generalSamlUpParty.Form.Model.ClaimTransforms) { if (claimTransform is SamlClaimTransformClaimInViewModel claimTransformClaimIn && !claimTransformClaimIn.ClaimIn.IsNullOrWhiteSpace()) { claimTransform.ClaimsIn = new List <string> { claimTransformClaimIn.ClaimIn }; } } } var samlUpParty = generalSamlUpParty.Form.Model.Map <SamlUpParty>(afterMap => { afterMap.DisableSingleLogout = !generalSamlUpParty.Form.Model.EnableSingleLogout; afterMap.AuthnBinding = new SamlBinding { RequestBinding = generalSamlUpParty.Form.Model.AuthnRequestBinding, ResponseBinding = generalSamlUpParty.Form.Model.AuthnResponseBinding }; if (!afterMap.LogoutUrl.IsNullOrEmpty()) { afterMap.LogoutBinding = new SamlBinding { RequestBinding = generalSamlUpParty.Form.Model.LogoutRequestBinding, ResponseBinding = generalSamlUpParty.Form.Model.LogoutResponseBinding }; } if (afterMap.ClaimTransforms?.Count() > 0) { int order = 1; foreach (var claimTransform in afterMap.ClaimTransforms) { claimTransform.Order = order++; } } }); if (generalSamlUpParty.CreateMode) { await UpPartyService.CreateSamlUpPartyAsync(samlUpParty); } else { await UpPartyService.UpdateSamlUpPartyAsync(samlUpParty); } generalSamlUpParty.Name = generalSamlUpParty.Form.Model.Name; generalSamlUpParty.Edit = false; await OnStateHasChanged.InvokeAsync(UpParty); } catch (FoxIDsApiException ex) { if (ex.StatusCode == System.Net.HttpStatusCode.Conflict) { generalSamlUpParty.Form.SetFieldError(nameof(generalSamlUpParty.Form.Model.Name), ex.Message); } else { throw; } } }
private async Task OnEditSamlUpPartyValidSubmitAsync(GeneralSamlUpPartyViewModel generalSamlUpParty, EditContext editContext) { try { if (generalSamlUpParty.Form.Model.ClaimTransforms?.Count() > 0) { foreach (var claimTransform in generalSamlUpParty.Form.Model.ClaimTransforms) { if (claimTransform is SamlClaimTransformClaimInViewModel claimTransformClaimIn && !claimTransformClaimIn.ClaimIn.IsNullOrWhiteSpace()) { claimTransform.ClaimsIn = new List <string> { claimTransformClaimIn.ClaimIn }; } } } var samlUpParty = generalSamlUpParty.Form.Model.Map <SamlUpParty>(afterMap => { afterMap.DisableSingleLogout = !generalSamlUpParty.Form.Model.EnableSingleLogout; if (generalSamlUpParty.Form.Model.AuthnContextComparisonViewModel != SamlAuthnContextComparisonTypesVievModel.Null) { afterMap.AuthnContextComparison = (SamlAuthnContextComparisonTypes)Enum.Parse(typeof(SamlAuthnContextComparisonTypes), generalSamlUpParty.Form.Model.AuthnContextComparisonViewModel.ToString()); } if (generalSamlUpParty.Form.Model.IsManual) { afterMap.UpdateState = PartyUpdateStates.Manual; } else { afterMap.UpdateState = PartyUpdateStates.Automatic; } if (afterMap.ClaimTransforms?.Count() > 0) { int order = 1; foreach (var claimTransform in afterMap.ClaimTransforms) { claimTransform.Order = order++; } } }); if (generalSamlUpParty.CreateMode) { var samlUpPartyResult = await UpPartyService.CreateSamlUpPartyAsync(samlUpParty); generalSamlUpParty.Form.UpdateModel(ToViewModel(generalSamlUpParty, samlUpPartyResult)); generalSamlUpParty.CreateMode = false; toastService.ShowSuccess("SAML 2.0 Up-party created.", "SUCCESS"); } else { var samlUpPartyResult = await UpPartyService.UpdateSamlUpPartyAsync(samlUpParty); generalSamlUpParty.Form.UpdateModel(ToViewModel(generalSamlUpParty, samlUpPartyResult)); toastService.ShowSuccess("SAML 2.0 Up-party updated.", "SUCCESS"); } generalSamlUpParty.Name = generalSamlUpParty.Form.Model.Name; } catch (FoxIDsApiException ex) { if (ex.StatusCode == System.Net.HttpStatusCode.Conflict) { generalSamlUpParty.Form.SetFieldError(nameof(generalSamlUpParty.Form.Model.Name), ex.Message); } else { throw; } } }