Example #1
0
 public CloudProvider(
     ProviderType.AuthenticationType authType,
     string providerKey)
 {
     _authType    = authType;
     _providerKey = providerKey;
 }
Example #2
0
        public static CloudProvider FromJSON(JObject json)
        {
            string id = json["ID"].Value <string>();

            ProviderType.AuthenticationType authType = (ProviderType.AuthenticationType)Enum.Parse(typeof(ProviderType.AuthenticationType), json["AuthType"].Value <string>(), true);
            string providerKey = json["ProviderKey"].Value <string>();

            return(new CloudProvider(
                       authType,
                       id,
                       providerKey));
        }
Example #3
0
        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);
        }