Files
monorepo/LCU.API.Internal.FTP/LCU.Api.Internal.FTP/Helpers/WinScpSessionOptionValidators.cs
T
2026-03-24 15:28:37 -05:00

30 lines
1.1 KiB
C#

using System;
using LCU.Api.Internal.FTPLib.Models;
namespace LCU.Api.Internal.FTP.Helpers;
[Obsolete("01/04/2022 - After the SftpController endpoints are no longer using this validation it can be removed. The model validation covers validation enough.")]
public static class WinScpSessionOptionValidators
{
public static bool IsValidSessionOptions(SftpRequest sftpRequest)
{
if (!IsValidHostInfo(sftpRequest) || !IsValidFileInfo(sftpRequest))
{
return false;
}
return WinScpSessionOptionsHelper.CreateSessionOptions(sftpRequest) != null;
}
private static bool IsValidFileInfo(SftpRequest sftpRequest)
{
return !string.IsNullOrWhiteSpace(sftpRequest.RemoteFilePath) &&
(!string.IsNullOrWhiteSpace(sftpRequest.LocalFilePath) || sftpRequest.LocalFileData != null);
}
private static bool IsValidHostInfo(SftpRequest sftpRequest)
{
return !string.IsNullOrWhiteSpace(sftpRequest.Password) &&
!string.IsNullOrWhiteSpace(sftpRequest.UserName) &&
!string.IsNullOrWhiteSpace(sftpRequest.HostName) && sftpRequest.PortNumber > 0;
}
}