mirror of
https://github.com/moparisthebest/keepass2android
synced 2025-01-30 22:50:21 -05:00
reduce interface dependency of NetFtpFileStorage
This commit is contained in:
parent
86bfae57c3
commit
fe3da55e0d
@ -12,11 +12,23 @@ using keepass2android.Io;
|
||||
|
||||
namespace keepass2android
|
||||
{
|
||||
public interface ICertificateValidationHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles a failed certificate validation. Returns true if the users wants to continue, false otherwise.
|
||||
/// see http://msdn.microsoft.com/en-us/library/system.net.icertificatepolicy(v=vs.110).aspx
|
||||
/// </summary>
|
||||
//bool OnServerCertificateError(int certificateProblem);
|
||||
|
||||
RemoteCertificateValidationCallback CertificateValidationCallback { get; }
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Interface through which Activities and the logic layer can access some app specific functionalities and Application static data
|
||||
/// </summary>
|
||||
/// This also contains methods which are UI specific and should be replacable for testing.
|
||||
public interface IKp2aApp
|
||||
public interface IKp2aApp: ICertificateValidationHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// Locks the currently open database, quicklocking if available (unless false is passed for allowQuickUnlock)
|
||||
@ -92,13 +104,6 @@ namespace keepass2android
|
||||
|
||||
void TriggerReload(Context context);
|
||||
|
||||
/// <summary>
|
||||
/// Handles a failed certificate validation. Returns true if the users wants to continue, false otherwise.
|
||||
/// see http://msdn.microsoft.com/en-us/library/system.net.icertificatepolicy(v=vs.110).aspx
|
||||
/// </summary>
|
||||
//bool OnServerCertificateError(int certificateProblem);
|
||||
|
||||
RemoteCertificateValidationCallback CertificateValidationCallback { get; }
|
||||
|
||||
bool CheckForDuplicateUuids { get; }
|
||||
}
|
||||
|
@ -106,13 +106,13 @@ namespace keepass2android.Io
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Context _context;
|
||||
private readonly ICertificateValidationHandler _app;
|
||||
|
||||
public MemoryStream traceStream;
|
||||
|
||||
public NetFtpFileStorage(Context context)
|
||||
public NetFtpFileStorage(Context context, ICertificateValidationHandler app)
|
||||
{
|
||||
_context = context;
|
||||
_app = app;
|
||||
traceStream = new MemoryStream();
|
||||
FtpTrace.AddListener(new System.Diagnostics.TextWriterTraceListener(traceStream));
|
||||
|
||||
@ -171,18 +171,15 @@ namespace keepass2android.Io
|
||||
if (!uri.IsDefaultPort) //TODO test
|
||||
client.Port = uri.Port;
|
||||
|
||||
//TODO Validate
|
||||
//client.ValidateCertificate += app...
|
||||
|
||||
// we don't need to be thread safe in a classic sense, but OpenRead and OpenWrite don't
|
||||
//perform the actual stream operation so we'd need to wrap the stream (or just enable this:)
|
||||
|
||||
client.ValidateCertificate += (control, args) =>
|
||||
{
|
||||
args.Accept = _app.CertificateValidationCallback(control, args.Certificate, args.Chain, args.PolicyErrors);
|
||||
};
|
||||
|
||||
client.EncryptionMode = ConnectionSettings.FromIoc(ioc).EncryptionMode;
|
||||
|
||||
|
||||
client.Connect();
|
||||
return client;
|
||||
client.Connect();
|
||||
return client;
|
||||
|
||||
}
|
||||
|
||||
@ -373,7 +370,7 @@ namespace keepass2android.Io
|
||||
|
||||
public void StartSelectFile(IFileStorageSetupInitiatorActivity activity, bool isForSave, int requestCode, string protocolId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
activity.PerformManualFileSelect(isForSave, requestCode, "ftp");
|
||||
}
|
||||
|
||||
public void PrepareFileUsage(IFileStorageSetupInitiatorActivity activity, IOConnectionInfo ioc, int requestCode,
|
||||
|
Loading…
Reference in New Issue
Block a user