diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/Info.plist b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/Info.plist index 8bc61f1..31c765e 100644 --- a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/Info.plist +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/Info.plist @@ -27,7 +27,7 @@ CFBundleIdentifier nl.resoftware.pocketgraph CFBundleVersion - 1.0.1 + 1.0.2 UILaunchStoryboardName LaunchScreen CFBundleName diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/Security/NativeTrustManager.cs b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/Security/NativeTrustManager.cs new file mode 100644 index 0000000..1114d7d --- /dev/null +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/Security/NativeTrustManager.cs @@ -0,0 +1,34 @@ +// +// NativeTrustManager.cs +// +// Trevi Awater +// 14-03-2022 +// +// © Xamarin.Neo4j.iOS +// + +using System; +using System.Net.Security; +using System.Security.Cryptography.X509Certificates; +using Neo4j.Driver; +using Security; + +namespace Xamarin.Neo4j +{ + public class NativeTrustManager : TrustManager + { + public override bool ValidateServerCertificate(Uri uri, X509Certificate2 certificate, X509Chain chain, + SslPolicyErrors sslPolicyErrors) + { + using (var cert = new SecCertificate(certificate)) + using (var policy = SecPolicy.CreateSslPolicy(true, uri.Host)) + using (var trustHandler = new SecTrust(cert, policy)) + { + if (!trustHandler.Evaluate(out var error)) + throw new Exception(error.ToString()); + + return true; + } + } + } +} diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/Services/TrustManagerService.cs b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/Services/TrustManagerService.cs new file mode 100644 index 0000000..f33d843 --- /dev/null +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/Services/TrustManagerService.cs @@ -0,0 +1,25 @@ +// +// TrustManagerService.cs +// +// Trevi Awater +// 14-03-2022 +// +// © Xamarin.Neo4j.iOS +// + +using Neo4j.Driver; +using Xamarin.Forms; +using Xamarin.Neo4j.iOS.Services; +using Xamarin.Neo4j.Services; + +[assembly: Dependency(typeof(TrustManagerService))] +namespace Xamarin.Neo4j.iOS.Services +{ + public class TrustManagerService : ITrustManagerService + { + public TrustManager GetNativeTrustManager() + { + return new NativeTrustManager(); + } + } +} diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/Xamarin.Neo4j.iOS.csproj b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/Xamarin.Neo4j.iOS.csproj index 0ac2af9..0257bc3 100644 --- a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/Xamarin.Neo4j.iOS.csproj +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/Xamarin.Neo4j.iOS.csproj @@ -97,7 +97,9 @@ + + diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Controls/LicenseCell.xaml b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Controls/LicenseCell.xaml new file mode 100644 index 0000000..719e28d --- /dev/null +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Controls/LicenseCell.xaml @@ -0,0 +1,13 @@ + + + + + + + + diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Controls/LicenseCell.xaml.cs b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Controls/LicenseCell.xaml.cs new file mode 100644 index 0000000..6f1dc36 --- /dev/null +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Controls/LicenseCell.xaml.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using Xamarin.Forms; +using Xamarin.Forms.Xaml; + +namespace Xamarin.Neo4j.Controls +{ + [XamlCompilation(XamlCompilationOptions.Compile)] + public partial class LicenseCell : ViewCell + { + public LicenseCell() + { + InitializeComponent(); + } + } +} diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Controls/QueryResultView.xaml.cs b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Controls/QueryResultView.xaml.cs index 9590d1f..8c312aa 100644 --- a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Controls/QueryResultView.xaml.cs +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Controls/QueryResultView.xaml.cs @@ -52,14 +52,16 @@ namespace Xamarin.Neo4j.Controls using (var stream = assembly.GetManifestResourceStream(resourceName)) using (var reader = new StreamReader(stream)) { + var (url, isEncrypted, ignoreTrust) = QueryResult.ConnectionString.ParseHost(); + var result = reader.ReadToEnd(); - result = result.Replace("{{host}}", QueryResult.ConnectionString.Host); - result = result.Replace("{{port}}", QueryResult.ConnectionString.Port.ToString()); + result = result.Replace("{{host}}", url); result = result.Replace("{{database}}", QueryResult.ConnectionString.Database); result = result.Replace("{{username}}", QueryResult.ConnectionString.Username); result = result.Replace("{{password}}", QueryResult.ConnectionString.Password); - result = result.Replace("{{encryption}}", QueryResult.ConnectionString.Encrypted ? "ENCRYPTION_ON" : "ENCRYPTION_OFF"); + result = result.Replace("{{encryption}}", isEncrypted ? "ENCRYPTION_ON" : "ENCRYPTION_OFF"); + result = result.Replace("{{trust}}", ignoreTrust ? "TRUST_ALL_CERTIFICATES" : "TRUST_SYSTEM_CA_SIGNED_CERTIFICATES"); result = result.Replace("{{query}}", QueryResult.Query); result = result.Replace("{{backgroundColor}}", App.Current.RequestedTheme == OSAppTheme.Dark ? "#292C31" : "#FFFFFF"); diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Models/License.cs b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Models/License.cs new file mode 100644 index 0000000..7467dd9 --- /dev/null +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Models/License.cs @@ -0,0 +1,30 @@ +// +// License.cs +// +// Trevi Awater +// 15-03-2022 +// +// © Xamarin.Neo4j +// + +using System; +using System.Windows.Input; +using Xamarin.Essentials; +using Xamarin.Forms; + +namespace Xamarin.Neo4j.Models +{ + public class License + { + public string Name { get; set; } + + public string Repo { get; set; } + + public string LicenseText { get; set; } + + /// + /// Opens the repository in the browser. + /// + public ICommand OpenRepo => new Command(() => Launcher.OpenAsync(new Uri(Repo))); + } +} diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Models/Neo4jConnectionString.cs b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Models/Neo4jConnectionString.cs index f75bb61..3c79839 100644 --- a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Models/Neo4jConnectionString.cs +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Models/Neo4jConnectionString.cs @@ -21,12 +21,25 @@ namespace Xamarin.Neo4j.Models public string Host { get; set; } - public int Port { get; set; } - public string Username { get; set; } public string Password { get; set; } - public bool Encrypted { get; set; } + public Tuple ParseHost() + { + if (Host.StartsWith("neo4j://")) + return new Tuple(Host, false, false); + + if (Host.StartsWith("bolt://")) + return new Tuple(Host.Replace("bolt://", "neo4j://"), false, false); + + if (Host.StartsWith("neo4j+s://")) + return new Tuple(Host.Replace("neo4j+s://", "neo4j://"), true, false); + + if (Host.StartsWith("neo4j+ssc://")) + return new Tuple(Host.Replace("neo4j+ssc://", "neo4j://"), true, true); + + throw new NotSupportedException("Unknown protocol."); + } } } diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Pages/AddConnectionPage.xaml b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Pages/AddConnectionPage.xaml index 91c11d7..563b8e7 100644 --- a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Pages/AddConnectionPage.xaml +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Pages/AddConnectionPage.xaml @@ -12,16 +12,6 @@ - - - - - - diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Resources/licenses.json b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Resources/licenses.json new file mode 100644 index 0000000..10f2304 --- /dev/null +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Resources/licenses.json @@ -0,0 +1,43 @@ +[ + { + "Name": "Xamarin.Forms", + "Repo": "https://github.com/xamarin/Xamarin.Forms", + "LicenseText": "MIT License (MIT)\n\nCopyright (c) .NET Foundation Contributors\n\nAll rights reserved.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE." + }, + + { + "Name": "Json.NET", + "Repo": "https://github.com/JamesNK/Newtonsoft.Json", + "LicenseText": "The MIT License (MIT)\n\nCopyright (c) 2007 James Newton-King\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE." + }, + + { + "Name": "Neovis.js", + "Repo": "https://github.com/neo4j-contrib/neovis.js", + "LicenseText": "Apache License\r\nVersion 2.0, January 2004\r\nhttp:\/\/www.apache.org\/licenses\/\r\n\r\nTERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r\n\r\n1. Definitions.\r\n\r\n\"License\" shall mean the terms and conditions for use, reproduction,\r\nand distribution as defined by Sections 1 through 9 of this document.\r\n\r\n\"Licensor\" shall mean the copyright owner or entity authorized by\r\nthe copyright owner that is granting the License.\r\n\r\n\"Legal Entity\" shall mean the union of the acting entity and all\r\nother entities that control, are controlled by, or are under common\r\ncontrol with that entity. For the purposes of this definition,\r\n\"control\" means (i) the power, direct or indirect, to cause the\r\ndirection or management of such entity, whether by contract or\r\notherwise, or (ii) ownership of fifty percent (50%) or more of the\r\noutstanding shares, or (iii) beneficial ownership of such entity.\r\n\r\n\"You\" (or \"Your\") shall mean an individual or Legal Entity\r\nexercising permissions granted by this License.\r\n\r\n\"Source\" form shall mean the preferred form for making modifications,\r\nincluding but not limited to software source code, documentation\r\nsource, and configuration files.\r\n\r\n\"Object\" form shall mean any form resulting from mechanical\r\ntransformation or translation of a Source form, including but\r\nnot limited to compiled object code, generated documentation,\r\nand conversions to other media types.\r\n\r\n\"Work\" shall mean the work of authorship, whether in Source or\r\nObject form, made available under the License, as indicated by a\r\ncopyright notice that is included in or attached to the work\r\n(an example is provided in the Appendix below).\r\n\r\n\"Derivative Works\" shall mean any work, whether in Source or Object\r\nform, that is based on (or derived from) the Work and for which the\r\neditorial revisions, annotations, elaborations, or other modifications\r\nrepresent, as a whole, an original work of authorship. For the purposes\r\nof this License, Derivative Works shall not include works that remain\r\nseparable from, or merely link (or bind by name) to the interfaces of,\r\nthe Work and Derivative Works thereof.\r\n\r\n\"Contribution\" shall mean any work of authorship, including\r\nthe original version of the Work and any modifications or additions\r\nto that Work or Derivative Works thereof, that is intentionally\r\nsubmitted to Licensor for inclusion in the Work by the copyright owner\r\nor by an individual or Legal Entity authorized to submit on behalf of\r\nthe copyright owner. For the purposes of this definition, \"submitted\"\r\nmeans any form of electronic, verbal, or written communication sent\r\nto the Licensor or its representatives, including but not limited to\r\ncommunication on electronic mailing lists, source code control systems,\r\nand issue tracking systems that are managed by, or on behalf of, the\r\nLicensor for the purpose of discussing and improving the Work, but\r\nexcluding communication that is conspicuously marked or otherwise\r\ndesignated in writing by the copyright owner as \"Not a Contribution.\"\r\n\r\n\"Contributor\" shall mean Licensor and any individual or Legal Entity\r\non behalf of whom a Contribution has been received by Licensor and\r\nsubsequently incorporated within the Work.\r\n\r\n2. Grant of Copyright License. Subject to the terms and conditions of\r\nthis License, each Contributor hereby grants to You a perpetual,\r\nworldwide, non-exclusive, no-charge, royalty-free, irrevocable\r\ncopyright license to reproduce, prepare Derivative Works of,\r\npublicly display, publicly perform, sublicense, and distribute the\r\nWork and such Derivative Works in Source or Object form.\r\n\r\n3. Grant of Patent License. Subject to the terms and conditions of\r\nthis License, each Contributor hereby grants to You a perpetual,\r\nworldwide, non-exclusive, no-charge, royalty-free, irrevocable\r\n(except as stated in this section) patent license to make, have made,\r\nuse, offer to sell, sell, import, and otherwise transfer the Work,\r\nwhere such license applies only to those patent claims licensable\r\nby such Contributor that are necessarily infringed by their\r\nContribution(s) alone or by combination of their Contribution(s)\r\nwith the Work to which such Contribution(s) was submitted. If You\r\ninstitute patent litigation against any entity (including a\r\ncross-claim or counterclaim in a lawsuit) alleging that the Work\r\nor a Contribution incorporated within the Work constitutes direct\r\nor contributory patent infringement, then any patent licenses\r\ngranted to You under this License for that Work shall terminate\r\nas of the date such litigation is filed.\r\n\r\n4. Redistribution. You may reproduce and distribute copies of the\r\nWork or Derivative Works thereof in any medium, with or without\r\nmodifications, and in Source or Object form, provided that You\r\nmeet the following conditions:\r\n\r\n(a) You must give any other recipients of the Work or\r\nDerivative Works a copy of this License; and\r\n\r\n(b) You must cause any modified files to carry prominent notices\r\nstating that You changed the files; and\r\n\r\n(c) You must retain, in the Source form of any Derivative Works\r\nthat You distribute, all copyright, patent, trademark, and\r\nattribution notices from the Source form of the Work,\r\nexcluding those notices that do not pertain to any part of\r\nthe Derivative Works; and\r\n\r\n(d) If the Work includes a \"NOTICE\" text file as part of its\r\ndistribution, then any Derivative Works that You distribute must\r\ninclude a readable copy of the attribution notices contained\r\nwithin such NOTICE file, excluding those notices that do not\r\npertain to any part of the Derivative Works, in at least one\r\nof the following places: within a NOTICE text file distributed\r\nas part of the Derivative Works; within the Source form or\r\ndocumentation, if provided along with the Derivative Works; or,\r\nwithin a display generated by the Derivative Works, if and\r\nwherever such third-party notices normally appear. The contents\r\nof the NOTICE file are for informational purposes only and\r\ndo not modify the License. You may add Your own attribution\r\nnotices within Derivative Works that You distribute, alongside\r\nor as an addendum to the NOTICE text from the Work, provided\r\nthat such additional attribution notices cannot be construed\r\nas modifying the License.\r\n\r\nYou may add Your own copyright statement to Your modifications and\r\nmay provide additional or different license terms and conditions\r\nfor use, reproduction, or distribution of Your modifications, or\r\nfor any such Derivative Works as a whole, provided Your use,\r\nreproduction, and distribution of the Work otherwise complies with\r\nthe conditions stated in this License.\r\n\r\n5. Submission of Contributions. Unless You explicitly state otherwise,\r\nany Contribution intentionally submitted for inclusion in the Work\r\nby You to the Licensor shall be under the terms and conditions of\r\nthis License, without any additional terms or conditions.\r\nNotwithstanding the above, nothing herein shall supersede or modify\r\nthe terms of any separate license agreement you may have executed\r\nwith Licensor regarding such Contributions.\r\n\r\n6. Trademarks. This License does not grant permission to use the trade\r\nnames, trademarks, service marks, or product names of the Licensor,\r\nexcept as required for reasonable and customary use in describing the\r\norigin of the Work and reproducing the content of the NOTICE file.\r\n\r\n7. Disclaimer of Warranty. Unless required by applicable law or\r\nagreed to in writing, Licensor provides the Work (and each\r\nContributor provides its Contributions) on an \"AS IS\" BASIS,\r\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r\nimplied, including, without limitation, any warranties or conditions\r\nof TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r\nPARTICULAR PURPOSE. You are solely responsible for determining the\r\nappropriateness of using or redistributing the Work and assume any\r\nrisks associated with Your exercise of permissions under this License.\r\n\r\n8. Limitation of Liability. In no event and under no legal theory,\r\nwhether in tort (including negligence), contract, or otherwise,\r\nunless required by applicable law (such as deliberate and grossly\r\nnegligent acts) or agreed to in writing, shall any Contributor be\r\nliable to You for damages, including any direct, indirect, special,\r\nincidental, or consequential damages of any character arising as a\r\nresult of this License or out of the use or inability to use the\r\nWork (including but not limited to damages for loss of goodwill,\r\nwork stoppage, computer failure or malfunction, or any and all\r\nother commercial damages or losses), even if such Contributor\r\nhas been advised of the possibility of such damages.\r\n\r\n9. Accepting Warranty or Additional Liability. While redistributing\r\nthe Work or Derivative Works thereof, You may choose to offer,\r\nand charge a fee for, acceptance of support, warranty, indemnity,\r\nor other liability obligations and\/or rights consistent with this\r\nLicense. However, in accepting such obligations, You may act only\r\non Your own behalf and on Your sole responsibility, not on behalf\r\nof any other Contributor, and only if You agree to indemnify,\r\ndefend, and hold each Contributor harmless for any liability\r\nincurred by, or claims asserted against, such Contributor by reason\r\nof your accepting any such warranty or additional liability.\r\n\r\nEND OF TERMS AND CONDITIONS\r\n\r\nAPPENDIX: How to apply the Apache License to your work.\r\n\r\nTo apply the Apache License to your work, attach the following\r\nboilerplate notice, with the fields enclosed by brackets \"{}\"\r\nreplaced with your own identifying information. (Don't include\r\nthe brackets!) The text should be enclosed in the appropriate\r\ncomment syntax for the file format. We also recommend that a\r\nfile or class name and description of purpose be included on the\r\nsame \"printed page\" as the copyright notice for easier\r\nidentification within third-party archives.\r\n\r\nCopyright {yyyy} {name of copyright owner}\r\n\r\nLicensed under the Apache License, Version 2.0 (the \"License\");\r\nyou may not use this file except in compliance with the License.\r\nYou may obtain a copy of the License at\r\n\r\nhttp:\/\/www.apache.org\/licenses\/LICENSE-2.0\r\n\r\nUnless required by applicable law or agreed to in writing, software\r\ndistributed under the License is distributed on an \"AS IS\" BASIS,\r\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\nSee the License for the specific language governing permissions and\r\nlimitations under the License.\r\n" + }, + + { + "Name": "Neo4jClient", + "Repo": "https://github.com/DotNet4Neo4j/Neo4jClient", + "LicenseText": "http://www.opensource.org/licenses/MS-PL\r\n\r\nMicrosoft Public License (MS-PL)\r\n\r\nThis license governs use of the accompanying software. If you use the software, you\r\naccept this license. If you do not accept the license, do not use the software.\r\n\r\n1. Definitions\r\nThe terms \"reproduce,\" \"reproduction,\" \"derivative works,\" and \"distribution\" have the\r\nsame meaning here as under U.S. copyright law.\r\nA \"contribution\" is the original software, or any additions or changes to the software.\r\nA \"contributor\" is any person that distributes its contribution under this license.\r\n\"Licensed patents\" are a contributor's patent claims that read directly on its contribution.\r\n\r\n2. Grant of Rights\r\n(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.\r\n(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.\r\n\r\n3. Conditions and Limitations\r\n(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.\r\n(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically.\r\n(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software.\r\n(D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license.\r\n(E) The software is licensed \"as-is.\" You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement." + }, + + { + "Name": "Acr.UserDialogs", + "Repo": "https://github.com/aritchie/userdialogs", + "LicenseText": "The MIT License (MIT) Copyright (c) 2016 Allan Ritchie\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE." + }, + + { + "Name": "Xamarin.Essentials", + "Repo": "https://github.com/xamarin/Essentials", + "LicenseText": "Xamarin.Essentials\r\n\r\nThe MIT License (MIT)\r\n\r\nCopyright (c) Microsoft Corporation\r\n\r\nAll rights reserved.\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\nSOFTWARE." + }, + + { + "Name": "Xamarin.Forms.PancakeView", + "Repo": "https://github.com/sthewissen/Xamarin.Forms.PancakeView", + "LicenseText": "MIT License\r\n\r\nCopyright (c) 2019 Steven Thewissen\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\nSOFTWARE." + } +] diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Services/Interfaces/ITrustManagerService.cs b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Services/Interfaces/ITrustManagerService.cs new file mode 100644 index 0000000..9731507 --- /dev/null +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Services/Interfaces/ITrustManagerService.cs @@ -0,0 +1,9 @@ +using Neo4j.Driver; + +namespace Xamarin.Neo4j.Services +{ + public interface ITrustManagerService + { + TrustManager GetNativeTrustManager(); + } +} diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Services/Neo4jService.cs b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Services/Neo4jService.cs index c61468b..56e369b 100644 --- a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Services/Neo4jService.cs +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Services/Neo4jService.cs @@ -16,26 +16,37 @@ using Neo4jClient.Cypher; using Xamarin.Forms; using Xamarin.Neo4j.Models; using Xamarin.Neo4j.Services; + [assembly: Dependency(typeof(Neo4jService))] + namespace Xamarin.Neo4j.Services { public class Neo4jService { + private readonly TrustManager _nativeTrustManager; + + public Neo4jService() + { + var trustManagerService = DependencyService.Get(); + + _nativeTrustManager = trustManagerService.GetNativeTrustManager(); + } + private BoltGraphClient GraphClient { get; set; } public async Task EstablishConnection(Neo4jConnectionString connectionString) { try { - var boltUri = $"bolt://{connectionString.Host}:{connectionString.Port}"; + var (url, isEncrypted, ignoreTrust) = connectionString.ParseHost(); - var driver = GraphDatabase.Driver(boltUri, - AuthTokens.Basic(connectionString.Username, connectionString.Password), - builder => + var driver = GraphDatabase.Driver(url, + AuthTokens.Basic(connectionString.Username, connectionString.Password), (config) => { - builder.WithEncryptionLevel(connectionString.Encrypted - ? EncryptionLevel.Encrypted - : EncryptionLevel.None); + config.WithEncryptionLevel(isEncrypted ? EncryptionLevel.Encrypted : EncryptionLevel.None); + + if (!ignoreTrust && Device.RuntimePlatform == Device.iOS) + config.WithTrustManager(_nativeTrustManager); }); GraphClient = new BoltGraphClient(driver); @@ -102,7 +113,7 @@ namespace Xamarin.Neo4j.Services if (results.ContainsKey(key) == false) results.Add(key, new List()); - foreach (var record in cursor.Current.Values) + foreach (var record in cursor.Current.Values) { var value = record.Value; diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/ViewModels/AddConnectionViewModel.cs b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/ViewModels/AddConnectionViewModel.cs index 62758f9..debb531 100644 --- a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/ViewModels/AddConnectionViewModel.cs +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/ViewModels/AddConnectionViewModel.cs @@ -25,12 +25,8 @@ namespace Xamarin.Neo4j.ViewModels { public class AddConnectionViewModel : ViewModelBase, INotifyPropertyChanged { - private bool _encrypted; - private string _host, _username, _password; - private int _port; - private readonly Neo4jService _neo4jService; public event PropertyChangedEventHandler PropertyChanged; @@ -83,7 +79,6 @@ namespace Xamarin.Neo4j.ViewModels private void InitializeDefaultValues() { Username = "neo4j"; - Port = 7687; } [NotifyPropertyChangedInvocator] @@ -98,27 +93,13 @@ namespace Xamarin.Neo4j.ViewModels { Id = Guid.NewGuid(), Host = Host, - Port = Port, Username = Username, - Password = Password, - Encrypted = Encrypted + Password = Password }; } #region Bindable Properties - public bool Encrypted - { - get => _encrypted; - - set - { - _encrypted = value; - - OnPropertyChanged(nameof(Encrypted)); - } - } - public string Host { get => _host; @@ -131,18 +112,6 @@ namespace Xamarin.Neo4j.ViewModels } } - public int Port - { - get => _port; - - set - { - _port = value; - - OnPropertyChanged(nameof(Port)); - } - } - public string Username { get => _username; diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/ViewModels/LicensesViewModel.cs b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/ViewModels/LicensesViewModel.cs new file mode 100644 index 0000000..d617f97 --- /dev/null +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/ViewModels/LicensesViewModel.cs @@ -0,0 +1,66 @@ +// +// LicensesViewModel.cs +// +// Trevi Awater +// 15-03-2022 +// +// © Xamarin.Neo4j +// + +using System.Collections.Generic; +using System.ComponentModel; +using System.IO; +using System.Reflection; +using System.Runtime.CompilerServices; +using Newtonsoft.Json; +using Xamarin.Forms; +using Xamarin.Neo4j.Annotations; +using License = Xamarin.Neo4j.Models.License; + +namespace Xamarin.Neo4j.ViewModels +{ + public class LicensesViewModel : ViewModelBase, INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + private List _licenses; + + public LicensesViewModel(INavigation navigation) : base(navigation) + { + LoadLicenses(); + } + + private void LoadLicenses() + { + var assembly = GetType().GetTypeInfo().Assembly; + + string licenseFile = $"Xamarin.Neo4j.Resources.licenses.json"; + + using (var stream = assembly.GetManifestResourceStream(licenseFile)) + using (var reader = new StreamReader(stream)) + Licenses = JsonConvert.DeserializeObject>(reader.ReadToEnd()); + } + + [NotifyPropertyChangedInvocator] + protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + + #region Bindable Properties + + public List Licenses + { + get => _licenses; + + set + { + _licenses = value; + + OnPropertyChanged(); + } + } + + #endregion + } +} diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/ViewModels/SessionViewModel.cs b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/ViewModels/SessionViewModel.cs index 0165caa..1493235 100644 --- a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/ViewModels/SessionViewModel.cs +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/ViewModels/SessionViewModel.cs @@ -55,6 +55,9 @@ namespace Xamarin.Neo4j.ViewModels Commands.Add("ExecuteQuery", new Command(async () => { + if (CanExecuteQuery == false) + return; + _connectionString.Database = CurrentDatabase.Name; var result = await _neo4jService.ExecuteQuery(Query, _connectionString); @@ -149,6 +152,8 @@ namespace Xamarin.Neo4j.ViewModels } } + public bool CanExecuteQuery => !string.IsNullOrWhiteSpace(Query) && CurrentDatabase != null; + #endregion } } diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/ViewModels/SettingsViewModel.cs b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/ViewModels/SettingsViewModel.cs index 43602c5..0dfe4e1 100644 --- a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/ViewModels/SettingsViewModel.cs +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/ViewModels/SettingsViewModel.cs @@ -13,6 +13,7 @@ using System.Runtime.CompilerServices; using Xamarin.Essentials; using Xamarin.Forms; using Xamarin.Neo4j.Annotations; +using Xamarin.Neo4j.Pages; namespace Xamarin.Neo4j.ViewModels { @@ -26,6 +27,11 @@ namespace Xamarin.Neo4j.ViewModels { await Launcher.OpenAsync(new Uri("https://resoftware.nl/")); })); + + Commands.Add("OpenLicensesPage", new Command(async () => + { + await Navigation.PushAsync(new LicensesPage()); + })); } [NotifyPropertyChangedInvocator] diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Visualization/neovis.html b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Visualization/neovis.html index 8936e6b..00c006b 100644 --- a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Visualization/neovis.html +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Visualization/neovis.html @@ -30,11 +30,12 @@ function draw() { const config = { container_id: "viz", - server_url: `bolt://{{host}}:{{port}}`, + server_url: `{{host}}`, server_user: `{{username}}`, server_database: `{{database}}`, server_password: `{{password}}`, encrypted: `{{encryption}}`, + trust: `{{trust}}`, initial_cypher: `{{query}}` }; diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.csproj b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.csproj index 32c2974..a9398f6 100644 --- a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.csproj +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.csproj @@ -21,5 +21,7 @@ + + \ No newline at end of file