public object Clone() { CloudProvider clone = new CloudProvider( AuthType, ProviderKey); return(clone); }
public CloudProvider AddProvider( ProviderType.AuthenticationType authType, string providerKey, string username, string secret, bool replaceExisting, string forceID = "") { if (replaceExisting) { IEnumerable <CloudProvider> matches = Providers.Where(cp => cp.ProviderKey == providerKey && cp.UserName == username); if (matches.Any()) { foreach (CloudProvider curMatch in matches) { RemoveProvider(curMatch.ID); } } } CloudProvider provider; if (!String.IsNullOrEmpty(forceID)) { CloudProvider[] matches = _providers.Where(cp => cp.ID == forceID).ToArray(); if (matches.Length > 0) { foreach (CloudProvider curProvider in matches) { _providers.Remove(curProvider); } } provider = new CloudProvider( authType, forceID, providerKey); } else { provider = new CloudProvider(authType, providerKey); } devoctomy.cachy.Framework.Native.Native.PasswordVault.StoreCredential(provider.ID, username, secret, true); _providers.Add(provider); Save(); return(provider); }
public static CloudProviders FromFile(string fullPath) { CloudProviders cloudProviders = new CloudProviders(); cloudProviders._fullPath = fullPath; if (System.IO.File.Exists(cloudProviders._fullPath)) { String providersData = System.IO.File.ReadAllText(fullPath); JObject providersJSON = JObject.Parse(providersData); JArray providers = providersJSON["Providers"].Value <JArray>(); foreach (JObject curProvider in providers) { CloudProvider provider = CloudProvider.FromJSON(curProvider); cloudProviders._providers.Add(provider); } } return(cloudProviders); }
public async Task <bool> UpdateProvider( string id, string username, string accessToken) { IEnumerable <CloudProvider> matches = _providers.Where(cp => cp.ID == id).ToArray(); if (matches.Any()) { CloudProvider provider = matches.First(); devoctomy.cachy.Framework.Native.Native.PasswordVault.StoreCredential( provider.ID, username, accessToken, true); await provider.CheckCredentialAccessAsync(); return(true); } else { return(false); } }