-
Notifications
You must be signed in to change notification settings - Fork 897
/
Copy pathSshAgentCredentials.cs
32 lines (28 loc) · 1.01 KB
/
SshAgentCredentials.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System;
using LibGit2Sharp.Core;
namespace LibGit2Sharp
{
/// <summary>
/// Class that holds SSH agent credentials for remote repository access.
/// </summary>
public sealed class SshAgentCredentials : Credentials
{
/// <summary>
/// Callback to acquire a credential object.
/// </summary>
/// <param name="cred">The newly created credential object.</param>
/// <returns>0 for success, < 0 to indicate an error, > 0 to indicate no credential was acquired.</returns>
protected internal override int GitCredentialHandler(out IntPtr cred)
{
if (Username == null)
{
throw new InvalidOperationException("SshAgentCredentials contains a null Username.");
}
return NativeMethods.git_cred_ssh_key_from_agent(out cred, Username);
}
/// <summary>
/// Username for SSH authentication.
/// </summary>
public string Username { get; set; }
}
}