-
-
Notifications
You must be signed in to change notification settings - Fork 990
Expand file tree
/
Copy pathAuthenticationMethod.cs
More file actions
81 lines (72 loc) · 2.7 KB
/
Copy pathAuthenticationMethod.cs
File metadata and controls
81 lines (72 loc) · 2.7 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using System;
namespace Renci.SshNet
{
/// <summary>
/// Base class for all supported authentication methods.
/// </summary>
public abstract class AuthenticationMethod : IAuthenticationMethod, IDisposable
{
/// <summary>
/// Gets the name of the authentication method.
/// </summary>
/// <value>
/// The name of the authentication method.
/// </value>
#pragma warning disable CA2119 // Seal methods that satisfy private interfaces
public abstract string Name { get; }
#pragma warning restore CA2119 // Seal methods that satisfy private interfaces
/// <summary>
/// Gets connection username.
/// </summary>
public string Username { get; private set; }
/// <summary>
/// Gets or sets the list of allowed authentications.
/// </summary>
public string[] AllowedAuthentications { get; protected set; }
/// <summary>
/// Initializes a new instance of the <see cref="AuthenticationMethod"/> class.
/// </summary>
/// <param name="username">The username.</param>
/// <exception cref="ArgumentException"><paramref name="username"/> is whitespace or <see langword="null"/>.</exception>
protected AuthenticationMethod(string username)
{
ArgumentException.ThrowIfNullOrWhiteSpace(username);
Username = username;
}
/// <summary>
/// Authenticates the specified session.
/// </summary>
/// <param name="session">The session to authenticate.</param>
/// <returns>
/// The result of the authentication process.
/// </returns>
public abstract AuthenticationResult Authenticate(Session session);
/// <summary>
/// Authenticates the specified session.
/// </summary>
/// <param name="session">The session to authenticate.</param>
/// <returns>
/// The result of the authentication process.
/// </returns>
AuthenticationResult IAuthenticationMethod.Authenticate(ISession session)
{
return Authenticate((Session)session);
}
/// <summary>
/// Releases unmanaged and - optionally - managed resources.
/// </summary>
/// <param name="disposing">
/// <see langword="true"/> to release both managed and unmanaged resources;
/// <see langword="false"/> to release only unmanaged resources.
/// </param>
protected virtual void Dispose(bool disposing)
{
}
/// <inheritdoc/>
public void Dispose()
{
Dispose(disposing: true);
GC.SuppressFinalize(this);
}
}
}