mirror of
https://github.com/moparisthebest/keepass2android
synced 2025-02-07 02:10:10 -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
|
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>
|
/// <summary>
|
||||||
/// Interface through which Activities and the logic layer can access some app specific functionalities and Application static data
|
/// Interface through which Activities and the logic layer can access some app specific functionalities and Application static data
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// This also contains methods which are UI specific and should be replacable for testing.
|
/// This also contains methods which are UI specific and should be replacable for testing.
|
||||||
public interface IKp2aApp
|
public interface IKp2aApp: ICertificateValidationHandler
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Locks the currently open database, quicklocking if available (unless false is passed for allowQuickUnlock)
|
/// Locks the currently open database, quicklocking if available (unless false is passed for allowQuickUnlock)
|
||||||
@ -92,14 +104,7 @@ namespace keepass2android
|
|||||||
|
|
||||||
void TriggerReload(Context context);
|
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; }
|
bool CheckForDuplicateUuids { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -106,13 +106,13 @@ namespace keepass2android.Io
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly Context _context;
|
private readonly ICertificateValidationHandler _app;
|
||||||
|
|
||||||
public MemoryStream traceStream;
|
public MemoryStream traceStream;
|
||||||
|
|
||||||
public NetFtpFileStorage(Context context)
|
public NetFtpFileStorage(Context context, ICertificateValidationHandler app)
|
||||||
{
|
{
|
||||||
_context = context;
|
_app = app;
|
||||||
traceStream = new MemoryStream();
|
traceStream = new MemoryStream();
|
||||||
FtpTrace.AddListener(new System.Diagnostics.TextWriterTraceListener(traceStream));
|
FtpTrace.AddListener(new System.Diagnostics.TextWriterTraceListener(traceStream));
|
||||||
|
|
||||||
@ -171,18 +171,15 @@ namespace keepass2android.Io
|
|||||||
if (!uri.IsDefaultPort) //TODO test
|
if (!uri.IsDefaultPort) //TODO test
|
||||||
client.Port = uri.Port;
|
client.Port = uri.Port;
|
||||||
|
|
||||||
//TODO Validate
|
client.ValidateCertificate += (control, args) =>
|
||||||
//client.ValidateCertificate += app...
|
{
|
||||||
|
args.Accept = _app.CertificateValidationCallback(control, args.Certificate, args.Chain, args.PolicyErrors);
|
||||||
// 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.EncryptionMode = ConnectionSettings.FromIoc(ioc).EncryptionMode;
|
client.EncryptionMode = ConnectionSettings.FromIoc(ioc).EncryptionMode;
|
||||||
|
|
||||||
|
|
||||||
client.Connect();
|
client.Connect();
|
||||||
return client;
|
return client;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -373,7 +370,7 @@ namespace keepass2android.Io
|
|||||||
|
|
||||||
public void StartSelectFile(IFileStorageSetupInitiatorActivity activity, bool isForSave, int requestCode, string protocolId)
|
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,
|
public void PrepareFileUsage(IFileStorageSetupInitiatorActivity activity, IOConnectionInfo ioc, int requestCode,
|
||||||
|
Loading…
Reference in New Issue
Block a user