當前位置: 首頁>>代碼示例>>C#>>正文


C# PasswordVault.RetrieveAll方法代碼示例

本文整理匯總了C#中Windows.Security.Credentials.PasswordVault.RetrieveAll方法的典型用法代碼示例。如果您正苦於以下問題:C# PasswordVault.RetrieveAll方法的具體用法?C# PasswordVault.RetrieveAll怎麽用?C# PasswordVault.RetrieveAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Windows.Security.Credentials.PasswordVault的用法示例。


在下文中一共展示了PasswordVault.RetrieveAll方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetSecretFor

        public string GetSecretFor(string name)
        {
            var vault = new PasswordVault();
            try
            {
                if (vault.RetrieveAll().Count == 0)
                {
                    return "";
                }

                var credentialList = vault.FindAllByResource(_key);

                return credentialList
                    .Where(x => x.UserName == name)
                    .Select(x =>
                    {
                        x.RetrievePassword();
                        return x.Password;
                    })
                    .FirstOrDefault();
            }
            catch (Exception)
            {
                // Exception is thrown if the vault isn't properly initialised
                return "";
            }
        }
開發者ID:alexhardwicke,項目名稱:Auth,代碼行數:27,代碼來源:PasswordHelper.cs

示例2: ClearRoamedAccounts

        public static void ClearRoamedAccounts()
        {
            PasswordVault vault = new PasswordVault();

            foreach (var credential in vault.RetrieveAll())
            {
                vault.Remove(credential);
            }
        }
開發者ID:mbmccormick,項目名稱:Authenticator,代碼行數:9,代碼來源:AccountManager.cs

示例3: 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

示例4: InitializePasswordVaultInTheBackground

 static bool InitializePasswordVaultInTheBackground()
 {
     // Explicitly place this task on a background thread.
     Task.Factory.StartNew(() =>
     {
         // any call to the password vault will load the vault.
         var vault = new PasswordVault();
         vault.RetrieveAll();
     });
     return true;
 }
開發者ID:COMIsLove,項目名稱:Windows-universal-samples,代碼行數:11,代碼來源:SampleConfiguration.cs

示例5: GetLoginInfo

        public Tuple<string, string> GetLoginInfo()
        {
            var passwordValut = new Windows.Security.Credentials.PasswordVault();
            var list = passwordValut.RetrieveAll();

            var login = list.FirstOrDefault(i => String.Compare(i.Resource, RESOURCE) == 0);
            if (login != null)
            {
                login.RetrievePassword();
                return new Tuple<string, string>(login.UserName, login.Password);
            }
            return new Tuple<string, string>(String.Empty, String.Empty);
        }
開發者ID:holtsoftware,項目名稱:bearded-avenger,代碼行數:13,代碼來源:WindowsLoginStore.cs

示例6: SaveIfttt

        public void SaveIfttt(string key)
        {
            if (string.IsNullOrWhiteSpace(key)) throw new ArgumentNullException(nameof(key));

            var vault = new PasswordVault();

            foreach (var item in vault.RetrieveAll().Where(v => v.Resource == "ifttt"))
            {
                vault.Remove(item);
            }

            vault.Add(new PasswordCredential("ifttt", "key", key));
        }
開發者ID:danpadmore,項目名稱:homebased,代碼行數:13,代碼來源:CredentialsRepository.cs

示例7: GetIfttt

        public string GetIfttt()
        {
            var vault = new PasswordVault();

            var credentials = vault.RetrieveAll().Where(v => v.Resource == "ifttt");
            if (credentials.Count(c => c.UserName == "key") != 1)
                return null;

            var key = credentials.Single();
            key.RetrievePassword();

            return key.Password;
        }
開發者ID:danpadmore,項目名稱:homebased,代碼行數:13,代碼來源:CredentialsRepository.cs

示例8: MainPage_AccountCommandsRequested

        private void MainPage_AccountCommandsRequested(AccountsSettingsPane sender,
			AccountsSettingsPaneCommandsRequestedEventArgs args)
        {
            var credDeletedHandler = new CredentialCommandCredentialDeletedHandler(h => AccountsSettingsPane.Show());

            var vault = new PasswordVault();
            var creds = vault.RetrieveAll();

            foreach (PasswordCredential c in creds)
            {
                var credCommand1 = new CredentialCommand(c, credDeletedHandler);
                args.CredentialCommands.Add(credCommand1);
            }
        }
開發者ID:robledop,項目名稱:Demos-20485,代碼行數:14,代碼來源:MainPage.xaml.cs

示例9: SetNotifierCredential

 public static void SetNotifierCredential(string username, string password)
 {
     var vault = new PasswordVault();
     var credentials = vault.RetrieveAll();
     foreach (var credential in credentials)
     {
         if (credential.Resource == "NOTCRED" && credential.UserName == username)
         {
             vault.Remove(credential);
         }
     }
     if (password != null)
     {
         vault.Add(new PasswordCredential("NOTCRED", username, password));
     }
 }
開發者ID:nidzo732,項目名稱:SecureMessaging,代碼行數:16,代碼來源:DataStorage.cs

示例10: GetNotifierCredentials

 public static List<string[]> GetNotifierCredentials()
 {
     List<string[]> returnedCredentials = new List<string[]>();
     var vault = new PasswordVault();
     var credentials = vault.RetrieveAll();
     if (credentials.Count == 0) return returnedCredentials;
     foreach (var credential in credentials)
     {
         if (credential.Resource == "NOTCRED")
         {
             credential.RetrievePassword();
             string[] credentialData = { credential.UserName, credential.Password };
             returnedCredentials.Add(credentialData);
         }
     }
     return returnedCredentials;
 }
開發者ID:nidzo732,項目名稱:SecureMessaging,代碼行數:17,代碼來源:DataStorage.cs

示例11: DeserializeRoamedAccounts

        public static void DeserializeRoamedAccounts()
        {
            PasswordVault vault = new PasswordVault();

            App.Accounts.Clear();

            foreach (var credential in vault.RetrieveAll())
            {
                credential.RetrievePassword();

                Account a = new Account();
                a.Name = credential.UserName;
                a.SecretKey = credential.Password;

                App.Accounts.Add(a);
            }
        }
開發者ID:mbmccormick,項目名稱:Authenticator,代碼行數:17,代碼來源:AccountManager.cs

示例12: SaveSettings

        private bool SaveSettings(string user, string password, string host, string port, Scheme scheme)
        {
            var vault = new PasswordVault();
            foreach (var pwdCredential in vault.RetrieveAll())
            {
                vault.Remove(pwdCredential);
            }

            vault.Add(new PasswordCredential(ResourceName, user, password));

            var res = vault.FindAllByUserName(user);
            ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;
            localSettings.Values["host"] = host;
            localSettings.Values["scheme"] = scheme.ToString();
            localSettings.Values["port"] = port.ToString();       
            MainPage.SplunkService = null;
            return true;
        }
開發者ID:Netsuye,項目名稱:Splunk-SDK,代碼行數:18,代碼來源:ConnectSetting.xaml.cs

示例13: SaveLogin

 public void SaveLogin(string username, string password)
 {
     PasswordCredential pc;
     var passwordVault = new Windows.Security.Credentials.PasswordVault();
     var list = passwordVault.RetrieveAll().Where(i => String.Compare(i.Resource, RESOURCE) == 0);
     if((pc = list.FirstOrDefault(i => String.Compare(i.UserName, username) == 0)) != null)
     {
         passwordVault.Remove(pc);
         passwordVault.Add(new Windows.Security.Credentials.PasswordCredential(RESOURCE, username, password));
     }
     else if(list.Count() > 0)
     {
         foreach(var p in list)
         {
             passwordVault.Remove(p);
         }
     }
     passwordVault.Add(new Windows.Security.Credentials.PasswordCredential(RESOURCE, username, password));
 }
開發者ID:holtsoftware,項目名稱:bearded-avenger,代碼行數:19,代碼來源:WindowsLoginStore.cs

示例14: SaveFifthplay

        public void SaveFifthplay(string username, string password)
        {
            if (username == null) throw new ArgumentNullException(nameof(username));
            if (password == null) throw new ArgumentNullException(nameof(password));

            var vault = new PasswordVault();

            foreach (var item in vault.RetrieveAll().Where(v => v.Resource == "fifthplay"))
            {
                vault.Remove(item);
            }

            vault.Add(new PasswordCredential("fifthplay", username, password));

            if (!ApplicationData.Current.LocalSettings.Values.ContainsKey("fifthplay-username"))
                ApplicationData.Current.LocalSettings.Values.Add("fifthplay-username", username);
            else
                ApplicationData.Current.LocalSettings.Values["fifthplay-username"] = username;
        }
開發者ID:danpadmore,項目名稱:homebased,代碼行數:19,代碼來源:CredentialsRepository.cs

示例15: ReadAll

        public IList<SecureAuthCode> ReadAll()
        {
            var vault = new PasswordVault();
            try
            {
                if (vault.RetrieveAll().Count == 0)
                {
                    return new List<SecureAuthCode>();
                }

                var credentialList = vault.FindAllByResource(_key);

                return credentialList.Select(x =>
                {
                    x.RetrievePassword();
                    return new SecureAuthCode(x.UserName, x.Password);
                }).ToList();
            }
            catch (Exception)
            {
                // Exception is thrown if the vault isn't properly initialised
                return new List<SecureAuthCode>();
            }
        }
開發者ID:alexhardwicke,項目名稱:Auth,代碼行數:24,代碼來源:PasswordHelper.cs


注:本文中的Windows.Security.Credentials.PasswordVault.RetrieveAll方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。