forked from libgit2/libgit2sharp
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSshKeyCredentials.cs
More file actions
51 lines (44 loc) · 1.65 KB
/
Copy pathSshKeyCredentials.cs
File metadata and controls
51 lines (44 loc) · 1.65 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using LibGit2Sharp.Ssh;
namespace LibGit2Sharp
{
/// <summary>
/// Class that holds SSH username with key credentials for remote repository access.
/// </summary>
public sealed class SshKeyCredentials : 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("SshUserKeyCredentials contains a null Username.");
}
if (PrivateKey == null)
{
throw new InvalidOperationException("SshUserKeyCredentials contains a null PrivateKey.");
}
return NativeMethods.git_cred_ssh_key_new(out cred, Username, PublicKey, PrivateKey, Passphrase);
}
/// <summary>
/// Username for SSH authentication.
/// </summary>
public string Username { get; set; }
/// <summary>
/// Public key file location for SSH authentication.
/// </summary>
public string PublicKey { get; set; }
/// <summary>
/// Private key file location for SSH authentication.
/// </summary>
public string PrivateKey { get; set; }
/// <summary>
/// Passphrase for SSH authentication.
/// </summary>
public string Passphrase { get; set; }
}
}