Created
August 25, 2017 16:20
-
-
Save grokys/fc673a863ec7dffca324d00f0c8cd278 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public Task<Tuple<string, string>> Load(HostAddress hostAddress) | |
| { | |
| Guard.ArgumentNotNull(hostAddress, nameof(hostAddress)); | |
| var keyGit = GetKeyGit(hostAddress.CredentialCacheKeyHost); | |
| var keyHost = GetKeyHost(hostAddress.CredentialCacheKeyHost); | |
| var gitFound = false; | |
| var hostFound = false; | |
| Tuple<string, string> result = null; | |
| using (var credentialGit = new Credential()) | |
| using (var credentialHost = new Credential()) | |
| { | |
| credentialGit.Target = keyGit; | |
| credentialGit.Type = CredentialType.Generic; | |
| gitFound = credentialGit.Load(); | |
| credentialHost.Target = keyHost; | |
| credentialHost.Type = CredentialType.Generic; | |
| hostFound = credentialHost.Load(); | |
| if (gitFound && hostFound && | |
| credentialGit.Username == credentialHost.Username && | |
| credentialGit.Password == credentialHost.Password) | |
| { | |
| result = Tuple.Create(credentialGit.Username, credentialGit.Password); | |
| } | |
| else if (gitFound) | |
| { | |
| Save(credentialGit.Username, credentialGit.Password, hostAddress); | |
| result = Tuple.Create(credentialGit.Username, credentialGit.Password); | |
| } | |
| else if (hostFound) | |
| { | |
| Save(credentialHost.Username, credentialHost.Password, hostAddress); | |
| result = Tuple.Create(credentialHost.Username, credentialHost.Password); | |
| } | |
| } | |
| return Task.FromResult(result); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment