本文整理汇总了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 "";
}
}
示例2: ClearRoamedAccounts
public static void ClearRoamedAccounts()
{
PasswordVault vault = new PasswordVault();
foreach (var credential in vault.RetrieveAll())
{
vault.Remove(credential);
}
}
示例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;
}
示例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;
}
示例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);
}
示例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));
}
示例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;
}
示例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);
}
}
示例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));
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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));
}
示例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;
}
示例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>();
}
}