当前位置: 首页>>代码示例>>C#>>正文


C# PasswordVault.Retrieve方法代码示例

本文整理汇总了C#中Windows.Security.Credentials.PasswordVault.Retrieve方法的典型用法代码示例。如果您正苦于以下问题:C# PasswordVault.Retrieve方法的具体用法?C# PasswordVault.Retrieve怎么用?C# PasswordVault.Retrieve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Windows.Security.Credentials.PasswordVault的用法示例。


在下文中一共展示了PasswordVault.Retrieve方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: VerifyUserCredentials

 public async Task<TunesUser> VerifyUserCredentials()
 {
     TunesUser tunesUser = null;
     Windows.Security.Credentials.PasswordVault vault = new Windows.Security.Credentials.PasswordVault();
     try
     {
         await Task.Run(() =>
         {
             var userName = (string)Windows.Storage.ApplicationData.Current.RoamingSettings.Values["username"];
             if (!string.IsNullOrEmpty(userName))
             {
                 var passwordCredential = vault.Retrieve(PasswordVaultResourceName, userName);
                 if (passwordCredential != null)
                 {
                     tunesUser = this.User = new TunesUser
                     {
                         UserName = userName,
                         Password = vault.Retrieve(PasswordVaultResourceName, passwordCredential.UserName).Password
                     };
                 }
             }
         });
     }
     catch { }
     return tunesUser;
 }
开发者ID:uwe-e,项目名称:BSE.Tunes,代码行数:26,代码来源:AccountService.cs

示例2: Storage

        public Storage(string fileName) {
            this.fileName = new String(fileName.ToCharArray());
            PasswordVault vault = new PasswordVault();

            try {
                this.password = vault.Retrieve(Conf.resource, Conf.username).Password;
            }
            catch (Exception e) {
                vault.Add(new PasswordCredential(Conf.resource, Conf.username, CryptographicBuffer.EncodeToBase64String(CryptographicBuffer.GenerateRandom(64))));
                this.password = vault.Retrieve(Conf.resource, Conf.username).Password;
            }
        }
开发者ID:yohanesmario,项目名称:Skripsi,代码行数:12,代码来源:Storage.cs

示例3: Login

        /// <summary>
        /// Attempt to sign in to GitHub using the credentials supplied. 
        /// </summary>
        /// <param name="username">GitHub username</param>
        /// <param name="password">GitHub password</param>
        /// <param name="cached">Whether these credentials came from local storage</param>
        /// <returns>true if successful, false otherwise</returns>
        public async Task<string> Login(string username, string password, bool cached = false)
        {
            client.Credentials = new Credentials(username, password);
            try
            {
                //hacky way of determining whether the creds are correct
                await client.GitDatabase.Reference.Get("dhbrett", "Graffiti", "heads/master");
                //we haven't thrown so all good
                SignedIn = true;

                //these are new credentials, save them
                if (!cached)
                {
                    var pv = new PasswordVault();
                    pv.Add(new PasswordCredential { Resource = RESOURCE, UserName = username, Password = password });

                    localSettings.Values[USERNAME] = username;
                }

                return "pass";
            }
            catch(Exception e)
            {
                if (e.Message.Contains("two-factor"))
                {
                    return "tfa";
                }
                else if (cached)
                {
                    var pv = new PasswordVault();
                    pv.Remove(pv.Retrieve(RESOURCE, username));
                }
                return "fail";
            }
        }
开发者ID:DHBrett,项目名称:Graffiti,代码行数:42,代码来源:GitHub.cs

示例4: SecureLoadPassword

        private dynamic SecureLoadPassword(string username)
        {
            // Credential Lockerから資格情報を取得する
            PasswordVault vault = new PasswordVault();
            PasswordCredential credential = vault.Retrieve(RESOURCE, username);

            return new { UserName = credential.UserName, Password = credential.Password };
        }
开发者ID:runceel,项目名称:winstoreapprecipe,代码行数:8,代码来源:MainPage.xaml.cs

示例5: GetPassword

        public static string GetPassword()
        {
            PasswordVault passwordVault = new PasswordVault();
            if (!passwordVault.RetrieveAll().Any(credential => credential.UserName == UserNameText && credential.Resource == ResourceText))
            {
                SetPassword();
            }

            return passwordVault.Retrieve(ResourceText, UserNameText).Password;
        }
开发者ID:QRyptoWire,项目名称:qrypto-wire,代码行数:10,代码来源:QryptoDbSecurity.cs

示例6: SettingsCommandsRequested

        private void SettingsCommandsRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args)
        {
            SettingsCommand about_cmd = new SettingsCommand("about", "About", (x) =>
            {
                _settingsPopup = new Popup();
                _settingsPopup.Closed += OnPopupClosed;
                Window.Current.Activated += OnWindowActivated;
                _settingsPopup.IsLightDismissEnabled = true;
                _settingsPopup.Width = _settingsWidth;
                _settingsPopup.Height = _windowBounds.Height;

                SettingsAboutView mypane = new SettingsAboutView();
                //SimpleSettingsNarrow mypane = new SimpleSettingsNarrow();
                mypane.Width = _settingsWidth;
                mypane.Height = _windowBounds.Height;

                _settingsPopup.Child = mypane;
                _settingsPopup.SetValue(Canvas.LeftProperty, _windowBounds.Width - _settingsWidth);
                _settingsPopup.SetValue(Canvas.TopProperty, 0);
                _settingsPopup.IsOpen = true;
            });

            args.Request.ApplicationCommands.Add(about_cmd);

            SettingsCommand logout_cmd = new SettingsCommand("logout", "Log out", (x) =>
            {
                var vault = new PasswordVault();
                vault.Remove(vault.Retrieve("Sovok.tv WinApp", App.ViewModel.UserAccount.login));
                bool nav = Frame.Navigate(typeof(Login));
                App.ViewModel = new Model.MainViewModel();
            });

            args.Request.ApplicationCommands.Add(logout_cmd);

            SettingsCommand settings_cmd = new SettingsCommand("settings", "Settings", (x) =>
            {
                _settingsPopup = new Popup();
                _settingsPopup.Closed += OnPopupClosed;
                Window.Current.Activated += OnWindowActivated;
                _settingsPopup.IsLightDismissEnabled = true;
                _settingsPopup.Width = _settingsWidth;
                _settingsPopup.Height = _windowBounds.Height;

                SettingsView mypane = new SettingsView();
                mypane.Width = _settingsWidth;
                mypane.Height = _windowBounds.Height;

                _settingsPopup.Child = mypane;
                _settingsPopup.SetValue(Canvas.LeftProperty, _windowBounds.Width - _settingsWidth);
                _settingsPopup.SetValue(Canvas.TopProperty, 0);
                _settingsPopup.IsOpen = true;
            });
            args.Request.ApplicationCommands.Add(settings_cmd);
        }
开发者ID:legator,项目名称:SovokTV,代码行数:54,代码来源:PlayerPage.xaml.cs

示例7: RetrieveCredential

 public static PasswordCredential RetrieveCredential(string username)
 {
     try
     {
         PasswordVault vault = new PasswordVault();
         return vault.Retrieve(CredentialSource, username);
     }
     catch
     {
         return null;
     }
 }
开发者ID:huangjia2107,项目名称:Joke,代码行数:12,代码来源:FileHelper.cs

示例8: Unprotect

 public string Unprotect(string key)
 {
     try
     {
         var vault = new PasswordVault();
         return vault.Retrieve(Package.Current.Id.Name, key).Password;
     }
     catch
     {
         return null;
     }
 }
开发者ID:Rumpel78,项目名称:MoneyFox.Windows,代码行数:12,代码来源:ProtectedData.cs

示例9: Retrieve

 public string Retrieve(string key)
 {
     try
     {
         var vault = new PasswordVault();
         return vault.Retrieve(key, "username").Password;
     }
     catch
     {
         return null;
     }
 }
开发者ID:nmetulev,项目名称:Modern-Gitter,代码行数:12,代码来源:PasswordStorageService.cs

示例10: RemovePassword

 /// <summary>
 ///     Removes the password from the secure storage.
 /// </summary>
 public void RemovePassword()
 {
     // If there where no element to remove it will throw a com exception who we handle.
     try
     {
         var vault = new PasswordVault();
         var passwordCredential = vault.Retrieve(Package.Current.Id.Name, PASSWORD_KEY);
         vault.Remove(passwordCredential);
     }
     catch (Exception)
     {
     }
 }
开发者ID:Rumpel78,项目名称:MoneyFox.Windows,代码行数:16,代码来源:PasswordStorage.cs

示例11: ClearCurrentUser

        public static async Task ClearCurrentUser()
        {
            string sessionKey = CurrentUser.SessionKey;
            await UsersPersister.Logout(sessionKey);
            var vault = new PasswordVault();
            vault.Remove(vault.Retrieve(UserCredentialsToken, CurrentUser.Username));


            localSettings.Values["ProfilePictureUrl"] = "";
            localSettings.Values["FirstName"] = "";
            localSettings.Values["LastName"] = "";
            localSettings.Values["Reputation"] = "";
        }
开发者ID:BlueForeverI,项目名称:INeedHelp.Client,代码行数:13,代码来源:AccountManager.cs

示例12: TryAuthenticateSilently

        public static async Task<bool> TryAuthenticateSilently(bool useCachedCredentials = true)
        {
            MobileServiceUser user = null;

            var vault = new PasswordVault();

            PasswordCredential savedCredentials = null;

            if (useCachedCredentials && LegacyUserId.Value != null)
            {
                try
                {
                    savedCredentials = vault.FindAllByResource(ProviderId).FirstOrDefault();
                }
                catch (Exception)
                {
                    // No credentials found.
                }
            }

            if (savedCredentials != null)
            {
                user = new MobileServiceUser(savedCredentials.UserName)
                {
                    MobileServiceAuthenticationToken = vault.Retrieve(ProviderId, savedCredentials.UserName).Password
                };

                MobileService.Client.CurrentUser = user;
            }

            if (user == null)
            {
                try
                {
                    user = await DoLoginAsync(CredentialPromptType.DoNotPrompt);
                }
                catch (Exception)
                {
                    // Do nothing
                }

                if (user != null)
                {
                    vault.Add(new PasswordCredential(ProviderId, user.UserId, user.MobileServiceAuthenticationToken));
                }
            }

            return user != null;
        }
开发者ID:pglazkov,项目名称:Linqua,代码行数:49,代码来源:SecurityManager.cs

示例13: LoadToken

        public void LoadToken()
        {
            if (this.IsFirst) { return; }

            try
            {
                var p = new PasswordVault();
                var accessToken = p.Retrieve("TwitterAppSample.AccessToken", this.ScreenName);
                var accessTokenSecret = p.Retrieve("TwitterAppSample.AccessTokenSecret", this.ScreenName);

                this.tokens = Tokens.Create(
                    Constants.ConsumerKey,
                    Constants.ConsumerSecret,
                    accessToken.Password,
                    accessTokenSecret.Password);

                this.tokens.Followers.ListAsync();
                this.OnPropertyChanged(() => this.IsAuth);
            }
            catch
            {
                // ignore
            }
        }
开发者ID:runceel,项目名称:samples,代码行数:24,代码来源:User.cs

示例14: GetSavedCredentials

 public PasswordCredential GetSavedCredentials(string resource) {
     try {
         var vault = new PasswordVault();
         var credentials = vault.FindAllByResource(resource);
         var cred = credentials.FirstOrDefault();
         if (cred != null)
             return vault.Retrieve(resource, cred.UserName);
         else
             return null;
     }
     // The password vault throws System.Exception if no credentials have been stored with this resource.
     catch (Exception) {
         return null;
     }
 }
开发者ID:ronlemire2,项目名称:PrismRT-CodeGen-v2.1,代码行数:15,代码来源:RoamingCredentialStore.cs

示例15: GetCredentialsFromVault

        private PasswordCredential GetCredentialsFromVault(PasswordVault vault)
        {
            PasswordCredential credentials;
            try
            {
                credentials = vault.FindAllByResource(PasswordVaultResourceName).FirstOrDefault();
                credentials = vault.Retrieve(PasswordVaultResourceName, credentials.UserName);
            }
            catch (Exception exception)
            {
                credentials = null;
                this.Log(exception);
            }

            return credentials;
        }
开发者ID:valentingovo,项目名称:SubSonic8,代码行数:16,代码来源:SettingsHelper.cs


注:本文中的Windows.Security.Credentials.PasswordVault.Retrieve方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。