// 초기화 코드 public void Init() { token = GetToken("0355094063652427", "X99IhH4l6FSbElhjFVUSl7DJKWw7AKGxTQfbykxE0pPFK7Zq3Ujo1W8MTEUtoA0iqguYB1DBrthcAgCD"); NavigationPage.SetHasNavigationBar(this, false); // Navigation Bar 지우는 코드 생성자에 입력 token = GetToken("0355094063652427", "X99IhH4l6FSbElhjFVUSl7DJKWw7AKGxTQfbykxE0pPFK7Zq3Ujo1W8MTEUtoA0iqguYB1DBrthcAgCD"); var webViewXaml = new HybridWebView { Uri = "file:///android_asset/IMP.html", HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Param = param, }; Content = webViewXaml; webViewXaml.RegisterAction(CallbackFunc); }
private void Init() { SubscribeYubiKey(true); if (_providers.Count > 1) { var sendEmailTask = SendEmailAsync(false); } ToolbarItems.Clear(); var scrollView = new ScrollView(); var anotherMethodButton = new ExtendedButton { Text = AppResources.UseAnotherTwoStepMethod, Style = (Style)Application.Current.Resources["btn-primaryAccent"], Margin = new Thickness(15, 0, 15, 25), Command = new Command(() => AnotherMethodAsync()), Uppercase = false, BackgroundColor = Color.Transparent, VerticalOptions = LayoutOptions.Start }; var instruction = new Label { LineBreakMode = LineBreakMode.WordWrap, Margin = new Thickness(15), HorizontalTextAlignment = TextAlignment.Center }; RememberCell = new ExtendedSwitchCell { Text = AppResources.RememberMe, On = false }; if (!_providerType.HasValue) { instruction.Text = AppResources.NoTwoStepAvailable; var layout = new StackLayout { Children = { instruction, anotherMethodButton }, Spacing = 0 }; scrollView.Content = layout; Title = AppResources.LoginUnavailable; Content = scrollView; } else if (_providerType.Value == TwoFactorProviderType.Authenticator || _providerType.Value == TwoFactorProviderType.Email) { var continueToolbarItem = new ToolbarItem(AppResources.Continue, Helpers.ToolbarImage("login.png"), async() => { var token = TokenCell?.Entry.Text.Trim().Replace(" ", ""); await LogInAsync(token); }, ToolbarItemOrder.Default, 0); var padding = Helpers.OnPlatform( iOS: new Thickness(15, 20), Android: new Thickness(15, 8), Windows: new Thickness(10, 8)); TokenCell = new FormEntryCell(AppResources.VerificationCode, useLabelAsPlaceholder: true, imageSource: "lock", containerPadding: padding); TokenCell.Entry.Keyboard = Keyboard.Numeric; TokenCell.Entry.ReturnType = ReturnType.Go; var table = new TwoFactorTable( new TableSection(Helpers.GetEmptyTableSectionTitle()) { TokenCell, RememberCell }); var layout = new RedrawableStackLayout { Children = { instruction, table }, Spacing = 0 }; table.WrappingStackLayout = () => layout; scrollView.Content = layout; switch (_providerType.Value) { case TwoFactorProviderType.Authenticator: instruction.Text = AppResources.EnterVerificationCodeApp; layout.Children.Add(anotherMethodButton); break; case TwoFactorProviderType.Email: var emailParams = _providers[TwoFactorProviderType.Email]; var redactedEmail = emailParams["Email"].ToString(); instruction.Text = string.Format(AppResources.EnterVerificationCodeEmail, redactedEmail); var resendEmailButton = new ExtendedButton { Text = AppResources.SendVerificationCodeAgain, Style = (Style)Application.Current.Resources["btn-primaryAccent"], Margin = new Thickness(15, 0, 15, 0), Command = new Command(async() => await SendEmailAsync(true)), Uppercase = false, BackgroundColor = Color.Transparent, VerticalOptions = LayoutOptions.Start }; layout.Children.Add(resendEmailButton); layout.Children.Add(anotherMethodButton); break; default: break; } ToolbarItems.Add(continueToolbarItem); Title = AppResources.VerificationCode; Content = scrollView; TokenCell.Entry.FocusWithDelay(); } else if (_providerType == TwoFactorProviderType.Duo) { var duoParams = _providers[TwoFactorProviderType.Duo]; var host = WebUtility.UrlEncode(duoParams["Host"].ToString()); var req = WebUtility.UrlEncode(duoParams["Signature"].ToString()); var webVaultUrl = "https://vault.bitwarden.com"; if (!string.IsNullOrWhiteSpace(_appSettingsService.BaseUrl)) { webVaultUrl = _appSettingsService.BaseUrl; } else if (!string.IsNullOrWhiteSpace(_appSettingsService.WebVaultUrl)) { webVaultUrl = _appSettingsService.WebVaultUrl; } var webView = new HybridWebView { Uri = $"{webVaultUrl}/duo-connector.html?host={host}&request={req}", HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, MinimumHeightRequest = 400 }; webView.RegisterAction(async(sig) => { await LogInAsync(sig); }); var table = new TwoFactorTable( new TableSection(Helpers.GetEmptyTableSectionTitle()) { RememberCell }); var layout = new RedrawableStackLayout { Children = { webView, table, anotherMethodButton }, Spacing = 0 }; table.WrappingStackLayout = () => layout; scrollView.Content = layout; Title = "Duo"; Content = scrollView; } else if (_providerType == TwoFactorProviderType.YubiKey) { instruction.Text = AppResources.YubiKeyInstruction; var image = new CachedImage { Source = "yubikey", VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.Center, WidthRequest = 266, HeightRequest = 160, Margin = new Thickness(0, 0, 0, 25) }; var table = new TwoFactorTable( new TableSection(Helpers.GetEmptyTableSectionTitle()) { RememberCell }); var layout = new RedrawableStackLayout { Children = { instruction, image, table, anotherMethodButton }, Spacing = 0 }; table.WrappingStackLayout = () => layout; scrollView.Content = layout; Title = AppResources.YubiKeyTitle; Content = scrollView; } }