private async Task DefaultLoadAsync() { try { var generalSamlUpParty = UpParty as GeneralSamlUpPartyViewModel; var samlUpParty = await UpPartyService.GetSamlUpPartyAsync(UpParty.Name); await generalSamlUpParty.Form.InitAsync(ToViewModel(generalSamlUpParty, samlUpParty)); } catch (TokenUnavailableException) { await(OpenidConnectPkce as TenantOpenidConnectPkce).TenantLoginAsync(); } catch (HttpRequestException ex) { UpParty.Error = ex.Message; } }
private async Task ShowUpdateUpPartyAsync(GeneralUpPartyViewModel upParty) { upParty.CreateMode = false; upParty.DeleteAcknowledge = false; upParty.ShowAdvanced = false; upParty.Error = null; upParty.Edit = true; if (upParty.Type == PartyTypes.Login) { try { var generalLoginUpParty = upParty as GeneralLoginUpPartyViewModel; var loginUpParty = await UpPartyService.GetLoginUpPartyAsync(upParty.Name); await generalLoginUpParty.Form.InitAsync(loginUpParty.Map <LoginUpPartyViewModel>(afterMap: afterMap => { afterMap.EnableSingleLogout = !loginUpParty.DisableSingleLogout; afterMap.EnableResetPassword = !loginUpParty.DisableResetPassword; if (afterMap.ClaimTransforms?.Count > 0) { afterMap.ClaimTransforms = afterMap.ClaimTransforms.MapClaimTransforms(); } })); } catch (TokenUnavailableException) { await(OpenidConnectPkce as TenantOpenidConnectPkce).TenantLoginAsync(); } catch (HttpRequestException ex) { upParty.Error = ex.Message; } } else if (upParty.Type == PartyTypes.Oidc) { try { var generalOidcUpParty = upParty as GeneralOidcUpPartyViewModel; var oidcUpParty = await UpPartyService.GetOidcUpPartyAsync(upParty.Name); await generalOidcUpParty.Form.InitAsync(oidcUpParty.Map((Action <OidcUpPartyViewModel>)(afterMap => { if (oidcUpParty.UpdateState == PartyUpdateStates.Manual) { afterMap.IsManual = true; } if (oidcUpParty.UpdateState == PartyUpdateStates.AutomaticStopped) { afterMap.AutomaticStopped = true; } else { afterMap.AutomaticStopped = false; } afterMap.EnableSingleLogout = !oidcUpParty.DisableSingleLogout; if (oidcUpParty.Client != null) { afterMap.Client.EnableFrontChannelLogout = !oidcUpParty.Client.DisableFrontChannelLogout; } foreach (var key in oidcUpParty.Keys) { afterMap.KeyIds.Add(key.Kid); } if (afterMap.ClaimTransforms?.Count > 0) { afterMap.ClaimTransforms = afterMap.ClaimTransforms.MapClaimTransforms(); } }))); } catch (TokenUnavailableException) { await(OpenidConnectPkce as TenantOpenidConnectPkce).TenantLoginAsync(); } catch (HttpRequestException ex) { upParty.Error = ex.Message; } } else if (upParty.Type == PartyTypes.Saml2) { try { var generalSamlUpParty = upParty as GeneralSamlUpPartyViewModel; var samlUpParty = await UpPartyService.GetSamlUpPartyAsync(upParty.Name); await generalSamlUpParty.Form.InitAsync(samlUpParty.Map <SamlUpPartyViewModel>(afterMap => { afterMap.EnableSingleLogout = !samlUpParty.DisableSingleLogout; afterMap.AuthnRequestBinding = samlUpParty.AuthnBinding.RequestBinding; afterMap.AuthnResponseBinding = samlUpParty.AuthnBinding.ResponseBinding; if (!samlUpParty.LogoutUrl.IsNullOrEmpty()) { afterMap.LogoutRequestBinding = samlUpParty.LogoutBinding.RequestBinding; afterMap.LogoutResponseBinding = samlUpParty.LogoutBinding.ResponseBinding; } generalSamlUpParty.CertificateInfoList.Clear(); foreach (var key in afterMap.Keys) { var certificate = new MTokens.JsonWebKey(key.JsonSerialize()).ToX509Certificate(); generalSamlUpParty.CertificateInfoList.Add(new CertificateInfoViewModel { Subject = certificate.Subject, ValidFrom = certificate.NotBefore, ValidTo = certificate.NotAfter, IsValid = certificate.IsValid(), Thumbprint = certificate.Thumbprint, Key = key }); } if (afterMap.ClaimTransforms?.Count > 0) { afterMap.ClaimTransforms = afterMap.ClaimTransforms.MapClaimTransforms(); } })); } catch (TokenUnavailableException) { await(OpenidConnectPkce as TenantOpenidConnectPkce).TenantLoginAsync(); } catch (HttpRequestException ex) { upParty.Error = ex.Message; } } }