Adding
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user