I took no chances and instead just did it in code with optional parameters, like this.
Covered all 3 of my use cases this way. Seems to work.
Covered all 3 of my use cases this way. Seems to work.
private static AuthenticationMethod createAuthObject(
string _uName,
bool _usePrivateKey,
string _uPassword = "",
string _ppkPassPhrase = "",
string _ppkPath = ""
)
{
PrivateKeyFile ppkFile;
if (_usePrivateKey)
{
if (_ppkPassPhrase != "")
{
ppkFile = new PrivateKeyFile(_ppkPath, _ppkPassPhrase);
}
else
{
ppkFile = new PrivateKeyFile(_ppkPath);
}
PrivateKeyAuthenticationMethod myAuth = new PrivateKeyAuthenticationMethod(_uName, ppkFile);
return myAuth;
}
else
{
PasswordAuthenticationMethod myAuth = new PasswordAuthenticationMethod(_uName, _uPassword);
return myAuth;
}
}