Ejemplo n.º 1
0
        public async Task <IKeychainAdapter> Load(UriString host)
        {
            Guard.ArgumentNotNull(host, nameof(host));

            var keychainAdapter = FindOrCreateAdapter(host);
            var connection      = GetConnection(host);

            var keychainItem = await credentialManager.Load(host);

            if (keychainItem == null)
            {
                logger.Warning("Cannot load host from Credential Manager; removing from cache");
                await Clear(host, false);

                keychainAdapter = null;
            }
            else
            {
                if (keychainItem.Username != connection.Username)
                {
                    logger.Warning("Keychain Username:\"{0}\" does not match cached Username:\"{1}\"; Hopefully it works", keychainItem.Username, connection.Username);
                }

                keychainAdapter.Set(keychainItem);
            }
            return(keychainAdapter);
        }
Ejemplo n.º 2
0
        public async Task <IKeychainAdapter> Load(UriString host)
        {
            KeychainAdapter keychainAdapter  = FindOrCreateAdapter(host);
            var             cachedConnection = connectionCache[host];

            logger.Trace($@"Loading KeychainAdapter Host:""{host}"" Cached Username:""{cachedConnection.Username}""");

            var keychainItem = await credentialManager.Load(host);

            if (keychainItem == null)
            {
                logger.Warning("Cannot load host from Credential Manager; removing from cache");
                await Clear(host, false);
            }
            else
            {
                if (keychainItem.Username != cachedConnection.Username)
                {
                    logger.Warning("Keychain Username: {0} does not match; Hopefully it works", keychainItem.Username);
                }

                logger.Trace("Loaded from Credential Manager Host:\"{0}\" Username:\"{1}\"", keychainItem.Host, keychainItem.Username);

                keychainAdapter.Set(keychainItem);
            }

            return(keychainAdapter);
        }
Ejemplo n.º 3
0
        public IKeychainAdapter LoadFromSystem(UriString host)
        {
            Guard.ArgumentNotNull(host, nameof(host));

            var keychainAdapter = Connect(host) as KeychainAdapter;
            var credential      = credentialManager.Load(host);

            if (credential == null)
            {
                logger.Warning("Cannot load host from Credential Manager; removing from cache");
                Clear(host, false);
                keychainAdapter = null;
            }
            else
            {
                keychainAdapter.Set(credential);
                var connection = GetConnection(host);
                if (connection.Username == null)
                {
                    connection.Username = credential.Username;
                    SaveConnectionsToDisk();
                }

                if (credential.Username != connection.Username)
                {
                    logger.Warning("Keychain Username:\"{0}\" does not match cached Username:\"{1}\"; Hopefully it works", credential.Username, connection.Username);
                }
            }
            return(keychainAdapter);
        }
Ejemplo n.º 4
0
        public async Task <IKeychainAdapter> Load(UriString host)
        {
            var keychainAdapter = FindOrCreateAdapter(host);

            logger.Trace("Load KeychainAdapter Host:\"{0}\"", host);
            var keychainItem = await credentialManager.Load(host);

            if (keychainItem == null)
            {
                logger.Warning("Cannot load host from credential manager; removing from cache");
                await Clear(host, false);
            }
            else
            {
                logger.Trace("Loading KeychainItem:{0}", keychainItem.ToString());
                keychainAdapter.Set(keychainItem);
            }

            return(keychainAdapter);
        }