示例#1
0
        private async void MetroWindow_Loaded(object sender, RoutedEventArgs e)
        {
            YubiCryptOAuth2Token t = Properties.Settings.Default.AccessToken;

            SettingKDFComboBox.ItemsSource             = _engine.KeyDerivationFunctionProviders;
            SettingSymmetricCipherComboBox.ItemsSource = _engine.SymmetricCipherProviders;
            SettingMACComboBox.ItemsSource             = _engine.MACProviders;

            if (!await LoadSettings())
            {
                return;
            }

            if (t == null)
            {
                await this.ShowMessageAsync("No YubiCrypt Access Token", "In order to access the YubiCrypt platform you must first request an access token.\nPlease sign in.", MessageDialogStyle.Affirmative);

                tabAccount.IsSelected = true;
                return;
            }

            _client = new YubiCryptClient(API_CLIENT_ID, API_CLIENT_SECRET, t);

            await LoadFiles();
        }
示例#2
0
        private void GetAuthorizationCode()
        {
            _client = new YubiCryptClient(clientId, clientSecret, callbackUrl);

            messageText.Text = "Please sign in to your YubiCrypt account:";
            var url = _client.GetAuthorizationCodeRequestUrl(new string[] { "files", "keys" });

            MainBrowser.Navigate(url);
        }
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session.  The state will be null the first time a page is visited.</param>
        private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            _client = e.NavigationParameter as YubiCryptClient;
            if (_client == null)
            {
                return;
            }

            var authUrl = _client.GetAuthorizationCodeRequestUrl(new string[] { "files", "keys" });

            browserView.Navigate(new Uri(authUrl));
        }
        private async Task RenewAccessToken()
        {
            client = new YubiCryptClient(clientId, clientSecret, callbackUrl);

            var noTokenMessage = new MessageDialog(this.resourceLoader.GetString("Message_NoAccessToken"));
            await noTokenMessage.ShowAsync();

            if (!Frame.Navigate(typeof(Authentication), client))
            {
                throw new Exception(this.resourceLoader.GetString("NavigationFailedExceptionMessage"));
            }
        }
示例#5
0
        void signInWindow_AccessTokenReceived(object sender, AccessTokenReceivedEventArgs e)
        {
            if (_client == null)
            {
                _client = new YubiCryptClient(API_CLIENT_ID, API_CLIENT_SECRET, e.AccessToken);
            }
            else
            {
                _client.OAuth2Token = e.AccessToken;
            }

            Properties.Settings.Default.AccessToken = e.AccessToken;
            Properties.Settings.Default.Save();

            UpdateTokenStatus();
        }
        private async Task RefreshUI()
        {
            YubiCryptOAuth2Token storedAccessToken = SettingsHelper.LoadSetting <YubiCryptOAuth2Token>(Consts.SETTINGS_ACCESS_TOKEN_KEY);

            if (CheckAccessToken(storedAccessToken))
            {
                client = new YubiCryptClient(clientId, clientSecret, storedAccessToken);
                if (!IsTokenSecretAvailable())
                {
                    await TokenSecretFirstTimeSetup();

                    return;
                }
                var secret = SettingsHelper.LoadSetting <TFTokenData>(Consts.SETTINGS_TOKEN_SECRET_KEY);
                await LoadFileListAsync();
            }
            else
            {
                await RenewAccessToken();
            }
        }