From c694ed0f96a61614b516aad4c2661f69c980f191 Mon Sep 17 00:00:00 2001 From: Philipp Crocoll Date: Wed, 3 Feb 2016 12:43:37 +0100 Subject: [PATCH] started working on FTP(S) implementation using netftp and introduction of "server accounts" --- .gitmodules | 3 + src/KeePass.sln | 67 ++++++--- .../Io/AndroidContentStorage.cs | 5 + .../Io/BuiltInFileStorage.cs | 5 + .../Io/CachingFileStorage.cs | 5 + src/Kp2aBusinessLogic/Io/IFileStorage.cs | 7 +- src/Kp2aBusinessLogic/Io/JavaFileStorage.cs | 5 + .../Io/OfflineSwitchableFileStorage.cs | 5 + .../Kp2aBusinessLogic.csproj | 5 + .../KP2ASoftkeyboard_AS/.idea/workspace.xml | 132 +++--------------- src/keepass2android/app/App.cs | 10 +- .../fileselect/FileDbHelper.cs | 7 +- .../fileselect/FileSelectActivity.cs | 4 +- src/netftpandroid | 1 + 14 files changed, 120 insertions(+), 141 deletions(-) create mode 160000 src/netftpandroid diff --git a/.gitmodules b/.gitmodules index d47b889f..bf04494d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "src/SamsungPass"] path = src/SamsungPass url = https://github.com/sraiteri/Xamarin-Samsung-Pass.git +[submodule "src/netftpandroid"] + path = src/netftpandroid + url = https://git01.codeplex.com/forks/philippc/netftpandroid diff --git a/src/KeePass.sln b/src/KeePass.sln index 8828693c..d4e8f78f 100644 --- a/src/KeePass.sln +++ b/src/KeePass.sln @@ -47,7 +47,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AncientIconSet", "AncientIc EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FingerprintTest", "FingerprintTest\FingerprintTest.csproj", "{52C0A0E7-D625-44BE-948E-D98BC6C82F0F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SamsungPass", "SamsungPass\Xamarin.SamsungPass\SamsungPass\SamsungPass.csproj", "{3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FtpClientTest", "FtpClientTest\FtpClientTest.csproj", "{8230EA71-1DC2-426A-A820-3B94E1678379}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Net.FtpClient.Android", "netftpandroid\System.Net.FtpClient\System.Net.FtpClient.Android.csproj", "{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -139,7 +141,6 @@ Global {A8779D4D-7C49-4C2F-82BD-2CDC448391DA}.ReleaseNoNet|x64.ActiveCfg = Release|Any CPU {53A9CB7F-6553-4BC0-B56B-9410BB2E59AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {53A9CB7F-6553-4BC0-B56B-9410BB2E59AA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {53A9CB7F-6553-4BC0-B56B-9410BB2E59AA}.Debug|Any CPU.Deploy.0 = Debug|Any CPU {53A9CB7F-6553-4BC0-B56B-9410BB2E59AA}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {53A9CB7F-6553-4BC0-B56B-9410BB2E59AA}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {53A9CB7F-6553-4BC0-B56B-9410BB2E59AA}.Debug|Win32.ActiveCfg = Debug|Any CPU @@ -218,7 +219,6 @@ Global {5CF675A5-9BEE-4720-BED9-D5BF14A2EBF9}.ReleaseNoNet|x64.ActiveCfg = Release|Any CPU {48574278-4779-4B3A-A9E4-9CF1BC285D0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {48574278-4779-4B3A-A9E4-9CF1BC285D0B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {48574278-4779-4B3A-A9E4-9CF1BC285D0B}.Debug|Any CPU.Deploy.0 = Debug|Any CPU {48574278-4779-4B3A-A9E4-9CF1BC285D0B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {48574278-4779-4B3A-A9E4-9CF1BC285D0B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {48574278-4779-4B3A-A9E4-9CF1BC285D0B}.Debug|Win32.ActiveCfg = Debug|Any CPU @@ -255,7 +255,6 @@ Global {3C0F7FE5-639F-4422-A087-8B26CF862D1B}.ReleaseNoNet|x64.ActiveCfg = Release|Any CPU {70D3844A-D9FA-4A64-B205-A84C6A822196}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {70D3844A-D9FA-4A64-B205-A84C6A822196}.Debug|Any CPU.Build.0 = Debug|Any CPU - {70D3844A-D9FA-4A64-B205-A84C6A822196}.Debug|Any CPU.Deploy.0 = Debug|Any CPU {70D3844A-D9FA-4A64-B205-A84C6A822196}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {70D3844A-D9FA-4A64-B205-A84C6A822196}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {70D3844A-D9FA-4A64-B205-A84C6A822196}.Debug|Win32.ActiveCfg = Debug|Any CPU @@ -530,24 +529,48 @@ Global {52C0A0E7-D625-44BE-948E-D98BC6C82F0F}.ReleaseNoNet|Mixed Platforms.Deploy.0 = Release|Any CPU {52C0A0E7-D625-44BE-948E-D98BC6C82F0F}.ReleaseNoNet|Win32.ActiveCfg = Release|Any CPU {52C0A0E7-D625-44BE-948E-D98BC6C82F0F}.ReleaseNoNet|x64.ActiveCfg = Release|Any CPU - {3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}.Debug|Win32.ActiveCfg = Debug|Any CPU - {3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}.Debug|x64.ActiveCfg = Debug|Any CPU - {3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}.Release|Any CPU.Build.0 = Release|Any CPU - {3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}.Release|Win32.ActiveCfg = Release|Any CPU - {3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}.Release|x64.ActiveCfg = Release|Any CPU - {3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}.ReleaseNoNet|Any CPU.ActiveCfg = Release|Any CPU - {3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}.ReleaseNoNet|Any CPU.Build.0 = Release|Any CPU - {3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}.ReleaseNoNet|Mixed Platforms.ActiveCfg = Release|Any CPU - {3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}.ReleaseNoNet|Mixed Platforms.Build.0 = Release|Any CPU - {3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}.ReleaseNoNet|Win32.ActiveCfg = Release|Any CPU - {3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}.ReleaseNoNet|x64.ActiveCfg = Release|Any CPU + {8230EA71-1DC2-426A-A820-3B94E1678379}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8230EA71-1DC2-426A-A820-3B94E1678379}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8230EA71-1DC2-426A-A820-3B94E1678379}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {8230EA71-1DC2-426A-A820-3B94E1678379}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {8230EA71-1DC2-426A-A820-3B94E1678379}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {8230EA71-1DC2-426A-A820-3B94E1678379}.Debug|Mixed Platforms.Deploy.0 = Debug|Any CPU + {8230EA71-1DC2-426A-A820-3B94E1678379}.Debug|Win32.ActiveCfg = Debug|Any CPU + {8230EA71-1DC2-426A-A820-3B94E1678379}.Debug|x64.ActiveCfg = Debug|Any CPU + {8230EA71-1DC2-426A-A820-3B94E1678379}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8230EA71-1DC2-426A-A820-3B94E1678379}.Release|Any CPU.Build.0 = Release|Any CPU + {8230EA71-1DC2-426A-A820-3B94E1678379}.Release|Any CPU.Deploy.0 = Release|Any CPU + {8230EA71-1DC2-426A-A820-3B94E1678379}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {8230EA71-1DC2-426A-A820-3B94E1678379}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {8230EA71-1DC2-426A-A820-3B94E1678379}.Release|Mixed Platforms.Deploy.0 = Release|Any CPU + {8230EA71-1DC2-426A-A820-3B94E1678379}.Release|Win32.ActiveCfg = Release|Any CPU + {8230EA71-1DC2-426A-A820-3B94E1678379}.Release|x64.ActiveCfg = Release|Any CPU + {8230EA71-1DC2-426A-A820-3B94E1678379}.ReleaseNoNet|Any CPU.ActiveCfg = Release|Any CPU + {8230EA71-1DC2-426A-A820-3B94E1678379}.ReleaseNoNet|Any CPU.Build.0 = Release|Any CPU + {8230EA71-1DC2-426A-A820-3B94E1678379}.ReleaseNoNet|Any CPU.Deploy.0 = Release|Any CPU + {8230EA71-1DC2-426A-A820-3B94E1678379}.ReleaseNoNet|Mixed Platforms.ActiveCfg = Release|Any CPU + {8230EA71-1DC2-426A-A820-3B94E1678379}.ReleaseNoNet|Mixed Platforms.Build.0 = Release|Any CPU + {8230EA71-1DC2-426A-A820-3B94E1678379}.ReleaseNoNet|Mixed Platforms.Deploy.0 = Release|Any CPU + {8230EA71-1DC2-426A-A820-3B94E1678379}.ReleaseNoNet|Win32.ActiveCfg = Release|Any CPU + {8230EA71-1DC2-426A-A820-3B94E1678379}.ReleaseNoNet|x64.ActiveCfg = Release|Any CPU + {146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.Debug|Win32.ActiveCfg = Debug|Any CPU + {146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.Debug|x64.ActiveCfg = Debug|Any CPU + {146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.Release|Any CPU.Build.0 = Release|Any CPU + {146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.Release|Win32.ActiveCfg = Release|Any CPU + {146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.Release|x64.ActiveCfg = Release|Any CPU + {146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.ReleaseNoNet|Any CPU.ActiveCfg = Release|Any CPU + {146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.ReleaseNoNet|Any CPU.Build.0 = Release|Any CPU + {146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.ReleaseNoNet|Mixed Platforms.ActiveCfg = Release|Any CPU + {146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.ReleaseNoNet|Mixed Platforms.Build.0 = Release|Any CPU + {146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.ReleaseNoNet|Win32.ActiveCfg = Release|Any CPU + {146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.ReleaseNoNet|x64.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Kp2aBusinessLogic/Io/AndroidContentStorage.cs b/src/Kp2aBusinessLogic/Io/AndroidContentStorage.cs index 86380a1b..d01ae872 100644 --- a/src/Kp2aBusinessLogic/Io/AndroidContentStorage.cs +++ b/src/Kp2aBusinessLogic/Io/AndroidContentStorage.cs @@ -255,6 +255,11 @@ namespace keepass2android.Io } } + + public void ResolveAccount(IOConnectionInfo ioc) + { + + } } class AndroidContentWriteTransaction : IWriteTransaction diff --git a/src/Kp2aBusinessLogic/Io/BuiltInFileStorage.cs b/src/Kp2aBusinessLogic/Io/BuiltInFileStorage.cs index 7481da6f..b3bf4245 100644 --- a/src/Kp2aBusinessLogic/Io/BuiltInFileStorage.cs +++ b/src/Kp2aBusinessLogic/Io/BuiltInFileStorage.cs @@ -395,6 +395,11 @@ namespace keepass2android.Io return false; } + public void ResolveAccount(IOConnectionInfo ioc) + { + + } + private bool IsLocalFileFlaggedReadOnly(IOConnectionInfo ioc) { try diff --git a/src/Kp2aBusinessLogic/Io/CachingFileStorage.cs b/src/Kp2aBusinessLogic/Io/CachingFileStorage.cs index 31d1d0bc..b62a2ccf 100644 --- a/src/Kp2aBusinessLogic/Io/CachingFileStorage.cs +++ b/src/Kp2aBusinessLogic/Io/CachingFileStorage.cs @@ -563,6 +563,11 @@ namespace keepass2android.Io return _cachedStorage.IsReadOnly(ioc, reason); } + public void ResolveAccount(IOConnectionInfo ioc) + { + _cachedStorage.ResolveAccount(ioc); + } + private void StoreFilePath(IOConnectionInfo folderPath, string filename, IOConnectionInfo res) { File.WriteAllText(CachedFilePath(GetPseudoIoc(folderPath, filename)) + ".filepath", res.Path); diff --git a/src/Kp2aBusinessLogic/Io/IFileStorage.cs b/src/Kp2aBusinessLogic/Io/IFileStorage.cs index 31d2b9c1..82f8a486 100644 --- a/src/Kp2aBusinessLogic/Io/IFileStorage.cs +++ b/src/Kp2aBusinessLogic/Io/IFileStorage.cs @@ -177,7 +177,12 @@ namespace keepass2android.Io /// bool IsReadOnly(IOConnectionInfo ioc, OptionalOut reason = null ); - + /// + /// if the ioc.Path contains a string which refers to a stored account (like FTP account with specific settings), + /// this method resolves the path so that it is a path which can be consumed by the file storage "operational" methods (=all other methods) + /// + /// + void ResolveAccount(IOConnectionInfo ioc); } public interface IPermissionRequestingFileStorage diff --git a/src/Kp2aBusinessLogic/Io/JavaFileStorage.cs b/src/Kp2aBusinessLogic/Io/JavaFileStorage.cs index fa584281..1934247a 100644 --- a/src/Kp2aBusinessLogic/Io/JavaFileStorage.cs +++ b/src/Kp2aBusinessLogic/Io/JavaFileStorage.cs @@ -294,6 +294,11 @@ namespace keepass2android.Io return false; //TODO implement. note, however, that we MAY return false even if it's read-only } + public void ResolveAccount(IOConnectionInfo ioc) + { + + } + public void OnCreate(IFileStorageSetupActivity activity, Bundle savedInstanceState) { _jfs.OnCreate(((IJavaFileStorageFileStorageSetupActivity)activity), savedInstanceState); diff --git a/src/Kp2aBusinessLogic/Io/OfflineSwitchableFileStorage.cs b/src/Kp2aBusinessLogic/Io/OfflineSwitchableFileStorage.cs index bf93653e..ba7f9a47 100644 --- a/src/Kp2aBusinessLogic/Io/OfflineSwitchableFileStorage.cs +++ b/src/Kp2aBusinessLogic/Io/OfflineSwitchableFileStorage.cs @@ -181,6 +181,11 @@ namespace keepass2android.Io return _baseStorage.IsReadOnly(ioc, reason); } + public void ResolveAccount(IOConnectionInfo ioc) + { + _baseStorage.ResolveAccount(ioc); + } + public void OnRequestPermissionsResult(IFileStorageSetupActivity fileStorageSetupActivity, int requestCode, string[] permissions, Permission[] grantResults) { diff --git a/src/Kp2aBusinessLogic/Kp2aBusinessLogic.csproj b/src/Kp2aBusinessLogic/Kp2aBusinessLogic.csproj index bc5de5f1..9d43a26a 100644 --- a/src/Kp2aBusinessLogic/Kp2aBusinessLogic.csproj +++ b/src/Kp2aBusinessLogic/Kp2aBusinessLogic.csproj @@ -86,6 +86,7 @@ + @@ -133,6 +134,10 @@ {70D3844A-D9FA-4A64-B205-A84C6A822196} KP2AKdbLibraryBinding + + {146FD497-BA03-4740-B6C5-5C84EA8FCDE2} + System.Net.FtpClient.Android + {5CF675A5-9BEE-4720-BED9-D5BF14A2EBF9} TwofishCipher diff --git a/src/java/KP2ASoftkeyboard_AS/.idea/workspace.xml b/src/java/KP2ASoftkeyboard_AS/.idea/workspace.xml index 2b5ccee1..ced9f3c9 100644 --- a/src/java/KP2ASoftkeyboard_AS/.idea/workspace.xml +++ b/src/java/KP2ASoftkeyboard_AS/.idea/workspace.xml @@ -42,50 +42,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -143,7 +100,7 @@ - + @@ -1520,21 +1477,6 @@ - - - - - - - - - - - @@ -1570,6 +1512,21 @@ + + + + + + + + + + + @@ -1766,26 +1723,26 @@ - - + - + - + + @@ -2131,50 +2088,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -2228,7 +2142,7 @@ - + diff --git a/src/keepass2android/app/App.cs b/src/keepass2android/app/App.cs index 8c9fd14f..5b2ab19e 100644 --- a/src/keepass2android/app/App.cs +++ b/src/keepass2android/app/App.cs @@ -549,20 +549,18 @@ namespace keepass2android switch (validationMode) { case ValidationMode.Ignore: + return (sender, certificate, chain, errors) => true; + case ValidationMode.Warn: return (sender, certificate, chain, errors) => { - ShowToast(Application.Context.GetString(Resource.String.CertificateWarning, + if (errors != SslPolicyErrors.None) + ShowToast(Application.Context.GetString(Resource.String.CertificateWarning, new Java.Lang.Object[] { errors.ToString() })); return true; }; - case ValidationMode.Warn: - return (sender, certificate, chain, errors) => - { - return true; - }; case ValidationMode.Error: return (sender, certificate, chain, errors) => diff --git a/src/keepass2android/fileselect/FileDbHelper.cs b/src/keepass2android/fileselect/FileDbHelper.cs index d002e6d0..a4af70bb 100644 --- a/src/keepass2android/fileselect/FileDbHelper.cs +++ b/src/keepass2android/fileselect/FileDbHelper.cs @@ -273,7 +273,7 @@ namespace keepass2android return null; var ioc = new IOConnectionInfo { - Path = cursor.GetString(cursor + Path = cursor.GetString(cursor .GetColumnIndexOrThrow(KeyFileFilename)), UserName = cursor.GetString(cursor .GetColumnIndexOrThrow(KeyFileUsername)), @@ -284,7 +284,10 @@ namespace keepass2android CredProtMode = IOCredProtMode.Obf }; - ioc.Obfuscate(false); + ioc.Obfuscate(false); + + App.Kp2a.GetFileStorage(ioc).ResolveAccount(ioc); + return ioc; } } diff --git a/src/keepass2android/fileselect/FileSelectActivity.cs b/src/keepass2android/fileselect/FileSelectActivity.cs index a29b084c..6dba61e8 100644 --- a/src/keepass2android/fileselect/FileSelectActivity.cs +++ b/src/keepass2android/fileselect/FileSelectActivity.cs @@ -218,7 +218,9 @@ namespace keepass2android String path = cursor.GetString(columnIndex); TextView textView = (TextView)view; IOConnectionInfo ioc = new IOConnectionInfo {Path = path}; - textView.Text = _app.GetFileStorage(ioc).GetDisplayName(ioc); + var fileStorage = _app.GetFileStorage(ioc); + fileStorage.ResolveAccount(ioc); + textView.Text = fileStorage.GetDisplayName(ioc); textView.Tag = ioc.Path; return true; } diff --git a/src/netftpandroid b/src/netftpandroid new file mode 160000 index 00000000..961c8718 --- /dev/null +++ b/src/netftpandroid @@ -0,0 +1 @@ +Subproject commit 961c87189241f38332a2dc0564eacf8bddfd37a6