| | | 1 | | using System; |
| | | 2 | | |
| | | 3 | | namespace Renci.SshNet.Messages.Authentication |
| | | 4 | | { |
| | | 5 | | /// <summary> |
| | | 6 | | /// Represents SSH_MSG_USERAUTH_FAILURE message. |
| | | 7 | | /// </summary> |
| | | 8 | | [Message("SSH_MSG_USERAUTH_FAILURE", 51)] |
| | | 9 | | public class FailureMessage : Message |
| | | 10 | | { |
| | | 11 | | /// <summary> |
| | | 12 | | /// Gets or sets the allowed authentications if available. |
| | | 13 | | /// </summary> |
| | | 14 | | /// <value> |
| | | 15 | | /// The allowed authentications. |
| | | 16 | | /// </value> |
| | 3684 | 17 | | public string[] AllowedAuthentications { get; set; } |
| | | 18 | | |
| | | 19 | | /// <summary> |
| | | 20 | | /// Gets failure message. |
| | | 21 | | /// </summary> |
| | 15 | 22 | | public string Message { get; private set; } |
| | | 23 | | |
| | | 24 | | /// <summary> |
| | | 25 | | /// Gets a value indicating whether authentication is partially successful. |
| | | 26 | | /// </summary> |
| | | 27 | | /// <value> |
| | | 28 | | /// <see langword="true"/> if partially successful; otherwise, <see langword="false"/>. |
| | | 29 | | /// </value> |
| | 4892 | 30 | | public bool PartialSuccess { get; private set; } |
| | | 31 | | |
| | | 32 | | /// <summary> |
| | | 33 | | /// Called when type specific data need to be loaded. |
| | | 34 | | /// </summary> |
| | | 35 | | protected override void LoadData() |
| | 1223 | 36 | | { |
| | 1223 | 37 | | AllowedAuthentications = ReadNamesList(); |
| | 1223 | 38 | | PartialSuccess = ReadBoolean(); |
| | 1223 | 39 | | if (PartialSuccess) |
| | 15 | 40 | | { |
| | | 41 | | #if NET || NETSTANDARD2_1_OR_GREATER |
| | 15 | 42 | | Message = string.Join(',', AllowedAuthentications); |
| | | 43 | | #else |
| | 0 | 44 | | Message = string.Join(",", AllowedAuthentications); |
| | | 45 | | #endif // NET || NETSTANDARD2_1_OR_GREATER |
| | 15 | 46 | | } |
| | 1223 | 47 | | } |
| | | 48 | | |
| | | 49 | | /// <summary> |
| | | 50 | | /// Called when type specific data need to be saved. |
| | | 51 | | /// </summary> |
| | | 52 | | protected override void SaveData() |
| | 0 | 53 | | { |
| | | 54 | | #pragma warning disable MA0025 // Implement the functionality instead of throwing NotImplementedException |
| | 0 | 55 | | throw new NotImplementedException(); |
| | | 56 | | #pragma warning restore MA0025 // Implement the functionality instead of throwing NotImplementedException |
| | | 57 | | } |
| | | 58 | | |
| | | 59 | | internal override void Process(Session session) |
| | 1223 | 60 | | { |
| | 1223 | 61 | | session.OnUserAuthenticationFailureReceived(this); |
| | 1223 | 62 | | } |
| | | 63 | | |
| | | 64 | | /// <inheritdoc/> |
| | | 65 | | public override string ToString() |
| | 1223 | 66 | | { |
| | | 67 | | #pragma warning disable MA0089 // Optimize string method usage |
| | 1223 | 68 | | return $"SSH_MSG_USERAUTH_FAILURE {string.Join(",", AllowedAuthentications)} ({nameof(PartialSuccess)}:{Part |
| | | 69 | | #pragma warning restore MA0089 // Optimize string method usage |
| | 1223 | 70 | | } |
| | | 71 | | } |
| | | 72 | | } |