using System;
using LibGit2Sharp.Core;
namespace LibGit2Sharp
{
///
/// Class that holds username and password credentials for remote repository access.
///
public sealed class UsernamePasswordCredentials : Credentials
{
///
/// Callback to acquire a credential object.
///
/// The newly created credential object.
/// 0 for success, < 0 to indicate an error, > 0 to indicate no credential was acquired.
protected internal override int GitCredentialHandler(out IntPtr cred)
{
if (Username == null || Password == null)
{
throw new InvalidOperationException("UsernamePasswordCredentials contains a null Username or Password.");
}
return NativeMethods.git_cred_userpass_plaintext_new(out cred, Username, Password);
}
///
/// Username for username/password authentication (as in HTTP basic auth).
///
public string Username { get; set; }
///
/// Password for username/password authentication (as in HTTP basic auth).
///
public string Password { get; set; }
}
}