internal void Store() { // parse the operations arguments from stdin (this is how git sends commands) // see: https://www.kernel.org/pub/software/scm/git/docs/technical/api-credentials.html // see: https://www.kernel.org/pub/software/scm/git/docs/git-credential.html using (var stdin = InStream) { OperationArguments operationArguments = new OperationArguments(stdin); Debug.Assert(operationArguments != null, "The operationArguments is null"); Debug.Assert(operationArguments.Username != null, "The operaionArgument.Username is null"); Debug.Assert(operationArguments.TargetUri != null, "The operationArgument.TargetUri is null"); LoadOperationArguments(operationArguments); EnableTraceLogging(operationArguments); var credentials = operationArguments.Credentials; var task = Task.Run(async() => { return(await CreateAuthentication(operationArguments)); }); BaseAuthentication authentication = task.Result; switch (operationArguments.Authority) { default: case AuthorityType.Basic: Git.Trace.WriteLine($"storing basic credentials for '{operationArguments.TargetUri}'."); break; case AuthorityType.Bitbucket: Git.Trace.WriteLine($"storing Bitbucket credentials for '{operationArguments.TargetUri}'."); break; case AuthorityType.AzureDirectory: case AuthorityType.MicrosoftAccount: Git.Trace.WriteLine($"storing VSTS credentials for '{operationArguments.TargetUri}'."); break; case AuthorityType.GitHub: Git.Trace.WriteLine($"storing GitHub credentials for '{operationArguments.TargetUri}'."); break; case AuthorityType.Ntlm: Git.Trace.WriteLine($"storing NTLM credentials for '{operationArguments.TargetUri}'."); break; } authentication.SetCredentials(operationArguments.TargetUri, credentials); } }
private static void Store() { // parse the operations arguments from stdin (this is how git sends commands) // see: https://www.kernel.org/pub/software/scm/git/docs/technical/api-credentials.html // see: https://www.kernel.org/pub/software/scm/git/docs/git-credential.html using (var stdin = Console.OpenStandardInput()) { OperationArguments operationArguments = new OperationArguments(stdin); Debug.Assert(operationArguments != null, "The operationArguments is null"); Debug.Assert(operationArguments.CredUsername != null, "The operaionArgument.Username is null"); Debug.Assert(operationArguments.TargetUri != null, "The operationArgument.TargetUri is null"); LoadOperationArguments(operationArguments); EnableTraceLogging(operationArguments); Credential credentials = new Credential(operationArguments.CredUsername, operationArguments.CredPassword); BaseAuthentication authentication = CreateAuthentication(operationArguments); switch (operationArguments.Authority) { default: case AuthorityType.Basic: Git.Trace.WriteLine($"storing basic credentials for '{operationArguments.TargetUri}'."); break; case AuthorityType.AzureDirectory: case AuthorityType.MicrosoftAccount: Git.Trace.WriteLine($"storing VSTS credentials for '{operationArguments.TargetUri}'."); break; case AuthorityType.GitHub: Git.Trace.WriteLine($"storing GitHub credentials for '{operationArguments.TargetUri}'."); break; case AuthorityType.Ntlm: Git.Trace.WriteLine($"storing NTLM credentials for '{operationArguments.TargetUri}'."); break; } authentication.SetCredentials(operationArguments.TargetUri, credentials); } }
private static void Store() { // parse the operations arguments from stdin (this is how git sends commands) // see: https://www.kernel.org/pub/software/scm/git/docs/technical/api-credentials.html // see: https://www.kernel.org/pub/software/scm/git/docs/git-credential.html var stdin = Console.OpenStandardInput(); OperationArguments operationArguments = new OperationArguments(stdin); Debug.Assert(operationArguments != null, "The operationArguments is null"); Debug.Assert(operationArguments.CredUsername != null, "The operaionArgument.Username is null"); Debug.Assert(operationArguments.TargetUri != null, "The operationArgument.TargetUri is null"); LoadOperationArguments(operationArguments); EnableTraceLogging(operationArguments); BaseAuthentication authentication = CreateAuthentication(operationArguments); Credential credentials = new Credential(operationArguments.CredUsername, operationArguments.CredPassword); authentication.SetCredentials(operationArguments.TargetUri, credentials); }
internal void Store() { // parse the operations arguments from stdin (this is how git sends commands) // see: https://www.kernel.org/pub/software/scm/git/docs/technical/api-credentials.html // see: https://www.kernel.org/pub/software/scm/git/docs/git-credential.html using (var stdin = InStream) { var operationArguments = new OperationArguments(_context); Task.Run(async() => { await operationArguments.ReadInput(stdin); if (operationArguments.TargetUri is null) { var inner = new ArgumentNullException(nameof(operationArguments.TargetUri)); throw new ArgumentException(inner.Message, nameof(operationArguments), inner); } if (operationArguments.Username is null) { var inner = new ArgumentNullException(nameof(operationArguments.Username)); throw new ArgumentException(inner.Message, nameof(operationArguments), inner); } // Load operation arguments. await LoadOperationArguments(operationArguments); EnableTraceLogging(operationArguments); // Read the details of any git-remote-http(s).exe parent process, but only if // an override hasn't been set which would override the git-remote details. if (string.IsNullOrEmpty(operationArguments.UrlOverride)) { ReadGitRemoteDetails(operationArguments); } // Set the parent window handle. ParentHwnd = operationArguments.ParentHwnd; var credentials = operationArguments.Credentials; BaseAuthentication authentication = await CreateAuthentication(operationArguments);; switch (operationArguments.Authority) { default: case AuthorityType.Basic: Trace.WriteLine($"storing basic credentials for '{operationArguments.TargetUri}'."); break; case AuthorityType.Bitbucket: Trace.WriteLine($"storing Bitbucket credentials for '{operationArguments.TargetUri}'."); break; case AuthorityType.AzureDirectory: case AuthorityType.MicrosoftAccount: Trace.WriteLine($"storing VSTS credentials for '{operationArguments.TargetUri}'."); break; case AuthorityType.GitHub: Trace.WriteLine($"storing GitHub credentials for '{operationArguments.TargetUri}'."); break; case AuthorityType.Ntlm: Trace.WriteLine($"storing NTLM credentials for '{operationArguments.TargetUri}'."); break; } await authentication.SetCredentials(operationArguments.TargetUri, credentials); }).Wait(); } }