mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
Compare commits
207 Commits
v1.76Alpha
...
v1.76.8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f10e54e47b | ||
|
|
704e0c1dc1 | ||
|
|
0c79a9acde | ||
|
|
ebfc2715e7 | ||
|
|
b0dbc9dc18 | ||
|
|
507cdf75a5 | ||
|
|
8f8492b0be | ||
|
|
457e715188 | ||
|
|
1724521ebf | ||
|
|
b0fb3596aa | ||
|
|
fb228d72b1 | ||
|
|
916361a3be | ||
|
|
408c40f699 | ||
|
|
4173f6d775 | ||
|
|
e6f3c22064 | ||
|
|
a013518eac | ||
|
|
9c88cacb3d | ||
|
|
d49bf04b15 | ||
|
|
1dbd5dc5bc | ||
|
|
c103706a54 | ||
|
|
b0a027df52 | ||
|
|
868641378a | ||
|
|
11baae3107 | ||
|
|
ed8125042e | ||
|
|
25b2655d0f | ||
|
|
145a264154 | ||
|
|
3e33170ae0 | ||
|
|
d18bf68f0e | ||
|
|
368917e108 | ||
|
|
cdea4c3911 | ||
|
|
b4b9b55bbf | ||
|
|
6092c63df4 | ||
|
|
fda5132184 | ||
|
|
6a9fb25a18 | ||
|
|
18d7344690 | ||
|
|
ba50cf20a0 | ||
|
|
7bd6e126e2 | ||
|
|
f7521c81d5 | ||
|
|
f483a2dc2f | ||
|
|
9769d5af06 | ||
|
|
0a2dc3563e | ||
|
|
e9f0157b2b | ||
|
|
e8e566fcdd | ||
|
|
72b7d22cef | ||
|
|
f79da476fd | ||
|
|
ef31b7844c | ||
|
|
f1ed1bf115 | ||
|
|
23ea028965 | ||
|
|
42046a614f | ||
|
|
36055f56e6 | ||
|
|
b693cb30fc | ||
|
|
20377d4ff5 | ||
|
|
570d732b0e | ||
|
|
d9d2b1de70 | ||
|
|
0a7eaaf36f | ||
|
|
36dd3e496d | ||
|
|
83fd914d7b | ||
|
|
281c6b13fa | ||
|
|
00b7b1221c | ||
|
|
56cbf0ff3f | ||
|
|
f852a4d341 | ||
|
|
7c8c7d482a | ||
|
|
9e95ae2cb0 | ||
|
|
0d2d935f17 | ||
|
|
eeb320a825 | ||
|
|
9452d4dbe3 | ||
|
|
03d2387cdd | ||
|
|
61b325ccb9 | ||
|
|
e57de9a4de | ||
|
|
96946f3a1e | ||
|
|
8cd6fb7ae2 | ||
|
|
a5afa90790 | ||
|
|
f634eb8d37 | ||
|
|
694b61a67b | ||
|
|
88f0d00a15 | ||
|
|
e31088fd2e | ||
|
|
1d7bb63710 | ||
|
|
af1ed5349f | ||
|
|
9dcf71dc31 | ||
|
|
8bf9af0ed8 | ||
|
|
aecfad5871 | ||
|
|
3edd155898 | ||
|
|
2c419c0b2e | ||
|
|
2fb67e7042 | ||
|
|
29483b2625 | ||
|
|
7fc59e79f3 | ||
|
|
79b3e21148 | ||
|
|
ee91117010 | ||
|
|
0548037ff3 | ||
|
|
46002632bb | ||
|
|
9659ac1611 | ||
|
|
bbc497e68d | ||
|
|
d7ec7574ad | ||
|
|
2f476d9e61 | ||
|
|
c74f37f0de | ||
|
|
d27a62cbfc | ||
|
|
8029e491a3 | ||
|
|
fe56268421 | ||
|
|
2db6fabbe9 | ||
|
|
035e89801a | ||
|
|
3bdcf655fd | ||
|
|
284755f298 | ||
|
|
ad5eed96e7 | ||
|
|
431c830ea0 | ||
|
|
da047427a5 | ||
|
|
69da1dca5f | ||
|
|
cc61501f63 | ||
|
|
4ced2d3392 | ||
|
|
7c72bfdf6b | ||
|
|
b8878e1458 | ||
|
|
abd40cec1b | ||
|
|
cc18da4f28 | ||
|
|
1a39039162 | ||
|
|
cf9dd72ea5 | ||
|
|
b7cdf81665 | ||
|
|
8497a05fd1 | ||
|
|
7db4eec45c | ||
|
|
cd822b545a | ||
|
|
e872581d3c | ||
|
|
defe9e094c | ||
|
|
5662735cb8 | ||
|
|
8646dce21b | ||
|
|
99a3eabbaf | ||
|
|
c57bd386f2 | ||
|
|
f2a52b03df | ||
|
|
860e1ccfaa | ||
|
|
49967b38d4 | ||
|
|
36038fff6d | ||
|
|
c5958954b0 | ||
|
|
d0d63016ca | ||
|
|
35f2484adf | ||
|
|
c2cf496ded | ||
|
|
8a172f02a9 | ||
|
|
f27935ea61 | ||
|
|
043df0aec3 | ||
|
|
63a2e18760 | ||
|
|
c3ced7ed03 | ||
|
|
f597e14b3d | ||
|
|
aff4ba9115 | ||
|
|
554e0805e3 | ||
|
|
f4efa74a23 | ||
|
|
ddc19587fa | ||
|
|
5f1232727e | ||
|
|
9c373e8f0a | ||
|
|
83942d788f | ||
|
|
73d6fec6f3 | ||
|
|
a37b5deaa1 | ||
|
|
3b9de847e7 | ||
|
|
924f1f1e48 | ||
|
|
7bdebbe25b | ||
|
|
8f46c25dc9 | ||
|
|
8bb4a03639 | ||
|
|
7b5bc5e057 | ||
|
|
35582a5e6a | ||
|
|
20340fd31f | ||
|
|
d6d7664b48 | ||
|
|
ce97e63876 | ||
|
|
378b98ff89 | ||
|
|
ce31199e57 | ||
|
|
227f3b2924 | ||
|
|
5076f1354c | ||
|
|
e5a34388ae | ||
|
|
6a5f65c018 | ||
|
|
6d5f41b3d8 | ||
|
|
64f10ead63 | ||
|
|
575dae446f | ||
|
|
9b438576f2 | ||
|
|
cbd32f1a07 | ||
|
|
516182ec40 | ||
|
|
4ad3a68d80 | ||
|
|
2f9ba32c07 | ||
|
|
dfc45a2904 | ||
|
|
563fdffb67 | ||
|
|
f2e9c5e2c0 | ||
|
|
86a591364c | ||
|
|
2a82485f81 | ||
|
|
e13549d361 | ||
|
|
a85c1bd7d3 | ||
|
|
946679f490 | ||
|
|
b6f27eac18 | ||
|
|
2cc82145a3 | ||
|
|
2dae0f2d8e | ||
|
|
412f6edc36 | ||
|
|
764791b8e5 | ||
|
|
bd20d6ae7d | ||
|
|
8db0bf7bea | ||
|
|
cff6aa72fc | ||
|
|
63ddf06057 | ||
|
|
3d9d57b7fa | ||
|
|
2c1734aea6 | ||
|
|
301c39aad0 | ||
|
|
5be346c89d | ||
|
|
e4eaf0037e | ||
|
|
8f97be82cb | ||
|
|
4ab7f92b82 | ||
|
|
0ec95a7729 | ||
|
|
98c38716cd | ||
|
|
6a46df780c | ||
|
|
7788198f26 | ||
|
|
3010963283 | ||
|
|
6522524c0f | ||
|
|
160434c114 | ||
|
|
36acb9ac12 | ||
|
|
ddbf6a2e7a | ||
|
|
8567e912a3 | ||
|
|
7c98f2809c | ||
|
|
0898ed8c00 |
38
.github/ISSUE_TEMPLATE.md
vendored
38
.github/ISSUE_TEMPLATE.md
vendored
@@ -1,16 +1,30 @@
|
||||
<!--
|
||||
Only file GitHub issues for bugs and feature requests. All other topics will be closed.
|
||||
<!--- Provide a general summary of the issue in the Title above -->
|
||||
|
||||
Before opening an issue, please search for a duplicate or closed issue.
|
||||
Please provide as much detail as possible for us to fix your issue.
|
||||
-->
|
||||
## Expected Behavior
|
||||
<!--- If you're describing a bug, tell us what should happen -->
|
||||
<!--- If you're suggesting a change/improvement, tell us how it should work -->
|
||||
|
||||
<!-- Bug -->
|
||||
|Detail|Value|
|
||||
|--:|---|
|
||||
|Operating system | Windows 10 x64 |
|
||||
|mRemoteNG version| 1.75.7008 |
|
||||
## Current Behavior
|
||||
<!--- If describing a bug, tell us what happens instead of the expected behavior -->
|
||||
<!--- If suggesting a change/improvement, explain the difference from current behavior -->
|
||||
|
||||
## Possible Solution
|
||||
<!--- Not obligatory, but suggest a fix/reason for the bug, -->
|
||||
<!--- or ideas how to implement the addition or change -->
|
||||
|
||||
<!-- Feature Request -->
|
||||
<!-- If you file a feature request, please delete the bug section -->
|
||||
## Steps to Reproduce (for bugs)
|
||||
<!--- Provide an unambiguous set of steps to reproduce -->
|
||||
<!--- this bug. Include code to reproduce, if relevant -->
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
4.
|
||||
|
||||
## Context
|
||||
<!--- How has this issue affected you? What are you trying to accomplish? -->
|
||||
<!--- Providing context helps us come up with a solution that is most useful in the real world -->
|
||||
|
||||
## Your Environment
|
||||
<!--- Include as many relevant details about the environment you experienced the bug in -->
|
||||
* Version used:
|
||||
* Operating System and version (e.g. Windows 10 1709 x64):
|
||||
|
||||
33
.github/PULL_REQUEST_TEMPLATE.md
vendored
33
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -1,4 +1,29 @@
|
||||
<!--
|
||||
Please provide as much detail as possible with what your pull request does.
|
||||
Include a reference to a filed issue if it exists.
|
||||
-->
|
||||
<!--- Provide a general summary of your changes in the Title above -->
|
||||
|
||||
## Description
|
||||
<!--- Describe your changes in detail -->
|
||||
|
||||
## Motivation and Context
|
||||
<!--- Why is this change required? What problem does it solve? -->
|
||||
<!--- If it fixes an open issue, please link to the issue here. -->
|
||||
|
||||
## How Has This Been Tested?
|
||||
<!--- Please describe in detail how you tested your changes. -->
|
||||
<!--- Include details of your testing environment, and the tests you ran to -->
|
||||
<!--- see how your change affects other areas of the code, etc. -->
|
||||
|
||||
## Screenshots (if appropriate):
|
||||
|
||||
## Types of changes
|
||||
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
|
||||
- [ ] Bug fix (non-breaking change which fixes an issue)
|
||||
- [ ] New feature (non-breaking change which adds functionality)
|
||||
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
|
||||
|
||||
## Checklist:
|
||||
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
|
||||
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
|
||||
- [ ] My code follows the code style of this project.
|
||||
- [ ] My change requires a change to the documentation.
|
||||
- [ ] I have updated the documentation accordingly.
|
||||
- [ ] I have read the **CONTRIBUTING** document.
|
||||
|
||||
@@ -1,3 +1,98 @@
|
||||
1.76.8 (2018-08-25):
|
||||
|
||||
Fixes:
|
||||
------
|
||||
#1088: Delete and Launch buttons are not disabled when last external tool deleted
|
||||
#1087: 'Save connections after every edit' setting not honored
|
||||
#1082: Connections not given GUID if Id is empty in connection xml
|
||||
|
||||
|
||||
1.76.7 (2018-08-22):
|
||||
|
||||
Fixes:
|
||||
------
|
||||
#1076: Wrong object selected when duplicating connection then switching between properties and inheritance in config window
|
||||
#1068: Fixed some toolbar positioning bugs
|
||||
|
||||
|
||||
1.76.6 (2018-08-03):
|
||||
|
||||
Fixes:
|
||||
------
|
||||
#1062: Entering correct password when starting app does not load connections file
|
||||
|
||||
1.76.5 (2018-08-02):
|
||||
|
||||
Fixes:
|
||||
------
|
||||
#1057: Hitting F2 with no connection node selected caused unhandled exception
|
||||
#1052: 'Switch to notification panel' feature does not always switch
|
||||
#1051: Tooltips always displayed regardless of 'Show description tooltips in connection tree' setting
|
||||
#1050: Config window retains access to previously selected node after loading new connections file
|
||||
#1045: Config window shows several incorrect properties for HTTPS connections
|
||||
#1040: Canceling "select panel" form does not cancel
|
||||
#1039: Set default theme when themes disabled
|
||||
#1038: Unable to add connection with active filter
|
||||
#1036: Exception when themes are active and options page closed on Connections then reopened
|
||||
#1034: Connection context menu not being translated
|
||||
#1030: Exception thrown if importing from port scan and no tree node is selected
|
||||
#1020: BackupFileKeepCount setting not limiting backup file count
|
||||
#1004: Duplicating root or PuTTy node through hotkey causes unhandled exception
|
||||
#1002: Disabling filtering without clearing keyword leaves filtered state
|
||||
#1001: Connection tree context menu hotkeys stop working and disappear in some cases
|
||||
#999: Some hotkeys stop working if File menu was called when PuTTy Saved Sessions was selected
|
||||
#998: Can sometimes add connection under PuTTY Sessions node
|
||||
#991: Error when deleting host in filtered view
|
||||
#971: Portable Settings now apply to any machine they are used on
|
||||
#961: Connections file overwritten if correct decryption password not provided
|
||||
#893: Removed unneeded files from build/package
|
||||
#868: if statement returned the same value
|
||||
#762: Increased button size to fit locaized text
|
||||
|
||||
|
||||
1.76.4 Alpha 6 (2018-06-03):
|
||||
|
||||
Features/Enhancements:
|
||||
----------------------
|
||||
#948: Fixed issue where many menu item translations were not being used
|
||||
#942: Improved Russian translation of several items
|
||||
#924: Notification for "No Host Specified" when clicking folders in quick-connect menu
|
||||
#902: Menu bar can once again be moved. View -> "Lock toolbar positions" now also locks the menu position
|
||||
Added option for creating an empty panel on startup
|
||||
|
||||
Fixes:
|
||||
------
|
||||
#938: Minor layout improvements on the Port Scan screen
|
||||
#916: Default properties were not being saved
|
||||
|
||||
|
||||
1.76.3 Alpha 5 (2018-03-14):
|
||||
|
||||
Fixes:
|
||||
------
|
||||
#911: Csv exports sometimes do not include all fields
|
||||
#807: Inheritance is sometimes turned on for nodes under root Connections node
|
||||
|
||||
|
||||
1.76.2 Alpha 4 (2018-03-03):
|
||||
|
||||
Fixes:
|
||||
------
|
||||
#899: DoNotPlay is Case Sensitive in XML Serialization
|
||||
|
||||
|
||||
1.76.1 Alpha 3 (2018-02-24):
|
||||
|
||||
Features/Enhancements:
|
||||
----------------------
|
||||
#625: Added ability to import mRemoteNG formatted CSV files
|
||||
#648: The port scan ping timeout is now configurable
|
||||
|
||||
Fixes:
|
||||
------
|
||||
Fixed a few Xml serialization bugs that would occur if boolean values weren't capitalized
|
||||
|
||||
|
||||
1.76.0 Alpha 2 (2018-02-01):
|
||||
|
||||
Features/Enhancements:
|
||||
@@ -24,6 +119,7 @@ Features/Enhancements:
|
||||
#671: Revamped UI theme system
|
||||
#611: Added multi-ssh toolbar for sending commands to many SSH clients at once
|
||||
#558: Connection tree now shows customizable icons instead of play/pause icon
|
||||
#519: You can now import normal mRemoteNG files - they do not have to be exports
|
||||
#504: Added Korean translation
|
||||
#485: The Domain field is now visible/editable for connection with the IntApp protocol
|
||||
#468: Default connection info Panel property is now saved
|
||||
|
||||
@@ -23,6 +23,7 @@ github.com/DamianBis
|
||||
github.com/pfjason
|
||||
github.com/sirLoaf
|
||||
github.com/Fyers
|
||||
Vladimir Semenov (github.com/sli-pro)
|
||||
|
||||
|
||||
Past Contributors
|
||||
@@ -59,6 +60,8 @@ Lukas Plachy (github.com/rheingold)
|
||||
Gyuha Shin
|
||||
Stefan (github.com/polluks)
|
||||
github.com/emazv72
|
||||
Vladimir Semenov (github.com/sli-pro)
|
||||
Marco Sousa (github.com/marcomsousa)
|
||||
|
||||
|
||||
Included Source Code
|
||||
|
||||
8
Jenkinsfile
vendored
8
Jenkinsfile
vendored
@@ -1,8 +1,8 @@
|
||||
#!groovy
|
||||
node('windows') {
|
||||
def jobDir = pwd()
|
||||
def solutionFilePath = "\"${jobDir}\\mRemoteV1.sln\""
|
||||
def vsToolsDir = "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\Tools"
|
||||
def vsExtensionsDir = "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\CommonExtensions\\Microsoft\\TestWindow"
|
||||
def msBuild = "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\MSBuild\\15.0\\Bin\\msbuild.exe"
|
||||
def nunitConsolePath = "${jobDir}\\packages\\NUnit.ConsoleRunner.3.7.0\\tools\\nunit3-console.exe"
|
||||
def openCoverPath = "${jobDir}\\packages\\OpenCover.4.6.519\\tools\\OpenCover.Console.exe"
|
||||
def reportGeneratorPath = "${jobDir}\\packages\\ReportGenerator.3.0.2\\tools\\ReportGenerator.exe"
|
||||
@@ -24,11 +24,11 @@ node('windows') {
|
||||
}
|
||||
|
||||
stage ('Build mRemoteNG (Normal)') {
|
||||
bat "\"${vsToolsDir}\\VsDevCmd.bat\" && msbuild.exe /nologo /p:Platform=x86 \"${jobDir}\\mRemoteV1.sln\""
|
||||
bat "\"${msBuild}\" /nologo /p:Platform=x86 \"${jobDir}\\mRemoteV1.sln\""
|
||||
}
|
||||
|
||||
stage ('Build mRemoteNG (Portable)') {
|
||||
bat "\"${vsToolsDir}\\VsDevCmd.bat\" && msbuild.exe /nologo /p:Configuration=\"Debug Portable\";Platform=x86 \"${jobDir}\\mRemoteV1.sln\""
|
||||
bat "\"${msBuild}\" /nologo /p:Configuration=\"Debug Portable\";Platform=x86 \"${jobDir}\\mRemoteV1.sln\""
|
||||
}
|
||||
|
||||
stage ('Run Unit Tests (Normal, w/coverage)') {
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
node('windows') {
|
||||
def jobDir = pwd()
|
||||
def solutionFilePath = "\"${jobDir}\\mRemoteV1.sln\""
|
||||
def vsToolsDir = "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\Tools"
|
||||
def vsExtensionsDir = "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\CommonExtensions\\Microsoft\\TestWindow"
|
||||
def nunitTestAdapterPath = "C:\\Users\\Administrator\\AppData\\Local\\Microsoft\\VisualStudio\\14.0\\Extensions"
|
||||
def msBuild = "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\MSBuild\\15.0\\Bin\\msbuild.exe"
|
||||
def nunitConsolePath = "${jobDir}\\packages\\NUnit.ConsoleRunner.3.7.0\\tools\\nunit3-console.exe"
|
||||
def openCoverPath = "${jobDir}\\packages\\OpenCover.4.6.519\\tools\\OpenCover.Console.exe"
|
||||
def testResultFilePrefix = "TestResult"
|
||||
def testResultFileNormal = "${testResultFilePrefix}_UnitTests_normal.xml"
|
||||
def testResultFilePortable = "${testResultFilePrefix}_UnitTests_portable.xml"
|
||||
def coverageReport = "code_coverage_report.xml"
|
||||
|
||||
|
||||
stage ('Clean output dir') {
|
||||
@@ -32,24 +36,24 @@ node('windows') {
|
||||
withCredentials([file(credentialsId: '9b674d57-6792-48e3-984a-4d1bab2abb64', variable: 'CODE_SIGNING_CERT')]) {
|
||||
withCredentials([usernamePassword(credentialsId: '05b7449b-05c0-490f-8661-236242526e62', passwordVariable: 'MRNG_CERT_PASSWORD', usernameVariable: 'NO_USERNAME')]) {
|
||||
stage ('Build mRemoteNG (Normal - MSI)') {
|
||||
bat "\"${vsToolsDir}\\VsDevCmd.bat\" && msbuild.exe /nologo /t:Clean,Build /p:Configuration=\"Release Installer\" /p:Platform=x86 /p:CertPath=\"${env.CODE_SIGNING_CERT}\" /p:CertPassword=${env.MRNG_CERT_PASSWORD} \"${jobDir}\\mRemoteV1.sln\""
|
||||
bat "\"${msBuild}\" /nologo /t:Clean,Build /p:Configuration=\"Release Installer\" /p:Platform=x86 /p:CertPath=\"${env.CODE_SIGNING_CERT}\" /p:CertPassword=${env.MRNG_CERT_PASSWORD} \"${jobDir}\\mRemoteV1.sln\""
|
||||
archiveArtifacts artifacts: "Release\\*.msi", caseSensitive: false, onlyIfSuccessful: true, fingerprint: true
|
||||
}
|
||||
|
||||
stage ('Build mRemoteNG (Portable)') {
|
||||
bat "\"${vsToolsDir}\\VsDevCmd.bat\" && msbuild.exe /nologo /t:Clean,Build /p:Configuration=\"Release Portable\" /p:Platform=x86 /p:CertPath=\"${env.CODE_SIGNING_CERT}\" /p:CertPassword=${env.MRNG_CERT_PASSWORD} \"${jobDir}\\mRemoteV1.sln\""
|
||||
bat "\"${msBuild}\" /nologo /t:Clean,Build /p:Configuration=\"Release Portable\" /p:Platform=x86 /p:CertPath=\"${env.CODE_SIGNING_CERT}\" /p:CertPassword=${env.MRNG_CERT_PASSWORD} \"${jobDir}\\mRemoteV1.sln\""
|
||||
archiveArtifacts artifacts: "Release\\*.zip", caseSensitive: false, onlyIfSuccessful: true, fingerprint: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage ('Run Unit Tests (Normal - MSI)') {
|
||||
bat "\"${vsToolsDir}\\VsDevCmd.bat\" && VSTest.Console.exe /logger:trx /TestAdapterPath:${nunitTestAdapterPath} \"${jobDir}\\mRemoteNGTests\\bin\\Release\\mRemoteNGTests.dll\""
|
||||
}
|
||||
|
||||
stage ('Run Unit Tests (Portable)') {
|
||||
bat "\"${vsToolsDir}\\VsDevCmd.bat\" && VSTest.Console.exe /logger:trx /TestAdapterPath:${nunitTestAdapterPath} \"${jobDir}\\mRemoteNGTests\\bin\\Release Portable\\mRemoteNGTests.dll\""
|
||||
}
|
||||
stage ('Run Unit Tests (Normal - MSI)') {
|
||||
bat "\"${nunitConsolePath}\" \"${jobDir}\\mRemoteNGTests\\bin\\release\\mRemoteNGTests.dll\" --result=${testResultFileNormal} --x86"
|
||||
}
|
||||
|
||||
stage ('Run Unit Tests (Portable)') {
|
||||
bat "\"${nunitConsolePath}\" \"${jobDir}\\mRemoteNGTests\\bin\\release portable\\mRemoteNGTests.dll\" --result=${testResultFilePortable} --x86"
|
||||
}
|
||||
|
||||
stage ('Generate UpdateCheck Files') {
|
||||
bat "powershell -ExecutionPolicy Bypass -File \"${jobDir}\\Tools\\create_upg_chk_files.ps1\" -TagName \"${env.TagName}\" -UpdateChannel \"${env.UpdateChannel}\""
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
|
||||
| Update Channel | Build Status | Downloads |
|
||||
| ---------------|--------------|-----------|
|
||||
| Stable | [](https://ci.appveyor.com/project/mremoteng/mremoteng/branch/master) | [](https://github.com/mRemoteNG/mRemoteNG/releases/tag/v1.75.7011) |
|
||||
| Beta | | [](https://github.com/mRemoteNG/mRemoteNG/releases/tag/v1.75.7011) |
|
||||
| Development | [](https://ci.appveyor.com/project/mremoteng/mremoteng/branch/develop) | - |
|
||||
| Stable | [](https://ci.appveyor.com/project/mremoteng/mremoteng/branch/master) | [](https://github.com/mRemoteNG/mRemoteNG/releases/tag/v1.75.7012) |
|
||||
| Beta | | [](https://github.com/mRemoteNG/mRemoteNG/releases/tag/v1.75.7012) |
|
||||
| Development | [](https://ci.appveyor.com/project/mremoteng/mremoteng/branch/develop) | [](https://github.com/mRemoteNG/mRemoteNG/releases/tag/v1.76Alpha5) |
|
||||
|
||||
mRemoteNG is the next generation of mRemote, a full-featured, multi-tab remote connections manager.
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -3,7 +3,7 @@
|
||||
License for use and distribution
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Copyright (C) 1999-2016 Igor Pavlov.
|
||||
Copyright (C) 1999-2018 Igor Pavlov.
|
||||
|
||||
7-Zip Extra files are under the GNU LGPL license.
|
||||
|
||||
|
||||
@@ -1,6 +1,25 @@
|
||||
7-Zip Extra history
|
||||
-------------------
|
||||
|
||||
This file contains only information about changes related to that package exclusively.
|
||||
The full history of changes is listed in history.txt in main 7-Zip program.
|
||||
|
||||
|
||||
18.05 2018-04-30
|
||||
-------------------------
|
||||
- The speed for LZMA/LZMA2 compressing was increased
|
||||
by 8% for fastest/fast compression levels and
|
||||
by 3% for normal/maximum compression levels.
|
||||
|
||||
|
||||
18.03 beta 2018-03-04
|
||||
-------------------------
|
||||
- The speed for single-thread LZMA/LZMA2 decoding
|
||||
was increased by 30% in x64 version and by 3% in x86 version.
|
||||
- 7-Zip now can use multi-threading for 7z/LZMA2 decoding,
|
||||
if there are multiple independent data chunks in LZMA2 stream.
|
||||
|
||||
|
||||
9.35 beta 2014-12-07
|
||||
------------------------------
|
||||
- SFX modules were moved to LZMA SDK package.
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
7-Zip Extra 16.02
|
||||
7-Zip Extra 18.05
|
||||
-----------------
|
||||
|
||||
7-Zip Extra is package of extra modules of 7-Zip.
|
||||
|
||||
7-Zip Copyright (C) 1999-2016 Igor Pavlov.
|
||||
7-Zip Copyright (C) 1999-2018 Igor Pavlov.
|
||||
|
||||
7-Zip is free software. Read License.txt for more information about license.
|
||||
|
||||
|
||||
114
Tools/CreateBulkConnections_ConfCons2_6.ps1
Normal file
114
Tools/CreateBulkConnections_ConfCons2_6.ps1
Normal file
@@ -0,0 +1,114 @@
|
||||
#####################################
|
||||
# Author: David Sparer
|
||||
# Summary:
|
||||
# This is intended to be a template for creating connections in bulk. This uses the serializers directly from the mRemoteNG binaries.
|
||||
# You will still need to create the connection info objects, but the library will handle serialization. It is expected that you
|
||||
# are familiar with PowerShell. If this is not the case, reach out to the mRemoteNG community for help.
|
||||
# Usage:
|
||||
# Replace or modify the examples that are shown toward the end of the script to create your own connection info objects.
|
||||
#####################################
|
||||
|
||||
$EncryptionKey = (Get-Credential -Message "Enter the encryption key you would like to use. This must match the encryption key used by the rest of the confCons file." -UserName "DontNeedUsername").Password
|
||||
$PathToMrngFolder = ""
|
||||
|
||||
if ($PathToMrngFolder -eq "") {
|
||||
Write-Error -Message 'You must set the $PathToMrngFolder variable in this script to the folder which contains mRemoteNG.exe'
|
||||
}
|
||||
|
||||
$assembly = [System.Reflection.Assembly]::LoadFile((Join-Path -Path $PathToMrngFolder -ChildPath "mRemoteNG.exe"))
|
||||
$assembly = [System.Reflection.Assembly]::LoadFile((Join-Path -Path $PathToMrngFolder -ChildPath "BouncyCastle.Crypto.dll"))
|
||||
|
||||
function New-mRemoteNGXmlSerializer {
|
||||
[CmdletBinding()]
|
||||
param (
|
||||
[SecureString]
|
||||
$EncryptionKey
|
||||
)
|
||||
|
||||
PROCESS {
|
||||
$cryptoProvider = New-Object -TypeName mRemoteNG.Security.SymmetricEncryption.AeadCryptographyProvider
|
||||
$saveFilter = New-Object -TypeName mRemoteNG.Security.SaveFilter -ArgumentList @($false)
|
||||
$xmlSerializer = New-Object -TypeName mRemoteNG.Config.Serializers.XmlConnectionNodeSerializer -ArgumentList @($cryptoProvider, $encryptionKey, $saveFilter)
|
||||
Write-Output $xmlSerializer
|
||||
}
|
||||
}
|
||||
|
||||
function New-mRemoteNGConnectionInfo {
|
||||
[CmdletBinding()]
|
||||
param ()
|
||||
|
||||
PROCESS {
|
||||
$connectionInfo = New-Object -TypeName mRemoteNG.Connection.ConnectionInfo
|
||||
Write-Output $connectionInfo
|
||||
}
|
||||
}
|
||||
|
||||
function New-mRemoteNGContainerInfo {
|
||||
[CmdletBinding()]
|
||||
param ()
|
||||
|
||||
PROCESS {
|
||||
$connectionInfo = New-Object -TypeName mRemoteNG.Container.ContainerInfo
|
||||
Write-Output $connectionInfo
|
||||
}
|
||||
}
|
||||
|
||||
# Setup the services needed to do serialization
|
||||
$xmlSerializer = New-mRemoteNGXmlSerializer -EncryptionKey $EncryptionKey
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------
|
||||
# Example 1: serialize many connections, no containers
|
||||
# Here you can define the number of connection info objects to create
|
||||
# You can also provide a list of desired hostnames and iterate over those
|
||||
$xml = ""
|
||||
foreach($i in 1..5)
|
||||
{
|
||||
$connectionInfo = New-mRemoteNGConnectionInfo
|
||||
|
||||
# Set connection info properties
|
||||
$connectionInfo.Name = "server-$i"
|
||||
$connectionInfo.Hostname = "some-win-server-$i"
|
||||
$connectionInfo.Protocol = [mRemoteNG.Connection.Protocol.ProtocolType]::RDP
|
||||
$connectionInfo.Inheritance.Username = $true
|
||||
$connectionInfo.Inheritance.Domain = $true
|
||||
$connectionInfo.Inheritance.Password = $true
|
||||
|
||||
$serializedConnection = $xmlSerializer.SerializeConnectionInfo($connectionInfo).ToString()
|
||||
$xml += $serializedConnection + [System.Environment]::NewLine
|
||||
}
|
||||
|
||||
Write-Output $xml
|
||||
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------
|
||||
# Example 2: serialize a container which has connections
|
||||
# You can also create containers and add connections to them, which will be nested correctly when serialized
|
||||
$xml = ""
|
||||
$container = New-mRemoteNGContainerInfo
|
||||
$container.Name = "ProductionServers"
|
||||
$serializedContainer = $xmlSerializer.SerializeConnectionInfo($container)
|
||||
|
||||
foreach($i in 1..3)
|
||||
{
|
||||
$connectionInfo = New-mRemoteNGConnectionInfo
|
||||
|
||||
# Set connection info properties
|
||||
$connectionInfo.Name = "server-$i"
|
||||
$connectionInfo.Hostname = "some-linux-server-$i"
|
||||
$connectionInfo.Protocol = [mRemoteNG.Connection.Protocol.ProtocolType]::SSH2
|
||||
$connectionInfo.Inheritance.Username = $true
|
||||
$connectionInfo.Inheritance.Domain = $true
|
||||
$connectionInfo.Inheritance.Password = $true
|
||||
|
||||
# serialize the connection
|
||||
$serializedConnection = $xmlSerializer.SerializeConnectionInfo($connectionInfo)
|
||||
# add the connection to the container
|
||||
$serializedContainer.Add($serializedConnection)
|
||||
}
|
||||
|
||||
# Call ToString() on the top-level container to get the XML of it and all its children
|
||||
Write-Output $serializedContainer.ToString()
|
||||
@@ -5,7 +5,7 @@ setlocal enabledelayedexpansion
|
||||
set SOLUTIONDIR=%~dp0..
|
||||
|
||||
rem Windows Sysinternals Sigcheck from http://technet.microsoft.com/en-us/sysinternals/bb897441
|
||||
set SIGCHECK="%SOLUTIONDIR%\Tools\sigcheck.exe"
|
||||
set SIGCHECK="%SOLUTIONDIR%\Tools\exes\sigcheck.exe"
|
||||
set SEVENZIP="%SOLUTIONDIR%\Tools\7zip\7za.exe"
|
||||
|
||||
set VCVARSALL="%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
|
||||
|
||||
BIN
Tools/exes/dumpbin.exe
Normal file
BIN
Tools/exes/dumpbin.exe
Normal file
Binary file not shown.
BIN
Tools/exes/editbin.exe
Normal file
BIN
Tools/exes/editbin.exe
Normal file
Binary file not shown.
BIN
Tools/exes/link.exe
Normal file
BIN
Tools/exes/link.exe
Normal file
Binary file not shown.
BIN
Tools/exes/mspdbcore.dll
Normal file
BIN
Tools/exes/mspdbcore.dll
Normal file
Binary file not shown.
@@ -1,3 +1,5 @@
|
||||
[CmdletBinding()]
|
||||
|
||||
param (
|
||||
[string]
|
||||
# Name of the file to find
|
||||
@@ -46,6 +48,7 @@ $rootSearchPaths = @(
|
||||
# Returns the first full path to the $FileName that our search can find
|
||||
foreach ($searchPath in $rootSearchPaths) {
|
||||
foreach ($visualStudioFolder in $searchPath) {
|
||||
Write-Verbose "Searching in folder '$visualStudioFolder'"
|
||||
$matchingExes = [System.IO.Directory]::EnumerateFileSystemEntries($visualStudioFolder, $FileName, [System.IO.SearchOption]::AllDirectories)
|
||||
foreach ($matchingExe in $matchingExes) {
|
||||
if ((EditBinCertificateIsValid -Path $matchingExe) -and (ToolCanBeExecuted -Path $matchingExe)) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
$githubUrl = 'https://api.github.com'
|
||||
|
||||
# GitHub doesn't support the default powershell protocol (TLS 1.0)
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
|
||||
function Publish-GitHubRelease {
|
||||
param (
|
||||
@@ -174,9 +175,14 @@ function Upload-GitHubReleaseAsset {
|
||||
)
|
||||
|
||||
$UploadUri = $UploadUri -replace "(\{[\w,\?]*\})$"
|
||||
$file = Get-Item -Path $FilePath
|
||||
$files = Get-Item -Path $FilePath
|
||||
|
||||
$req_uploadZipAsset = Invoke-WebRequest -Uri "$($UploadUri)?name=$($file.Name)" -Method Post -Headers @{"Authorization"="token $AuthToken"} -ContentType $ContentType -InFile $file.FullName -ErrorAction Stop
|
||||
# Get-Item could produce an array of files if a wildcard is provided. (C:\*.txt)
|
||||
# Upload each matching item individually
|
||||
foreach ($file in $files) {
|
||||
Write-Output "Uploading asset to GitHub release: '$($file.FullName)'"
|
||||
$req_uploadZipAsset = Invoke-WebRequest -Uri "$($UploadUri)?name=$($file.Name)" -Method Post -Headers @{"Authorization"="token $AuthToken"} -ContentType $ContentType -InFile $file.FullName -ErrorAction Stop
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -45,5 +45,6 @@ Format-Table -AutoSize -Wrap -InputObject @{
|
||||
& "$PSScriptRoot\verify_LargeAddressAware.ps1" -TargetDir $TargetDir -TargetFileName $TargetFileName
|
||||
& "$PSScriptRoot\tidy_files_for_release.ps1" -TargetDir $TargetDir -ConfigurationName $ConfigurationName
|
||||
& "$PSScriptRoot\sign_binaries.ps1" -TargetDir $TargetDir -CertificatePath $CertificatePath -CertificatePassword $CertificatePassword -ConfigurationName $ConfigurationName -Exclude $ExcludeFromSigning
|
||||
& "$PSScriptRoot\verify_binary_signatures.ps1" -TargetDir $TargetDir -ConfigurationName $ConfigurationName
|
||||
& "$PSScriptRoot\verify_binary_signatures.ps1" -TargetDir $TargetDir -ConfigurationName $ConfigurationName -CertificatePath $CertificatePath
|
||||
& "$PSScriptRoot\zip_symbols.ps1" -SolutionDir $SolutionDir -TargetDir $TargetDir -ConfigurationName $ConfigurationName
|
||||
& "$PSScriptRoot\zip_portable_files.ps1" -SolutionDir $SolutionDir -TargetDir $TargetDir -ConfigurationName $ConfigurationName
|
||||
@@ -9,7 +9,7 @@ Write-Host $SolutionDir
|
||||
Write-Host $renameTarget
|
||||
|
||||
$targetVersionedFile = "$SolutionDir\mRemoteV1\bin\Release\mRemoteNG.exe"
|
||||
$version = &"$SolutionDir\Tools\sigcheck.exe" /accepteula -q -n $targetVersionedFile
|
||||
$version = &"$SolutionDir\Tools\exes\sigcheck.exe" /accepteula -q -n $targetVersionedFile
|
||||
|
||||
|
||||
$renameTargetFileObject = Get-Item -Path $renameTarget -ErrorAction SilentlyContinue
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
[CmdletBinding()]
|
||||
|
||||
param (
|
||||
[string]
|
||||
[Parameter(Mandatory=$true)]
|
||||
@@ -10,13 +12,11 @@ param (
|
||||
|
||||
Write-Output "===== Beginning $($PSCmdlet.MyInvocation.MyCommand) ====="
|
||||
|
||||
# Find editbin.exe
|
||||
$path_editBin = & "$PSScriptRoot\find_vstool.ps1" -FileName "editbin.exe"
|
||||
|
||||
$path_editBin = Join-Path -Path $PSScriptRoot -ChildPath "exes\editbin.exe"
|
||||
$path_outputExe = Join-Path -Path $TargetDir -ChildPath $TargetFileName
|
||||
|
||||
# Set LargeAddressAware
|
||||
Write-Output "Setting LargeAddressAware on binary file:`n`"$path_outputExe`" `nwith:`n`"$path_editBin`""
|
||||
& $path_editBin "/largeaddressaware" "$path_outputExe"
|
||||
& "$path_editBin" /largeaddressaware "$path_outputExe"
|
||||
|
||||
Write-Output ""
|
||||
@@ -15,7 +15,6 @@ if ($ConfigurationName -match "Release") {
|
||||
Write-Output "Removing unnecessary files from Release versions"
|
||||
Remove-Item -Path (Join-Path -Path $TargetDir -ChildPath "app.publish") -Recurse -Force
|
||||
$filesToDelete = Get-ChildItem -Path $TargetDir -Recurse -Include @(
|
||||
"*.pdb",
|
||||
"*.publish",
|
||||
"*.xml",
|
||||
"*.backup",
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
[CmdletBinding()]
|
||||
|
||||
param (
|
||||
[string]
|
||||
[Parameter(Mandatory=$true)]
|
||||
@@ -10,13 +12,11 @@ param (
|
||||
|
||||
Write-Output "===== Beginning $($PSCmdlet.MyInvocation.MyCommand) ====="
|
||||
|
||||
# Find editbin.exe
|
||||
$path_dumpBin = & "$PSScriptRoot\find_vstool.ps1" -FileName "dumpbin.exe"
|
||||
|
||||
$path_dumpBin = Join-Path -Path $PSScriptRoot -ChildPath "exes\dumpbin.exe"
|
||||
$path_outputExe = Join-Path -Path $TargetDir -ChildPath $TargetFileName
|
||||
|
||||
# Dump exe header
|
||||
$output = & "$path_dumpBin" /NOLOGO /HEADERS $path_outputExe | Select-String large
|
||||
$output = & "$path_dumpBin" /NOLOGO /HEADERS "$path_outputExe" | Select-String large
|
||||
|
||||
if ($output -eq $null)
|
||||
{
|
||||
@@ -27,6 +27,4 @@ else
|
||||
Write-Output $output.ToString().TrimStart(" ")
|
||||
}
|
||||
|
||||
|
||||
|
||||
Write-Output ""
|
||||
@@ -8,6 +8,7 @@ param (
|
||||
$ConfigurationName,
|
||||
|
||||
[string]
|
||||
[Parameter(Mandatory=$true)]
|
||||
# The code signing certificate to use when signing the files.
|
||||
$CertificatePath
|
||||
)
|
||||
@@ -17,11 +18,11 @@ Write-Output "===== Beginning $($PSCmdlet.MyInvocation.MyCommand) ====="
|
||||
# validate release versions and if the certificate is available
|
||||
if ($ConfigurationName -match "Release") {
|
||||
|
||||
if ($CertificatePath -eq "" -or !(Test-Path -Path $CertificatePath -PathType Leaf))
|
||||
{
|
||||
if ($CertificatePath -eq "" -or !(Test-Path -Path $CertificatePath -PathType Leaf))
|
||||
{
|
||||
Write-Output "Certificate is not present - files likely not signed - we won't verify file signatures."
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
Write-Output "Verifying signature of binaries"
|
||||
Write-Output "Getting files from path: $TargetDir"
|
||||
|
||||
@@ -13,13 +13,49 @@ param (
|
||||
)
|
||||
|
||||
Write-Output "===== Beginning $($PSCmdlet.MyInvocation.MyCommand) ====="
|
||||
$path_packageZipScript = Join-Path -Path $SolutionDir -ChildPath "Tools\build-relport.cmd"
|
||||
|
||||
if(-not [string]::IsNullOrEmpty($Env:APPVEYOR_BUILD_FOLDER)) {
|
||||
Write-Output "Too early to run via Appveyor - artifacts don't get generated properly. Exiting"
|
||||
Exit
|
||||
}
|
||||
|
||||
Write-Output "Solution Dir: '$($SolutionDir)'"
|
||||
Write-Output "Target Dir: '$($TargetDir)'"
|
||||
$ConfigurationName = $ConfigurationName.Trim()
|
||||
Write-Output "Config Name (tirmmed): '$($ConfigurationName)'"
|
||||
|
||||
|
||||
# Windows Sysinternals Sigcheck from http://technet.microsoft.com/en-us/sysinternals/bb897441
|
||||
$SIGCHECK="$($SolutionDir)Tools\exes\sigcheck.exe"
|
||||
$SEVENZIP="$($SolutionDir)Tools\7zip\7za.exe"
|
||||
|
||||
# Package Zip
|
||||
if ($ConfigurationName -match "Release" -and $ConfigurationName -match "Portable") {
|
||||
if ($ConfigurationName -eq "Release Portable") {
|
||||
Write-Output "Packaging Release Portable ZIP"
|
||||
& $path_packageZipScript
|
||||
|
||||
$version = & $SIGCHECK /accepteula -q -n "$($SolutionDir)mRemoteV1\bin\$($ConfigurationName)\mRemoteNG.exe"
|
||||
|
||||
Write-Output "Version is $($version)"
|
||||
|
||||
$PortableZip="$($SolutionDir)Release\mRemoteNG-Portable-$($version).zip"
|
||||
|
||||
$tempFolderPath = Join-Path -Path $SolutionDir -ChildPath "mRemoteV1\bin\package"
|
||||
Remove-Item -Recurse $tempFolderPath -ErrorAction SilentlyContinue | Out-Null
|
||||
New-Item $tempFolderPath -ItemType "directory" | Out-Null
|
||||
|
||||
Copy-Item "$($SolutionDir)mRemoteV1\Resources\PuTTYNG.exe" -Destination $tempFolderPath
|
||||
|
||||
#Write-Output "$($SolutionDir)mRemoteV1\bin\$ConfigurationName"
|
||||
#Write-Output "$($SolutionDir)mRemoteV1\bin\package"
|
||||
Copy-Item "$($SolutionDir)mRemoteV1\bin\$ConfigurationName\*" -Destination $tempFolderPath -Recurse -Force
|
||||
# Delete any PDB files that accidentally get copied into the temp folder
|
||||
Get-ChildItem -Path $tempFolderPath -Filter "*.pdb" | Remove-Item
|
||||
Copy-Item "$($SolutionDir)*.txt" -Destination $tempFolderPath
|
||||
|
||||
Write-Output "Creating portable ZIP file $($PortableZip)"
|
||||
Remove-Item -Force $PortableZip -ErrorAction SilentlyContinue
|
||||
& $SEVENZIP a -bt -bd -bb1 -mx=9 -tzip -y -r $PortableZip (Join-Path -Path $tempFolderPath -ChildPath "*.*")
|
||||
#& $SEVENZIP a -bt -mx=9 -tzip -y $PortableZip "$($SolutionDir)*.TXT"
|
||||
}
|
||||
else {
|
||||
Write-Output "We will not zip anything - this isnt a portable release build."
|
||||
|
||||
39
Tools/zip_portable_files_appv.ps1
Normal file
39
Tools/zip_portable_files_appv.ps1
Normal file
@@ -0,0 +1,39 @@
|
||||
if([string]::IsNullOrEmpty($Env:APPVEYOR_BUILD_FOLDER)) {
|
||||
Write-Output "NOT running via Appveyor - Exiting"
|
||||
Exit
|
||||
}
|
||||
|
||||
$appvDir = $Env:APPVEYOR_BUILD_FOLDER
|
||||
|
||||
Write-Output "Appveyor Build Dir: '$($appvDir)'"
|
||||
$ConfigurationName = $Env:CONFIGURATION.Trim()
|
||||
Write-Output "Config Name (tirmmed): '$($ConfigurationName)'"
|
||||
|
||||
|
||||
$SIGCHECK="$($SolutionDir)Tools\exes\sigcheck.exe"
|
||||
$SEVENZIP="$($SolutionDir)Tools\7zip\7za.exe"
|
||||
|
||||
if ($ConfigurationName -eq "Release Portable") {
|
||||
Write-Output "Packaging Release Portable ZIP"
|
||||
|
||||
$version = & $SIGCHECK /accepteula -q -n "$($SolutionDir)mRemoteV1\bin\$($ConfigurationName)\mRemoteNG.exe"
|
||||
|
||||
Write-Output "Version is $($version)"
|
||||
|
||||
$PortableZip="$($SolutionDir)Release\mRemoteNG-Portable-$($version).zip"
|
||||
|
||||
Remove-Item -Recurse "$($SolutionDir)mRemoteV1\bin\package" -ErrorAction SilentlyContinue | Out-Null
|
||||
New-Item "$($SolutionDir)mRemoteV1\bin\package" -ItemType "directory" | Out-Null
|
||||
|
||||
Copy-Item "$($SolutionDir)mRemoteV1\Resources\PuTTYNG.exe" -Destination "$($SolutionDir)mRemoteV1\bin\package"
|
||||
|
||||
Copy-Item "$($SolutionDir)mRemoteV1\bin\$ConfigurationName\*" -Destination "$($SolutionDir)mRemoteV1\bin\package" -Recurse -Force
|
||||
Copy-Item "$($SolutionDir)*.txt" -Destination "$($SolutionDir)mRemoteV1\bin\package"
|
||||
|
||||
Write-Output "Creating portable ZIP file $($PortableZip)"
|
||||
Remove-Item -Force $PortableZip -ErrorAction SilentlyContinue
|
||||
& $SEVENZIP a -bt -bd -bb1 -mx=9 -tzip -y -r $PortableZip "$($SolutionDir)mRemoteV1\bin\package\*.*"
|
||||
}
|
||||
else {
|
||||
Write-Output "We will not zip anything - this isnt a portable release build."
|
||||
}
|
||||
56
Tools/zip_symbols.ps1
Normal file
56
Tools/zip_symbols.ps1
Normal file
@@ -0,0 +1,56 @@
|
||||
param (
|
||||
[string]
|
||||
[Parameter(Mandatory=$true)]
|
||||
$SolutionDir,
|
||||
|
||||
[string]
|
||||
[Parameter(Mandatory=$true)]
|
||||
$TargetDir,
|
||||
|
||||
[string]
|
||||
[Parameter(Mandatory=$true)]
|
||||
$ConfigurationName
|
||||
)
|
||||
|
||||
Write-Output "===== Beginning $($PSCmdlet.MyInvocation.MyCommand) ====="
|
||||
|
||||
if(-not [string]::IsNullOrEmpty($Env:APPVEYOR_BUILD_FOLDER)) {
|
||||
Write-Output "Too early to run via Appveyor - artifacts don't get generated properly. Exiting"
|
||||
Exit
|
||||
}
|
||||
|
||||
Write-Output "Solution Dir: '$($SolutionDir)'"
|
||||
Write-Output "Target Dir: '$($TargetDir)'"
|
||||
$ConfigurationName = $ConfigurationName.Trim()
|
||||
Write-Output "Config Name (trimmed): '$($ConfigurationName)'"
|
||||
|
||||
|
||||
# Windows Sysinternals Sigcheck from http://technet.microsoft.com/en-us/sysinternals/bb897441
|
||||
$SIGCHECK="$($SolutionDir)Tools\exes\sigcheck.exe"
|
||||
$SEVENZIP="$($SolutionDir)Tools\7zip\7za.exe"
|
||||
|
||||
# Package Zip
|
||||
if ($ConfigurationName -match "Release") {
|
||||
Write-Output "Packaging debug symbols"
|
||||
|
||||
$version = & $SIGCHECK /accepteula -q -n "$($SolutionDir)mRemoteV1\bin\$($ConfigurationName)\mRemoteNG.exe"
|
||||
|
||||
Write-Output "Version is $($version)"
|
||||
|
||||
if ($ConfigurationName -match "Portable") {
|
||||
$zipFilePrefix = "mRemoteNG-Portable-symbols"
|
||||
} else {
|
||||
$zipFilePrefix = "mRemoteNG-symbols"
|
||||
}
|
||||
|
||||
$outputZipPath="$($SolutionDir)Release\$zipFilePrefix-$($version).zip"
|
||||
|
||||
Write-Output "Creating debug symbols ZIP file $($outputZipPath)"
|
||||
Remove-Item -Force $outputZipPath -ErrorAction SilentlyContinue
|
||||
& $SEVENZIP a -bt -bd -bb1 -mx=9 -tzip -y -r $outputZipPath (Join-Path -Path $TargetDir -ChildPath "*.pdb")
|
||||
}
|
||||
else {
|
||||
Write-Output "We will not package debug symbols - this isnt a release build."
|
||||
}
|
||||
|
||||
Write-Output ""
|
||||
12
appveyor.yml
12
appveyor.yml
@@ -1,10 +1,11 @@
|
||||
version: 1.0.{build}
|
||||
version: 1.76.{build}
|
||||
pull_requests:
|
||||
do_not_increment_build_number: true
|
||||
image: Visual Studio 2017
|
||||
configuration:
|
||||
- Release
|
||||
- Release Portable
|
||||
- Release Installer
|
||||
platform: x86
|
||||
clone_depth: 1
|
||||
install:
|
||||
@@ -14,7 +15,14 @@ before_build:
|
||||
build:
|
||||
project: mRemoteV1.sln
|
||||
verbosity: normal
|
||||
after_build:
|
||||
- ps: "if([string]::IsNullOrEmpty($Env:APPVEYOR_BUILD_FOLDER)) {\n Write-Output \"NOT running via Appveyor - Exiting\"\n Exit\n}\n\n$appvDir = $Env:APPVEYOR_BUILD_FOLDER\n\nWrite-Output \"Appveyor Build Dir: '$($appvDir)'\"\n$ConfigurationName = $Env:CONFIGURATION.Trim()\nWrite-Output \"Config Name (tirmmed): '$($ConfigurationName)'\"\n\n\n$SIGCHECK=\"$($SolutionDir)Tools\\exes\\sigcheck.exe\"\n$SEVENZIP=\"$($SolutionDir)Tools\\7zip\\7za.exe\"\n\nif ($ConfigurationName -eq \"Release Portable\") {\n Write-Output \"Packaging Release Portable ZIP\"\n \n $version = & $SIGCHECK /accepteula -q -n \"$($SolutionDir)mRemoteV1\\bin\\$($ConfigurationName)\\mRemoteNG.exe\"\n\n Write-Output \"Version is $($version)\"\n\n $PortableZip=\"$($SolutionDir)Release\\mRemoteNG-Portable-$($version).zip\"\n\n Remove-Item -Recurse \"$($SolutionDir)mRemoteV1\\bin\\package\" -ErrorAction SilentlyContinue | Out-Null\n New-Item \"$($SolutionDir)mRemoteV1\\bin\\package\" -ItemType \"directory\" | Out-Null\n \n Copy-Item \"$($SolutionDir)mRemoteV1\\Resources\\PuTTYNG.exe\" -Destination \"$($SolutionDir)mRemoteV1\\bin\\package\"\n\n Copy-Item \"$($SolutionDir)mRemoteV1\\bin\\$ConfigurationName\\*\" -Destination \"$($SolutionDir)mRemoteV1\\bin\\package\" -Recurse -Force \n Copy-Item \"$($SolutionDir)*.txt\" -Destination \"$($SolutionDir)mRemoteV1\\bin\\package\"\n\n Write-Output \"Creating portable ZIP file $($PortableZip)\"\n Remove-Item -Force $PortableZip -ErrorAction SilentlyContinue\n & $SEVENZIP a -bt -bd -bb1 -mx=9 -tzip -y -r $PortableZip \"$($SolutionDir)mRemoteV1\\bin\\package\\*.*\"\n}\nelse {\n Write-Output \"We will not zip anything - this isnt a portable release build.\"\n}"
|
||||
test:
|
||||
assemblies:
|
||||
only:
|
||||
- mRemoteNGTests\bin\$(configuration)\mRemoteNGTests.dll
|
||||
- mRemoteNGTests\bin\$(configuration)\mRemoteNGTests.dll
|
||||
artifacts:
|
||||
- path: Release\*.msi
|
||||
name: mRemoteNG-installer.msi
|
||||
- path: Release\*.zip
|
||||
name: mRemoteNG-portable.zip
|
||||
@@ -4,6 +4,7 @@ using System.Security;
|
||||
using System.Xml.Linq;
|
||||
using mRemoteNG.Config;
|
||||
using mRemoteNG.Config.Serializers;
|
||||
using mRemoteNG.Config.Serializers.Xml;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Security;
|
||||
|
||||
@@ -0,0 +1,185 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using mRemoteNG.Config.Serializers.Csv;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Connection.Protocol.Http;
|
||||
using mRemoteNG.Connection.Protocol.ICA;
|
||||
using mRemoteNG.Connection.Protocol.RDP;
|
||||
using mRemoteNG.Connection.Protocol.VNC;
|
||||
using mRemoteNG.Credential;
|
||||
using mRemoteNG.Security;
|
||||
using mRemoteNGTests.TestHelpers;
|
||||
using NSubstitute;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers.Csv
|
||||
{
|
||||
public class CsvConnectionsDeserializerMremotengFormatTests
|
||||
{
|
||||
private CsvConnectionsDeserializerMremotengFormat _deserializer;
|
||||
private CsvConnectionsSerializerMremotengFormat _serializer;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_deserializer = new CsvConnectionsDeserializerMremotengFormat();
|
||||
var credentialRepositoryList = Substitute.For<ICredentialRepositoryList>();
|
||||
_serializer = new CsvConnectionsSerializerMremotengFormat(new SaveFilter(), credentialRepositoryList);
|
||||
}
|
||||
|
||||
[TestCaseSource(typeof(DeserializationTestSource), nameof(DeserializationTestSource.ConnectionPropertyTestCases))]
|
||||
public object ConnectionPropertiesDeserializedCorrectly(string propertyToCheck)
|
||||
{
|
||||
var csv = _serializer.Serialize(GetTestConnection());
|
||||
var deserializedConnections = _deserializer.Deserialize(csv);
|
||||
var connection = deserializedConnections.GetRecursiveChildList().FirstOrDefault();
|
||||
var propertyValue = typeof(ConnectionInfo).GetProperty(propertyToCheck)?.GetValue(connection);
|
||||
return propertyValue;
|
||||
}
|
||||
|
||||
[TestCaseSource(typeof(DeserializationTestSource), nameof(DeserializationTestSource.InheritanceTestCases))]
|
||||
public object InheritancePropertiesDeserializedCorrectly(string propertyToCheck)
|
||||
{
|
||||
var csv = _serializer.Serialize(GetTestConnectionWithAllInherited());
|
||||
var deserializedConnections = _deserializer.Deserialize(csv);
|
||||
var connection = deserializedConnections.GetRecursiveChildList().FirstOrDefault();
|
||||
connection?.RemoveParent();
|
||||
var propertyValue = typeof(ConnectionInfoInheritance).GetProperty(propertyToCheck)?.GetValue(connection?.Inheritance);
|
||||
return propertyValue;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TreeStructureDeserializedCorrectly()
|
||||
{
|
||||
//Root
|
||||
// |- folder1
|
||||
// | |- Con1
|
||||
// |- Con2
|
||||
var treeModel = new ConnectionTreeModelBuilder().Build();
|
||||
var csv = _serializer.Serialize(treeModel);
|
||||
var deserializedConnections = _deserializer.Deserialize(csv);
|
||||
var con1 = deserializedConnections.GetRecursiveChildList().First(info => info.Name == "Con1");
|
||||
var folder1 = deserializedConnections.GetRecursiveChildList().First(info => info.Name == "folder1");
|
||||
Assert.That(con1.Parent, Is.EqualTo(folder1));
|
||||
}
|
||||
|
||||
internal static ConnectionInfo GetTestConnection()
|
||||
{
|
||||
return new ConnectionInfo
|
||||
{
|
||||
Name = "SomeName",
|
||||
Description = "SomeDescription",
|
||||
Icon = "SomeIcon",
|
||||
Panel = "SomePanel",
|
||||
Username = "SomeUsername",
|
||||
Password = "SomePassword",
|
||||
Domain = "SomeDomain",
|
||||
Hostname = "SomeHostname",
|
||||
PuttySession = "SomePuttySession",
|
||||
LoadBalanceInfo = "SomeLoadBalanceInfo",
|
||||
PreExtApp = "SomePreExtApp",
|
||||
PostExtApp = "SomePostExtApp",
|
||||
MacAddress = "SomeMacAddress",
|
||||
UserField = "SomeUserField",
|
||||
ExtApp = "SomeExtApp",
|
||||
VNCProxyUsername = "SomeVNCProxyUsername",
|
||||
VNCProxyPassword = "SomeVNCProxyPassword",
|
||||
RDGatewayUsername = "SomeRDGatewayUsername",
|
||||
RDGatewayPassword = "SomeRDGatewayPassword",
|
||||
RDGatewayDomain = "SomeRDGatewayDomain",
|
||||
VNCProxyIP = "SomeVNCProxyIP",
|
||||
RDGatewayHostname = "SomeRDGatewayHostname",
|
||||
Protocol = ProtocolType.ICA,
|
||||
Port = 999,
|
||||
UseConsoleSession = true,
|
||||
UseCredSsp = true,
|
||||
RenderingEngine = HTTPBase.RenderingEngine.Gecko,
|
||||
ICAEncryptionStrength = IcaProtocol.EncryptionStrength.Encr40Bit,
|
||||
RDPAuthenticationLevel = RdpProtocol.AuthenticationLevel.WarnOnFailedAuth,
|
||||
Colors = RdpProtocol.RDPColors.Colors16Bit,
|
||||
Resolution = RdpProtocol.RDPResolutions.Res1366x768,
|
||||
AutomaticResize = true,
|
||||
DisplayWallpaper = true,
|
||||
DisplayThemes = true,
|
||||
EnableFontSmoothing = true,
|
||||
EnableDesktopComposition = true,
|
||||
CacheBitmaps = true,
|
||||
RedirectDiskDrives = true,
|
||||
RedirectPorts = true,
|
||||
RedirectPrinters = true,
|
||||
RedirectSmartCards = true,
|
||||
RedirectSound = RdpProtocol.RDPSounds.LeaveAtRemoteComputer,
|
||||
RedirectKeys = true,
|
||||
VNCCompression = ProtocolVNC.Compression.Comp4,
|
||||
VNCEncoding = ProtocolVNC.Encoding.EncRRE,
|
||||
VNCAuthMode = ProtocolVNC.AuthMode.AuthVNC,
|
||||
VNCProxyType = ProtocolVNC.ProxyType.ProxySocks5,
|
||||
VNCProxyPort = 123,
|
||||
VNCColors = ProtocolVNC.Colors.Col8Bit,
|
||||
VNCSmartSizeMode = ProtocolVNC.SmartSizeMode.SmartSAspect,
|
||||
VNCViewOnly = true,
|
||||
RDGatewayUsageMethod = RdpProtocol.RDGatewayUsageMethod.Detect,
|
||||
RDGatewayUseConnectionCredentials = RdpProtocol.RDGatewayUseConnectionCredentials.SmartCard
|
||||
};
|
||||
}
|
||||
|
||||
internal static ConnectionInfo GetTestConnectionWithAllInherited()
|
||||
{
|
||||
var connectionInfo = new ConnectionInfo();
|
||||
connectionInfo.Inheritance.TurnOnInheritanceCompletely();
|
||||
return connectionInfo;
|
||||
}
|
||||
|
||||
private class DeserializationTestSource
|
||||
{
|
||||
public static IEnumerable ConnectionPropertyTestCases()
|
||||
{
|
||||
var ignoreProperties = new[]
|
||||
{
|
||||
nameof(ConnectionInfo.Inheritance),
|
||||
nameof(ConnectionInfo.ConstantID),
|
||||
nameof(ConnectionInfo.Parent)
|
||||
};
|
||||
var properties = typeof(ConnectionInfo)
|
||||
.GetProperties()
|
||||
.Where(property => !ignoreProperties.Contains(property.Name));
|
||||
var testCases = new List<TestCaseData>();
|
||||
var testConnectionInfo = GetTestConnection();
|
||||
|
||||
foreach (var property in properties)
|
||||
{
|
||||
testCases.Add(
|
||||
new TestCaseData(property.Name)
|
||||
.Returns(property.GetValue(testConnectionInfo)));
|
||||
}
|
||||
|
||||
return testCases;
|
||||
}
|
||||
|
||||
public static IEnumerable InheritanceTestCases()
|
||||
{
|
||||
var ignoreProperties = new[]
|
||||
{
|
||||
nameof(ConnectionInfoInheritance.EverythingInherited),
|
||||
nameof(ConnectionInfoInheritance.Parent)
|
||||
};
|
||||
var properties = typeof(ConnectionInfoInheritance)
|
||||
.GetProperties()
|
||||
.Where(property => !ignoreProperties.Contains(property.Name));
|
||||
var testCases = new List<TestCaseData>();
|
||||
var testInheritance = GetTestConnectionWithAllInherited().Inheritance;
|
||||
|
||||
foreach (var property in properties)
|
||||
{
|
||||
testCases.Add(
|
||||
new TestCaseData(property.Name)
|
||||
.Returns(property.GetValue(testInheritance)));
|
||||
}
|
||||
|
||||
return testCases;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,17 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using mRemoteNG.Config.Serializers;
|
||||
using mRemoteNG.Config.Serializers.Csv;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Credential;
|
||||
using mRemoteNG.Security;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNGTests.TestHelpers;
|
||||
using NSubstitute;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.Config.Serializers.MiscSerializers
|
||||
namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers.Csv
|
||||
{
|
||||
public class CsvConnectionsSerializerMremotengFormatTests
|
||||
{
|
||||
@@ -28,6 +32,24 @@ namespace mRemoteNGTests.Config.Serializers.MiscSerializers
|
||||
_credentialRepositoryList.GetCredentialRecord(new Guid()).ReturnsForAnyArgs(credRecord);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SerializesNodeId()
|
||||
{
|
||||
var serializer = new CsvConnectionsSerializerMremotengFormat(new SaveFilter(), _credentialRepositoryList);
|
||||
var connectionInfo = BuildConnectionInfo();
|
||||
var csv = serializer.Serialize(connectionInfo);
|
||||
Assert.That(csv, Does.Match(connectionInfo.ConstantID));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DoesntSerializeTheRootNode()
|
||||
{
|
||||
var serializer = new CsvConnectionsSerializerMremotengFormat(new SaveFilter(), _credentialRepositoryList);
|
||||
var treeModel = new ConnectionTreeModelBuilder().Build();
|
||||
var csv = serializer.Serialize(treeModel);
|
||||
Assert.That(csv, Does.Not.Match($"{treeModel.RootNodes[0].ConstantID};.*;{TreeNodeType.Root}"));
|
||||
}
|
||||
|
||||
[TestCase(Username)]
|
||||
[TestCase(Domain)]
|
||||
[TestCase(Password)]
|
||||
@@ -82,6 +104,32 @@ namespace mRemoteNGTests.Config.Serializers.MiscSerializers
|
||||
Assert.Throws<ArgumentNullException>(() => serializer.Serialize((ConnectionTreeModel)null));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FoldersAreSerialized()
|
||||
{
|
||||
var serializer = new CsvConnectionsSerializerMremotengFormat(new SaveFilter(), _credentialRepositoryList);
|
||||
var container = BuildContainer();
|
||||
var csv = serializer.Serialize(container);
|
||||
Assert.That(csv, Does.Match(container.Name));
|
||||
Assert.That(csv, Does.Match(container.Username));
|
||||
Assert.That(csv, Does.Match(container.Domain));
|
||||
Assert.That(csv, Does.Match(container.Password));
|
||||
Assert.That(csv, Does.Contain(TreeNodeType.Container.ToString()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SerializationIncludesRawInheritedValuesIfObjectInheritsFromParentOutsideOfSerializationScope()
|
||||
{
|
||||
var serializer = new CsvConnectionsSerializerMremotengFormat(new SaveFilter(), _credentialRepositoryList);
|
||||
var treeModel = new ConnectionTreeModelBuilder().Build();
|
||||
var serializationTarget = treeModel.GetRecursiveChildList().First(info => info.Name == "folder3");
|
||||
var csv = serializer.Serialize(serializationTarget);
|
||||
var lineWithFolder3 = csv.Split(new[] {Environment.NewLine}, StringSplitOptions.None).First(s => s.Contains(serializationTarget.Name));
|
||||
Assert.That(lineWithFolder3, Does.Contain(serializationTarget.Username));
|
||||
Assert.That(lineWithFolder3, Does.Contain(serializationTarget.Domain));
|
||||
Assert.That(lineWithFolder3, Does.Contain(serializationTarget.Password));
|
||||
}
|
||||
|
||||
private ConnectionInfo BuildConnectionInfo()
|
||||
{
|
||||
return new ConnectionInfo
|
||||
@@ -93,5 +141,16 @@ namespace mRemoteNGTests.Config.Serializers.MiscSerializers
|
||||
Inheritance = {Colors = true}
|
||||
};
|
||||
}
|
||||
|
||||
private ContainerInfo BuildContainer()
|
||||
{
|
||||
return new ContainerInfo
|
||||
{
|
||||
Name = "MyFolder",
|
||||
Username = "BlahBlah1",
|
||||
Domain = "aklkskkksh8",
|
||||
Password = "qweraslkdjf87"
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Xml.Schema;
|
||||
using mRemoteNG.Config.Serializers.Xml;
|
||||
using mRemoteNG.Security;
|
||||
using mRemoteNG.Security.SymmetricEncryption;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNG.Tree.Root;
|
||||
using mRemoteNGTests.TestHelpers;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers.Xml
|
||||
{
|
||||
public class ValidateXmlSchemas
|
||||
{
|
||||
private XmlConnectionsSerializer _serializer;
|
||||
private ConnectionTreeModel _connectionTreeModel;
|
||||
private ICryptographyProvider _cryptographyProvider;
|
||||
private XmlReaderSettings _xmlReaderSettings;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_connectionTreeModel = new ConnectionTreeModelBuilder().Build();
|
||||
_cryptographyProvider = new AeadCryptographyProvider();
|
||||
var connectionNodeSerializer = new XmlConnectionNodeSerializer26(
|
||||
_cryptographyProvider,
|
||||
_connectionTreeModel.RootNodes.OfType<RootNodeInfo>().First().PasswordString.ConvertToSecureString(),
|
||||
new SaveFilter());
|
||||
_serializer = new XmlConnectionsSerializer(_cryptographyProvider, connectionNodeSerializer);
|
||||
_xmlReaderSettings = new XmlReaderSettings
|
||||
{
|
||||
ValidationType = ValidationType.Schema,
|
||||
ValidationFlags = XmlSchemaValidationFlags.ProcessInlineSchema |
|
||||
XmlSchemaValidationFlags.ProcessSchemaLocation |
|
||||
XmlSchemaValidationFlags.ReportValidationWarnings
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ValidateSchema()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
var xml = _serializer.Serialize(_connectionTreeModel);
|
||||
|
||||
var schemaFile = GetTargetPath("mremoteng_confcons_v2_6.xsd");
|
||||
_xmlReaderSettings.Schemas.Add("http://mremoteng.org", schemaFile);
|
||||
_xmlReaderSettings.ValidationEventHandler += (sender, args) =>
|
||||
{
|
||||
sb.AppendLine($"{args.Severity}: {args.Message}");
|
||||
};
|
||||
|
||||
using (var stream = GenerateStreamFromString(xml))
|
||||
{
|
||||
var reader = XmlReader.Create(stream, _xmlReaderSettings);
|
||||
while (reader.Read()) ;
|
||||
}
|
||||
|
||||
Assert.That(sb.ToString(), Is.Empty);
|
||||
}
|
||||
|
||||
public string GetTargetPath(string fileName, [CallerFilePath] string sourceFilePath = "")
|
||||
{
|
||||
const string debugOrRelease =
|
||||
#if DEBUG
|
||||
"Debug";
|
||||
#else
|
||||
"Release";
|
||||
#endif
|
||||
|
||||
const string normalOrPortable =
|
||||
#if PORTABLE
|
||||
" Portable";
|
||||
#else
|
||||
"";
|
||||
#endif
|
||||
var path = Path.GetDirectoryName(sourceFilePath);
|
||||
var filePath = $@"{path}\..\..\..\..\bin\{debugOrRelease}{normalOrPortable}\Schemas\{fileName}";
|
||||
return filePath;
|
||||
}
|
||||
|
||||
private Stream GenerateStreamFromString(string s)
|
||||
{
|
||||
var stream = new MemoryStream();
|
||||
var writer = new StreamWriter(stream);
|
||||
writer.Write(s);
|
||||
writer.Flush();
|
||||
stream.Position = 0;
|
||||
return stream;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using mRemoteNG.Config.Serializers;
|
||||
using mRemoteNG.Config.Serializers.Xml;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Security;
|
||||
@@ -9,7 +9,7 @@ using mRemoteNG.Tree;
|
||||
using mRemoteNGTests.Properties;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers
|
||||
namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers.Xml
|
||||
{
|
||||
public class XmlConnectionsDeserializerTests
|
||||
{
|
||||
@@ -18,7 +18,7 @@ namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers
|
||||
|
||||
public void Setup(string confCons, string password)
|
||||
{
|
||||
_xmlConnectionsDeserializer = new XmlConnectionsDeserializer(password.ConvertToSecureString);
|
||||
_xmlConnectionsDeserializer = new XmlConnectionsDeserializer(() => password.ConvertToSecureString());
|
||||
_connectionTreeModel = _xmlConnectionsDeserializer.Deserialize(confCons);
|
||||
}
|
||||
|
||||
@@ -104,6 +104,14 @@ namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers
|
||||
Assert.That(folder22.Inheritance.Username, Is.True);
|
||||
}
|
||||
|
||||
[TestCaseSource(typeof(XmlConnectionsDeserializerFixtureData), nameof(XmlConnectionsDeserializerFixtureData.FixtureParams))]
|
||||
public void ExpandedPropertyGetsDeserialized(Datagram testData)
|
||||
{
|
||||
Setup(testData.ConfCons, testData.Password);
|
||||
var folder1 = GetFolderNamed("Folder1", _connectionTreeModel.GetRecursiveChildList());
|
||||
Assert.That(folder1.IsExpanded, Is.True);
|
||||
}
|
||||
|
||||
private bool ContainsNodeNamed(string name, IEnumerable<ConnectionInfo> list)
|
||||
{
|
||||
return list.Any(node => node.Name == name);
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Linq;
|
||||
using System.Xml.XPath;
|
||||
using mRemoteNG.Config.Serializers;
|
||||
using mRemoteNG.Config.Serializers.Xml;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Security;
|
||||
@@ -9,7 +10,7 @@ using mRemoteNG.Tree;
|
||||
using mRemoteNG.Tree.Root;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers
|
||||
namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers.Xml
|
||||
{
|
||||
public class XmlConnectionsDocumentCompilerTests
|
||||
{
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using mRemoteNG.Config.Serializers;
|
||||
using mRemoteNG.Config.Serializers.Xml;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Security;
|
||||
@@ -9,7 +10,7 @@ using mRemoteNG.Tree;
|
||||
using mRemoteNG.Tree.Root;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers
|
||||
namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers.Xml
|
||||
{
|
||||
public class XmlConnectionsDocumentEncryptorTests
|
||||
{
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
using mRemoteNG.Config.Serializers;
|
||||
using mRemoteNG.Config.Serializers.Xml;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Security;
|
||||
@@ -10,7 +11,7 @@ using mRemoteNG.Tree;
|
||||
using mRemoteNG.Tree.Root;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers
|
||||
namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers.Xml
|
||||
{
|
||||
public class XmlConnectionsSerializerTests
|
||||
{
|
||||
@@ -55,7 +56,7 @@ namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers
|
||||
[TestCase("Username", "")]
|
||||
[TestCase("Domain", "")]
|
||||
[TestCase("Password", "")]
|
||||
[TestCase("InheritAutomaticResize", "False")]
|
||||
[TestCase("InheritAutomaticResize", "false")]
|
||||
public void SerializerRespectsSaveFilterSettings(string attributeName, string expectedValue)
|
||||
{
|
||||
var connectionNodeSerializer = new XmlConnectionNodeSerializer26(
|
||||
@@ -2,13 +2,14 @@
|
||||
using System.Collections;
|
||||
using System.Xml.Linq;
|
||||
using mRemoteNG.Config.Serializers;
|
||||
using mRemoteNG.Config.Serializers.Xml;
|
||||
using mRemoteNG.Security;
|
||||
using mRemoteNG.Security.Factories;
|
||||
using mRemoteNG.Security.SymmetricEncryption;
|
||||
using mRemoteNG.Tree.Root;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers
|
||||
namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers.Xml
|
||||
{
|
||||
public class XmlRootNodeSerializerTests
|
||||
{
|
||||
@@ -75,7 +76,7 @@ namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers
|
||||
{
|
||||
var element = _rootNodeSerializer.SerializeRootNodeInfo(_rootNodeInfo, _cryptographyProvider, fullFileEncryption);
|
||||
var attributeValue = element.Attribute(XName.Get("FullFileEncryption"))?.Value;
|
||||
Assert.That(attributeValue, Is.EqualTo(fullFileEncryption.ToString()));
|
||||
Assert.That(bool.Parse(attributeValue), Is.EqualTo(fullFileEncryption));
|
||||
}
|
||||
|
||||
[TestCase("", "ThisIsNotProtected")]
|
||||
@@ -1,4 +1,5 @@
|
||||
using mRemoteNG.Config.Serializers;
|
||||
using System.Linq;
|
||||
using mRemoteNG.Config.Serializers;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Security;
|
||||
@@ -26,7 +27,7 @@ namespace mRemoteNGTests.Config.Serializers
|
||||
{
|
||||
var model = CreateConnectionTreeModel();
|
||||
var dataTable = _dataTableSerializer.Serialize(model);
|
||||
Assert.That(dataTable.Rows.Count, Is.EqualTo(3));
|
||||
Assert.That(dataTable.Rows.Count, Is.EqualTo(model.GetRecursiveChildList().Count()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using mRemoteNG.Connection;
|
||||
using System;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Connection.Protocol.Http;
|
||||
using mRemoteNG.Connection.Protocol.ICA;
|
||||
@@ -9,10 +10,14 @@ using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.Connection
|
||||
{
|
||||
public class AbstractConnectionInfoDataTests
|
||||
public class AbstractConnectionInfoDataTests
|
||||
{
|
||||
#pragma warning disable 618
|
||||
private class TestAbstractConnectionInfoData : AbstractConnectionRecord {}
|
||||
private class TestAbstractConnectionInfoData : AbstractConnectionRecord {
|
||||
public TestAbstractConnectionInfoData() : base(Guid.NewGuid().ToString())
|
||||
{
|
||||
}
|
||||
}
|
||||
#pragma warning restore 618
|
||||
private TestAbstractConnectionInfoData _testAbstractConnectionInfoData;
|
||||
|
||||
|
||||
@@ -27,22 +27,6 @@ namespace mRemoteNGTests.Connection
|
||||
_connectionInfo = null;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CreatingConnectionInfoWithParentSetsTheParentProperty()
|
||||
{
|
||||
var container = new ContainerInfo();
|
||||
var connectionInfo = new ConnectionInfo(container);
|
||||
Assert.That(connectionInfo.Parent, Is.EqualTo(container));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CreatingConnectionInfoWithParentAddsToTheParentsChildList()
|
||||
{
|
||||
var container = new ContainerInfo();
|
||||
var connectionInfo = new ConnectionInfo(container);
|
||||
Assert.That(container.Children, Does.Contain(connectionInfo));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CopyCreatesMemberwiseCopy()
|
||||
{
|
||||
@@ -59,6 +43,20 @@ namespace mRemoteNGTests.Connection
|
||||
Assert.That(clonedConnection.Parent, Is.Null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CloneAlsoCopiesInheritanceObject()
|
||||
{
|
||||
var clonedConnection = _connectionInfo.Clone();
|
||||
Assert.That(clonedConnection.Inheritance, Is.Not.EqualTo(_connectionInfo.Inheritance));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CloneCorrectlySetsParentOfInheritanceObject()
|
||||
{
|
||||
var clonedConnection = _connectionInfo.Clone();
|
||||
Assert.That(clonedConnection.Inheritance.Parent, Is.EqualTo(clonedConnection));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CopyFromCopiesProperties()
|
||||
{
|
||||
|
||||
@@ -1,73 +1,62 @@
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNGTests.TestHelpers;
|
||||
using NUnit.Framework;
|
||||
|
||||
|
||||
namespace mRemoteNGTests.Connection
|
||||
{
|
||||
public class DefaultConnectionInfoTests
|
||||
{
|
||||
private string _testDomain = "somedomain";
|
||||
public class DefaultConnectionInfoTests
|
||||
{
|
||||
private ConnectionInfo _randomizedConnectionInfo;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
DefaultConnectionInfo.Instance.Domain = "";
|
||||
_randomizedConnectionInfo = ConnectionInfoHelpers.GetRandomizedConnectionInfo();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LoadingDefaultInfoUpdatesAllProperties()
|
||||
[TestCaseSource(nameof(GetConnectionInfoProperties))]
|
||||
public void LoadingDefaultInfoUpdatesAllProperties(PropertyInfo property)
|
||||
{
|
||||
var connectionInfoSource = new ConnectionInfo { Domain = _testDomain };
|
||||
DefaultConnectionInfo.Instance.LoadFrom(connectionInfoSource);
|
||||
Assert.That(DefaultConnectionInfo.Instance.Domain, Is.EqualTo(_testDomain));
|
||||
DefaultConnectionInfo.Instance.LoadFrom(_randomizedConnectionInfo);
|
||||
var valueInDestination = property.GetValue(DefaultConnectionInfo.Instance);
|
||||
var valueInSource = property.GetValue(_randomizedConnectionInfo);
|
||||
Assert.That(valueInDestination, Is.EqualTo(valueInSource));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SavingDefaultConnectionInfoExportsAllProperties()
|
||||
[TestCaseSource(nameof(GetConnectionInfoProperties))]
|
||||
public void SavingDefaultConnectionInfoExportsAllProperties(PropertyInfo property)
|
||||
{
|
||||
var saveTarget = new ConnectionInfo();
|
||||
DefaultConnectionInfo.Instance.Domain = _testDomain;
|
||||
var randomizedValue = property.GetValue(_randomizedConnectionInfo);
|
||||
property.SetValue(DefaultConnectionInfo.Instance, randomizedValue);
|
||||
DefaultConnectionInfo.Instance.SaveTo(saveTarget);
|
||||
Assert.That(saveTarget.Domain, Is.EqualTo(_testDomain));
|
||||
var valueInDestination = property.GetValue(saveTarget);
|
||||
var valueInSource = property.GetValue(DefaultConnectionInfo.Instance);
|
||||
Assert.That(valueInDestination, Is.EqualTo(valueInSource));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanSaveEnumValuesToString()
|
||||
{
|
||||
const ProtocolType targetProtocol = ProtocolType.RAW;
|
||||
var saveTarget = new AllStringPropertySaveTarget();
|
||||
DefaultConnectionInfo.Instance.Protocol = targetProtocol;
|
||||
[TestCaseSource(nameof(GetConnectionInfoProperties))]
|
||||
public void CanSaveDefaultConnectionToModelWithAllStringProperties(PropertyInfo property)
|
||||
{
|
||||
var saveTarget = new SerializableConnectionInfoAllPropertiesOfType<string>();
|
||||
|
||||
// randomize default connnection values to ensure we dont get false passing tests
|
||||
var randomizedValue = property.GetValue(_randomizedConnectionInfo);
|
||||
property.SetValue(DefaultConnectionInfo.Instance, randomizedValue);
|
||||
|
||||
DefaultConnectionInfo.Instance.SaveTo(saveTarget);
|
||||
Assert.That(saveTarget.Protocol, Is.EqualTo(targetProtocol.ToString()));
|
||||
|
||||
var valueInSource = property.GetValue(DefaultConnectionInfo.Instance).ToString();
|
||||
var valueInDestination = saveTarget.GetType().GetProperty(property.Name).GetValue(saveTarget).ToString();
|
||||
Assert.That(valueInDestination, Is.EqualTo(valueInSource));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanSaveIntegerValuesToString()
|
||||
{
|
||||
const int targetValue = 123;
|
||||
var saveTarget = new AllStringPropertySaveTarget();
|
||||
DefaultConnectionInfo.Instance.RDPMinutesToIdleTimeout = targetValue;
|
||||
DefaultConnectionInfo.Instance.SaveTo(saveTarget);
|
||||
Assert.That(saveTarget.RDPMinutesToIdleTimeout, Is.EqualTo(targetValue.ToString()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanSaveStringValuesToString()
|
||||
{
|
||||
const string targetName = "hello";
|
||||
var saveTarget = new AllStringPropertySaveTarget();
|
||||
DefaultConnectionInfo.Instance.Username = targetName;
|
||||
DefaultConnectionInfo.Instance.SaveTo(saveTarget);
|
||||
Assert.That(saveTarget.Username, Is.EqualTo(targetName));
|
||||
}
|
||||
|
||||
|
||||
private class AllStringPropertySaveTarget
|
||||
{
|
||||
public string Username { get; set; }
|
||||
public string Protocol { get; set; }
|
||||
public string RDPMinutesToIdleTimeout { get; set; }
|
||||
}
|
||||
private static IEnumerable<PropertyInfo> GetConnectionInfoProperties()
|
||||
{
|
||||
return new ConnectionInfo().GetSerializableProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,34 +1,40 @@
|
||||
using mRemoteNG.Connection;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using mRemoteNG.Connection;
|
||||
using NUnit.Framework;
|
||||
|
||||
|
||||
namespace mRemoteNGTests.Connection
|
||||
{
|
||||
public class DefaultConnectionInheritanceTests
|
||||
public class DefaultConnectionInheritanceTests
|
||||
{
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
[TestCaseSource(nameof(GetInheritanceProperties))]
|
||||
public void LoadingDefaultInheritanceUpdatesAllProperties(PropertyInfo property)
|
||||
{
|
||||
DefaultConnectionInheritance.Instance.TurnOffInheritanceCompletely();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LoadingDefaultInheritanceUpdatesAllProperties()
|
||||
{
|
||||
var inheritanceSource = new ConnectionInfoInheritance(new object(), true);
|
||||
var inheritanceSource = new ConnectionInfoInheritance(new object(), true);
|
||||
inheritanceSource.TurnOnInheritanceCompletely();
|
||||
DefaultConnectionInheritance.Instance.LoadFrom(inheritanceSource);
|
||||
Assert.That(DefaultConnectionInheritance.Instance.EverythingInherited, Is.True);
|
||||
}
|
||||
DefaultConnectionInheritance.Instance.TurnOffInheritanceCompletely();
|
||||
|
||||
[Test]
|
||||
public void SavingDefaultInheritanceExportsAllProperties()
|
||||
DefaultConnectionInheritance.Instance.LoadFrom(inheritanceSource);
|
||||
|
||||
var valueInDestination = property.GetValue(DefaultConnectionInheritance.Instance);
|
||||
var valueInSource = property.GetValue(inheritanceSource);
|
||||
Assert.That(valueInDestination, Is.EqualTo(valueInSource));
|
||||
}
|
||||
|
||||
[TestCaseSource(nameof(GetInheritanceProperties))]
|
||||
public void SavingDefaultInheritanceExportsAllProperties(PropertyInfo property)
|
||||
{
|
||||
var inheritanceDestination = new ConnectionInfoInheritance(new object(), true);
|
||||
DefaultConnectionInheritance.Instance.AutomaticResize = true;
|
||||
DefaultConnectionInheritance.Instance.SaveTo(inheritanceDestination);
|
||||
Assert.That(inheritanceDestination.AutomaticResize, Is.True);
|
||||
}
|
||||
var saveTarget = new ConnectionInfoInheritance(new object(), true);
|
||||
saveTarget.TurnOffInheritanceCompletely();
|
||||
DefaultConnectionInheritance.Instance.TurnOnInheritanceCompletely();
|
||||
|
||||
DefaultConnectionInheritance.Instance.SaveTo(saveTarget);
|
||||
|
||||
var valueInDestination = property.GetValue(saveTarget);
|
||||
var valueInSource = property.GetValue(DefaultConnectionInheritance.Instance);
|
||||
Assert.That(valueInDestination, Is.EqualTo(valueInSource));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NewInheritanceInstancesCreatedWithDefaultInheritanceValues()
|
||||
@@ -38,12 +44,20 @@ namespace mRemoteNGTests.Connection
|
||||
Assert.That(inheritanceInstance.Domain, Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NewInheritanceInstancesCreatedWithAllDefaultInheritanceValues()
|
||||
[TestCaseSource(nameof(GetInheritanceProperties))]
|
||||
public void NewInheritanceInstancesCreatedWithAllDefaultInheritanceValues(PropertyInfo property)
|
||||
{
|
||||
DefaultConnectionInheritance.Instance.TurnOnInheritanceCompletely();
|
||||
var inheritanceInstance = new ConnectionInfoInheritance(new object());
|
||||
Assert.That(inheritanceInstance.EverythingInherited, Is.True);
|
||||
}
|
||||
}
|
||||
|
||||
var valueInDestination = property.GetValue(inheritanceInstance);
|
||||
var valueInSource = property.GetValue(DefaultConnectionInheritance.Instance);
|
||||
Assert.That(valueInDestination, Is.EqualTo(valueInSource));
|
||||
}
|
||||
|
||||
private static IEnumerable<PropertyInfo> GetInheritanceProperties()
|
||||
{
|
||||
return new ConnectionInfoInheritance(new object(), true).GetProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
18
mRemoteNGTests/Container/RootNodeInfoTests.cs
Normal file
18
mRemoteNGTests/Container/RootNodeInfoTests.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Tree.Root;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.Container
|
||||
{
|
||||
public class RootNodeInfoTests
|
||||
{
|
||||
[Test]
|
||||
public void InheritanceIsDisabledForNodesDirectlyUnderRootNode()
|
||||
{
|
||||
var rootNode = new RootNodeInfo(RootNodeType.Connection);
|
||||
var con1 = new ConnectionInfo { Inheritance = { Password = true } };
|
||||
rootNode.AddChild(con1);
|
||||
Assert.That(con1.Inheritance.Password, Is.False);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using mRemoteNG.Config.Serializers;
|
||||
using mRemoteNG.Config.Serializers.Xml;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Security;
|
||||
@@ -28,20 +31,19 @@ namespace mRemoteNGTests.IntegrationTests
|
||||
_originalModel.RootNodes.OfType<RootNodeInfo>().First().PasswordString.ConvertToSecureString(),
|
||||
new SaveFilter());
|
||||
_serializer = new XmlConnectionsSerializer(cryptoProvider, nodeSerializer);
|
||||
_deserializer = new XmlConnectionsDeserializer();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void Teardown()
|
||||
{
|
||||
_serializer = null;
|
||||
_deserializer = null;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SerializeThenDeserialize()
|
||||
{
|
||||
var serializedContent = _serializer.Serialize(_originalModel);
|
||||
_deserializer = new XmlConnectionsDeserializer();
|
||||
var deserializedModel = _deserializer.Deserialize(serializedContent);
|
||||
var nodeNamesFromDeserializedModel = deserializedModel.GetRecursiveChildList().Select(node => node.Name);
|
||||
var nodeNamesFromOriginalModel = _originalModel.GetRecursiveChildList().Select(node => node.Name);
|
||||
@@ -53,7 +55,6 @@ namespace mRemoteNGTests.IntegrationTests
|
||||
{
|
||||
_serializer.UseFullEncryption = true;
|
||||
var serializedContent = _serializer.Serialize(_originalModel);
|
||||
_deserializer = new XmlConnectionsDeserializer();
|
||||
var deserializedModel = _deserializer.Deserialize(serializedContent);
|
||||
var nodeNamesFromDeserializedModel = deserializedModel.GetRecursiveChildList().Select(node => node.Name);
|
||||
var nodeNamesFromOriginalModel = _originalModel.GetRecursiveChildList().Select(node => node.Name);
|
||||
@@ -65,7 +66,6 @@ namespace mRemoteNGTests.IntegrationTests
|
||||
{
|
||||
var originalConnectionInfo = new ConnectionInfo {Name = "con1", Description = "£°úg¶┬ä" };
|
||||
var serializedContent = _serializer.Serialize(originalConnectionInfo);
|
||||
_deserializer = new XmlConnectionsDeserializer();
|
||||
var deserializedModel = _deserializer.Deserialize(serializedContent);
|
||||
var deserializedConnectionInfo = deserializedModel.GetRecursiveChildList().First(node => node.Name == originalConnectionInfo.Name);
|
||||
Assert.That(deserializedConnectionInfo.Description, Is.EqualTo(originalConnectionInfo.Description));
|
||||
@@ -83,13 +83,26 @@ namespace mRemoteNGTests.IntegrationTests
|
||||
new SaveFilter());
|
||||
_serializer = new XmlConnectionsSerializer(cryptoProvider, nodeSerializer);
|
||||
var serializedContent = _serializer.Serialize(_originalModel);
|
||||
_deserializer = new XmlConnectionsDeserializer();
|
||||
var deserializedModel = _deserializer.Deserialize(serializedContent);
|
||||
var nodeNamesFromDeserializedModel = deserializedModel.GetRecursiveChildList().Select(node => node.Name);
|
||||
var nodeNamesFromOriginalModel = _originalModel.GetRecursiveChildList().Select(node => node.Name);
|
||||
Assert.That(nodeNamesFromDeserializedModel, Is.EquivalentTo(nodeNamesFromOriginalModel));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GuidCreatedIfNonExistedInXml()
|
||||
{
|
||||
var originalConnectionInfo = new ConnectionInfo { Name = "con1" };
|
||||
var serializedContent = _serializer.Serialize(originalConnectionInfo);
|
||||
|
||||
// remove GUID from connection xml
|
||||
serializedContent = serializedContent.Replace(originalConnectionInfo.ConstantID, "");
|
||||
|
||||
var deserializedModel = _deserializer.Deserialize(serializedContent);
|
||||
var deserializedConnectionInfo = deserializedModel.GetRecursiveChildList().First(node => node.Name == originalConnectionInfo.Name);
|
||||
Assert.That(Guid.TryParse(deserializedConnectionInfo.ConstantID, out var guid));
|
||||
}
|
||||
|
||||
|
||||
private ConnectionTreeModel SetupConnectionTreeModel()
|
||||
{
|
||||
|
||||
@@ -34,8 +34,9 @@
|
||||
|
||||
using System.Collections;
|
||||
using System.Windows.Forms;
|
||||
using NUnit.Extensions.Forms;
|
||||
|
||||
namespace NUnit.Extensions.Forms
|
||||
namespace mRemoteNGTests
|
||||
{
|
||||
/// <summary>
|
||||
/// A ControlTester for testing List Views.
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using mRemoteNG.Security;
|
||||
using mRemoteNG.Security.Authentication;
|
||||
using mRemoteNG.Security.SymmetricEncryption;
|
||||
using mRemoteNG.Tools;
|
||||
using NUnit.Framework;
|
||||
|
||||
|
||||
@@ -9,35 +10,31 @@ namespace mRemoteNGTests.Security.Authentication
|
||||
{
|
||||
public class PasswordAuthenticatorTests
|
||||
{
|
||||
private PasswordAuthenticator _authenticator;
|
||||
private ICryptographyProvider _cryptographyProvider;
|
||||
private string _cipherText;
|
||||
private readonly SecureString _correctPassword = "9theCorrectPass#5".ConvertToSecureString();
|
||||
private readonly SecureString _wrongPassword = "wrongPassword".ConvertToSecureString();
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
var cryptoProvider = new AeadCryptographyProvider {KeyDerivationIterations = 10000};
|
||||
const string cipherText = "MPELiwk7+xeNlruIyt5uxTvVB+/RLVoLdUGnwY4CWCqwKe7T2IBwWo4oaKum5hdv7447g5m2nZsYPrfARSlotQB4r1KZQg==";
|
||||
_authenticator = new PasswordAuthenticator(cryptoProvider, cipherText);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void Teardown()
|
||||
{
|
||||
_authenticator = null;
|
||||
_cryptographyProvider = new AeadCryptographyProvider {KeyDerivationIterations = 10000};
|
||||
_cipherText = "MPELiwk7+xeNlruIyt5uxTvVB+/RLVoLdUGnwY4CWCqwKe7T2IBwWo4oaKum5hdv7447g5m2nZsYPrfARSlotQB4r1KZQg==";
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AuthenticatingWithCorrectPasswordReturnsTrue()
|
||||
{
|
||||
var authenticated = _authenticator.Authenticate(_correctPassword);
|
||||
var authenticator = new PasswordAuthenticator(_cryptographyProvider, _cipherText, () => Optional<SecureString>.Empty);
|
||||
var authenticated = authenticator.Authenticate(_correctPassword);
|
||||
Assert.That(authenticated);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AuthenticatingWithWrongPasswordReturnsFalse()
|
||||
{
|
||||
var authenticated = _authenticator.Authenticate(_wrongPassword);
|
||||
var authenticator = new PasswordAuthenticator(_cryptographyProvider, _cipherText, () => Optional<SecureString>.Empty);
|
||||
var authenticated = authenticator.Authenticate(_wrongPassword);
|
||||
Assert.That(!authenticated);
|
||||
}
|
||||
|
||||
@@ -45,12 +42,15 @@ namespace mRemoteNGTests.Security.Authentication
|
||||
public void AuthenticationRequestorIsCalledWhenInitialPasswordIsWrong()
|
||||
{
|
||||
var wasCalled = false;
|
||||
_authenticator.AuthenticationRequestor = () =>
|
||||
|
||||
Optional<SecureString> AuthenticationRequestor()
|
||||
{
|
||||
wasCalled = true;
|
||||
return _correctPassword;
|
||||
};
|
||||
_authenticator.Authenticate(_wrongPassword);
|
||||
}
|
||||
|
||||
var authenticator = new PasswordAuthenticator(_cryptographyProvider, _cipherText, AuthenticationRequestor);
|
||||
authenticator.Authenticate(_wrongPassword);
|
||||
Assert.That(wasCalled);
|
||||
}
|
||||
|
||||
@@ -58,28 +58,30 @@ namespace mRemoteNGTests.Security.Authentication
|
||||
public void AuthenticationRequestorNotCalledWhenInitialPasswordIsCorrect()
|
||||
{
|
||||
var wasCalled = false;
|
||||
_authenticator.AuthenticationRequestor = () =>
|
||||
Optional<SecureString> AuthenticationRequestor()
|
||||
{
|
||||
wasCalled = true;
|
||||
return _correctPassword;
|
||||
};
|
||||
_authenticator.Authenticate(_correctPassword);
|
||||
}
|
||||
|
||||
var authenticator = new PasswordAuthenticator(_cryptographyProvider, _cipherText, AuthenticationRequestor);
|
||||
authenticator.Authenticate(_correctPassword);
|
||||
Assert.That(!wasCalled);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ProvidingCorrectPasswordToTheAuthenticationRequestorReturnsTrue()
|
||||
{
|
||||
_authenticator.AuthenticationRequestor = () => _correctPassword;
|
||||
var authenticated = _authenticator.Authenticate(_wrongPassword);
|
||||
var authenticator = new PasswordAuthenticator(_cryptographyProvider, _cipherText, () => _correctPassword);
|
||||
var authenticated = authenticator.Authenticate(_wrongPassword);
|
||||
Assert.That(authenticated);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AuthenticationFailsWhenAuthenticationRequestorGivenEmptyPassword()
|
||||
{
|
||||
_authenticator.AuthenticationRequestor = () => new SecureString();
|
||||
var authenticated = _authenticator.Authenticate(_wrongPassword);
|
||||
var authenticator = new PasswordAuthenticator(_cryptographyProvider, _cipherText, () => new SecureString());
|
||||
var authenticated = authenticator.Authenticate(_wrongPassword);
|
||||
Assert.That(!authenticated);
|
||||
}
|
||||
|
||||
@@ -87,27 +89,34 @@ namespace mRemoteNGTests.Security.Authentication
|
||||
public void AuthenticatorRespectsMaxAttempts()
|
||||
{
|
||||
var authAttempts = 0;
|
||||
_authenticator.AuthenticationRequestor = () =>
|
||||
Optional<SecureString> AuthenticationRequestor()
|
||||
{
|
||||
authAttempts++;
|
||||
return _wrongPassword;
|
||||
};
|
||||
_authenticator.Authenticate(_wrongPassword);
|
||||
Assert.That(authAttempts == _authenticator.MaxAttempts);
|
||||
}
|
||||
|
||||
var authenticator = new PasswordAuthenticator(_cryptographyProvider, _cipherText, AuthenticationRequestor);
|
||||
authenticator.Authenticate(_wrongPassword);
|
||||
Assert.That(authAttempts == authenticator.MaxAttempts);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AuthenticatorRespectsMaxAttemptsCustomValue()
|
||||
{
|
||||
const int customMaxAttempts = 5;
|
||||
_authenticator.MaxAttempts = customMaxAttempts;
|
||||
var authAttempts = 0;
|
||||
_authenticator.AuthenticationRequestor = () =>
|
||||
Optional<SecureString> AuthenticationRequestor()
|
||||
{
|
||||
authAttempts++;
|
||||
return _wrongPassword;
|
||||
};
|
||||
_authenticator.Authenticate(_wrongPassword);
|
||||
}
|
||||
|
||||
var authenticator =
|
||||
new PasswordAuthenticator(_cryptographyProvider, _cipherText, AuthenticationRequestor)
|
||||
{
|
||||
MaxAttempts = customMaxAttempts
|
||||
};
|
||||
authenticator.Authenticate(_wrongPassword);
|
||||
Assert.That(authAttempts == customMaxAttempts);
|
||||
}
|
||||
}
|
||||
|
||||
132
mRemoteNGTests/TestHelpers/ConnectionInfoHelpers.cs
Normal file
132
mRemoteNGTests/TestHelpers/ConnectionInfoHelpers.cs
Normal file
@@ -0,0 +1,132 @@
|
||||
using System;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Connection.Protocol.Http;
|
||||
using mRemoteNG.Connection.Protocol.ICA;
|
||||
using mRemoteNG.Connection.Protocol.RDP;
|
||||
using mRemoteNG.Connection.Protocol.VNC;
|
||||
|
||||
namespace mRemoteNGTests.TestHelpers
|
||||
{
|
||||
internal static class ConnectionInfoHelpers
|
||||
{
|
||||
private static readonly Random _random = new Random();
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="ConnectionInfo"/> object with randomized
|
||||
/// values in all fields.
|
||||
/// </summary>
|
||||
internal static ConnectionInfo GetRandomizedConnectionInfo(bool randomizeInheritance = false)
|
||||
{
|
||||
var connectionInfo = new ConnectionInfo
|
||||
{
|
||||
// string types
|
||||
Name = RandomString(),
|
||||
Hostname = RandomString(),
|
||||
Description = RandomString(),
|
||||
Domain = RandomString(),
|
||||
ExtApp = RandomString(),
|
||||
Icon = RandomString(),
|
||||
LoadBalanceInfo = RandomString(),
|
||||
MacAddress = RandomString(),
|
||||
Panel = RandomString(),
|
||||
Password = RandomString(),
|
||||
PostExtApp = RandomString(),
|
||||
PreExtApp = RandomString(),
|
||||
PuttySession = RandomString(),
|
||||
RDGatewayHostname = RandomString(),
|
||||
RDGatewayUsername = RandomString(),
|
||||
RDGatewayDomain = RandomString(),
|
||||
RDGatewayPassword = RandomString(),
|
||||
UserField = RandomString(),
|
||||
Username = RandomString(),
|
||||
VNCProxyIP = RandomString(),
|
||||
VNCProxyPassword = RandomString(),
|
||||
VNCProxyUsername = RandomString(),
|
||||
|
||||
// bool types
|
||||
AutomaticResize = RandomBool(),
|
||||
CacheBitmaps = RandomBool(),
|
||||
DisplayThemes = RandomBool(),
|
||||
DisplayWallpaper = RandomBool(),
|
||||
EnableDesktopComposition = RandomBool(),
|
||||
EnableFontSmoothing = RandomBool(),
|
||||
IsContainer = RandomBool(),
|
||||
IsDefault = RandomBool(),
|
||||
IsQuickConnect = RandomBool(),
|
||||
PleaseConnect = RandomBool(),
|
||||
RDPAlertIdleTimeout = RandomBool(),
|
||||
RedirectDiskDrives = RandomBool(),
|
||||
RedirectKeys = RandomBool(),
|
||||
RedirectPorts = RandomBool(),
|
||||
RedirectPrinters = RandomBool(),
|
||||
RedirectSmartCards = RandomBool(),
|
||||
UseConsoleSession = RandomBool(),
|
||||
UseCredSsp = RandomBool(),
|
||||
VNCViewOnly = RandomBool(),
|
||||
|
||||
// ints
|
||||
Port = RandomInt(),
|
||||
RDPMinutesToIdleTimeout = RandomInt(),
|
||||
VNCProxyPort = RandomInt(),
|
||||
|
||||
// enums
|
||||
Colors = RandomEnum<RdpProtocol.RDPColors>(),
|
||||
ICAEncryptionStrength = RandomEnum<IcaProtocol.EncryptionStrength> (),
|
||||
Protocol = RandomEnum<ProtocolType>(),
|
||||
RDGatewayUsageMethod = RandomEnum<RdpProtocol.RDGatewayUsageMethod>(),
|
||||
RDGatewayUseConnectionCredentials = RandomEnum<RdpProtocol.RDGatewayUseConnectionCredentials>(),
|
||||
RDPAuthenticationLevel = RandomEnum<RdpProtocol.AuthenticationLevel>(),
|
||||
RedirectSound = RandomEnum<RdpProtocol.RDPSounds>(),
|
||||
RenderingEngine = RandomEnum<HTTPBase.RenderingEngine>(),
|
||||
Resolution = RandomEnum<RdpProtocol.RDPResolutions>(),
|
||||
SoundQuality = RandomEnum<RdpProtocol.RDPSoundQuality>(),
|
||||
VNCAuthMode = RandomEnum<ProtocolVNC.AuthMode>(),
|
||||
VNCColors = RandomEnum<ProtocolVNC.Colors>(),
|
||||
VNCCompression = RandomEnum<ProtocolVNC.Compression>(),
|
||||
VNCEncoding = RandomEnum<ProtocolVNC.Encoding>(),
|
||||
VNCProxyType = RandomEnum<ProtocolVNC.ProxyType>(),
|
||||
VNCSmartSizeMode = RandomEnum<ProtocolVNC.SmartSizeMode>(),
|
||||
};
|
||||
|
||||
if (randomizeInheritance)
|
||||
connectionInfo.Inheritance = GetRandomizedInheritance(connectionInfo);
|
||||
|
||||
return connectionInfo;
|
||||
}
|
||||
|
||||
internal static ConnectionInfoInheritance GetRandomizedInheritance(ConnectionInfo parent)
|
||||
{
|
||||
var inheritance = new ConnectionInfoInheritance(parent, true);
|
||||
foreach (var property in inheritance.GetProperties())
|
||||
{
|
||||
property.SetValue(inheritance, RandomBool());
|
||||
}
|
||||
return inheritance;
|
||||
}
|
||||
|
||||
internal static string RandomString()
|
||||
{
|
||||
return Guid.NewGuid().ToString("N");
|
||||
}
|
||||
|
||||
internal static bool RandomBool()
|
||||
{
|
||||
return _random.Next() % 2 == 0;
|
||||
}
|
||||
|
||||
internal static int RandomInt()
|
||||
{
|
||||
return _random.Next();
|
||||
}
|
||||
|
||||
internal static T RandomEnum<T>() where T : struct, IConvertible
|
||||
{
|
||||
if (!typeof(T).IsEnum)
|
||||
throw new ArgumentException("T must be an enum");
|
||||
|
||||
var values = Enum.GetValues(typeof(T));
|
||||
return (T)values.GetValue(_random.Next(values.Length));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,17 +7,52 @@ namespace mRemoteNGTests.TestHelpers
|
||||
{
|
||||
public class ConnectionTreeModelBuilder
|
||||
{
|
||||
/// <summary>
|
||||
/// Builds a tree which looks like:
|
||||
/// Root
|
||||
/// |- folder1
|
||||
/// | |- con1
|
||||
/// |- con2
|
||||
/// |- folder2
|
||||
/// |- folder3
|
||||
/// |- con3
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public ConnectionTreeModel Build()
|
||||
{
|
||||
var model = new ConnectionTreeModel();
|
||||
var root = new RootNodeInfo(RootNodeType.Connection);
|
||||
var folder1 = new ContainerInfo { Name = "folder1", Username = "user1", Domain = "domain1", Password = "password1" };
|
||||
var folder2 = new ContainerInfo { Name = "folder2", Username = "user2", Domain = "domain2", Password = "password2" };
|
||||
var folder3 = new ContainerInfo
|
||||
{
|
||||
Name = "folder3",
|
||||
Inheritance =
|
||||
{
|
||||
Username = true,
|
||||
Domain = true,
|
||||
Password = true
|
||||
}
|
||||
};
|
||||
var con1 = new ConnectionInfo { Name = "Con1", Username = "user1", Domain = "domain1", Password = "password1" };
|
||||
var con2 = new ConnectionInfo { Name = "Con2", Username = "user2", Domain = "domain2", Password = "password2" };
|
||||
var con3 = new ContainerInfo
|
||||
{
|
||||
Name = "con3",
|
||||
Inheritance =
|
||||
{
|
||||
Username = true,
|
||||
Domain = true,
|
||||
Password = true
|
||||
}
|
||||
};
|
||||
|
||||
root.AddChild(folder1);
|
||||
root.AddChild(con2);
|
||||
folder1.AddChild(con1);
|
||||
root.AddChild(folder2);
|
||||
folder2.AddChild(folder3);
|
||||
folder3.AddChild(con3);
|
||||
model.AddRootNode(root);
|
||||
return model;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
namespace mRemoteNGTests.TestHelpers
|
||||
{
|
||||
/// <summary>
|
||||
/// A ConnectionInfo that has only the serializable properties as string types.
|
||||
/// Only used for testing.
|
||||
/// </summary>
|
||||
internal class SerializableConnectionInfoAllPropertiesOfType<TType>
|
||||
{
|
||||
public TType Description { get; set; }
|
||||
public TType Icon { get; set; }
|
||||
public TType Panel { get; set; }
|
||||
public TType Username { get; set; }
|
||||
public TType Password { get; set; }
|
||||
public TType Domain { get; set; }
|
||||
public TType Protocol { get; set; }
|
||||
public TType ExtApp { get; set; }
|
||||
public TType PuttySession { get; set; }
|
||||
public TType ICAEncryptionStrength { get; set; }
|
||||
public TType UseConsoleSession { get; set; }
|
||||
public TType RDPAuthenticationLevel { get; set; }
|
||||
public TType RDPMinutesToIdleTimeout { get; set; }
|
||||
public TType RDPAlertIdleTimeout { get; set; }
|
||||
public TType LoadBalanceInfo { get; set; }
|
||||
public TType RenderingEngine { get; set; }
|
||||
public TType UseCredSsp { get; set; }
|
||||
public TType RDGatewayUsageMethod { get; set; }
|
||||
public TType RDGatewayHostname { get; set; }
|
||||
public TType RDGatewayUseConnectionCredentials { get; set; }
|
||||
public TType RDGatewayUsername { get; set; }
|
||||
public TType RDGatewayPassword { get; set; }
|
||||
public TType RDGatewayDomain { get; set; }
|
||||
public TType Resolution { get; set; }
|
||||
public TType AutomaticResize { get; set; }
|
||||
public TType Colors { get; set; }
|
||||
public TType CacheBitmaps { get; set; }
|
||||
public TType DisplayWallpaper { get; set; }
|
||||
public TType DisplayThemes { get; set; }
|
||||
public TType EnableFontSmoothing { get; set; }
|
||||
public TType EnableDesktopComposition { get; set; }
|
||||
public TType RedirectKeys { get; set; }
|
||||
public TType RedirectDiskDrives { get; set; }
|
||||
public TType RedirectPrinters { get; set; }
|
||||
public TType RedirectPorts { get; set; }
|
||||
public TType RedirectSmartCards { get; set; }
|
||||
public TType RedirectSound { get; set; }
|
||||
public TType SoundQuality { get; set; }
|
||||
public TType PreExtApp { get; set; }
|
||||
public TType PostExtApp { get; set; }
|
||||
public TType MacAddress { get; set; }
|
||||
public TType UserField { get; set; }
|
||||
public TType VNCCompression { get; set; }
|
||||
public TType VNCEncoding { get; set; }
|
||||
public TType VNCAuthMode { get; set; }
|
||||
public TType VNCProxyType { get; set; }
|
||||
public TType VNCProxyIP { get; set; }
|
||||
public TType VNCProxyPort { get; set; }
|
||||
public TType VNCProxyUsername { get; set; }
|
||||
public TType VNCProxyPassword { get; set; }
|
||||
public TType VNCColors { get; set; }
|
||||
public TType VNCSmartSizeMode { get; set; }
|
||||
public TType VNCViewOnly { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -3,12 +3,12 @@ using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.Tools
|
||||
{
|
||||
public class MaybeTests
|
||||
public class OptionalTests
|
||||
{
|
||||
[Test]
|
||||
public void MaybeReturnsEmptyListWhenGivenNullValue()
|
||||
{
|
||||
var sut = new Maybe<object>(null);
|
||||
var sut = new Optional<object>(null);
|
||||
Assert.That(sut, Is.Empty);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace mRemoteNGTests.Tools
|
||||
public void MaybeReturnsValueIfNotNull()
|
||||
{
|
||||
var expected = new object();
|
||||
var sut = new Maybe<object>(expected);
|
||||
var sut = new Optional<object>(expected);
|
||||
Assert.That(sut, Has.Member(expected));
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.Tree
|
||||
{
|
||||
public class NodeSearcherTests
|
||||
public class NodeSearcherTests
|
||||
{
|
||||
private NodeSearcher _nodeSearcher;
|
||||
private ContainerInfo _folder1;
|
||||
@@ -104,6 +104,14 @@ namespace mRemoteNGTests.Tree
|
||||
_con4 = new ConnectionInfo { Name = "con4", Description="description6", Hostname="hostname6" };
|
||||
_con5 = new ConnectionInfo { Name = "con5", Description="description7", Hostname="hostname7" };
|
||||
|
||||
_folder1.Inheritance.TurnOffInheritanceCompletely();
|
||||
_con1.Inheritance.TurnOffInheritanceCompletely();
|
||||
_con2.Inheritance.TurnOffInheritanceCompletely();
|
||||
_folder2.Inheritance.TurnOffInheritanceCompletely();
|
||||
_con3.Inheritance.TurnOffInheritanceCompletely();
|
||||
_con4.Inheritance.TurnOffInheritanceCompletely();
|
||||
_con5.Inheritance.TurnOffInheritanceCompletely();
|
||||
|
||||
connectionTreeModel.AddRootNode(root);
|
||||
root.AddChildRange(new [] { _folder1, _folder2, _con5 });
|
||||
_folder1.AddChildRange(new [] { _con1, _con2 });
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using mRemoteNG.Tree.Root;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNG.Tree.Root;
|
||||
using NUnit.Framework;
|
||||
|
||||
|
||||
@@ -46,5 +47,13 @@ namespace mRemoteNGTests.Tree
|
||||
_rootNodeInfo.PasswordString = password;
|
||||
Assert.That(_rootNodeInfo.PasswordString, Is.EqualTo(password));
|
||||
}
|
||||
|
||||
[TestCase(RootNodeType.Connection, TreeNodeType.Root)]
|
||||
[TestCase(RootNodeType.PuttySessions, TreeNodeType.PuttyRoot)]
|
||||
public void RootNodeHasCorrectTreeNodeType(RootNodeType rootNodeType, TreeNodeType expectedTreeNodeType)
|
||||
{
|
||||
var rootNode = new RootNodeInfo(rootNodeType);
|
||||
Assert.That(rootNode.GetTreeNodeType(), Is.EqualTo(expectedTreeNodeType));
|
||||
}
|
||||
}
|
||||
}
|
||||
202
mRemoteNGTests/UI/Controls/ConnectionTreeTests.cs
Normal file
202
mRemoteNGTests/UI/Controls/ConnectionTreeTests.cs
Normal file
@@ -0,0 +1,202 @@
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNG.Tree.Root;
|
||||
using mRemoteNG.UI.Controls;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.UI.Controls
|
||||
{
|
||||
public class ConnectionTreeTests
|
||||
{
|
||||
private ConnectionTreeSearchTextFilter _filter;
|
||||
private ConnectionTree _connectionTree;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_filter = new ConnectionTreeSearchTextFilter();
|
||||
_connectionTree = new ConnectionTree
|
||||
{
|
||||
UseFiltering = true
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Apartment(ApartmentState.STA)]
|
||||
public void FilteringIsRetainedAndUpdatedWhenNodeDeleted()
|
||||
{
|
||||
// root
|
||||
// |- folder1
|
||||
// | |- con1
|
||||
// | |- dontshowme
|
||||
// |- folder2
|
||||
// |- con2
|
||||
var connectionTreeModel = new ConnectionTreeModel();
|
||||
var root = new RootNodeInfo(RootNodeType.Connection);
|
||||
var folder1 = new ContainerInfo {Name = "folder1"};
|
||||
var folder2 = new ContainerInfo {Name = "folder2"};
|
||||
var con1 = new ConnectionInfo {Name = "con1"};
|
||||
var con2 = new ConnectionInfo {Name = "con2"};
|
||||
var conDontShow = new ConnectionInfo {Name = "dontshowme" };
|
||||
root.AddChildRange(new []{folder1, folder2});
|
||||
folder1.AddChildRange(new []{con1, conDontShow});
|
||||
folder2.AddChild(con2);
|
||||
connectionTreeModel.AddRootNode(root);
|
||||
|
||||
_connectionTree.ConnectionTreeModel = connectionTreeModel;
|
||||
// ensure all folders expanded
|
||||
_connectionTree.ExpandAll();
|
||||
|
||||
// apply filtering on the tree
|
||||
_filter.FilterText = "con";
|
||||
_connectionTree.ModelFilter = _filter;
|
||||
|
||||
connectionTreeModel.DeleteNode(con1);
|
||||
|
||||
Assert.That(_connectionTree.IsFiltering, Is.True);
|
||||
Assert.That(_connectionTree.FilteredObjects, Does.Not.Contain(con1));
|
||||
Assert.That(_connectionTree.FilteredObjects, Does.Not.Contain(conDontShow));
|
||||
Assert.That(_connectionTree.FilteredObjects, Does.Contain(con2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Apartment(ApartmentState.STA)]
|
||||
public void CannotAddConnectionToPuttySessionNode()
|
||||
{
|
||||
var connectionTreeModel = new ConnectionTreeModel();
|
||||
var root = new RootNodeInfo(RootNodeType.Connection);
|
||||
var puttyRoot = new RootNodeInfo(RootNodeType.PuttySessions);
|
||||
connectionTreeModel.AddRootNode(root);
|
||||
connectionTreeModel.AddRootNode(puttyRoot);
|
||||
|
||||
_connectionTree.ConnectionTreeModel = connectionTreeModel;
|
||||
|
||||
_connectionTree.SelectedObject = puttyRoot;
|
||||
_connectionTree.AddConnection();
|
||||
|
||||
Assert.That(puttyRoot.Children, Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Apartment(ApartmentState.STA)]
|
||||
public void CannotAddFolderToPuttySessionNode()
|
||||
{
|
||||
var connectionTreeModel = new ConnectionTreeModel();
|
||||
var root = new RootNodeInfo(RootNodeType.Connection);
|
||||
var puttyRoot = new RootNodeInfo(RootNodeType.PuttySessions);
|
||||
connectionTreeModel.AddRootNode(root);
|
||||
connectionTreeModel.AddRootNode(puttyRoot);
|
||||
|
||||
_connectionTree.ConnectionTreeModel = connectionTreeModel;
|
||||
|
||||
_connectionTree.SelectedObject = puttyRoot;
|
||||
_connectionTree.AddFolder();
|
||||
|
||||
Assert.That(puttyRoot.Children, Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Apartment(ApartmentState.STA)]
|
||||
public void CannotDuplicateRootConnectionNode()
|
||||
{
|
||||
var connectionTreeModel = new ConnectionTreeModel();
|
||||
var root = new RootNodeInfo(RootNodeType.Connection);
|
||||
connectionTreeModel.AddRootNode(root);
|
||||
_connectionTree.ConnectionTreeModel = connectionTreeModel;
|
||||
|
||||
_connectionTree.SelectedObject = root;
|
||||
_connectionTree.DuplicateSelectedNode();
|
||||
|
||||
Assert.That(connectionTreeModel.RootNodes, Has.One.Items);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Apartment(ApartmentState.STA)]
|
||||
public void CannotDuplicateRootPuttyNode()
|
||||
{
|
||||
var connectionTreeModel = new ConnectionTreeModel();
|
||||
var puttyRoot = new RootNodeInfo(RootNodeType.PuttySessions);
|
||||
connectionTreeModel.AddRootNode(puttyRoot);
|
||||
_connectionTree.ConnectionTreeModel = connectionTreeModel;
|
||||
|
||||
_connectionTree.SelectedObject = puttyRoot;
|
||||
_connectionTree.DuplicateSelectedNode();
|
||||
|
||||
Assert.That(connectionTreeModel.RootNodes, Has.One.Items);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Apartment(ApartmentState.STA)]
|
||||
public void CannotDuplicatePuttyConnectionNode()
|
||||
{
|
||||
var connectionTreeModel = new ConnectionTreeModel();
|
||||
var puttyRoot = new RootNodeInfo(RootNodeType.PuttySessions);
|
||||
var puttyConnection = new PuttySessionInfo();
|
||||
puttyRoot.AddChild(puttyConnection);
|
||||
connectionTreeModel.AddRootNode(puttyRoot);
|
||||
_connectionTree.ConnectionTreeModel = connectionTreeModel;
|
||||
_connectionTree.ExpandAll();
|
||||
|
||||
_connectionTree.SelectedObject = puttyConnection;
|
||||
_connectionTree.DuplicateSelectedNode();
|
||||
|
||||
Assert.That(puttyRoot.Children, Has.One.Items);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Apartment(ApartmentState.STA)]
|
||||
public void DuplicatingWithNoNodeSelectedDoesNothing()
|
||||
{
|
||||
var connectionTreeModel = new ConnectionTreeModel();
|
||||
var puttyRoot = new RootNodeInfo(RootNodeType.PuttySessions);
|
||||
connectionTreeModel.AddRootNode(puttyRoot);
|
||||
_connectionTree.ConnectionTreeModel = connectionTreeModel;
|
||||
|
||||
_connectionTree.SelectedObject = null;
|
||||
_connectionTree.DuplicateSelectedNode();
|
||||
|
||||
Assert.That(connectionTreeModel.RootNodes, Has.One.Items);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Apartment(ApartmentState.STA)]
|
||||
public void ExpandingAllItemsUpdatesColumnWidthAppropriately()
|
||||
{
|
||||
var connectionTreeModel = new ConnectionTreeModel();
|
||||
var root = new RootNodeInfo(RootNodeType.Connection);
|
||||
connectionTreeModel.AddRootNode(root);
|
||||
ContainerInfo parent = root;
|
||||
foreach (var i in Enumerable.Repeat("", 8))
|
||||
{
|
||||
var newContainer = new ContainerInfo {IsExpanded = false};
|
||||
parent.AddChild(newContainer);
|
||||
parent = newContainer;
|
||||
}
|
||||
|
||||
_connectionTree.ConnectionTreeModel = connectionTreeModel;
|
||||
|
||||
var widthBefore = _connectionTree.Columns[0].Width;
|
||||
_connectionTree.ExpandAll();
|
||||
var widthAfter = _connectionTree.Columns[0].Width;
|
||||
|
||||
Assert.That(widthAfter, Is.GreaterThan(widthBefore));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Apartment(ApartmentState.STA)]
|
||||
public void RenamingNodeWithNothingSelectedDoesNothing()
|
||||
{
|
||||
var connectionTreeModel = new ConnectionTreeModel();
|
||||
var root = new RootNodeInfo(RootNodeType.Connection);
|
||||
connectionTreeModel.AddRootNode(root);
|
||||
|
||||
_connectionTree.ConnectionTreeModel = connectionTreeModel;
|
||||
_connectionTree.SelectedObject = null;
|
||||
|
||||
Assert.DoesNotThrow(() => _connectionTree.RenameSelectedNode());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,224 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Connection.Protocol.RDP;
|
||||
using mRemoteNG.Connection.Protocol.VNC;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Tree.Root;
|
||||
using mRemoteNG.UI.Window;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.UI.Window.ConfigWindowTests
|
||||
{
|
||||
public class ConfigWindowGeneralTests
|
||||
{
|
||||
private ConfigWindow _configWindow;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_configWindow = new ConfigWindow
|
||||
{
|
||||
PropertiesVisible = true
|
||||
};
|
||||
}
|
||||
|
||||
[TestCaseSource(nameof(ConnectionInfoGeneralTestCases))]
|
||||
public void PropertyGridShowCorrectPropertiesForConnectionInfo(ConnectionInfo connectionInfo, IEnumerable<string> expectedVisibleProperties)
|
||||
{
|
||||
_configWindow.SelectedTreeNode = connectionInfo;
|
||||
Assert.That(_configWindow.VisibleObjectProperties, Is.EquivalentTo(expectedVisibleProperties));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PropertyGridShowCorrectPropertiesForRootConnectionInfo()
|
||||
{
|
||||
var expectedVisibleProperties = new[]
|
||||
{
|
||||
nameof(RootNodeInfo.Name),
|
||||
nameof(RootNodeInfo.Password),
|
||||
};
|
||||
|
||||
_configWindow.SelectedTreeNode = new RootNodeInfo(RootNodeType.Connection);
|
||||
Assert.That(_configWindow.VisibleObjectProperties, Is.EquivalentTo(expectedVisibleProperties));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PropertyGridShowCorrectPropertiesForRootPuttyInfo()
|
||||
{
|
||||
var expectedVisibleProperties = new[]
|
||||
{
|
||||
nameof(RootNodeInfo.Name),
|
||||
};
|
||||
|
||||
_configWindow.SelectedTreeNode = new RootPuttySessionsNodeInfo();
|
||||
Assert.That(_configWindow.VisibleObjectProperties, Is.EquivalentTo(expectedVisibleProperties));
|
||||
}
|
||||
|
||||
private static IEnumerable<TestCaseData> ConnectionInfoGeneralTestCases()
|
||||
{
|
||||
var protocolTypes = typeof(ProtocolType).GetEnumValues().OfType<ProtocolType>();
|
||||
var testCases = new List<TestCaseData>();
|
||||
|
||||
foreach (var protocol in protocolTypes)
|
||||
{
|
||||
var expectedPropertyListConnection = BuildExpectedConnectionInfoPropertyList(protocol, false);
|
||||
var connectionInfo = ConstructConnectionInfo(protocol, false);
|
||||
var testCaseConnection = new TestCaseData(connectionInfo, expectedPropertyListConnection)
|
||||
.SetName(protocol + ", ConnectionInfo");
|
||||
testCases.Add(testCaseConnection);
|
||||
|
||||
var expectedPropertyListContainer = BuildExpectedConnectionInfoPropertyList(protocol, true);
|
||||
var containerInfo = ConstructConnectionInfo(protocol, true);
|
||||
var testCaseContainer = new TestCaseData(containerInfo, expectedPropertyListContainer)
|
||||
.SetName(protocol + ", ContainerInfo");
|
||||
testCases.Add(testCaseContainer);
|
||||
}
|
||||
|
||||
return testCases;
|
||||
}
|
||||
|
||||
internal static ConnectionInfo ConstructConnectionInfo(ProtocolType protocol, bool isContainer)
|
||||
{
|
||||
// build connection info. set certain connection properties so
|
||||
// that toggled properties are hidden in the property grid. We
|
||||
// will test those separately in the special protocol tests.
|
||||
var node = isContainer
|
||||
? new ContainerInfo()
|
||||
: new ConnectionInfo();
|
||||
|
||||
node.Protocol = protocol;
|
||||
node.Resolution = RdpProtocol.RDPResolutions.Res800x600;
|
||||
node.RDGatewayUsageMethod = RdpProtocol.RDGatewayUsageMethod.Never;
|
||||
node.RDGatewayUseConnectionCredentials = RdpProtocol.RDGatewayUseConnectionCredentials.Yes;
|
||||
node.RedirectSound = RdpProtocol.RDPSounds.DoNotPlay;
|
||||
node.VNCAuthMode = ProtocolVNC.AuthMode.AuthVNC;
|
||||
node.VNCProxyType = ProtocolVNC.ProxyType.ProxyNone;
|
||||
node.Inheritance.TurnOffInheritanceCompletely();
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
internal static List<string> BuildExpectedConnectionInfoPropertyList(ProtocolType protocol, bool isContainer)
|
||||
{
|
||||
var expectedProperties = new List<string>
|
||||
{
|
||||
nameof(ConnectionInfo.Name),
|
||||
nameof(ConnectionInfo.Description),
|
||||
nameof(ConnectionInfo.Icon),
|
||||
nameof(ConnectionInfo.Panel),
|
||||
nameof(ConnectionInfo.Protocol),
|
||||
nameof(ConnectionInfo.PreExtApp),
|
||||
nameof(ConnectionInfo.PostExtApp),
|
||||
nameof(ConnectionInfo.MacAddress),
|
||||
nameof(ConnectionInfo.UserField),
|
||||
};
|
||||
|
||||
if (!isContainer)
|
||||
{
|
||||
expectedProperties.AddRange(new []
|
||||
{
|
||||
nameof(ConnectionInfo.Hostname),
|
||||
});
|
||||
}
|
||||
|
||||
switch (protocol)
|
||||
{
|
||||
case ProtocolType.RDP:
|
||||
expectedProperties.AddRange(new []
|
||||
{
|
||||
nameof(ConnectionInfo.Username),
|
||||
nameof(ConnectionInfo.Password),
|
||||
nameof(ConnectionInfo.Domain),
|
||||
nameof(ConnectionInfo.Port),
|
||||
nameof(ConnectionInfo.UseConsoleSession),
|
||||
nameof(ConnectionInfo.RDPAuthenticationLevel),
|
||||
nameof(ConnectionInfo.RDPMinutesToIdleTimeout),
|
||||
nameof(ConnectionInfo.LoadBalanceInfo),
|
||||
nameof(ConnectionInfo.UseCredSsp),
|
||||
nameof(ConnectionInfo.RDGatewayUsageMethod),
|
||||
nameof(ConnectionInfo.Resolution),
|
||||
nameof(ConnectionInfo.Colors),
|
||||
nameof(ConnectionInfo.CacheBitmaps),
|
||||
nameof(ConnectionInfo.DisplayWallpaper),
|
||||
nameof(ConnectionInfo.DisplayThemes),
|
||||
nameof(ConnectionInfo.EnableFontSmoothing),
|
||||
nameof(ConnectionInfo.EnableDesktopComposition),
|
||||
nameof(ConnectionInfo.RedirectKeys),
|
||||
nameof(ConnectionInfo.RedirectDiskDrives),
|
||||
nameof(ConnectionInfo.RedirectPrinters),
|
||||
nameof(ConnectionInfo.RedirectPorts),
|
||||
nameof(ConnectionInfo.RedirectSmartCards),
|
||||
nameof(ConnectionInfo.RedirectSound),
|
||||
});
|
||||
break;
|
||||
case ProtocolType.VNC:
|
||||
expectedProperties.AddRange(new []
|
||||
{
|
||||
nameof(ConnectionInfo.Password),
|
||||
nameof(ConnectionInfo.Port),
|
||||
nameof(ConnectionInfo.VNCSmartSizeMode),
|
||||
nameof(ConnectionInfo.VNCViewOnly),
|
||||
});
|
||||
break;
|
||||
case ProtocolType.SSH1:
|
||||
case ProtocolType.SSH2:
|
||||
expectedProperties.AddRange(new []
|
||||
{
|
||||
nameof(ConnectionInfo.Username),
|
||||
nameof(ConnectionInfo.Password),
|
||||
nameof(ConnectionInfo.Port),
|
||||
nameof(ConnectionInfo.PuttySession)
|
||||
});
|
||||
break;
|
||||
case ProtocolType.Telnet:
|
||||
case ProtocolType.Rlogin:
|
||||
case ProtocolType.RAW:
|
||||
expectedProperties.AddRange(new[]
|
||||
{
|
||||
nameof(ConnectionInfo.Port),
|
||||
nameof(ConnectionInfo.PuttySession),
|
||||
});
|
||||
break;
|
||||
case ProtocolType.HTTP:
|
||||
case ProtocolType.HTTPS:
|
||||
expectedProperties.AddRange(new []
|
||||
{
|
||||
nameof(ConnectionInfo.Username),
|
||||
nameof(ConnectionInfo.Password),
|
||||
nameof(ConnectionInfo.Port),
|
||||
nameof(ConnectionInfo.RenderingEngine),
|
||||
});
|
||||
break;
|
||||
case ProtocolType.ICA:
|
||||
expectedProperties.AddRange(new []
|
||||
{
|
||||
nameof(ConnectionInfo.Username),
|
||||
nameof(ConnectionInfo.Password),
|
||||
nameof(ConnectionInfo.Domain),
|
||||
nameof(ConnectionInfo.ICAEncryptionStrength),
|
||||
nameof(ConnectionInfo.Resolution),
|
||||
nameof(ConnectionInfo.Colors),
|
||||
nameof(ConnectionInfo.CacheBitmaps),
|
||||
});
|
||||
break;
|
||||
case ProtocolType.IntApp:
|
||||
expectedProperties.AddRange(new[]
|
||||
{
|
||||
nameof(ConnectionInfo.Username),
|
||||
nameof(ConnectionInfo.Password),
|
||||
nameof(ConnectionInfo.Domain),
|
||||
nameof(ConnectionInfo.Port),
|
||||
nameof(ConnectionInfo.ExtApp),
|
||||
});
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(protocol), protocol, null);
|
||||
}
|
||||
|
||||
return expectedProperties;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Connection.Protocol.RDP;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.UI.Window.ConfigWindowTests
|
||||
{
|
||||
public class ConfigWindowRdpSpecialTests : ConfigWindowSpecialTestsBase
|
||||
{
|
||||
protected override ProtocolType Protocol => ProtocolType.RDP;
|
||||
|
||||
[Test]
|
||||
public void PropertyShownWhenActive_RdpMinutesToIdleTimeout()
|
||||
{
|
||||
ConnectionInfo.RDPMinutesToIdleTimeout = 1;
|
||||
ExpectedPropertyList.Add(nameof(mRemoteNG.Connection.ConnectionInfo.RDPAlertIdleTimeout));
|
||||
|
||||
RunVerification();
|
||||
}
|
||||
|
||||
[TestCase(RdpProtocol.RDGatewayUsageMethod.Always)]
|
||||
[TestCase(RdpProtocol.RDGatewayUsageMethod.Detect)]
|
||||
public void RdGatewayPropertiesShown_WhenRdGatewayUsageMethodIsNotNever(RdpProtocol.RDGatewayUsageMethod gatewayUsageMethod)
|
||||
{
|
||||
ConnectionInfo.RDGatewayUsageMethod = gatewayUsageMethod;
|
||||
ConnectionInfo.RDGatewayUseConnectionCredentials = RdpProtocol.RDGatewayUseConnectionCredentials.Yes;
|
||||
ExpectedPropertyList.AddRange(new []
|
||||
{
|
||||
nameof(mRemoteNG.Connection.ConnectionInfo.RDGatewayHostname),
|
||||
nameof(mRemoteNG.Connection.ConnectionInfo.RDGatewayUseConnectionCredentials)
|
||||
});
|
||||
|
||||
RunVerification();
|
||||
}
|
||||
|
||||
[TestCase(RdpProtocol.RDGatewayUseConnectionCredentials.No)]
|
||||
[TestCase(RdpProtocol.RDGatewayUseConnectionCredentials.SmartCard)]
|
||||
public void RdGatewayPropertiesShown_WhenRDGatewayUseConnectionCredentialsIsNotYes(RdpProtocol.RDGatewayUseConnectionCredentials useConnectionCredentials)
|
||||
{
|
||||
ConnectionInfo.RDGatewayUsageMethod = RdpProtocol.RDGatewayUsageMethod.Always;
|
||||
ConnectionInfo.RDGatewayUseConnectionCredentials = useConnectionCredentials;
|
||||
ExpectedPropertyList.AddRange(new []
|
||||
{
|
||||
nameof(mRemoteNG.Connection.ConnectionInfo.RDGatewayHostname),
|
||||
nameof(mRemoteNG.Connection.ConnectionInfo.RDGatewayUsername),
|
||||
nameof(mRemoteNG.Connection.ConnectionInfo.RDGatewayPassword),
|
||||
nameof(mRemoteNG.Connection.ConnectionInfo.RDGatewayDomain),
|
||||
nameof(mRemoteNG.Connection.ConnectionInfo.RDGatewayUseConnectionCredentials)
|
||||
});
|
||||
|
||||
RunVerification();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SoundQualityPropertyShown_WhenRdpSoundsSetToBringToThisComputer()
|
||||
{
|
||||
ConnectionInfo.RedirectSound = RdpProtocol.RDPSounds.BringToThisComputer;
|
||||
ExpectedPropertyList.Add(nameof(mRemoteNG.Connection.ConnectionInfo.SoundQuality));
|
||||
|
||||
RunVerification();
|
||||
}
|
||||
|
||||
[TestCase(RdpProtocol.RDPResolutions.FitToWindow)]
|
||||
[TestCase(RdpProtocol.RDPResolutions.Fullscreen)]
|
||||
public void AutomaticResizePropertyShown_WhenResolutionIsDynamic(RdpProtocol.RDPResolutions resolution)
|
||||
{
|
||||
ConnectionInfo.Resolution = resolution;
|
||||
ExpectedPropertyList.Add(nameof(mRemoteNG.Connection.ConnectionInfo.AutomaticResize));
|
||||
|
||||
RunVerification();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using System.Collections.Generic;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.UI.Window;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.UI.Window.ConfigWindowTests
|
||||
{
|
||||
public abstract class ConfigWindowSpecialTestsBase
|
||||
{
|
||||
protected abstract ProtocolType Protocol { get; }
|
||||
protected bool TestAgainstContainerInfo { get; set; } = false;
|
||||
protected ConfigWindow ConfigWindow;
|
||||
protected ConnectionInfo ConnectionInfo;
|
||||
protected List<string> ExpectedPropertyList;
|
||||
|
||||
[SetUp]
|
||||
public virtual void Setup()
|
||||
{
|
||||
ConnectionInfo = ConfigWindowGeneralTests.ConstructConnectionInfo(Protocol, TestAgainstContainerInfo);
|
||||
ExpectedPropertyList = ConfigWindowGeneralTests.BuildExpectedConnectionInfoPropertyList(Protocol, TestAgainstContainerInfo);
|
||||
|
||||
ConfigWindow = new ConfigWindow
|
||||
{
|
||||
PropertiesVisible = true,
|
||||
};
|
||||
}
|
||||
|
||||
public void RunVerification()
|
||||
{
|
||||
ConfigWindow.SelectedTreeNode = ConnectionInfo;
|
||||
Assert.That(
|
||||
ConfigWindow.VisibleObjectProperties,
|
||||
Is.EquivalentTo(ExpectedPropertyList));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Connection.Protocol.VNC;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.UI.Window.ConfigWindowTests
|
||||
{
|
||||
public class ConfigWindowVncSpecialTests : ConfigWindowSpecialTestsBase
|
||||
{
|
||||
protected override ProtocolType Protocol => ProtocolType.VNC;
|
||||
|
||||
[Test]
|
||||
public void UserDomainPropertiesShown_WhenAuthModeIsWindows()
|
||||
{
|
||||
ConnectionInfo.VNCAuthMode = ProtocolVNC.AuthMode.AuthWin;
|
||||
ExpectedPropertyList.AddRange(new []
|
||||
{
|
||||
nameof(ConnectionInfo.Username),
|
||||
nameof(ConnectionInfo.Domain),
|
||||
});
|
||||
}
|
||||
|
||||
[TestCase(ProtocolVNC.ProxyType.ProxyHTTP)]
|
||||
[TestCase(ProtocolVNC.ProxyType.ProxySocks5)]
|
||||
[TestCase(ProtocolVNC.ProxyType.ProxyUltra)]
|
||||
public void ProxyPropertiesShown_WhenProxyModeIsNotNone(ProtocolVNC.ProxyType proxyType)
|
||||
{
|
||||
ConnectionInfo.VNCProxyType = proxyType;
|
||||
ExpectedPropertyList.AddRange(new[]
|
||||
{
|
||||
nameof(ConnectionInfo.VNCProxyIP),
|
||||
nameof(ConnectionInfo.VNCProxyPort),
|
||||
nameof(ConnectionInfo.VNCProxyUsername),
|
||||
nameof(ConnectionInfo.VNCProxyPassword),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -114,6 +114,7 @@
|
||||
<Compile Include="Config\DataProviders\FileBackupCreatorTests.cs" />
|
||||
<Compile Include="Config\DataProviders\FileDataProviderTests.cs" />
|
||||
<Compile Include="Config\DataProviders\FileDataProviderWithRollingBackupTests.cs" />
|
||||
<Compile Include="Config\Serializers\ConnectionSerializers\Xml\ValidateXmlSchemas.cs" />
|
||||
<Compile Include="Config\Serializers\DataTableDeserializerTests.cs" />
|
||||
<Compile Include="Config\CredentialHarvesterTests.cs" />
|
||||
<Compile Include="Config\CredentialRecordLoaderTests.cs" />
|
||||
@@ -121,20 +122,21 @@
|
||||
<Compile Include="Config\Serializers\CredentialProviderSerializerTests.cs" />
|
||||
<Compile Include="Config\Serializers\CredentialSerializers\XmlCredentialPasswordDecryptorDecoratorTests.cs" />
|
||||
<Compile Include="Config\Serializers\CredentialSerializers\XmlCredentialPasswordEncryptorDecoratorTests.cs" />
|
||||
<Compile Include="Config\Serializers\MiscSerializers\CsvConnectionsSerializerMremotengFormatTests.cs" />
|
||||
<Compile Include="Config\Serializers\ConnectionSerializers\Csv\CsvConnectionsDeserializerMremotengFormatTests.cs" />
|
||||
<Compile Include="Config\Serializers\ConnectionSerializers\Csv\CsvConnectionsSerializerMremotengFormatTests.cs" />
|
||||
<Compile Include="Config\Serializers\DataTableSerializerTests.cs" />
|
||||
<Compile Include="Config\Serializers\MiscSerializers\PortScanDeserializerTests.cs" />
|
||||
<Compile Include="Config\Serializers\MiscSerializers\PuttyConnectionManagerDeserializerTests.cs" />
|
||||
<Compile Include="Config\Serializers\ConnectionSerializers\XmlConnectionsDeserializerTests.cs" />
|
||||
<Compile Include="Config\Serializers\ConnectionSerializers\Xml\XmlConnectionsDeserializerTests.cs" />
|
||||
<Compile Include="Config\Serializers\MiscSerializers\RemoteDesktopConnectionDeserializerTests.cs" />
|
||||
<Compile Include="Config\Serializers\MiscSerializers\RemoteDesktopConnectionManager27DeserializerTests.cs" />
|
||||
<Compile Include="Config\Serializers\MiscSerializers\RemoteDesktopConnectionManagerDeserializerTests.cs" />
|
||||
<Compile Include="Config\Serializers\ConnectionSerializers\XmlConnectionsDocumentCompilerTests.cs" />
|
||||
<Compile Include="Config\Serializers\ConnectionSerializers\XmlConnectionsDocumentEncryptorTests.cs" />
|
||||
<Compile Include="Config\Serializers\ConnectionSerializers\XmlConnectionsSerializerTests.cs" />
|
||||
<Compile Include="Config\Serializers\ConnectionSerializers\Xml\XmlConnectionsDocumentCompilerTests.cs" />
|
||||
<Compile Include="Config\Serializers\ConnectionSerializers\Xml\XmlConnectionsDocumentEncryptorTests.cs" />
|
||||
<Compile Include="Config\Serializers\ConnectionSerializers\Xml\XmlConnectionsSerializerTests.cs" />
|
||||
<Compile Include="Config\Serializers\CredentialSerializers\XmlCredentialRecordDeserializerTests.cs" />
|
||||
<Compile Include="Config\Serializers\CredentialSerializers\XmlCredentialSerializerTests.cs" />
|
||||
<Compile Include="Config\Serializers\ConnectionSerializers\XmlRootNodeSerializerTests.cs" />
|
||||
<Compile Include="Config\Serializers\ConnectionSerializers\Xml\XmlRootNodeSerializerTests.cs" />
|
||||
<Compile Include="Config\Serializers\Versioning\SqlVersion22To23UpgraderTests.cs" />
|
||||
<Compile Include="Config\Serializers\Versioning\SqlVersion23To24UpgraderTests.cs" />
|
||||
<Compile Include="Config\Serializers\Versioning\SqlVersion24To25UpgraderTests.cs" />
|
||||
@@ -144,6 +146,7 @@
|
||||
<Compile Include="Connection\ConnectionInfoComparerTests.cs" />
|
||||
<Compile Include="Connection\Protocol\IntegratedProgramTests.cs" />
|
||||
<Compile Include="Connection\Protocol\ProtocolListTests.cs" />
|
||||
<Compile Include="Container\RootNodeInfoTests.cs" />
|
||||
<Compile Include="Credential\CompositeRepositoryUnlockerTests.cs" />
|
||||
<Compile Include="Credential\CredentialChangedEventArgsTests.cs" />
|
||||
<Compile Include="Credential\CredentialDeletionMsgBoxConfirmerTests.cs" />
|
||||
@@ -167,12 +170,14 @@
|
||||
<Compile Include="Security\PasswordCreation\PasswordLengthConstraintTests.cs" />
|
||||
<Compile Include="Security\RandomGeneratorTests.cs" />
|
||||
<Compile Include="Security\SecureStringExtensionsTests.cs" />
|
||||
<Compile Include="TestHelpers\ConnectionInfoHelpers.cs" />
|
||||
<Compile Include="TestHelpers\ConnectionTreeModelBuilder.cs" />
|
||||
<Compile Include="Security\XmlCryptoProviderBuilderTests.cs" />
|
||||
<Compile Include="TestHelpers\FileTestHelpers.cs" />
|
||||
<Compile Include="TestHelpers\SerializableConnectionInfoAllPropertiesOfType.cs" />
|
||||
<Compile Include="Tools\ExternalToolsArgumentParserTests.cs" />
|
||||
<Compile Include="Tools\FullyObservableCollectionTests.cs" />
|
||||
<Compile Include="Tools\MaybeTests.cs" />
|
||||
<Compile Include="Tools\OptionalTests.cs" />
|
||||
<Compile Include="Tree\ClickHandlers\TreeNodeCompositeClickHandlerTests.cs" />
|
||||
<Compile Include="Tree\ConnectionTreeDragAndDropHandlerTests.cs" />
|
||||
<Compile Include="Tree\ConnectionTreeModelTests.cs" />
|
||||
@@ -202,6 +207,7 @@
|
||||
<Compile Include="Tree\RootNodeInfoTests.cs" />
|
||||
<Compile Include="Tree\ClickHandlers\SwitchToConnectionClickHandlerTests.cs" />
|
||||
<Compile Include="Tree\SelectedConnectionDeletionConfirmerTests.cs" />
|
||||
<Compile Include="UI\Controls\ConnectionTreeTests.cs" />
|
||||
<Compile Include="UI\Controls\PageSequenceTests.cs" />
|
||||
<Compile Include="UI\Controls\SecureTextBoxTestForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
@@ -226,6 +232,10 @@
|
||||
<Compile Include="UI\Forms\OptionsFormSetupAndTeardown.cs" />
|
||||
<Compile Include="UI\Forms\PasswordFormTests.cs" />
|
||||
<Compile Include="UI\WindowListTests.cs" />
|
||||
<Compile Include="UI\Window\ConfigWindowTests\ConfigWindowGeneralTests.cs" />
|
||||
<Compile Include="UI\Window\ConfigWindowTests\ConfigWindowRdpSpecialTests.cs" />
|
||||
<Compile Include="UI\Window\ConfigWindowTests\ConfigWindowSpecialTestsBase.cs" />
|
||||
<Compile Include="UI\Window\ConfigWindowTests\ConfigWindowVncSpecialTests.cs" />
|
||||
<Compile Include="UI\Window\ConnectionTreeWindowTests.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -33,16 +33,19 @@ Global
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Debug Portable|Any CPU.ActiveCfg = Debug Portable|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Debug Portable|Any CPU.Build.0 = Debug Portable|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Debug Portable|x86.ActiveCfg = Debug Portable|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Debug Portable|x86.Build.0 = Debug Portable|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Debug|Any CPU.Build.0 = Debug|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Debug|x86.Build.0 = Debug|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Release Installer|Any CPU.ActiveCfg = Release Portable|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Release Installer|Any CPU.Build.0 = Release Portable|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Release Installer|Any CPU.ActiveCfg = Release|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Release Installer|Any CPU.Build.0 = Release|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Release Installer|x86.ActiveCfg = Release|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Release Installer|x86.Build.0 = Release|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Release Portable|Any CPU.ActiveCfg = Release Portable|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Release Portable|Any CPU.Build.0 = Release Portable|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Release Portable|x86.ActiveCfg = Release Portable|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Release Portable|x86.Build.0 = Release Portable|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
@@ -50,24 +53,26 @@ Global
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Release|x86.ActiveCfg = Release|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Release|x86.Build.0 = Release|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Debug Portable|Any CPU.ActiveCfg = Debug Portable|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Debug Portable|Any CPU.Build.0 = Debug Portable|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Debug Portable|x86.ActiveCfg = Debug Portable|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Debug Portable|x86.Build.0 = Debug Portable|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Debug|Any CPU.Build.0 = Debug|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Debug|x86.Build.0 = Debug|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Release Installer|Any CPU.ActiveCfg = Release Portable|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Release Installer|Any CPU.Build.0 = Release Portable|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Release Installer|Any CPU.ActiveCfg = Release|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Release Installer|Any CPU.Build.0 = Release|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Release Installer|x86.ActiveCfg = Release|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Release Installer|x86.Build.0 = Release|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Release Portable|Any CPU.ActiveCfg = Release Portable|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Release Portable|Any CPU.Build.0 = Release Portable|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Release Portable|x86.ActiveCfg = Release Portable|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Release Portable|x86.Build.0 = Release Portable|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Release|Any CPU.Build.0 = Release|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Release|x86.ActiveCfg = Release|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Release|x86.Build.0 = Release|x86
|
||||
{5423D985-CB48-4344-B47F-E8C6D60C8B04}.Debug Portable|Any CPU.ActiveCfg = Release|x86
|
||||
{5423D985-CB48-4344-B47F-E8C6D60C8B04}.Debug Portable|Any CPU.Build.0 = Release|x86
|
||||
{5423D985-CB48-4344-B47F-E8C6D60C8B04}.Debug Portable|Any CPU.ActiveCfg = Debug|x86
|
||||
{5423D985-CB48-4344-B47F-E8C6D60C8B04}.Debug Portable|x86.ActiveCfg = Debug|x86
|
||||
{5423D985-CB48-4344-B47F-E8C6D60C8B04}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{5423D985-CB48-4344-B47F-E8C6D60C8B04}.Debug|x86.ActiveCfg = Debug|x86
|
||||
@@ -77,7 +82,6 @@ Global
|
||||
{5423D985-CB48-4344-B47F-E8C6D60C8B04}.Release Installer|x86.ActiveCfg = Release|x86
|
||||
{5423D985-CB48-4344-B47F-E8C6D60C8B04}.Release Installer|x86.Build.0 = Release|x86
|
||||
{5423D985-CB48-4344-B47F-E8C6D60C8B04}.Release Portable|Any CPU.ActiveCfg = Release|x86
|
||||
{5423D985-CB48-4344-B47F-E8C6D60C8B04}.Release Portable|Any CPU.Build.0 = Release|x86
|
||||
{5423D985-CB48-4344-B47F-E8C6D60C8B04}.Release Portable|x86.ActiveCfg = Release|x86
|
||||
{5423D985-CB48-4344-B47F-E8C6D60C8B04}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
{5423D985-CB48-4344-B47F-E8C6D60C8B04}.Release|Any CPU.Build.0 = Release|x86
|
||||
@@ -86,8 +90,8 @@ Global
|
||||
{F0168B9F-6815-40DF-BA53-46CEE7683B68}.Debug Portable|x86.ActiveCfg = Debug Portable|x86
|
||||
{F0168B9F-6815-40DF-BA53-46CEE7683B68}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{F0168B9F-6815-40DF-BA53-46CEE7683B68}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{F0168B9F-6815-40DF-BA53-46CEE7683B68}.Release Installer|Any CPU.ActiveCfg = Release Portable|x86
|
||||
{F0168B9F-6815-40DF-BA53-46CEE7683B68}.Release Installer|Any CPU.Build.0 = Release Portable|x86
|
||||
{F0168B9F-6815-40DF-BA53-46CEE7683B68}.Release Installer|Any CPU.ActiveCfg = Release|x86
|
||||
{F0168B9F-6815-40DF-BA53-46CEE7683B68}.Release Installer|Any CPU.Build.0 = Release|x86
|
||||
{F0168B9F-6815-40DF-BA53-46CEE7683B68}.Release Installer|x86.ActiveCfg = Release|x86
|
||||
{F0168B9F-6815-40DF-BA53-46CEE7683B68}.Release Installer|x86.Build.0 = Release|x86
|
||||
{F0168B9F-6815-40DF-BA53-46CEE7683B68}.Release Portable|Any CPU.ActiveCfg = Release Portable|x86
|
||||
|
||||
@@ -4,6 +4,8 @@ using System.Windows.Forms;
|
||||
using mRemoteNG.Config.Connections;
|
||||
using mRemoteNG.Config.DataProviders;
|
||||
using mRemoteNG.Config.Serializers;
|
||||
using mRemoteNG.Config.Serializers.Csv;
|
||||
using mRemoteNG.Config.Serializers.Xml;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Security;
|
||||
|
||||
@@ -7,22 +7,10 @@ using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Tools;
|
||||
|
||||
|
||||
namespace mRemoteNG.App
|
||||
{
|
||||
public static class Import
|
||||
{
|
||||
private enum FileType
|
||||
{
|
||||
Unknown = 0,
|
||||
// ReSharper disable once InconsistentNaming
|
||||
mRemoteXml,
|
||||
RemoteDesktopConnection,
|
||||
RemoteDesktopConnectionManager,
|
||||
PuttyConnectionManager
|
||||
}
|
||||
|
||||
#region Public Methods
|
||||
public static void ImportFromFile(ContainerInfo importDestinationContainer)
|
||||
{
|
||||
try
|
||||
@@ -34,8 +22,9 @@ namespace mRemoteNG.App
|
||||
openFileDialog.Multiselect = true;
|
||||
|
||||
var fileTypes = new List<string>();
|
||||
fileTypes.AddRange(new[] {Language.strFilterAllImportable, "*.xml;*.rdp;*.rdg;*.dat"});
|
||||
fileTypes.AddRange(new[] {Language.strFilterAllImportable, "*.xml;*.rdp;*.rdg;*.dat;*.csv"});
|
||||
fileTypes.AddRange(new[] {Language.strFiltermRemoteXML, "*.xml"});
|
||||
fileTypes.AddRange(new[] {Language.strFiltermRemoteCSV, "*.csv"});
|
||||
fileTypes.AddRange(new[] {Language.strFilterRDP, "*.rdp"});
|
||||
fileTypes.AddRange(new[] {Language.strFilterRdgFiles, "*.rdg"});
|
||||
fileTypes.AddRange(new[] {Language.strFilterPuttyConnectionManager, "*.dat"});
|
||||
@@ -50,32 +39,14 @@ namespace mRemoteNG.App
|
||||
{
|
||||
try
|
||||
{
|
||||
IConnectionImporter importer;
|
||||
// ReSharper disable once SwitchStatementMissingSomeCases
|
||||
switch (DetermineFileType(fileName))
|
||||
{
|
||||
case FileType.mRemoteXml:
|
||||
importer = new mRemoteNGImporter();
|
||||
break;
|
||||
case FileType.RemoteDesktopConnection:
|
||||
importer = new RemoteDesktopConnectionImporter();
|
||||
break;
|
||||
case FileType.RemoteDesktopConnectionManager:
|
||||
importer = new RemoteDesktopConnectionManagerImporter();
|
||||
break;
|
||||
case FileType.PuttyConnectionManager:
|
||||
importer = new PuttyConnectionManagerImporter();
|
||||
break;
|
||||
default:
|
||||
throw new FileFormatException("Unrecognized file format.");
|
||||
}
|
||||
var importer = BuildConnectionImporterFromFileExtension(fileName);
|
||||
importer.Import(fileName, importDestinationContainer);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(string.Format(Language.strImportFileFailedContent, fileName), Language.strImportFileFailedMainInstruction,
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
|
||||
Runtime.MessageCollector.AddExceptionMessage("App.Import.ImportFromFile() failed:1", ex);
|
||||
Runtime.MessageCollector.AddExceptionMessage("Unable to import file.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,15 +55,15 @@ namespace mRemoteNG.App
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage("App.Import.ImportFromFile() failed:2", ex);
|
||||
Runtime.MessageCollector.AddExceptionMessage("Unable to import file.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ImportFromActiveDirectory(string ldapPath, ContainerInfo importDestinationContainer, bool importSubOU)
|
||||
public static void ImportFromActiveDirectory(string ldapPath, ContainerInfo importDestinationContainer, bool importSubOu)
|
||||
{
|
||||
try
|
||||
{
|
||||
ActiveDirectoryImporter.Import(ldapPath, importDestinationContainer, importSubOU);
|
||||
ActiveDirectoryImporter.Import(ldapPath, importDestinationContainer, importSubOu);
|
||||
Runtime.ConnectionsService.SaveConnectionsAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -114,25 +85,25 @@ namespace mRemoteNG.App
|
||||
Runtime.MessageCollector.AddExceptionMessage("App.Import.ImportFromPortScan() failed.", ex);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
private static FileType DetermineFileType(string fileName)
|
||||
private static IConnectionImporter<string> BuildConnectionImporterFromFileExtension(string fileName)
|
||||
{
|
||||
// TODO: Use the file contents to determine the file type instead of trusting the extension
|
||||
var extension = Path.GetExtension(fileName);
|
||||
if (extension == null) return FileType.Unknown;
|
||||
var extension = Path.GetExtension(fileName) ?? "";
|
||||
switch (extension.ToLowerInvariant())
|
||||
{
|
||||
case ".xml":
|
||||
return FileType.mRemoteXml;
|
||||
return new MRemoteNGXmlImporter();
|
||||
case ".csv":
|
||||
return new MRemoteNGCsvImporter();
|
||||
case ".rdp":
|
||||
return FileType.RemoteDesktopConnection;
|
||||
return new RemoteDesktopConnectionImporter();
|
||||
case ".rdg":
|
||||
return FileType.RemoteDesktopConnectionManager;
|
||||
return new RemoteDesktopConnectionManagerImporter();
|
||||
case ".dat":
|
||||
return FileType.PuttyConnectionManager;
|
||||
return new PuttyConnectionManagerImporter();
|
||||
default:
|
||||
return FileType.Unknown;
|
||||
throw new FileFormatException("Unrecognized file format.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,6 @@ using System.Security;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using mRemoteNG.App.Info;
|
||||
using mRemoteNG.Config.Connections.Multiuser;
|
||||
using mRemoteNG.Config.DataProviders;
|
||||
using mRemoteNG.Config.Putty;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Credential;
|
||||
@@ -20,7 +18,7 @@ using mRemoteNG.UI.TaskDialog;
|
||||
|
||||
namespace mRemoteNG.App
|
||||
{
|
||||
public static class Runtime
|
||||
public static class Runtime
|
||||
{
|
||||
public static bool IsPortableEdition
|
||||
{
|
||||
@@ -79,12 +77,6 @@ namespace mRemoteNG.App
|
||||
{
|
||||
connectionFileName = ConnectionsService.GetStartupConnectionFileName();
|
||||
}
|
||||
|
||||
var backupFileCreator = new FileBackupCreator();
|
||||
backupFileCreator.CreateBackupFile(connectionFileName);
|
||||
|
||||
var backupPruner = new FileBackupPruner();
|
||||
backupPruner.PruneBackupFiles(connectionFileName);
|
||||
}
|
||||
|
||||
ConnectionsService.LoadConnections(Settings.Default.UseSQLServer, false, connectionFileName);
|
||||
@@ -93,18 +85,6 @@ namespace mRemoteNG.App
|
||||
{
|
||||
ConnectionsService.LastSqlUpdate = DateTime.Now;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (connectionFileName == ConnectionsService.GetDefaultStartupConnectionFileName())
|
||||
{
|
||||
Settings.Default.LoadConsFromCustomLocation = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Settings.Default.LoadConsFromCustomLocation = true;
|
||||
Settings.Default.CustomConsPath = connectionFileName;
|
||||
}
|
||||
}
|
||||
|
||||
// re-enable sql update checking after updates are loaded
|
||||
ConnectionsService.RemoteConnectionsSyncronizer?.Enable();
|
||||
@@ -147,7 +127,14 @@ namespace mRemoteNG.App
|
||||
{
|
||||
try
|
||||
{
|
||||
CTaskDialog.ShowTaskDialogBox(GeneralAppInfo.ProductName, Language.ConfigurationFileNotFound, "", "", "", "", "", string.Join(" | ", commandButtons), ETaskDialogButtons.None, ESysIcons.Question, ESysIcons.Question);
|
||||
CTaskDialog.ShowTaskDialogBox(
|
||||
GeneralAppInfo.ProductName,
|
||||
Language.ConnectionFileNotFound,
|
||||
"", "", "", "", "",
|
||||
string.Join(" | ", commandButtons),
|
||||
ETaskDialogButtons.None,
|
||||
ESysIcons.Question,
|
||||
ESysIcons.Question);
|
||||
|
||||
switch (CTaskDialog.CommandButtonResult)
|
||||
{
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using mRemoteNG.UI.Forms;
|
||||
using mRemoteNG.UI.Window;
|
||||
using System;
|
||||
using System;
|
||||
using mRemoteNG.Messages;
|
||||
using mRemoteNG.UI;
|
||||
using mRemoteNG.UI.Forms;
|
||||
using mRemoteNG.UI.Window;
|
||||
|
||||
namespace mRemoteNG.App
|
||||
{
|
||||
@@ -15,8 +15,14 @@ namespace mRemoteNG.App
|
||||
private static PortScanWindow _portscanForm;
|
||||
private static UltraVNCWindow _ultravncscForm;
|
||||
private static ComponentsCheckWindow _componentscheckForm;
|
||||
private static ConnectionTreeWindow _treeForm;
|
||||
|
||||
internal static ConnectionTreeWindow TreeForm
|
||||
{
|
||||
get => _treeForm ?? (_treeForm = new ConnectionTreeWindow());
|
||||
set => _treeForm = value;
|
||||
}
|
||||
|
||||
internal static ConnectionTreeWindow TreeForm { get; set; } = new ConnectionTreeWindow();
|
||||
internal static ConfigWindow ConfigForm { get; set; } = new ConfigWindow();
|
||||
internal static ErrorAndInfoWindow ErrorsForm { get; set; } = new ErrorAndInfoWindow();
|
||||
internal static ScreenshotManagerWindow ScreenshotForm { get; set; } = new ScreenshotManagerWindow();
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace mRemoteNG.Config.Connections
|
||||
/// The previous <see cref="ConnectionTreeModel"/> that is being
|
||||
/// unloaded.
|
||||
/// </summary>
|
||||
public Maybe<ConnectionTreeModel> PreviousConnectionTreeModel { get; }
|
||||
public Optional<ConnectionTreeModel> PreviousConnectionTreeModel { get; }
|
||||
|
||||
/// <summary>
|
||||
/// True if the previous <see cref="ConnectionTreeModel"/> was loaded from
|
||||
@@ -37,7 +37,7 @@ namespace mRemoteNG.Config.Connections
|
||||
public string NewSourcePath { get; }
|
||||
|
||||
public ConnectionsLoadedEventArgs(
|
||||
Maybe<ConnectionTreeModel> previousTreeModelModel, ConnectionTreeModel newTreeModelModel,
|
||||
Optional<ConnectionTreeModel> previousTreeModelModel, ConnectionTreeModel newTreeModelModel,
|
||||
bool previousSourceWasDatabase, bool newSourceIsDatabase,
|
||||
string newSourcePath)
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.Config.DataProviders;
|
||||
using mRemoteNG.Config.Serializers;
|
||||
using mRemoteNG.Config.Serializers.Csv;
|
||||
using mRemoteNG.Security;
|
||||
using mRemoteNG.Tree;
|
||||
|
||||
|
||||
@@ -20,10 +20,9 @@ namespace mRemoteNG.Config.Connections
|
||||
|
||||
private void ConnectionsServiceOnConnectionsLoaded(object sender, ConnectionsLoadedEventArgs connectionsLoadedEventArgs)
|
||||
{
|
||||
|
||||
|
||||
connectionsLoadedEventArgs.NewConnectionTreeModel.CollectionChanged += ConnectionTreeModelOnCollectionChanged;
|
||||
connectionsLoadedEventArgs.NewConnectionTreeModel.PropertyChanged += ConnectionTreeModelOnPropertyChanged;
|
||||
|
||||
foreach (var oldTree in connectionsLoadedEventArgs.PreviousConnectionTreeModel)
|
||||
{
|
||||
oldTree.CollectionChanged -= ConnectionTreeModelOnCollectionChanged;
|
||||
@@ -45,7 +44,8 @@ namespace mRemoteNG.Config.Connections
|
||||
{
|
||||
if (!mRemoteNG.Settings.Default.SaveConnectionsAfterEveryEdit)
|
||||
return;
|
||||
_connectionsService.SaveConnections();
|
||||
|
||||
_connectionsService.SaveConnectionsAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security;
|
||||
using mRemoteNG.Config.DataProviders;
|
||||
using mRemoteNG.Config.Serializers;
|
||||
using mRemoteNG.Config.Serializers.Xml;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.Tree;
|
||||
using System.IO;
|
||||
|
||||
namespace mRemoteNG.Config.Connections
|
||||
{
|
||||
public class XmlConnectionsLoader
|
||||
public class XmlConnectionsLoader
|
||||
{
|
||||
private readonly string _connectionFilePath;
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace mRemoteNG.Config.Connections
|
||||
return deserializer.Deserialize(xmlString);
|
||||
}
|
||||
|
||||
private SecureString PromptForPassword()
|
||||
private Optional<SecureString> PromptForPassword()
|
||||
{
|
||||
var password = MiscTools.PasswordDialog("", false);
|
||||
return password;
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Linq;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.Config.DataProviders;
|
||||
using mRemoteNG.Config.Serializers;
|
||||
using mRemoteNG.Config.Serializers.Xml;
|
||||
using mRemoteNG.Security;
|
||||
using mRemoteNG.Security.Factories;
|
||||
using mRemoteNG.Tree;
|
||||
|
||||
@@ -1,26 +1,29 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace mRemoteNG.Config.DataProviders
|
||||
{
|
||||
public class FileBackupPruner
|
||||
{
|
||||
public void PruneBackupFiles(string baseName)
|
||||
public void PruneBackupFiles(string filePath, int maxBackupsToKeep)
|
||||
{
|
||||
var fileName = Path.GetFileName(baseName);
|
||||
var directoryName = Path.GetDirectoryName(baseName);
|
||||
var fileName = Path.GetFileName(filePath);
|
||||
var directoryName = Path.GetDirectoryName(filePath);
|
||||
|
||||
if (string.IsNullOrEmpty(fileName) || string.IsNullOrEmpty(directoryName)) return;
|
||||
if (string.IsNullOrEmpty(fileName) || string.IsNullOrEmpty(directoryName))
|
||||
return;
|
||||
|
||||
var searchPattern = string.Format(mRemoteNG.Settings.Default.BackupFileNameFormat, fileName, "*");
|
||||
var files = Directory.GetFiles(directoryName, searchPattern);
|
||||
|
||||
if (files.Length <= mRemoteNG.Settings.Default.BackupFileKeepCount) return;
|
||||
if (files.Length <= maxBackupsToKeep)
|
||||
return;
|
||||
|
||||
Array.Sort(files);
|
||||
Array.Resize(ref files, files.Length - mRemoteNG.Settings.Default.BackupFileKeepCount);
|
||||
var filesToDelete = files
|
||||
.OrderByDescending(s => s)
|
||||
.Skip(maxBackupsToKeep);
|
||||
|
||||
foreach (var file in files)
|
||||
foreach (var file in filesToDelete)
|
||||
{
|
||||
File.Delete(file);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,10 @@ namespace mRemoteNG.Config.DataProviders
|
||||
{
|
||||
fileContents = File.ReadAllText(FilePath);
|
||||
}
|
||||
catch (FileNotFoundException ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionStackTrace($"Could not load file. File does not exist '{FilePath}'", ex);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionStackTrace($"Failed to load file {FilePath}", ex);
|
||||
|
||||
@@ -3,24 +3,23 @@ using System.Linq;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.Config.Serializers;
|
||||
using mRemoteNG.Container;
|
||||
|
||||
using mRemoteNG.Tools;
|
||||
|
||||
namespace mRemoteNG.Config.Import
|
||||
{
|
||||
public class ActiveDirectoryImporter : IConnectionImporter
|
||||
public class ActiveDirectoryImporter : IConnectionImporter<string>
|
||||
{
|
||||
public void Import(object ldapPath, ContainerInfo destinationContainer)
|
||||
public void Import(string ldapPath, ContainerInfo destinationContainer)
|
||||
{
|
||||
var ldapPathAsString = ldapPath as string;
|
||||
if (ldapPathAsString == null) return;
|
||||
Import(ldapPathAsString, destinationContainer);
|
||||
Import(ldapPath, destinationContainer, false);
|
||||
}
|
||||
|
||||
public static void Import(string ldapPath, ContainerInfo destinationContainer, bool importSubOU = false)
|
||||
public static void Import(string ldapPath, ContainerInfo destinationContainer, bool importSubOu)
|
||||
{
|
||||
try
|
||||
{
|
||||
var deserializer = new ActiveDirectoryDeserializer(ldapPath, importSubOU);
|
||||
ldapPath.ThrowIfNullOrEmpty(nameof(ldapPath));
|
||||
var deserializer = new ActiveDirectoryDeserializer(ldapPath, importSubOu);
|
||||
var connectionTreeModel = deserializer.Deserialize();
|
||||
var importedRootNode = connectionTreeModel.RootNodes.First();
|
||||
if (importedRootNode == null) return;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using mRemoteNG.Container;
|
||||
|
||||
|
||||
namespace mRemoteNG.Config.Import
|
||||
{
|
||||
public interface IConnectionImporter
|
||||
public interface IConnectionImporter<in TSource>
|
||||
where TSource : class
|
||||
{
|
||||
void Import(object source, ContainerInfo destinationContainer);
|
||||
void Import(TSource source, ContainerInfo destinationContainer);
|
||||
}
|
||||
}
|
||||
@@ -1,42 +1,34 @@
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.Config.DataProviders;
|
||||
using mRemoteNG.Config.Serializers;
|
||||
using mRemoteNG.Config.Serializers.Csv;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Messages;
|
||||
|
||||
|
||||
namespace mRemoteNG.Config.Import
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public class mRemoteNGImporter : IConnectionImporter
|
||||
{
|
||||
public void Import(object filePath, ContainerInfo destinationContainer)
|
||||
{
|
||||
var filePathAsString = filePath as string;
|
||||
if (filePathAsString == null)
|
||||
{
|
||||
public class MRemoteNGCsvImporter : IConnectionImporter<string>
|
||||
{
|
||||
public void Import(string filePath, ContainerInfo destinationContainer)
|
||||
{
|
||||
if (string.IsNullOrEmpty(filePath))
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "Unable to import file. File path is null.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(File.Exists(filePathAsString))
|
||||
Import(filePathAsString, destinationContainer);
|
||||
else
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, $"Unable to import file. File does not exist. Path: {filePathAsString}");
|
||||
}
|
||||
if (!File.Exists(filePath))
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, $"Unable to import file. File does not exist. Path: {filePath}");
|
||||
|
||||
public void Import(string fileName, ContainerInfo destinationContainer)
|
||||
{
|
||||
var dataProvider = new FileDataProvider(fileName);
|
||||
var dataProvider = new FileDataProvider(filePath);
|
||||
var xmlString = dataProvider.Load();
|
||||
var xmlConnectionsDeserializer = new XmlConnectionsDeserializer();
|
||||
var connectionTreeModel = xmlConnectionsDeserializer.Deserialize(xmlString, true);
|
||||
var xmlConnectionsDeserializer = new CsvConnectionsDeserializerMremotengFormat();
|
||||
var connectionTreeModel = xmlConnectionsDeserializer.Deserialize(xmlString);
|
||||
|
||||
var rootImportContainer = new ContainerInfo { Name = Path.GetFileNameWithoutExtension(fileName) };
|
||||
var rootImportContainer = new ContainerInfo { Name = Path.GetFileNameWithoutExtension(filePath) };
|
||||
rootImportContainer.AddChildRange(connectionTreeModel.RootNodes.First().Children.ToArray());
|
||||
destinationContainer.AddChild(rootImportContainer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
37
mRemoteV1/Config/Import/MRemoteNGXmlImporter.cs
Normal file
37
mRemoteV1/Config/Import/MRemoteNGXmlImporter.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.Config.DataProviders;
|
||||
using mRemoteNG.Config.Serializers;
|
||||
using mRemoteNG.Config.Serializers.Xml;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Messages;
|
||||
|
||||
|
||||
namespace mRemoteNG.Config.Import
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public class MRemoteNGXmlImporter : IConnectionImporter<string>
|
||||
{
|
||||
public void Import(string fileName, ContainerInfo destinationContainer)
|
||||
{
|
||||
if (fileName == null)
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "Unable to import file. File path is null.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!File.Exists(fileName))
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, $"Unable to import file. File does not exist. Path: {fileName}");
|
||||
|
||||
var dataProvider = new FileDataProvider(fileName);
|
||||
var xmlString = dataProvider.Load();
|
||||
var xmlConnectionsDeserializer = new XmlConnectionsDeserializer();
|
||||
var connectionTreeModel = xmlConnectionsDeserializer.Deserialize(xmlString, true);
|
||||
|
||||
var rootImportContainer = new ContainerInfo { Name = Path.GetFileNameWithoutExtension(fileName) };
|
||||
rootImportContainer.AddChildRange(connectionTreeModel.RootNodes.First().Children.ToArray());
|
||||
destinationContainer.AddChild(rootImportContainer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ using mRemoteNG.Tools;
|
||||
|
||||
namespace mRemoteNG.Config.Import
|
||||
{
|
||||
public class PortScanImporter : IConnectionImporter
|
||||
public class PortScanImporter : IConnectionImporter<IEnumerable<ScanHost>>
|
||||
{
|
||||
private readonly ProtocolType _targetProtocolType;
|
||||
|
||||
@@ -17,13 +17,6 @@ namespace mRemoteNG.Config.Import
|
||||
_targetProtocolType = targetProtocolType;
|
||||
}
|
||||
|
||||
public void Import(object hosts, ContainerInfo destinationContainer)
|
||||
{
|
||||
var hostsAsEnumerableScanHost = hosts as IEnumerable<ScanHost>;
|
||||
if (hostsAsEnumerableScanHost == null) return;
|
||||
Import(hostsAsEnumerableScanHost, destinationContainer);
|
||||
}
|
||||
|
||||
public void Import(IEnumerable<ScanHost> hosts, ContainerInfo destinationContainer)
|
||||
{
|
||||
var deserializer = new PortScanDeserializer(_targetProtocolType);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using mRemoteNG.Config.DataProviders;
|
||||
using mRemoteNG.Config.Serializers;
|
||||
@@ -7,17 +6,8 @@ using mRemoteNG.Container;
|
||||
|
||||
namespace mRemoteNG.Config.Import
|
||||
{
|
||||
public class PuttyConnectionManagerImporter : IConnectionImporter
|
||||
public class PuttyConnectionManagerImporter : IConnectionImporter<string>
|
||||
{
|
||||
public void Import(object filePath, ContainerInfo destinationContainer)
|
||||
{
|
||||
var filePathAsString = filePath as string;
|
||||
if (filePathAsString == null)
|
||||
return;
|
||||
if (File.Exists(filePathAsString))
|
||||
Import(filePathAsString, destinationContainer);
|
||||
}
|
||||
|
||||
public void Import(string filePath, ContainerInfo destinationContainer)
|
||||
{
|
||||
var dataProvider = new FileDataProvider(filePath);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using mRemoteNG.Config.DataProviders;
|
||||
@@ -8,17 +7,8 @@ using mRemoteNG.Container;
|
||||
|
||||
namespace mRemoteNG.Config.Import
|
||||
{
|
||||
public class RemoteDesktopConnectionImporter : IConnectionImporter
|
||||
public class RemoteDesktopConnectionImporter : IConnectionImporter<string>
|
||||
{
|
||||
public void Import(object fileName, ContainerInfo destinationContainer)
|
||||
{
|
||||
var fileNameAsString = fileName as string;
|
||||
if(fileNameAsString == null)
|
||||
return;
|
||||
if (File.Exists(fileNameAsString))
|
||||
Import(fileNameAsString, destinationContainer);
|
||||
}
|
||||
|
||||
public void Import(string fileName, ContainerInfo destinationContainer)
|
||||
{
|
||||
var dataProvider = new FileDataProvider(fileName);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using mRemoteNG.Config.DataProviders;
|
||||
using mRemoteNG.Config.Serializers;
|
||||
@@ -7,18 +6,9 @@ using mRemoteNG.Container;
|
||||
|
||||
namespace mRemoteNG.Config.Import
|
||||
{
|
||||
public class RemoteDesktopConnectionManagerImporter : IConnectionImporter
|
||||
public class RemoteDesktopConnectionManagerImporter : IConnectionImporter<string>
|
||||
{
|
||||
public void Import(object filePath, ContainerInfo destinationContainer)
|
||||
{
|
||||
var fileNameAsString = filePath as string;
|
||||
if (fileNameAsString == null)
|
||||
return;
|
||||
if (File.Exists(fileNameAsString))
|
||||
Import(fileNameAsString, destinationContainer);
|
||||
}
|
||||
|
||||
private static void Import(string filePath, ContainerInfo destinationContainer)
|
||||
public void Import(string filePath, ContainerInfo destinationContainer)
|
||||
{
|
||||
var dataProvider = new FileDataProvider(filePath);
|
||||
var fileContent = dataProvider.Load();
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
using mRemoteNG.Tools;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.Tree.Root;
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.Config.Putty
|
||||
{
|
||||
public class PuttySessionsManager
|
||||
public class PuttySessionsManager
|
||||
{
|
||||
public static PuttySessionsManager Instance { get; } = new PuttySessionsManager();
|
||||
|
||||
@@ -35,10 +35,12 @@ namespace mRemoteNG.Config.Putty
|
||||
}
|
||||
}
|
||||
|
||||
private void AddSessionsFromProvider(AbstractPuttySessionsProvider provider)
|
||||
private void AddSessionsFromProvider(AbstractPuttySessionsProvider puttySessionProvider)
|
||||
{
|
||||
var rootTreeNode = provider.RootInfo;
|
||||
provider.GetSessions();
|
||||
puttySessionProvider.ThrowIfNull(nameof(puttySessionProvider));
|
||||
|
||||
var rootTreeNode = puttySessionProvider.RootInfo;
|
||||
puttySessionProvider.GetSessions();
|
||||
|
||||
if (!RootPuttySessionsNodes.Contains(rootTreeNode) && rootTreeNode.HasChildren())
|
||||
RootPuttySessionsNodes.Add(rootTreeNode);
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
using Microsoft.Win32;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Messages;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Management;
|
||||
using System.Security.Principal;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using Microsoft.Win32;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Messages;
|
||||
|
||||
|
||||
namespace mRemoteNG.Config.Putty
|
||||
{
|
||||
public class PuttySessionsRegistryProvider : AbstractPuttySessionsProvider
|
||||
public class PuttySessionsRegistryProvider : AbstractPuttySessionsProvider
|
||||
{
|
||||
private const string PuttySessionsKey = "Software\\SimonTatham\\PuTTY\\Sessions";
|
||||
private static ManagementEventWatcher _eventWatcher;
|
||||
@@ -39,7 +39,10 @@ namespace mRemoteNG.Config.Putty
|
||||
}
|
||||
|
||||
public override PuttySessionInfo GetSession(string sessionName)
|
||||
{
|
||||
{
|
||||
if (string.IsNullOrEmpty(sessionName))
|
||||
return null;
|
||||
|
||||
var sessionsKey = Registry.CurrentUser.OpenSubKey(PuttySessionsKey);
|
||||
var sessionKey = sessionsKey?.OpenSubKey(sessionName);
|
||||
if (sessionKey == null) return null;
|
||||
@@ -50,10 +53,15 @@ namespace mRemoteNG.Config.Putty
|
||||
{
|
||||
PuttySession = sessionName,
|
||||
Name = sessionName,
|
||||
Hostname = Convert.ToString(sessionKey.GetValue("HostName")),
|
||||
Username = Convert.ToString(sessionKey.GetValue("UserName"))
|
||||
Hostname = sessionKey.GetValue("HostName")?.ToString() ?? "",
|
||||
Username = sessionKey.GetValue("UserName")?.ToString() ?? ""
|
||||
};
|
||||
var protocol = Convert.ToString(sessionKey.GetValue("Protocol")) ?? "ssh";
|
||||
|
||||
|
||||
var protocol = string.IsNullOrEmpty(sessionKey.GetValue("Protocol")?.ToString())
|
||||
? "ssh"
|
||||
: sessionKey.GetValue("Protocol").ToString();
|
||||
|
||||
switch (protocol.ToLowerInvariant())
|
||||
{
|
||||
case "raw":
|
||||
@@ -65,16 +73,15 @@ namespace mRemoteNG.Config.Putty
|
||||
case "serial":
|
||||
return null;
|
||||
case "ssh":
|
||||
var sshVersionObject = sessionKey.GetValue("SshProt");
|
||||
if (sshVersionObject != null)
|
||||
{
|
||||
var sshVersion = Convert.ToInt32(sshVersionObject);
|
||||
sessionInfo.Protocol = sshVersion >= 2 ? ProtocolType.SSH2 : ProtocolType.SSH1;
|
||||
}
|
||||
else
|
||||
{
|
||||
sessionInfo.Protocol = ProtocolType.SSH2;
|
||||
}
|
||||
int.TryParse(sessionKey.GetValue("SshProt")?.ToString(), out var sshVersion);
|
||||
/* Per PUTTY.H in PuTTYNG & PuTTYNG Upstream (PuTTY proper currently)
|
||||
* expect 0 for SSH1, 3 for SSH2 ONLY
|
||||
* 1 for SSH1 with a 2 fallback
|
||||
* 2 for SSH2 with a 1 fallback
|
||||
*
|
||||
* default to SSH2 if any other value is received
|
||||
*/
|
||||
sessionInfo.Protocol = sshVersion == 1 || sshVersion == 0 ? ProtocolType.SSH1 : ProtocolType.SSH2;
|
||||
break;
|
||||
case "telnet":
|
||||
sessionInfo.Protocol = ProtocolType.Telnet;
|
||||
@@ -82,7 +89,12 @@ namespace mRemoteNG.Config.Putty
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
sessionInfo.Port = Convert.ToInt32(sessionKey.GetValue("PortNumber"));
|
||||
|
||||
int.TryParse(sessionKey.GetValue("PortNumber")?.ToString(), out var portNumber);
|
||||
if (portNumber == default(int))
|
||||
sessionInfo.SetDefaultPort();
|
||||
else
|
||||
sessionInfo.Port = portNumber;
|
||||
|
||||
return sessionInfo;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace mRemoteNG.Config.Putty
|
||||
foreach (var sessionName in Directory.GetFiles(sessionsFolderPath))
|
||||
{
|
||||
var sessionFileName = Path.GetFileName(sessionName);
|
||||
// ReSharper disable once ConstantConditionalAccessQualifier
|
||||
sessionNames.Add(raw ? sessionFileName : System.Web.HttpUtility.UrlDecode(sessionFileName?.Replace("+", "%2B")));
|
||||
}
|
||||
|
||||
@@ -125,9 +126,6 @@ namespace mRemoteNG.Config.Putty
|
||||
|
||||
public override void StartWatcher()
|
||||
{
|
||||
PuttySessionsRegistryProvider.StartWatcher();
|
||||
PuttySessionsRegistryProvider.PuttySessionChanged += OnRegistrySessionChanged;
|
||||
|
||||
if (_eventWatcher != null)
|
||||
{
|
||||
return;
|
||||
@@ -136,18 +134,22 @@ namespace mRemoteNG.Config.Putty
|
||||
try
|
||||
{
|
||||
var sessionsFolderPath = GetSessionsFolderPath();
|
||||
if (Directory.Exists(sessionsFolderPath))
|
||||
{
|
||||
_eventWatcher = new FileSystemWatcher(sessionsFolderPath)
|
||||
{
|
||||
NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite
|
||||
};
|
||||
_eventWatcher.Changed += OnFileSystemEventArrived;
|
||||
_eventWatcher.Created += OnFileSystemEventArrived;
|
||||
_eventWatcher.Deleted += OnFileSystemEventArrived;
|
||||
_eventWatcher.Renamed += OnFileSystemEventArrived;
|
||||
_eventWatcher.EnableRaisingEvents = true;
|
||||
}
|
||||
|
||||
if (!Directory.Exists(sessionsFolderPath))
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, $"XmingPortablePuttySessions.Watcher.StartWatching() failed: '{sessionsFolderPath}' does not exist.", true);
|
||||
return;
|
||||
}
|
||||
|
||||
_eventWatcher = new FileSystemWatcher(sessionsFolderPath)
|
||||
{
|
||||
NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite
|
||||
};
|
||||
_eventWatcher.Changed += OnFileSystemEventArrived;
|
||||
_eventWatcher.Created += OnFileSystemEventArrived;
|
||||
_eventWatcher.Deleted += OnFileSystemEventArrived;
|
||||
_eventWatcher.Renamed += OnFileSystemEventArrived;
|
||||
_eventWatcher.EnableRaisingEvents = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -173,7 +175,8 @@ namespace mRemoteNG.Config.Putty
|
||||
private static string GetPuttyConfPath()
|
||||
{
|
||||
var puttyPath = mRemoteNG.Settings.Default.UseCustomPuttyPath ? mRemoteNG.Settings.Default.CustomPuttyPath : App.Info.GeneralAppInfo.PuttyPath;
|
||||
return Path.Combine(Path.GetDirectoryName(puttyPath), "putty.conf");
|
||||
puttyPath = Path.GetDirectoryName(puttyPath);
|
||||
return string.IsNullOrEmpty(puttyPath) ? null : Path.Combine(puttyPath, "putty.conf");
|
||||
}
|
||||
|
||||
private static string GetSessionsFolderPath()
|
||||
@@ -200,6 +203,9 @@ namespace mRemoteNG.Config.Putty
|
||||
|
||||
private static PuttySessionInfo ModifyRegistrySessionInfo(PuttySessionInfo sessionInfo)
|
||||
{
|
||||
if (sessionInfo == null)
|
||||
return null;
|
||||
|
||||
sessionInfo.Name = string.Format(RegistrySessionNameFormat, sessionInfo.Name);
|
||||
sessionInfo.PuttySession = string.Format(RegistrySessionNameFormat, sessionInfo.PuttySession);
|
||||
return sessionInfo;
|
||||
|
||||
@@ -0,0 +1,712 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Connection.Protocol.Http;
|
||||
using mRemoteNG.Connection.Protocol.ICA;
|
||||
using mRemoteNG.Connection.Protocol.RDP;
|
||||
using mRemoteNG.Connection.Protocol.VNC;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNG.Tree.Root;
|
||||
|
||||
namespace mRemoteNG.Config.Serializers.Csv
|
||||
{
|
||||
public class CsvConnectionsDeserializerMremotengFormat : IDeserializer<string, ConnectionTreeModel>
|
||||
{
|
||||
public ConnectionTreeModel Deserialize(string serializedData)
|
||||
{
|
||||
var lines = serializedData.Split(new []{"\r\n", "\r", "\n"}, StringSplitOptions.RemoveEmptyEntries);
|
||||
var csvHeaders = new List<string>();
|
||||
// used to map a connectioninfo to it's parent's GUID
|
||||
var parentMapping = new Dictionary<ConnectionInfo, string>();
|
||||
|
||||
for (var lineNumber = 0; lineNumber < lines.Length; lineNumber++)
|
||||
{
|
||||
var line = lines[lineNumber].Split(';');
|
||||
if (lineNumber == 0)
|
||||
csvHeaders = line.ToList();
|
||||
else
|
||||
{
|
||||
var connectionInfo = ParseConnectionInfo(csvHeaders, line);
|
||||
parentMapping.Add(connectionInfo, line[csvHeaders.IndexOf("Parent")]);
|
||||
}
|
||||
}
|
||||
|
||||
var root = CreateTreeStructure(parentMapping);
|
||||
var connectionTreeModel = new ConnectionTreeModel();
|
||||
connectionTreeModel.AddRootNode(root);
|
||||
return connectionTreeModel;
|
||||
}
|
||||
|
||||
private RootNodeInfo CreateTreeStructure(Dictionary<ConnectionInfo, string> parentMapping)
|
||||
{
|
||||
var root = new RootNodeInfo(RootNodeType.Connection);
|
||||
|
||||
foreach (var node in parentMapping)
|
||||
{
|
||||
// no parent mapped, add to root
|
||||
if (string.IsNullOrEmpty(node.Value))
|
||||
{
|
||||
root.AddChild(node.Key);
|
||||
continue;
|
||||
}
|
||||
|
||||
// search for parent in the list by GUID
|
||||
var parent = parentMapping
|
||||
.Keys
|
||||
.OfType<ContainerInfo>()
|
||||
.FirstOrDefault(info => info.ConstantID == node.Value);
|
||||
|
||||
if (parent != null)
|
||||
{
|
||||
parent.AddChild(node.Key);
|
||||
}
|
||||
else
|
||||
{
|
||||
root.AddChild(node.Key);
|
||||
}
|
||||
}
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
private ConnectionInfo ParseConnectionInfo(IList<string> headers, string[] connectionCsv)
|
||||
{
|
||||
var nodeType = headers.Contains("NodeType")
|
||||
? (TreeNodeType)Enum.Parse(typeof(TreeNodeType), connectionCsv[headers.IndexOf("NodeType")], true)
|
||||
: TreeNodeType.Connection;
|
||||
|
||||
var nodeId = headers.Contains("Id")
|
||||
? connectionCsv[headers.IndexOf("Id")]
|
||||
: Guid.NewGuid().ToString();
|
||||
|
||||
var connectionRecord = nodeType == TreeNodeType.Connection
|
||||
? new ConnectionInfo(nodeId)
|
||||
: new ContainerInfo(nodeId);
|
||||
|
||||
connectionRecord.Name = headers.Contains("Name") ? connectionCsv[headers.IndexOf("Name")] : "";
|
||||
connectionRecord.Description = headers.Contains("Description") ? connectionCsv[headers.IndexOf("Description")] : "";
|
||||
connectionRecord.Icon = headers.Contains("Icon") ? connectionCsv[headers.IndexOf("Icon")] : "";
|
||||
connectionRecord.Panel = headers.Contains("Panel") ? connectionCsv[headers.IndexOf("Panel")] : "";
|
||||
connectionRecord.Username = headers.Contains("Username") ? connectionCsv[headers.IndexOf("Username")] : "";
|
||||
connectionRecord.Password = headers.Contains("Password") ? connectionCsv[headers.IndexOf("Password")] : "";
|
||||
connectionRecord.Domain = headers.Contains("Domain") ? connectionCsv[headers.IndexOf("Domain")] : "";
|
||||
connectionRecord.Hostname = headers.Contains("Hostname") ? connectionCsv[headers.IndexOf("Hostname")] : "";
|
||||
connectionRecord.PuttySession = headers.Contains("PuttySession") ? connectionCsv[headers.IndexOf("PuttySession")] : "";
|
||||
connectionRecord.LoadBalanceInfo = headers.Contains("LoadBalanceInfo") ? connectionCsv[headers.IndexOf("LoadBalanceInfo")] : "";
|
||||
connectionRecord.PreExtApp = headers.Contains("PreExtApp") ? connectionCsv[headers.IndexOf("PreExtApp")] : "";
|
||||
connectionRecord.PostExtApp = headers.Contains("PostExtApp") ? connectionCsv[headers.IndexOf("PostExtApp")] : "";
|
||||
connectionRecord.MacAddress = headers.Contains("MacAddress") ? connectionCsv[headers.IndexOf("MacAddress")] : "";
|
||||
connectionRecord.UserField = headers.Contains("UserField") ? connectionCsv[headers.IndexOf("UserField")] : "";
|
||||
connectionRecord.ExtApp = headers.Contains("ExtApp") ? connectionCsv[headers.IndexOf("ExtApp")] : "";
|
||||
connectionRecord.VNCProxyUsername = headers.Contains("VNCProxyUsername") ? connectionCsv[headers.IndexOf("VNCProxyUsername")] : "";
|
||||
connectionRecord.VNCProxyPassword = headers.Contains("VNCProxyPassword") ? connectionCsv[headers.IndexOf("VNCProxyPassword")] : "";
|
||||
connectionRecord.RDGatewayUsername = headers.Contains("RDGatewayUsername") ? connectionCsv[headers.IndexOf("RDGatewayUsername")] : "";
|
||||
connectionRecord.RDGatewayPassword = headers.Contains("RDGatewayPassword") ? connectionCsv[headers.IndexOf("RDGatewayPassword")] : "";
|
||||
connectionRecord.RDGatewayDomain = headers.Contains("RDGatewayDomain") ? connectionCsv[headers.IndexOf("RDGatewayDomain")] : "";
|
||||
connectionRecord.VNCProxyIP = headers.Contains("VNCProxyIP") ? connectionCsv[headers.IndexOf("VNCProxyIP")] : "";
|
||||
connectionRecord.RDGatewayHostname = headers.Contains("RDGatewayHostname") ? connectionCsv[headers.IndexOf("RDGatewayHostname")] : "";
|
||||
|
||||
if (headers.Contains("Protocol"))
|
||||
{
|
||||
ProtocolType protocolType;
|
||||
if (Enum.TryParse(connectionCsv[headers.IndexOf("Protocol")], out protocolType))
|
||||
connectionRecord.Protocol = protocolType;
|
||||
}
|
||||
|
||||
if (headers.Contains("Port"))
|
||||
{
|
||||
int port;
|
||||
if (int.TryParse(connectionCsv[headers.IndexOf("Port")], out port))
|
||||
connectionRecord.Port = port;
|
||||
}
|
||||
|
||||
if (headers.Contains("ConnectToConsole"))
|
||||
{
|
||||
bool useConsoleSession;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("ConnectToConsole")], out useConsoleSession))
|
||||
connectionRecord.UseConsoleSession = useConsoleSession;
|
||||
}
|
||||
|
||||
if (headers.Contains("UseCredSsp"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("UseCredSsp")], out value))
|
||||
connectionRecord.UseCredSsp = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("RenderingEngine"))
|
||||
{
|
||||
HTTPBase.RenderingEngine value;
|
||||
if (Enum.TryParse(connectionCsv[headers.IndexOf("RenderingEngine")], out value))
|
||||
connectionRecord.RenderingEngine = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("ICAEncryptionStrength"))
|
||||
{
|
||||
IcaProtocol.EncryptionStrength value;
|
||||
if (Enum.TryParse(connectionCsv[headers.IndexOf("ICAEncryptionStrength")], out value))
|
||||
connectionRecord.ICAEncryptionStrength = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("RDPAuthenticationLevel"))
|
||||
{
|
||||
RdpProtocol.AuthenticationLevel value;
|
||||
if (Enum.TryParse(connectionCsv[headers.IndexOf("RDPAuthenticationLevel")], out value))
|
||||
connectionRecord.RDPAuthenticationLevel = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("Colors"))
|
||||
{
|
||||
RdpProtocol.RDPColors value;
|
||||
if (Enum.TryParse(connectionCsv[headers.IndexOf("Colors")], out value))
|
||||
connectionRecord.Colors = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("Resolution"))
|
||||
{
|
||||
RdpProtocol.RDPResolutions value;
|
||||
if (Enum.TryParse(connectionCsv[headers.IndexOf("Resolution")], out value))
|
||||
connectionRecord.Resolution = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("AutomaticResize"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("AutomaticResize")], out value))
|
||||
connectionRecord.AutomaticResize = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("DisplayWallpaper"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("DisplayWallpaper")], out value))
|
||||
connectionRecord.DisplayWallpaper = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("DisplayThemes"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("DisplayThemes")], out value))
|
||||
connectionRecord.DisplayThemes = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("EnableFontSmoothing"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("EnableFontSmoothing")], out value))
|
||||
connectionRecord.EnableFontSmoothing = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("EnableDesktopComposition"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("EnableDesktopComposition")], out value))
|
||||
connectionRecord.EnableDesktopComposition = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("CacheBitmaps"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("CacheBitmaps")], out value))
|
||||
connectionRecord.CacheBitmaps = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("RedirectDiskDrives"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("RedirectDiskDrives")], out value))
|
||||
connectionRecord.RedirectDiskDrives = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("RedirectPorts"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("RedirectPorts")], out value))
|
||||
connectionRecord.RedirectPorts = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("RedirectPrinters"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("RedirectPrinters")], out value))
|
||||
connectionRecord.RedirectPrinters = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("RedirectSmartCards"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("RedirectSmartCards")], out value))
|
||||
connectionRecord.RedirectSmartCards = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("RedirectSound"))
|
||||
{
|
||||
RdpProtocol.RDPSounds value;
|
||||
if (Enum.TryParse(connectionCsv[headers.IndexOf("RedirectSound")], out value))
|
||||
connectionRecord.RedirectSound = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("RedirectKeys"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("RedirectKeys")], out value))
|
||||
connectionRecord.RedirectKeys = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("VNCCompression"))
|
||||
{
|
||||
ProtocolVNC.Compression value;
|
||||
if (Enum.TryParse(connectionCsv[headers.IndexOf("VNCCompression")], out value))
|
||||
connectionRecord.VNCCompression = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("VNCEncoding"))
|
||||
{
|
||||
ProtocolVNC.Encoding value;
|
||||
if (Enum.TryParse(connectionCsv[headers.IndexOf("VNCEncoding")], out value))
|
||||
connectionRecord.VNCEncoding = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("VNCAuthMode"))
|
||||
{
|
||||
ProtocolVNC.AuthMode value;
|
||||
if (Enum.TryParse(connectionCsv[headers.IndexOf("VNCAuthMode")], out value))
|
||||
connectionRecord.VNCAuthMode = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("VNCProxyType"))
|
||||
{
|
||||
ProtocolVNC.ProxyType value;
|
||||
if (Enum.TryParse(connectionCsv[headers.IndexOf("VNCProxyType")], out value))
|
||||
connectionRecord.VNCProxyType = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("VNCProxyPort"))
|
||||
{
|
||||
int value;
|
||||
if (int.TryParse(connectionCsv[headers.IndexOf("VNCProxyPort")], out value))
|
||||
connectionRecord.VNCProxyPort = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("VNCColors"))
|
||||
{
|
||||
ProtocolVNC.Colors value;
|
||||
if (Enum.TryParse(connectionCsv[headers.IndexOf("VNCColors")], out value))
|
||||
connectionRecord.VNCColors = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("VNCSmartSizeMode"))
|
||||
{
|
||||
ProtocolVNC.SmartSizeMode value;
|
||||
if (Enum.TryParse(connectionCsv[headers.IndexOf("VNCSmartSizeMode")], out value))
|
||||
connectionRecord.VNCSmartSizeMode = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("VNCViewOnly"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("VNCViewOnly")], out value))
|
||||
connectionRecord.VNCViewOnly = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("RDGatewayUsageMethod"))
|
||||
{
|
||||
RdpProtocol.RDGatewayUsageMethod value;
|
||||
if (Enum.TryParse(connectionCsv[headers.IndexOf("RDGatewayUsageMethod")], out value))
|
||||
connectionRecord.RDGatewayUsageMethod = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("RDGatewayUseConnectionCredentials"))
|
||||
{
|
||||
RdpProtocol.RDGatewayUseConnectionCredentials value;
|
||||
if (Enum.TryParse(connectionCsv[headers.IndexOf("RDGatewayUseConnectionCredentials")], out value))
|
||||
connectionRecord.RDGatewayUseConnectionCredentials = value;
|
||||
}
|
||||
|
||||
#region Inheritance
|
||||
if (headers.Contains("InheritCacheBitmaps"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritCacheBitmaps")], out value))
|
||||
connectionRecord.Inheritance.CacheBitmaps = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritColors"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritColors")], out value))
|
||||
connectionRecord.Inheritance.Colors = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritDescription"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritDescription")], out value))
|
||||
connectionRecord.Inheritance.Description = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritDisplayThemes"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritDisplayThemes")], out value))
|
||||
connectionRecord.Inheritance.DisplayThemes = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritDisplayWallpaper"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritDisplayWallpaper")], out value))
|
||||
connectionRecord.Inheritance.DisplayWallpaper = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritEnableFontSmoothing"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritEnableFontSmoothing")], out value))
|
||||
connectionRecord.Inheritance.EnableFontSmoothing = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritEnableDesktopComposition"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritEnableDesktopComposition")], out value))
|
||||
connectionRecord.Inheritance.EnableDesktopComposition = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritDomain"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritDomain")], out value))
|
||||
connectionRecord.Inheritance.Domain = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritIcon"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritIcon")], out value))
|
||||
connectionRecord.Inheritance.Icon = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritPanel"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritPanel")], out value))
|
||||
connectionRecord.Inheritance.Panel = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritPassword"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritPassword")], out value))
|
||||
connectionRecord.Inheritance.Password = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritPort"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritPort")], out value))
|
||||
connectionRecord.Inheritance.Port = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritProtocol"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritProtocol")], out value))
|
||||
connectionRecord.Inheritance.Protocol = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritPuttySession"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritPuttySession")], out value))
|
||||
connectionRecord.Inheritance.PuttySession = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritRedirectDiskDrives"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRedirectDiskDrives")], out value))
|
||||
connectionRecord.Inheritance.RedirectDiskDrives = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritRedirectKeys"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRedirectKeys")], out value))
|
||||
connectionRecord.Inheritance.RedirectKeys = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritRedirectPorts"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRedirectPorts")], out value))
|
||||
connectionRecord.Inheritance.RedirectPorts = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritRedirectPrinters"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRedirectPrinters")], out value))
|
||||
connectionRecord.Inheritance.RedirectPrinters = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritRedirectSmartCards"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRedirectSmartCards")], out value))
|
||||
connectionRecord.Inheritance.RedirectSmartCards = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritRedirectSound"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRedirectSound")], out value))
|
||||
connectionRecord.Inheritance.RedirectSound = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritResolution"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritResolution")], out value))
|
||||
connectionRecord.Inheritance.Resolution = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritAutomaticResize"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritAutomaticResize")], out value))
|
||||
connectionRecord.Inheritance.AutomaticResize = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritUseConsoleSession"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritUseConsoleSession")], out value))
|
||||
connectionRecord.Inheritance.UseConsoleSession = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritUseCredSsp"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritUseCredSsp")], out value))
|
||||
connectionRecord.Inheritance.UseCredSsp = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritRenderingEngine"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRenderingEngine")], out value))
|
||||
connectionRecord.Inheritance.RenderingEngine = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritUsername"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritUsername")], out value))
|
||||
connectionRecord.Inheritance.Username = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritICAEncryptionStrength"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritICAEncryptionStrength")], out value))
|
||||
connectionRecord.Inheritance.ICAEncryptionStrength = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritRDPAuthenticationLevel"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDPAuthenticationLevel")], out value))
|
||||
connectionRecord.Inheritance.RDPAuthenticationLevel = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritLoadBalanceInfo"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritLoadBalanceInfo")], out value))
|
||||
connectionRecord.Inheritance.LoadBalanceInfo = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritPreExtApp"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritPreExtApp")], out value))
|
||||
connectionRecord.Inheritance.PreExtApp = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritPostExtApp"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritPostExtApp")], out value))
|
||||
connectionRecord.Inheritance.PostExtApp = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritMacAddress"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritMacAddress")], out value))
|
||||
connectionRecord.Inheritance.MacAddress = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritUserField"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritUserField")], out value))
|
||||
connectionRecord.Inheritance.UserField = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritExtApp"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritExtApp")], out value))
|
||||
connectionRecord.Inheritance.ExtApp = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritVNCCompression"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCCompression")], out value))
|
||||
connectionRecord.Inheritance.VNCCompression = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritVNCEncoding"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCEncoding")], out value))
|
||||
connectionRecord.Inheritance.VNCEncoding = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritVNCAuthMode"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCAuthMode")], out value))
|
||||
connectionRecord.Inheritance.VNCAuthMode = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritVNCProxyType"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCProxyType")], out value))
|
||||
connectionRecord.Inheritance.VNCProxyType = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritVNCProxyIP"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCProxyIP")], out value))
|
||||
connectionRecord.Inheritance.VNCProxyIP = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritVNCProxyPort"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCProxyPort")], out value))
|
||||
connectionRecord.Inheritance.VNCProxyPort = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritVNCProxyUsername"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCProxyUsername")], out value))
|
||||
connectionRecord.Inheritance.VNCProxyUsername = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritVNCProxyPassword"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCProxyPassword")], out value))
|
||||
connectionRecord.Inheritance.VNCProxyPassword = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritVNCColors"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCColors")], out value))
|
||||
connectionRecord.Inheritance.VNCColors = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritVNCSmartSizeMode"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCSmartSizeMode")], out value))
|
||||
connectionRecord.Inheritance.VNCSmartSizeMode = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritVNCViewOnly"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCViewOnly")], out value))
|
||||
connectionRecord.Inheritance.VNCViewOnly = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritRDGatewayUsageMethod"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDGatewayUsageMethod")], out value))
|
||||
connectionRecord.Inheritance.RDGatewayUsageMethod = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritRDGatewayHostname"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDGatewayHostname")], out value))
|
||||
connectionRecord.Inheritance.RDGatewayHostname = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritRDGatewayUseConnectionCredentials"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDGatewayUseConnectionCredentials")], out value))
|
||||
connectionRecord.Inheritance.RDGatewayUseConnectionCredentials = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritRDGatewayUsername"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDGatewayUsername")], out value))
|
||||
connectionRecord.Inheritance.RDGatewayUsername = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritRDGatewayPassword"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDGatewayPassword")], out value))
|
||||
connectionRecord.Inheritance.RDGatewayPassword = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritRDGatewayDomain"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDGatewayDomain")], out value))
|
||||
connectionRecord.Inheritance.RDGatewayDomain = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritRDPAlertIdleTimeout"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDPAlertIdleTimeout")], out value))
|
||||
connectionRecord.Inheritance.RDPAlertIdleTimeout = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritRDPMinutesToIdleTimeout"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDPMinutesToIdleTimeout")], out value))
|
||||
connectionRecord.Inheritance.RDPMinutesToIdleTimeout = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritSoundQuality"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritSoundQuality")], out value))
|
||||
connectionRecord.Inheritance.SoundQuality = value;
|
||||
}
|
||||
#endregion
|
||||
|
||||
return connectionRecord;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Credential;
|
||||
using mRemoteNG.Security;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNG.Tree.Root;
|
||||
|
||||
namespace mRemoteNG.Config.Serializers.Csv
|
||||
{
|
||||
public class CsvConnectionsSerializerMremotengFormat : ISerializer<ConnectionInfo,string>
|
||||
{
|
||||
private readonly SaveFilter _saveFilter;
|
||||
private readonly ICredentialRepositoryList _credentialRepositoryList;
|
||||
|
||||
public CsvConnectionsSerializerMremotengFormat(SaveFilter saveFilter, ICredentialRepositoryList credentialRepositoryList)
|
||||
{
|
||||
saveFilter.ThrowIfNull(nameof(saveFilter));
|
||||
credentialRepositoryList.ThrowIfNull(nameof(credentialRepositoryList));
|
||||
|
||||
_saveFilter = saveFilter;
|
||||
_credentialRepositoryList = credentialRepositoryList;
|
||||
}
|
||||
|
||||
public string Serialize(ConnectionTreeModel connectionTreeModel)
|
||||
{
|
||||
connectionTreeModel.ThrowIfNull(nameof(connectionTreeModel));
|
||||
|
||||
var rootNode = connectionTreeModel.RootNodes.First(node => node is RootNodeInfo);
|
||||
return Serialize(rootNode);
|
||||
}
|
||||
|
||||
public string Serialize(ConnectionInfo serializationTarget)
|
||||
{
|
||||
serializationTarget.ThrowIfNull(nameof(serializationTarget));
|
||||
var sb = new StringBuilder();
|
||||
|
||||
WriteCsvHeader(sb);
|
||||
SerializeNodesRecursive(serializationTarget, sb);
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private void WriteCsvHeader(StringBuilder sb)
|
||||
{
|
||||
sb.Append("Name;Id;Parent;NodeType;Description;Icon;Panel;");
|
||||
if (_saveFilter.SaveUsername)
|
||||
sb.Append("Username;");
|
||||
if (_saveFilter.SavePassword)
|
||||
sb.Append("Password;");
|
||||
if (_saveFilter.SaveDomain)
|
||||
sb.Append("Domain;");
|
||||
sb.Append("Hostname;Protocol;PuttySession;Port;ConnectToConsole;UseCredSsp;RenderingEngine;ICAEncryptionStrength;RDPAuthenticationLevel;LoadBalanceInfo;Colors;Resolution;AutomaticResize;DisplayWallpaper;DisplayThemes;EnableFontSmoothing;EnableDesktopComposition;CacheBitmaps;RedirectDiskDrives;RedirectPorts;RedirectPrinters;RedirectSmartCards;RedirectSound;RedirectKeys;PreExtApp;PostExtApp;MacAddress;UserField;ExtApp;VNCCompression;VNCEncoding;VNCAuthMode;VNCProxyType;VNCProxyIP;VNCProxyPort;VNCProxyUsername;VNCProxyPassword;VNCColors;VNCSmartSizeMode;VNCViewOnly;RDGatewayUsageMethod;RDGatewayHostname;RDGatewayUseConnectionCredentials;RDGatewayUsername;RDGatewayPassword;RDGatewayDomain;");
|
||||
if (_saveFilter.SaveInheritance)
|
||||
sb.Append("InheritCacheBitmaps;InheritColors;InheritDescription;InheritDisplayThemes;InheritDisplayWallpaper;InheritEnableFontSmoothing;InheritEnableDesktopComposition;InheritDomain;InheritIcon;InheritPanel;InheritPassword;InheritPort;InheritProtocol;InheritPuttySession;InheritRedirectDiskDrives;InheritRedirectKeys;InheritRedirectPorts;InheritRedirectPrinters;InheritRedirectSmartCards;InheritRedirectSound;InheritResolution;InheritAutomaticResize;InheritUseConsoleSession;InheritUseCredSsp;InheritRenderingEngine;InheritUsername;InheritICAEncryptionStrength;InheritRDPAuthenticationLevel;InheritLoadBalanceInfo;InheritPreExtApp;InheritPostExtApp;InheritMacAddress;InheritUserField;InheritExtApp;InheritVNCCompression;InheritVNCEncoding;InheritVNCAuthMode;InheritVNCProxyType;InheritVNCProxyIP;InheritVNCProxyPort;InheritVNCProxyUsername;InheritVNCProxyPassword;InheritVNCColors;InheritVNCSmartSizeMode;InheritVNCViewOnly;InheritRDGatewayUsageMethod;InheritRDGatewayHostname;InheritRDGatewayUseConnectionCredentials;InheritRDGatewayUsername;InheritRDGatewayPassword;InheritRDGatewayDomain;InheritRDPAlertIdleTimeout;InheritRDPMinutesToIdleTimeout;InheritSoundQuality");
|
||||
}
|
||||
|
||||
private void SerializeNodesRecursive(ConnectionInfo node, StringBuilder sb)
|
||||
{
|
||||
var nodeAsContainer = node as ContainerInfo;
|
||||
if (nodeAsContainer != null)
|
||||
{
|
||||
foreach (var child in nodeAsContainer.Children)
|
||||
{
|
||||
SerializeNodesRecursive(child, sb);
|
||||
}
|
||||
}
|
||||
|
||||
// dont serialize the root node
|
||||
if (node is RootNodeInfo)
|
||||
return;
|
||||
|
||||
SerializeConnectionInfo(node, sb);
|
||||
}
|
||||
|
||||
private void SerializeConnectionInfo(ConnectionInfo con, StringBuilder sb)
|
||||
{
|
||||
sb.AppendLine();
|
||||
sb.Append(FormatForCsv(con.Name))
|
||||
.Append(FormatForCsv(con.ConstantID))
|
||||
.Append(FormatForCsv(con.Parent?.ConstantID ?? ""))
|
||||
.Append(FormatForCsv(con.GetTreeNodeType()))
|
||||
.Append(FormatForCsv(con.Description))
|
||||
.Append(FormatForCsv(con.Icon))
|
||||
.Append(FormatForCsv(con.Panel));
|
||||
|
||||
if (_saveFilter.SaveUsername)
|
||||
sb.Append(FormatForCsv(con.Username));
|
||||
|
||||
if (_saveFilter.SavePassword)
|
||||
sb.Append(FormatForCsv(con.Password));
|
||||
|
||||
if (_saveFilter.SaveDomain)
|
||||
sb.Append(FormatForCsv(con.Domain));
|
||||
|
||||
sb.Append(FormatForCsv(con.Hostname))
|
||||
.Append(FormatForCsv(con.Protocol))
|
||||
.Append(FormatForCsv(con.PuttySession))
|
||||
.Append(FormatForCsv(con.Port))
|
||||
.Append(FormatForCsv(con.UseConsoleSession))
|
||||
.Append(FormatForCsv(con.UseCredSsp))
|
||||
.Append(FormatForCsv(con.RenderingEngine))
|
||||
.Append(FormatForCsv(con.ICAEncryptionStrength))
|
||||
.Append(FormatForCsv(con.RDPAuthenticationLevel))
|
||||
.Append(FormatForCsv(con.LoadBalanceInfo))
|
||||
.Append(FormatForCsv(con.Colors))
|
||||
.Append(FormatForCsv(con.Resolution))
|
||||
.Append(FormatForCsv(con.AutomaticResize))
|
||||
.Append(FormatForCsv(con.DisplayWallpaper))
|
||||
.Append(FormatForCsv(con.DisplayThemes))
|
||||
.Append(FormatForCsv(con.EnableFontSmoothing))
|
||||
.Append(FormatForCsv(con.EnableDesktopComposition))
|
||||
.Append(FormatForCsv(con.CacheBitmaps))
|
||||
.Append(FormatForCsv(con.RedirectDiskDrives))
|
||||
.Append(FormatForCsv(con.RedirectPorts))
|
||||
.Append(FormatForCsv(con.RedirectPrinters))
|
||||
.Append(FormatForCsv(con.RedirectSmartCards))
|
||||
.Append(FormatForCsv(con.RedirectSound))
|
||||
.Append(FormatForCsv(con.RedirectKeys))
|
||||
.Append(FormatForCsv(con.PreExtApp))
|
||||
.Append(FormatForCsv(con.PostExtApp))
|
||||
.Append(FormatForCsv(con.MacAddress))
|
||||
.Append(FormatForCsv(con.UserField))
|
||||
.Append(FormatForCsv(con.ExtApp))
|
||||
.Append(FormatForCsv(con.VNCCompression))
|
||||
.Append(FormatForCsv(con.VNCEncoding))
|
||||
.Append(FormatForCsv(con.VNCAuthMode))
|
||||
.Append(FormatForCsv(con.VNCProxyType))
|
||||
.Append(FormatForCsv(con.VNCProxyIP))
|
||||
.Append(FormatForCsv(con.VNCProxyPort))
|
||||
.Append(FormatForCsv(con.VNCProxyUsername))
|
||||
.Append(FormatForCsv(con.VNCProxyPassword))
|
||||
.Append(FormatForCsv(con.VNCColors))
|
||||
.Append(FormatForCsv(con.VNCSmartSizeMode))
|
||||
.Append(FormatForCsv(con.VNCViewOnly))
|
||||
.Append(FormatForCsv(con.RDGatewayUsageMethod))
|
||||
.Append(FormatForCsv(con.RDGatewayHostname))
|
||||
.Append(FormatForCsv(con.RDGatewayUseConnectionCredentials))
|
||||
.Append(FormatForCsv(con.RDGatewayUsername))
|
||||
.Append(FormatForCsv(con.RDGatewayPassword))
|
||||
.Append(FormatForCsv(con.RDGatewayDomain));
|
||||
|
||||
|
||||
if (!_saveFilter.SaveInheritance)
|
||||
return;
|
||||
|
||||
sb.Append(FormatForCsv(con.Inheritance.CacheBitmaps))
|
||||
.Append(FormatForCsv(con.Inheritance.Colors))
|
||||
.Append(FormatForCsv(con.Inheritance.Description))
|
||||
.Append(FormatForCsv(con.Inheritance.DisplayThemes))
|
||||
.Append(FormatForCsv(con.Inheritance.DisplayWallpaper))
|
||||
.Append(FormatForCsv(con.Inheritance.EnableFontSmoothing))
|
||||
.Append(FormatForCsv(con.Inheritance.EnableDesktopComposition))
|
||||
.Append(FormatForCsv(con.Inheritance.Domain))
|
||||
.Append(FormatForCsv(con.Inheritance.Icon))
|
||||
.Append(FormatForCsv(con.Inheritance.Panel))
|
||||
.Append(FormatForCsv(con.Inheritance.Password))
|
||||
.Append(FormatForCsv(con.Inheritance.Port))
|
||||
.Append(FormatForCsv(con.Inheritance.Protocol))
|
||||
.Append(FormatForCsv(con.Inheritance.PuttySession))
|
||||
.Append(FormatForCsv(con.Inheritance.RedirectDiskDrives))
|
||||
.Append(FormatForCsv(con.Inheritance.RedirectKeys))
|
||||
.Append(FormatForCsv(con.Inheritance.RedirectPorts))
|
||||
.Append(FormatForCsv(con.Inheritance.RedirectPrinters))
|
||||
.Append(FormatForCsv(con.Inheritance.RedirectSmartCards))
|
||||
.Append(FormatForCsv(con.Inheritance.RedirectSound))
|
||||
.Append(FormatForCsv(con.Inheritance.Resolution))
|
||||
.Append(FormatForCsv(con.Inheritance.AutomaticResize))
|
||||
.Append(FormatForCsv(con.Inheritance.UseConsoleSession))
|
||||
.Append(FormatForCsv(con.Inheritance.UseCredSsp))
|
||||
.Append(FormatForCsv(con.Inheritance.RenderingEngine))
|
||||
.Append(FormatForCsv(con.Inheritance.Username))
|
||||
.Append(FormatForCsv(con.Inheritance.ICAEncryptionStrength))
|
||||
.Append(FormatForCsv(con.Inheritance.RDPAuthenticationLevel))
|
||||
.Append(FormatForCsv(con.Inheritance.LoadBalanceInfo))
|
||||
.Append(FormatForCsv(con.Inheritance.PreExtApp))
|
||||
.Append(FormatForCsv(con.Inheritance.PostExtApp))
|
||||
.Append(FormatForCsv(con.Inheritance.MacAddress))
|
||||
.Append(FormatForCsv(con.Inheritance.UserField))
|
||||
.Append(FormatForCsv(con.Inheritance.ExtApp))
|
||||
.Append(FormatForCsv(con.Inheritance.VNCCompression))
|
||||
.Append(FormatForCsv(con.Inheritance.VNCEncoding))
|
||||
.Append(FormatForCsv(con.Inheritance.VNCAuthMode))
|
||||
.Append(FormatForCsv(con.Inheritance.VNCProxyType))
|
||||
.Append(FormatForCsv(con.Inheritance.VNCProxyIP))
|
||||
.Append(FormatForCsv(con.Inheritance.VNCProxyPort))
|
||||
.Append(FormatForCsv(con.Inheritance.VNCProxyUsername))
|
||||
.Append(FormatForCsv(con.Inheritance.VNCProxyPassword))
|
||||
.Append(FormatForCsv(con.Inheritance.VNCColors))
|
||||
.Append(FormatForCsv(con.Inheritance.VNCSmartSizeMode))
|
||||
.Append(FormatForCsv(con.Inheritance.VNCViewOnly))
|
||||
.Append(FormatForCsv(con.Inheritance.RDGatewayUsageMethod))
|
||||
.Append(FormatForCsv(con.Inheritance.RDGatewayHostname))
|
||||
.Append(FormatForCsv(con.Inheritance.RDGatewayUseConnectionCredentials))
|
||||
.Append(FormatForCsv(con.Inheritance.RDGatewayUsername))
|
||||
.Append(FormatForCsv(con.Inheritance.RDGatewayPassword))
|
||||
.Append(FormatForCsv(con.Inheritance.RDGatewayDomain))
|
||||
.Append(FormatForCsv(con.Inheritance.RDPAlertIdleTimeout))
|
||||
.Append(FormatForCsv(con.Inheritance.RDPMinutesToIdleTimeout))
|
||||
.Append(FormatForCsv(con.Inheritance.SoundQuality));
|
||||
}
|
||||
|
||||
private string FormatForCsv(object value)
|
||||
{
|
||||
var cleanedString = value.ToString().Replace(";", "");
|
||||
return cleanedString + ";";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,7 @@ using mRemoteNG.Connection;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Security;
|
||||
|
||||
|
||||
namespace mRemoteNG.Config.Serializers
|
||||
namespace mRemoteNG.Config.Serializers.Xml
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public class XmlConnectionNodeSerializer26 : ISerializer<ConnectionInfo,XElement>
|
||||
@@ -43,7 +42,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
element.Add(new XAttribute("Name", connectionInfo.Name));
|
||||
element.Add(new XAttribute("Type", connectionInfo.GetTreeNodeType().ToString()));
|
||||
if (nodeAsContainer != null)
|
||||
element.Add(new XAttribute("Expanded", nodeAsContainer.IsExpanded.ToString()));
|
||||
element.Add(new XAttribute("Expanded", nodeAsContainer.IsExpanded.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("Descr", connectionInfo.Description));
|
||||
element.Add(new XAttribute("Icon", connectionInfo.Icon));
|
||||
element.Add(new XAttribute("Panel", connectionInfo.Panel));
|
||||
@@ -66,30 +65,30 @@ namespace mRemoteNG.Config.Serializers
|
||||
element.Add(new XAttribute("Protocol", connectionInfo.Protocol));
|
||||
element.Add(new XAttribute("PuttySession", connectionInfo.PuttySession));
|
||||
element.Add(new XAttribute("Port", connectionInfo.Port));
|
||||
element.Add(new XAttribute("ConnectToConsole", connectionInfo.UseConsoleSession.ToString()));
|
||||
element.Add(new XAttribute("UseCredSsp", connectionInfo.UseCredSsp.ToString()));
|
||||
element.Add(new XAttribute("ConnectToConsole", connectionInfo.UseConsoleSession.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("UseCredSsp", connectionInfo.UseCredSsp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RenderingEngine", connectionInfo.RenderingEngine));
|
||||
element.Add(new XAttribute("ICAEncryptionStrength", connectionInfo.ICAEncryptionStrength));
|
||||
element.Add(new XAttribute("RDPAuthenticationLevel", connectionInfo.RDPAuthenticationLevel));
|
||||
element.Add(new XAttribute("RDPMinutesToIdleTimeout", connectionInfo.RDPMinutesToIdleTimeout));
|
||||
element.Add(new XAttribute("RDPAlertIdleTimeout", connectionInfo.RDPAlertIdleTimeout));
|
||||
element.Add(new XAttribute("RDPAlertIdleTimeout", connectionInfo.RDPAlertIdleTimeout.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("LoadBalanceInfo", connectionInfo.LoadBalanceInfo));
|
||||
element.Add(new XAttribute("Colors", connectionInfo.Colors));
|
||||
element.Add(new XAttribute("Resolution", connectionInfo.Resolution));
|
||||
element.Add(new XAttribute("AutomaticResize", connectionInfo.AutomaticResize.ToString()));
|
||||
element.Add(new XAttribute("DisplayWallpaper", connectionInfo.DisplayWallpaper.ToString()));
|
||||
element.Add(new XAttribute("DisplayThemes", connectionInfo.DisplayThemes.ToString()));
|
||||
element.Add(new XAttribute("EnableFontSmoothing", connectionInfo.EnableFontSmoothing.ToString()));
|
||||
element.Add(new XAttribute("EnableDesktopComposition", connectionInfo.EnableDesktopComposition.ToString()));
|
||||
element.Add(new XAttribute("CacheBitmaps", connectionInfo.CacheBitmaps.ToString()));
|
||||
element.Add(new XAttribute("RedirectDiskDrives", connectionInfo.RedirectDiskDrives.ToString()));
|
||||
element.Add(new XAttribute("RedirectPorts", connectionInfo.RedirectPorts.ToString()));
|
||||
element.Add(new XAttribute("RedirectPrinters", connectionInfo.RedirectPrinters.ToString()));
|
||||
element.Add(new XAttribute("RedirectSmartCards", connectionInfo.RedirectSmartCards.ToString()));
|
||||
element.Add(new XAttribute("AutomaticResize", connectionInfo.AutomaticResize.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("DisplayWallpaper", connectionInfo.DisplayWallpaper.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("DisplayThemes", connectionInfo.DisplayThemes.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("EnableFontSmoothing", connectionInfo.EnableFontSmoothing.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("EnableDesktopComposition", connectionInfo.EnableDesktopComposition.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("CacheBitmaps", connectionInfo.CacheBitmaps.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectDiskDrives", connectionInfo.RedirectDiskDrives.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectPorts", connectionInfo.RedirectPorts.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectPrinters", connectionInfo.RedirectPrinters.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectSmartCards", connectionInfo.RedirectSmartCards.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectSound", connectionInfo.RedirectSound.ToString()));
|
||||
element.Add(new XAttribute("SoundQuality", connectionInfo.SoundQuality.ToString()));
|
||||
element.Add(new XAttribute("RedirectKeys", connectionInfo.RedirectKeys.ToString()));
|
||||
element.Add(new XAttribute("Connected", (connectionInfo.OpenConnections.Count > 0).ToString()));
|
||||
element.Add(new XAttribute("RedirectKeys", connectionInfo.RedirectKeys.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("Connected", (connectionInfo.OpenConnections.Count > 0).ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("PreExtApp", connectionInfo.PreExtApp));
|
||||
element.Add(new XAttribute("PostExtApp", connectionInfo.PostExtApp));
|
||||
element.Add(new XAttribute("MacAddress", connectionInfo.MacAddress));
|
||||
@@ -113,7 +112,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
|
||||
element.Add(new XAttribute("VNCColors", connectionInfo.VNCColors));
|
||||
element.Add(new XAttribute("VNCSmartSizeMode", connectionInfo.VNCSmartSizeMode));
|
||||
element.Add(new XAttribute("VNCViewOnly", connectionInfo.VNCViewOnly.ToString()));
|
||||
element.Add(new XAttribute("VNCViewOnly", connectionInfo.VNCViewOnly.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RDGatewayUsageMethod", connectionInfo.RDGatewayUsageMethod));
|
||||
element.Add(new XAttribute("RDGatewayHostname", connectionInfo.RDGatewayHostname));
|
||||
element.Add(new XAttribute("RDGatewayUseConnectionCredentials", connectionInfo.RDGatewayUseConnectionCredentials));
|
||||
@@ -136,117 +135,118 @@ namespace mRemoteNG.Config.Serializers
|
||||
{
|
||||
if (_saveFilter.SaveInheritance)
|
||||
{
|
||||
element.Add(new XAttribute("InheritCacheBitmaps", connectionInfo.Inheritance.CacheBitmaps.ToString()));
|
||||
element.Add(new XAttribute("InheritColors", connectionInfo.Inheritance.Colors.ToString()));
|
||||
element.Add(new XAttribute("InheritDescription", connectionInfo.Inheritance.Description.ToString()));
|
||||
element.Add(new XAttribute("InheritDisplayThemes", connectionInfo.Inheritance.DisplayThemes.ToString()));
|
||||
element.Add(new XAttribute("InheritDisplayWallpaper", connectionInfo.Inheritance.DisplayWallpaper.ToString()));
|
||||
element.Add(new XAttribute("InheritEnableFontSmoothing", connectionInfo.Inheritance.EnableFontSmoothing.ToString()));
|
||||
element.Add(new XAttribute("InheritEnableDesktopComposition", connectionInfo.Inheritance.EnableDesktopComposition.ToString()));
|
||||
element.Add(new XAttribute("InheritDomain", connectionInfo.Inheritance.Domain.ToString()));
|
||||
element.Add(new XAttribute("InheritIcon", connectionInfo.Inheritance.Icon.ToString()));
|
||||
element.Add(new XAttribute("InheritPanel", connectionInfo.Inheritance.Panel.ToString()));
|
||||
element.Add(new XAttribute("InheritPassword", connectionInfo.Inheritance.Password.ToString()));
|
||||
element.Add(new XAttribute("InheritPort", connectionInfo.Inheritance.Port.ToString()));
|
||||
element.Add(new XAttribute("InheritProtocol", connectionInfo.Inheritance.Protocol.ToString()));
|
||||
element.Add(new XAttribute("InheritPuttySession", connectionInfo.Inheritance.PuttySession.ToString()));
|
||||
element.Add(new XAttribute("InheritRedirectDiskDrives", connectionInfo.Inheritance.RedirectDiskDrives.ToString()));
|
||||
element.Add(new XAttribute("InheritRedirectKeys", connectionInfo.Inheritance.RedirectKeys.ToString()));
|
||||
element.Add(new XAttribute("InheritRedirectPorts", connectionInfo.Inheritance.RedirectPorts.ToString()));
|
||||
element.Add(new XAttribute("InheritRedirectPrinters", connectionInfo.Inheritance.RedirectPrinters.ToString()));
|
||||
element.Add(new XAttribute("InheritRedirectSmartCards", connectionInfo.Inheritance.RedirectSmartCards.ToString()));
|
||||
element.Add(new XAttribute("InheritRedirectSound", connectionInfo.Inheritance.RedirectSound.ToString()));
|
||||
element.Add(new XAttribute("InheritSoundQuality", connectionInfo.Inheritance.SoundQuality.ToString()));
|
||||
element.Add(new XAttribute("InheritResolution", connectionInfo.Inheritance.Resolution.ToString()));
|
||||
element.Add(new XAttribute("InheritAutomaticResize", connectionInfo.Inheritance.AutomaticResize.ToString()));
|
||||
element.Add(new XAttribute("InheritUseConsoleSession", connectionInfo.Inheritance.UseConsoleSession.ToString()));
|
||||
element.Add(new XAttribute("InheritUseCredSsp", connectionInfo.Inheritance.UseCredSsp.ToString()));
|
||||
element.Add(new XAttribute("InheritRenderingEngine", connectionInfo.Inheritance.RenderingEngine.ToString()));
|
||||
element.Add(new XAttribute("InheritUsername", connectionInfo.Inheritance.Username.ToString()));
|
||||
element.Add(new XAttribute("InheritICAEncryptionStrength", connectionInfo.Inheritance.ICAEncryptionStrength.ToString()));
|
||||
element.Add(new XAttribute("InheritRDPAuthenticationLevel", connectionInfo.Inheritance.RDPAuthenticationLevel.ToString()));
|
||||
element.Add(new XAttribute("InheritRDPMinutesToIdleTimeout", connectionInfo.Inheritance.RDPMinutesToIdleTimeout.ToString()));
|
||||
element.Add(new XAttribute("InheritRDPAlertIdleTimeout", connectionInfo.Inheritance.RDPAlertIdleTimeout.ToString()));
|
||||
element.Add(new XAttribute("InheritLoadBalanceInfo", connectionInfo.Inheritance.LoadBalanceInfo.ToString()));
|
||||
element.Add(new XAttribute("InheritPreExtApp", connectionInfo.Inheritance.PreExtApp.ToString()));
|
||||
element.Add(new XAttribute("InheritPostExtApp", connectionInfo.Inheritance.PostExtApp.ToString()));
|
||||
element.Add(new XAttribute("InheritMacAddress", connectionInfo.Inheritance.MacAddress.ToString()));
|
||||
element.Add(new XAttribute("InheritUserField", connectionInfo.Inheritance.UserField.ToString()));
|
||||
element.Add(new XAttribute("InheritExtApp", connectionInfo.Inheritance.ExtApp.ToString()));
|
||||
element.Add(new XAttribute("InheritVNCCompression", connectionInfo.Inheritance.VNCCompression.ToString()));
|
||||
element.Add(new XAttribute("InheritVNCEncoding", connectionInfo.Inheritance.VNCEncoding.ToString()));
|
||||
element.Add(new XAttribute("InheritVNCAuthMode", connectionInfo.Inheritance.VNCAuthMode.ToString()));
|
||||
element.Add(new XAttribute("InheritVNCProxyType", connectionInfo.Inheritance.VNCProxyType.ToString()));
|
||||
element.Add(new XAttribute("InheritVNCProxyIP", connectionInfo.Inheritance.VNCProxyIP.ToString()));
|
||||
element.Add(new XAttribute("InheritVNCProxyPort", connectionInfo.Inheritance.VNCProxyPort.ToString()));
|
||||
element.Add(new XAttribute("InheritVNCProxyUsername", connectionInfo.Inheritance.VNCProxyUsername.ToString()));
|
||||
element.Add(new XAttribute("InheritVNCProxyPassword", connectionInfo.Inheritance.VNCProxyPassword.ToString()));
|
||||
element.Add(new XAttribute("InheritVNCColors", connectionInfo.Inheritance.VNCColors.ToString()));
|
||||
element.Add(new XAttribute("InheritVNCSmartSizeMode", connectionInfo.Inheritance.VNCSmartSizeMode.ToString()));
|
||||
element.Add(new XAttribute("InheritVNCViewOnly", connectionInfo.Inheritance.VNCViewOnly.ToString()));
|
||||
element.Add(new XAttribute("InheritRDGatewayUsageMethod", connectionInfo.Inheritance.RDGatewayUsageMethod.ToString()));
|
||||
element.Add(new XAttribute("InheritRDGatewayHostname", connectionInfo.Inheritance.RDGatewayHostname.ToString()));
|
||||
element.Add(new XAttribute("InheritRDGatewayUseConnectionCredentials", connectionInfo.Inheritance.RDGatewayUseConnectionCredentials.ToString()));
|
||||
element.Add(new XAttribute("InheritRDGatewayUsername", connectionInfo.Inheritance.RDGatewayUsername.ToString()));
|
||||
element.Add(new XAttribute("InheritRDGatewayPassword", connectionInfo.Inheritance.RDGatewayPassword.ToString()));
|
||||
element.Add(new XAttribute("InheritRDGatewayDomain", connectionInfo.Inheritance.RDGatewayDomain.ToString()));
|
||||
element.Add(new XAttribute("InheritCacheBitmaps", connectionInfo.Inheritance.CacheBitmaps.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritColors", connectionInfo.Inheritance.Colors.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritDescription", connectionInfo.Inheritance.Description.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritDisplayThemes", connectionInfo.Inheritance.DisplayThemes.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritDisplayWallpaper", connectionInfo.Inheritance.DisplayWallpaper.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritEnableFontSmoothing", connectionInfo.Inheritance.EnableFontSmoothing.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritEnableDesktopComposition", connectionInfo.Inheritance.EnableDesktopComposition.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritDomain", connectionInfo.Inheritance.Domain.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritIcon", connectionInfo.Inheritance.Icon.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPanel", connectionInfo.Inheritance.Panel.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPassword", connectionInfo.Inheritance.Password.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPort", connectionInfo.Inheritance.Port.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritProtocol", connectionInfo.Inheritance.Protocol.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPuttySession", connectionInfo.Inheritance.PuttySession.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectDiskDrives", connectionInfo.Inheritance.RedirectDiskDrives.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectKeys", connectionInfo.Inheritance.RedirectKeys.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectPorts", connectionInfo.Inheritance.RedirectPorts.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectPrinters", connectionInfo.Inheritance.RedirectPrinters.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectSmartCards", connectionInfo.Inheritance.RedirectSmartCards.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectSound", connectionInfo.Inheritance.RedirectSound.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritSoundQuality", connectionInfo.Inheritance.SoundQuality.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritResolution", connectionInfo.Inheritance.Resolution.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritAutomaticResize", connectionInfo.Inheritance.AutomaticResize.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritUseConsoleSession", connectionInfo.Inheritance.UseConsoleSession.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritUseCredSsp", connectionInfo.Inheritance.UseCredSsp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRenderingEngine", connectionInfo.Inheritance.RenderingEngine.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritUsername", connectionInfo.Inheritance.Username.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritICAEncryptionStrength", connectionInfo.Inheritance.ICAEncryptionStrength.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDPAuthenticationLevel", connectionInfo.Inheritance.RDPAuthenticationLevel.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDPMinutesToIdleTimeout", connectionInfo.Inheritance.RDPMinutesToIdleTimeout.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDPAlertIdleTimeout", connectionInfo.Inheritance.RDPAlertIdleTimeout.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritLoadBalanceInfo", connectionInfo.Inheritance.LoadBalanceInfo.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPreExtApp", connectionInfo.Inheritance.PreExtApp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPostExtApp", connectionInfo.Inheritance.PostExtApp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritMacAddress", connectionInfo.Inheritance.MacAddress.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritUserField", connectionInfo.Inheritance.UserField.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritExtApp", connectionInfo.Inheritance.ExtApp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCCompression", connectionInfo.Inheritance.VNCCompression.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCEncoding", connectionInfo.Inheritance.VNCEncoding.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCAuthMode", connectionInfo.Inheritance.VNCAuthMode.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyType", connectionInfo.Inheritance.VNCProxyType.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyIP", connectionInfo.Inheritance.VNCProxyIP.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyPort", connectionInfo.Inheritance.VNCProxyPort.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyUsername", connectionInfo.Inheritance.VNCProxyUsername.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyPassword", connectionInfo.Inheritance.VNCProxyPassword.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCColors", connectionInfo.Inheritance.VNCColors.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCSmartSizeMode", connectionInfo.Inheritance.VNCSmartSizeMode.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCViewOnly", connectionInfo.Inheritance.VNCViewOnly.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayUsageMethod", connectionInfo.Inheritance.RDGatewayUsageMethod.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayHostname", connectionInfo.Inheritance.RDGatewayHostname.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayUseConnectionCredentials", connectionInfo.Inheritance.RDGatewayUseConnectionCredentials.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayUsername", connectionInfo.Inheritance.RDGatewayUsername.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayPassword", connectionInfo.Inheritance.RDGatewayPassword.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayDomain", connectionInfo.Inheritance.RDGatewayDomain.ToString().ToLowerInvariant()));
|
||||
}
|
||||
else
|
||||
{
|
||||
element.Add(new XAttribute("InheritCacheBitmaps", false.ToString()));
|
||||
element.Add(new XAttribute("InheritColors", false.ToString()));
|
||||
element.Add(new XAttribute("InheritDescription", false.ToString()));
|
||||
element.Add(new XAttribute("InheritDisplayThemes", false.ToString()));
|
||||
element.Add(new XAttribute("InheritDisplayWallpaper", false.ToString()));
|
||||
element.Add(new XAttribute("InheritEnableFontSmoothing", false.ToString()));
|
||||
element.Add(new XAttribute("InheritEnableDesktopComposition", false.ToString()));
|
||||
element.Add(new XAttribute("InheritDomain", false.ToString()));
|
||||
element.Add(new XAttribute("InheritIcon", false.ToString()));
|
||||
element.Add(new XAttribute("InheritPanel", false.ToString()));
|
||||
element.Add(new XAttribute("InheritPassword", false.ToString()));
|
||||
element.Add(new XAttribute("InheritPort", false.ToString()));
|
||||
element.Add(new XAttribute("InheritProtocol", false.ToString()));
|
||||
element.Add(new XAttribute("InheritPuttySession", false.ToString()));
|
||||
element.Add(new XAttribute("InheritRedirectDiskDrives", false.ToString()));
|
||||
element.Add(new XAttribute("InheritRedirectKeys", false.ToString()));
|
||||
element.Add(new XAttribute("InheritRedirectPorts", false.ToString()));
|
||||
element.Add(new XAttribute("InheritRedirectPrinters", false.ToString()));
|
||||
element.Add(new XAttribute("InheritRedirectSmartCards", false.ToString()));
|
||||
element.Add(new XAttribute("InheritRedirectSound", false.ToString()));
|
||||
element.Add(new XAttribute("InheritSoundQuality", false.ToString()));
|
||||
element.Add(new XAttribute("InheritResolution", false.ToString()));
|
||||
element.Add(new XAttribute("InheritAutomaticResize", false.ToString()));
|
||||
element.Add(new XAttribute("InheritUseConsoleSession", false.ToString()));
|
||||
element.Add(new XAttribute("InheritUseCredSsp", false.ToString()));
|
||||
element.Add(new XAttribute("InheritRenderingEngine", false.ToString()));
|
||||
element.Add(new XAttribute("InheritUsername", false.ToString()));
|
||||
element.Add(new XAttribute("InheritICAEncryptionStrength", false.ToString()));
|
||||
element.Add(new XAttribute("InheritRDPAuthenticationLevel", false.ToString()));
|
||||
element.Add(new XAttribute("InheritRDPMinutesToIdleTimeout", false.ToString()));
|
||||
element.Add(new XAttribute("InheritRDPAlertIdleTimeout", false.ToString()));
|
||||
element.Add(new XAttribute("InheritLoadBalanceInfo", false.ToString()));
|
||||
element.Add(new XAttribute("InheritPreExtApp", false.ToString()));
|
||||
element.Add(new XAttribute("InheritPostExtApp", false.ToString()));
|
||||
element.Add(new XAttribute("InheritMacAddress", false.ToString()));
|
||||
element.Add(new XAttribute("InheritUserField", false.ToString()));
|
||||
element.Add(new XAttribute("InheritExtApp", false.ToString()));
|
||||
element.Add(new XAttribute("InheritVNCCompression", false.ToString()));
|
||||
element.Add(new XAttribute("InheritVNCEncoding", false.ToString()));
|
||||
element.Add(new XAttribute("InheritVNCAuthMode", false.ToString()));
|
||||
element.Add(new XAttribute("InheritVNCProxyType", false.ToString()));
|
||||
element.Add(new XAttribute("InheritVNCProxyIP", false.ToString()));
|
||||
element.Add(new XAttribute("InheritVNCProxyPort", false.ToString()));
|
||||
element.Add(new XAttribute("InheritVNCProxyUsername", false.ToString()));
|
||||
element.Add(new XAttribute("InheritVNCProxyPassword", false.ToString()));
|
||||
element.Add(new XAttribute("InheritVNCColors", false.ToString()));
|
||||
element.Add(new XAttribute("InheritVNCSmartSizeMode", false.ToString()));
|
||||
element.Add(new XAttribute("InheritVNCViewOnly", false.ToString()));
|
||||
element.Add(new XAttribute("InheritRDGatewayUsageMethod", false.ToString()));
|
||||
element.Add(new XAttribute("InheritRDGatewayHostname", false.ToString()));
|
||||
element.Add(new XAttribute("InheritRDGatewayUseConnectionCredentials", false.ToString()));
|
||||
element.Add(new XAttribute("InheritRDGatewayUsername", false.ToString()));
|
||||
element.Add(new XAttribute("InheritRDGatewayPassword", false.ToString()));
|
||||
element.Add(new XAttribute("InheritRDGatewayDomain", false.ToString()));
|
||||
var falseString = false.ToString().ToLowerInvariant();
|
||||
element.Add(new XAttribute("InheritCacheBitmaps", falseString));
|
||||
element.Add(new XAttribute("InheritColors", falseString));
|
||||
element.Add(new XAttribute("InheritDescription", falseString));
|
||||
element.Add(new XAttribute("InheritDisplayThemes", falseString));
|
||||
element.Add(new XAttribute("InheritDisplayWallpaper", falseString));
|
||||
element.Add(new XAttribute("InheritEnableFontSmoothing", falseString));
|
||||
element.Add(new XAttribute("InheritEnableDesktopComposition", falseString));
|
||||
element.Add(new XAttribute("InheritDomain", falseString));
|
||||
element.Add(new XAttribute("InheritIcon", falseString));
|
||||
element.Add(new XAttribute("InheritPanel", falseString));
|
||||
element.Add(new XAttribute("InheritPassword", falseString));
|
||||
element.Add(new XAttribute("InheritPort", falseString));
|
||||
element.Add(new XAttribute("InheritProtocol", falseString));
|
||||
element.Add(new XAttribute("InheritPuttySession", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectDiskDrives", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectKeys", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectPorts", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectPrinters", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectSmartCards", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectSound", falseString));
|
||||
element.Add(new XAttribute("InheritSoundQuality", falseString));
|
||||
element.Add(new XAttribute("InheritResolution", falseString));
|
||||
element.Add(new XAttribute("InheritAutomaticResize", falseString));
|
||||
element.Add(new XAttribute("InheritUseConsoleSession", falseString));
|
||||
element.Add(new XAttribute("InheritUseCredSsp", falseString));
|
||||
element.Add(new XAttribute("InheritRenderingEngine", falseString));
|
||||
element.Add(new XAttribute("InheritUsername", falseString));
|
||||
element.Add(new XAttribute("InheritICAEncryptionStrength", falseString));
|
||||
element.Add(new XAttribute("InheritRDPAuthenticationLevel", falseString));
|
||||
element.Add(new XAttribute("InheritRDPMinutesToIdleTimeout", falseString));
|
||||
element.Add(new XAttribute("InheritRDPAlertIdleTimeout", falseString));
|
||||
element.Add(new XAttribute("InheritLoadBalanceInfo", falseString));
|
||||
element.Add(new XAttribute("InheritPreExtApp", falseString));
|
||||
element.Add(new XAttribute("InheritPostExtApp", falseString));
|
||||
element.Add(new XAttribute("InheritMacAddress", falseString));
|
||||
element.Add(new XAttribute("InheritUserField", falseString));
|
||||
element.Add(new XAttribute("InheritExtApp", falseString));
|
||||
element.Add(new XAttribute("InheritVNCCompression", falseString));
|
||||
element.Add(new XAttribute("InheritVNCEncoding", falseString));
|
||||
element.Add(new XAttribute("InheritVNCAuthMode", falseString));
|
||||
element.Add(new XAttribute("InheritVNCProxyType", falseString));
|
||||
element.Add(new XAttribute("InheritVNCProxyIP", falseString));
|
||||
element.Add(new XAttribute("InheritVNCProxyPort", falseString));
|
||||
element.Add(new XAttribute("InheritVNCProxyUsername", falseString));
|
||||
element.Add(new XAttribute("InheritVNCProxyPassword", falseString));
|
||||
element.Add(new XAttribute("InheritVNCColors", falseString));
|
||||
element.Add(new XAttribute("InheritVNCSmartSizeMode", falseString));
|
||||
element.Add(new XAttribute("InheritVNCViewOnly", falseString));
|
||||
element.Add(new XAttribute("InheritRDGatewayUsageMethod", falseString));
|
||||
element.Add(new XAttribute("InheritRDGatewayHostname", falseString));
|
||||
element.Add(new XAttribute("InheritRDGatewayUseConnectionCredentials", falseString));
|
||||
element.Add(new XAttribute("InheritRDGatewayUsername", falseString));
|
||||
element.Add(new XAttribute("InheritRDGatewayPassword", falseString));
|
||||
element.Add(new XAttribute("InheritRDGatewayDomain", falseString));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,9 +19,9 @@ using mRemoteNG.Tree.Root;
|
||||
using mRemoteNG.UI.Forms;
|
||||
using mRemoteNG.UI.TaskDialog;
|
||||
|
||||
namespace mRemoteNG.Config.Serializers
|
||||
namespace mRemoteNG.Config.Serializers.Xml
|
||||
{
|
||||
public class XmlConnectionsDeserializer : IDeserializer<string, ConnectionTreeModel>
|
||||
public class XmlConnectionsDeserializer : IDeserializer<string, ConnectionTreeModel>
|
||||
{
|
||||
private XmlDocument _xmlDocument;
|
||||
private double _confVersion;
|
||||
@@ -30,9 +30,9 @@ namespace mRemoteNG.Config.Serializers
|
||||
private const double MaxSupportedConfVersion = 2.8;
|
||||
private readonly RootNodeInfo _rootNodeInfo = new RootNodeInfo(RootNodeType.Connection);
|
||||
|
||||
public Func<SecureString> AuthenticationRequestor { get; set; }
|
||||
public Func<Optional<SecureString>> AuthenticationRequestor { get; set; }
|
||||
|
||||
public XmlConnectionsDeserializer(Func<SecureString> authenticationRequestor = null)
|
||||
public XmlConnectionsDeserializer(Func<Optional<SecureString>> authenticationRequestor = null)
|
||||
{
|
||||
AuthenticationRequestor = authenticationRequestor;
|
||||
}
|
||||
@@ -48,8 +48,6 @@ namespace mRemoteNG.Config.Serializers
|
||||
{
|
||||
LoadXmlConnectionData(xml);
|
||||
ValidateConnectionFileVersion();
|
||||
if (!import)
|
||||
Runtime.ConnectionsService.IsConnectionsFileLoaded = false;
|
||||
|
||||
var rootXmlElement = _xmlDocument.DocumentElement;
|
||||
InitializeRootNode(rootXmlElement);
|
||||
@@ -63,15 +61,14 @@ namespace mRemoteNG.Config.Serializers
|
||||
var protectedString = _xmlDocument.DocumentElement?.Attributes["Protected"].Value;
|
||||
if (!_decryptor.ConnectionsFileIsAuthentic(protectedString, _rootNodeInfo.PasswordString.ConvertToSecureString()))
|
||||
{
|
||||
mRemoteNG.Settings.Default.LoadConsFromCustomLocation = false;
|
||||
mRemoteNG.Settings.Default.CustomConsPath = "";
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (_confVersion >= 2.6)
|
||||
{
|
||||
if (rootXmlElement?.Attributes["FullFileEncryption"].Value == "True")
|
||||
var fullFileEncryptionValue = rootXmlElement?.Attributes["FullFileEncryption"].Value ?? "";
|
||||
if (bool.Parse(fullFileEncryptionValue))
|
||||
{
|
||||
var decryptedContent = _decryptor.Decrypt(rootXmlElement.InnerText);
|
||||
rootXmlElement.InnerXml = decryptedContent;
|
||||
@@ -143,10 +140,10 @@ namespace mRemoteNG.Config.Serializers
|
||||
if (_confVersion >= 2.6)
|
||||
{
|
||||
BlockCipherEngines engine;
|
||||
Enum.TryParse(connectionsRootElement?.Attributes["EncryptionEngine"].Value, out engine);
|
||||
Enum.TryParse(connectionsRootElement?.Attributes["EncryptionEngine"].Value, true, out engine);
|
||||
|
||||
BlockCipherModes mode;
|
||||
Enum.TryParse(connectionsRootElement?.Attributes["BlockCipherMode"].Value, out mode);
|
||||
Enum.TryParse(connectionsRootElement?.Attributes["BlockCipherMode"].Value, true, out mode);
|
||||
|
||||
int keyDerivationIterations;
|
||||
int.TryParse(connectionsRootElement?.Attributes["KdfIterations"].Value, out keyDerivationIterations);
|
||||
@@ -186,7 +183,10 @@ namespace mRemoteNG.Config.Serializers
|
||||
if (_confVersion >= 0.9)
|
||||
containerInfo.CopyFrom(GetConnectionInfoFromXml(xmlNode));
|
||||
if (_confVersion >= 0.8)
|
||||
containerInfo.IsExpanded = xmlNode.Attributes?["Expanded"].Value == "True";
|
||||
{
|
||||
var expandedValue = xmlNode.Attributes?["Expanded"].Value ?? "";
|
||||
containerInfo.IsExpanded = bool.Parse(expandedValue);
|
||||
}
|
||||
|
||||
parentContainer.AddChild(containerInfo);
|
||||
AddNodesFromXmlRecursive(xmlNode, containerInfo);
|
||||
@@ -204,7 +204,11 @@ namespace mRemoteNG.Config.Serializers
|
||||
private ConnectionInfo GetConnectionInfoFromXml(XmlNode xmlnode)
|
||||
{
|
||||
if (xmlnode.Attributes == null) return null;
|
||||
var connectionInfo = new ConnectionInfo();
|
||||
|
||||
var connectionId = xmlnode.Attributes["Id"]?.Value;
|
||||
if (string.IsNullOrWhiteSpace(connectionId))
|
||||
connectionId = Guid.NewGuid().ToString();
|
||||
var connectionInfo = new ConnectionInfo(connectionId);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -219,7 +223,9 @@ namespace mRemoteNG.Config.Serializers
|
||||
|
||||
if (_confVersion < 1.1) //1.0 - 0.1
|
||||
{
|
||||
connectionInfo.Resolution = Convert.ToBoolean(xmlnode.Attributes["Fullscreen"].Value) ? RdpProtocol.RDPResolutions.Fullscreen : RdpProtocol.RDPResolutions.FitToWindow;
|
||||
connectionInfo.Resolution = Convert.ToBoolean(xmlnode.Attributes["Fullscreen"].Value)
|
||||
? RdpProtocol.RDPResolutions.Fullscreen
|
||||
: RdpProtocol.RDPResolutions.FitToWindow;
|
||||
}
|
||||
|
||||
if (_confVersion <= 2.6) // 0.2 - 2.6
|
||||
@@ -257,7 +263,9 @@ namespace mRemoteNG.Config.Serializers
|
||||
{
|
||||
if (_confVersion < 0.7)
|
||||
{
|
||||
connectionInfo.Port = Convert.ToInt32(Convert.ToBoolean(xmlnode.Attributes["UseVNC"].Value) ? xmlnode.Attributes["VNCPort"].Value : xmlnode.Attributes["RDPPort"].Value);
|
||||
connectionInfo.Port = Convert.ToInt32(Convert.ToBoolean(xmlnode.Attributes["UseVNC"].Value)
|
||||
? xmlnode.Attributes["VNCPort"].Value
|
||||
: xmlnode.Attributes["RDPPort"].Value);
|
||||
}
|
||||
|
||||
connectionInfo.UseConsoleSession = bool.Parse(xmlnode.Attributes["ConnectToConsole"].Value);
|
||||
@@ -291,7 +299,9 @@ namespace mRemoteNG.Config.Serializers
|
||||
|
||||
if (_confVersion >= 0.7)
|
||||
{
|
||||
connectionInfo.Protocol = (ProtocolType)MiscTools.StringToEnum(typeof(ProtocolType), xmlnode.Attributes["Protocol"].Value);
|
||||
ProtocolType protocolType;
|
||||
Enum.TryParse(xmlnode.Attributes["Protocol"].Value, true, out protocolType);
|
||||
connectionInfo.Protocol = protocolType;
|
||||
connectionInfo.Port = Convert.ToInt32(xmlnode.Attributes["Port"].Value);
|
||||
}
|
||||
|
||||
@@ -307,9 +317,9 @@ namespace mRemoteNG.Config.Serializers
|
||||
|
||||
if (_confVersion >= 1.3)
|
||||
{
|
||||
connectionInfo.Colors = (RdpProtocol.RDPColors)MiscTools.StringToEnum(typeof(RdpProtocol.RDPColors), xmlnode.Attributes["Colors"].Value);
|
||||
connectionInfo.Resolution = (RdpProtocol.RDPResolutions)MiscTools.StringToEnum(typeof(RdpProtocol.RDPResolutions), Convert.ToString(xmlnode.Attributes["Resolution"].Value));
|
||||
connectionInfo.RedirectSound = (RdpProtocol.RDPSounds)MiscTools.StringToEnum(typeof(RdpProtocol.RDPSounds), Convert.ToString(xmlnode.Attributes["RedirectSound"].Value));
|
||||
connectionInfo.Colors = (RdpProtocol.RDPColors)Enum.Parse(typeof(RdpProtocol.RDPColors), xmlnode.Attributes["Colors"].Value, true);
|
||||
connectionInfo.Resolution = (RdpProtocol.RDPResolutions)Enum.Parse(typeof(RdpProtocol.RDPResolutions), xmlnode.Attributes["Resolution"].Value, true);
|
||||
connectionInfo.RedirectSound = (RdpProtocol.RDPSounds)Enum.Parse(typeof(RdpProtocol.RDPSounds), xmlnode.Attributes["RedirectSound"].Value, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -385,7 +395,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
|
||||
if (_confVersion >= 1.6)
|
||||
{
|
||||
connectionInfo.ICAEncryptionStrength = (IcaProtocol.EncryptionStrength)MiscTools.StringToEnum(typeof(IcaProtocol.EncryptionStrength), xmlnode.Attributes["ICAEncryptionStrength"].Value);
|
||||
connectionInfo.ICAEncryptionStrength = (IcaProtocol.EncryptionStrength)Enum.Parse(typeof(IcaProtocol.EncryptionStrength), xmlnode.Attributes["ICAEncryptionStrength"].Value, true);
|
||||
connectionInfo.Inheritance.ICAEncryptionStrength = bool.Parse(xmlnode.Attributes["InheritICAEncryptionStrength"].Value);
|
||||
connectionInfo.PreExtApp = xmlnode.Attributes["PreExtApp"].Value;
|
||||
connectionInfo.PostExtApp = xmlnode.Attributes["PostExtApp"].Value;
|
||||
@@ -395,16 +405,16 @@ namespace mRemoteNG.Config.Serializers
|
||||
|
||||
if (_confVersion >= 1.7)
|
||||
{
|
||||
connectionInfo.VNCCompression = (ProtocolVNC.Compression)MiscTools.StringToEnum(typeof(ProtocolVNC.Compression), xmlnode.Attributes["VNCCompression"].Value);
|
||||
connectionInfo.VNCEncoding = (ProtocolVNC.Encoding)MiscTools.StringToEnum(typeof(ProtocolVNC.Encoding), Convert.ToString(xmlnode.Attributes["VNCEncoding"].Value));
|
||||
connectionInfo.VNCAuthMode = (ProtocolVNC.AuthMode)MiscTools.StringToEnum(typeof(ProtocolVNC.AuthMode), xmlnode.Attributes["VNCAuthMode"].Value);
|
||||
connectionInfo.VNCProxyType = (ProtocolVNC.ProxyType)MiscTools.StringToEnum(typeof(ProtocolVNC.ProxyType), xmlnode.Attributes["VNCProxyType"].Value);
|
||||
connectionInfo.VNCCompression = (ProtocolVNC.Compression)Enum.Parse(typeof(ProtocolVNC.Compression), xmlnode.Attributes["VNCCompression"].Value, true);
|
||||
connectionInfo.VNCEncoding = (ProtocolVNC.Encoding)Enum.Parse(typeof(ProtocolVNC.Encoding), xmlnode.Attributes["VNCEncoding"].Value, true);
|
||||
connectionInfo.VNCAuthMode = (ProtocolVNC.AuthMode)Enum.Parse(typeof(ProtocolVNC.AuthMode), xmlnode.Attributes["VNCAuthMode"].Value, true);
|
||||
connectionInfo.VNCProxyType = (ProtocolVNC.ProxyType)Enum.Parse(typeof(ProtocolVNC.ProxyType), xmlnode.Attributes["VNCProxyType"].Value, true);
|
||||
connectionInfo.VNCProxyIP = xmlnode.Attributes["VNCProxyIP"].Value;
|
||||
connectionInfo.VNCProxyPort = Convert.ToInt32(xmlnode.Attributes["VNCProxyPort"].Value);
|
||||
connectionInfo.VNCProxyUsername = xmlnode.Attributes["VNCProxyUsername"].Value;
|
||||
connectionInfo.VNCProxyPassword = _decryptor.Decrypt(xmlnode.Attributes["VNCProxyPassword"].Value);
|
||||
connectionInfo.VNCColors = (ProtocolVNC.Colors)MiscTools.StringToEnum(typeof(ProtocolVNC.Colors), xmlnode.Attributes["VNCColors"].Value);
|
||||
connectionInfo.VNCSmartSizeMode = (ProtocolVNC.SmartSizeMode)MiscTools.StringToEnum(typeof(ProtocolVNC.SmartSizeMode), xmlnode.Attributes["VNCSmartSizeMode"].Value);
|
||||
connectionInfo.VNCColors = (ProtocolVNC.Colors)Enum.Parse(typeof(ProtocolVNC.Colors), xmlnode.Attributes["VNCColors"].Value, true);
|
||||
connectionInfo.VNCSmartSizeMode = (ProtocolVNC.SmartSizeMode)Enum.Parse(typeof(ProtocolVNC.SmartSizeMode), xmlnode.Attributes["VNCSmartSizeMode"].Value, true);
|
||||
connectionInfo.VNCViewOnly = bool.Parse(xmlnode.Attributes["VNCViewOnly"].Value);
|
||||
connectionInfo.Inheritance.VNCCompression = bool.Parse(xmlnode.Attributes["InheritVNCCompression"].Value);
|
||||
connectionInfo.Inheritance.VNCEncoding = bool.Parse(xmlnode.Attributes["InheritVNCEncoding"].Value);
|
||||
@@ -421,13 +431,13 @@ namespace mRemoteNG.Config.Serializers
|
||||
|
||||
if (_confVersion >= 1.8)
|
||||
{
|
||||
connectionInfo.RDPAuthenticationLevel = (RdpProtocol.AuthenticationLevel)MiscTools.StringToEnum(typeof(RdpProtocol.AuthenticationLevel), xmlnode.Attributes["RDPAuthenticationLevel"].Value);
|
||||
connectionInfo.RDPAuthenticationLevel = (RdpProtocol.AuthenticationLevel)Enum.Parse(typeof(RdpProtocol.AuthenticationLevel), xmlnode.Attributes["RDPAuthenticationLevel"].Value, true);
|
||||
connectionInfo.Inheritance.RDPAuthenticationLevel = bool.Parse(xmlnode.Attributes["InheritRDPAuthenticationLevel"].Value);
|
||||
}
|
||||
|
||||
if (_confVersion >= 1.9)
|
||||
{
|
||||
connectionInfo.RenderingEngine = (HTTPBase.RenderingEngine)MiscTools.StringToEnum(typeof(HTTPBase.RenderingEngine), xmlnode.Attributes["RenderingEngine"].Value);
|
||||
connectionInfo.RenderingEngine = (HTTPBase.RenderingEngine)Enum.Parse(typeof(HTTPBase.RenderingEngine), xmlnode.Attributes["RenderingEngine"].Value, true);
|
||||
connectionInfo.MacAddress = xmlnode.Attributes["MacAddress"].Value;
|
||||
connectionInfo.Inheritance.RenderingEngine = bool.Parse(xmlnode.Attributes["InheritRenderingEngine"].Value);
|
||||
connectionInfo.Inheritance.MacAddress = bool.Parse(xmlnode.Attributes["InheritMacAddress"].Value);
|
||||
@@ -448,9 +458,9 @@ namespace mRemoteNG.Config.Serializers
|
||||
if (_confVersion >= 2.2)
|
||||
{
|
||||
// Get settings
|
||||
connectionInfo.RDGatewayUsageMethod = (RdpProtocol.RDGatewayUsageMethod)MiscTools.StringToEnum(typeof(RdpProtocol.RDGatewayUsageMethod), Convert.ToString(xmlnode.Attributes["RDGatewayUsageMethod"].Value));
|
||||
connectionInfo.RDGatewayUsageMethod = (RdpProtocol.RDGatewayUsageMethod)Enum.Parse(typeof(RdpProtocol.RDGatewayUsageMethod), xmlnode.Attributes["RDGatewayUsageMethod"].Value, true);
|
||||
connectionInfo.RDGatewayHostname = xmlnode.Attributes["RDGatewayHostname"].Value;
|
||||
connectionInfo.RDGatewayUseConnectionCredentials = (RdpProtocol.RDGatewayUseConnectionCredentials)MiscTools.StringToEnum(typeof(RdpProtocol.RDGatewayUseConnectionCredentials), Convert.ToString(xmlnode.Attributes["RDGatewayUseConnectionCredentials"].Value));
|
||||
connectionInfo.RDGatewayUseConnectionCredentials = (RdpProtocol.RDGatewayUseConnectionCredentials)Enum.Parse(typeof(RdpProtocol.RDGatewayUseConnectionCredentials), xmlnode.Attributes["RDGatewayUseConnectionCredentials"].Value, true);
|
||||
connectionInfo.RDGatewayUsername = xmlnode.Attributes["RDGatewayUsername"].Value;
|
||||
connectionInfo.RDGatewayPassword = _decryptor.Decrypt(Convert.ToString(xmlnode.Attributes["RDGatewayPassword"].Value));
|
||||
connectionInfo.RDGatewayDomain = xmlnode.Attributes["RDGatewayDomain"].Value;
|
||||
@@ -491,8 +501,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
|
||||
if (_confVersion >= 2.6)
|
||||
{
|
||||
connectionInfo.ConstantID = xmlnode.Attributes["Id"]?.Value ?? connectionInfo.ConstantID;
|
||||
connectionInfo.SoundQuality = (RdpProtocol.RDPSoundQuality)MiscTools.StringToEnum(typeof(RdpProtocol.RDPSoundQuality), Convert.ToString(xmlnode.Attributes["SoundQuality"].Value));
|
||||
connectionInfo.SoundQuality = (RdpProtocol.RDPSoundQuality)Enum.Parse(typeof(RdpProtocol.RDPSoundQuality), xmlnode.Attributes["SoundQuality"].Value, true);
|
||||
connectionInfo.Inheritance.SoundQuality = bool.Parse(xmlnode.Attributes["InheritSoundQuality"].Value);
|
||||
connectionInfo.RDPMinutesToIdleTimeout = Convert.ToInt32(xmlnode.Attributes["RDPMinutesToIdleTimeout"]?.Value ?? "0");
|
||||
connectionInfo.Inheritance.RDPMinutesToIdleTimeout = bool.Parse(xmlnode.Attributes["InheritRDPMinutesToIdleTimeout"]?.Value ?? "False");
|
||||
@@ -8,8 +8,7 @@ using mRemoteNG.Security;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNG.Tree.Root;
|
||||
|
||||
|
||||
namespace mRemoteNG.Config.Serializers
|
||||
namespace mRemoteNG.Config.Serializers.Xml
|
||||
{
|
||||
public class XmlConnectionsDocumentCompiler
|
||||
{
|
||||
@@ -2,8 +2,7 @@
|
||||
using System.Xml.Linq;
|
||||
using mRemoteNG.Security;
|
||||
|
||||
|
||||
namespace mRemoteNG.Config.Serializers
|
||||
namespace mRemoteNG.Config.Serializers.Xml
|
||||
{
|
||||
public class XmlConnectionsDocumentEncryptor
|
||||
{
|
||||
@@ -10,7 +10,7 @@ using mRemoteNG.Security;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNG.Tree.Root;
|
||||
|
||||
namespace mRemoteNG.Config.Serializers
|
||||
namespace mRemoteNG.Config.Serializers.Xml
|
||||
{
|
||||
public class XmlConnectionsSerializer : ISerializer<ConnectionTreeModel,string>, ISerializer<ConnectionInfo, string>
|
||||
{
|
||||
@@ -2,19 +2,21 @@
|
||||
using mRemoteNG.Security;
|
||||
using mRemoteNG.Tree.Root;
|
||||
|
||||
|
||||
namespace mRemoteNG.Config.Serializers
|
||||
namespace mRemoteNG.Config.Serializers.Xml
|
||||
{
|
||||
public class XmlRootNodeSerializer
|
||||
public class XmlRootNodeSerializer
|
||||
{
|
||||
public XElement SerializeRootNodeInfo(RootNodeInfo rootNodeInfo, ICryptographyProvider cryptographyProvider, bool fullFileEncryption = false)
|
||||
{
|
||||
var element = new XElement("Connections");
|
||||
XNamespace xmlNamespace = "http://mremoteng.org";
|
||||
var element = new XElement(xmlNamespace + "Connections");
|
||||
element.Add(new XAttribute(XNamespace.Xmlns+"mrng", xmlNamespace));
|
||||
element.Add(new XAttribute(XName.Get("Name"), rootNodeInfo.Name));
|
||||
element.Add(new XAttribute(XName.Get("EncryptionEngine"), cryptographyProvider.CipherEngine));
|
||||
element.Add(new XAttribute(XName.Get("Export"), "false"));
|
||||
element.Add(new XAttribute(XName.Get("EncryptionEngine"), cryptographyProvider.CipherEngine));
|
||||
element.Add(new XAttribute(XName.Get("BlockCipherMode"), cryptographyProvider.CipherMode));
|
||||
element.Add(new XAttribute(XName.Get("KdfIterations"), cryptographyProvider.KeyDerivationIterations));
|
||||
element.Add(new XAttribute(XName.Get("FullFileEncryption"), fullFileEncryption.ToString()));
|
||||
element.Add(new XAttribute(XName.Get("FullFileEncryption"), fullFileEncryption.ToString().ToLowerInvariant()));
|
||||
element.Add(CreateProtectedAttribute(rootNodeInfo, cryptographyProvider));
|
||||
element.Add(new XAttribute(XName.Get("ConfVersion"), "2.6"));
|
||||
return element;
|
||||
@@ -15,7 +15,7 @@ using mRemoteNG.Tree.Root;
|
||||
|
||||
namespace mRemoteNG.Config.Serializers
|
||||
{
|
||||
public class DataTableDeserializer : IDeserializer<DataTable, ConnectionTreeModel>
|
||||
public class DataTableDeserializer : IDeserializer<DataTable, ConnectionTreeModel>
|
||||
{
|
||||
public ConnectionTreeModel Deserialize(DataTable table)
|
||||
{
|
||||
@@ -46,14 +46,16 @@ namespace mRemoteNG.Config.Serializers
|
||||
|
||||
private ConnectionInfo DeserializeConnectionInfo(DataRow row)
|
||||
{
|
||||
var connectionInfo = new ConnectionInfo();
|
||||
var connectionId = row["ConstantID"] as string ?? Guid.NewGuid().ToString();
|
||||
var connectionInfo = new ConnectionInfo(connectionId);
|
||||
PopulateConnectionInfoFromDatarow(row, connectionInfo);
|
||||
return connectionInfo;
|
||||
}
|
||||
|
||||
private ContainerInfo DeserializeContainerInfo(DataRow row)
|
||||
{
|
||||
var containerInfo = new ContainerInfo();
|
||||
var containerId = row["ConstantID"] as string ?? Guid.NewGuid().ToString();
|
||||
var containerInfo = new ContainerInfo(containerId);
|
||||
PopulateConnectionInfoFromDatarow(row, containerInfo);
|
||||
return containerInfo;
|
||||
}
|
||||
@@ -61,7 +63,6 @@ namespace mRemoteNG.Config.Serializers
|
||||
private void PopulateConnectionInfoFromDatarow(DataRow dataRow, ConnectionInfo connectionInfo)
|
||||
{
|
||||
connectionInfo.Name = (string)dataRow["Name"];
|
||||
connectionInfo.ConstantID = (string)dataRow["ConstantID"];
|
||||
|
||||
// This throws a NPE - Parent is a connectionInfo object which will be null at this point.
|
||||
// The Parent object is linked properly later in CreateNodeHierarchy()
|
||||
@@ -187,7 +188,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
private ConnectionTreeModel CreateNodeHierarchy(List<ConnectionInfo> connectionList, DataTable dataTable)
|
||||
{
|
||||
var connectionTreeModel = new ConnectionTreeModel();
|
||||
var rootNode = new RootNodeInfo(RootNodeType.Connection) {ConstantID = "0"};
|
||||
var rootNode = new RootNodeInfo(RootNodeType.Connection, "0");
|
||||
connectionTreeModel.AddRootNode(rootNode);
|
||||
|
||||
foreach (DataRow row in dataTable.Rows)
|
||||
|
||||
@@ -5,6 +5,7 @@ using mRemoteNG.App;
|
||||
using mRemoteNG.Config.Import;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNG.Tree.Root;
|
||||
|
||||
@@ -14,12 +15,12 @@ namespace mRemoteNG.Config.Serializers
|
||||
public class ActiveDirectoryDeserializer
|
||||
{
|
||||
private readonly string _ldapPath;
|
||||
private readonly bool _importSubOU;
|
||||
private readonly bool _importSubOu;
|
||||
|
||||
public ActiveDirectoryDeserializer(string ldapPath, bool importSubOU)
|
||||
public ActiveDirectoryDeserializer(string ldapPath, bool importSubOu)
|
||||
{
|
||||
_ldapPath = ldapPath;
|
||||
_importSubOU = importSubOU;
|
||||
_ldapPath = ldapPath.ThrowIfNullOrEmpty(nameof(ldapPath));
|
||||
_importSubOu = importSubOu;
|
||||
}
|
||||
|
||||
public ConnectionTreeModel Deserialize()
|
||||
@@ -64,9 +65,10 @@ namespace mRemoteNG.Config.Serializers
|
||||
if (directoryEntry.Properties["objectClass"].Contains("organizationalUnit"))
|
||||
{
|
||||
// check/continue here so we don't create empty connection objects
|
||||
if(!_importSubOU) continue;
|
||||
if(!_importSubOu) continue;
|
||||
|
||||
ActiveDirectoryImporter.Import(ldapResult.Path, parentContainer, _importSubOU);
|
||||
// TODO - this is a circular call. A deserializer should not call an importer
|
||||
ActiveDirectoryImporter.Import(ldapResult.Path, parentContainer, _importSubOu);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,221 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Credential;
|
||||
using mRemoteNG.Security;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNG.Tree.Root;
|
||||
|
||||
namespace mRemoteNG.Config.Serializers
|
||||
{
|
||||
public class CsvConnectionsSerializerMremotengFormat : ISerializer<ConnectionInfo,string>
|
||||
{
|
||||
private string _csv = "";
|
||||
private ConnectionInfo _serializationTarget;
|
||||
private readonly SaveFilter _saveFilter;
|
||||
private readonly ICredentialRepositoryList _credentialRepositoryList;
|
||||
|
||||
|
||||
public CsvConnectionsSerializerMremotengFormat(SaveFilter saveFilter, ICredentialRepositoryList credentialRepositoryList)
|
||||
{
|
||||
if (saveFilter == null)
|
||||
throw new ArgumentNullException(nameof(saveFilter));
|
||||
if (credentialRepositoryList == null)
|
||||
throw new ArgumentNullException(nameof(credentialRepositoryList));
|
||||
|
||||
_saveFilter = saveFilter;
|
||||
_credentialRepositoryList = credentialRepositoryList;
|
||||
}
|
||||
|
||||
public string Serialize(ConnectionTreeModel connectionTreeModel)
|
||||
{
|
||||
if (connectionTreeModel == null)
|
||||
throw new ArgumentNullException(nameof(connectionTreeModel));
|
||||
|
||||
var rootNode = connectionTreeModel.RootNodes.First(node => node is RootNodeInfo);
|
||||
return Serialize(rootNode);
|
||||
}
|
||||
|
||||
public string Serialize(ConnectionInfo serializationTarget)
|
||||
{
|
||||
if (serializationTarget == null)
|
||||
throw new ArgumentNullException(nameof(serializationTarget));
|
||||
|
||||
_csv = "";
|
||||
_serializationTarget = serializationTarget;
|
||||
WriteCsvHeader();
|
||||
SerializeNodesRecursive(serializationTarget);
|
||||
return _csv;
|
||||
}
|
||||
|
||||
private void WriteCsvHeader()
|
||||
{
|
||||
var csvHeader = string.Empty;
|
||||
csvHeader += "Name;Folder;Description;Icon;Panel;";
|
||||
if (_saveFilter.SaveUsername)
|
||||
csvHeader += "Username;";
|
||||
if (_saveFilter.SavePassword)
|
||||
csvHeader += "Password;";
|
||||
if (_saveFilter.SaveDomain)
|
||||
csvHeader += "Domain;";
|
||||
csvHeader += "Hostname;Protocol;PuttySession;Port;ConnectToConsole;UseCredSsp;RenderingEngine;ICAEncryptionStrength;RDPAuthenticationLevel;LoadBalanceInfo;Colors;Resolution;AutomaticResize;DisplayWallpaper;DisplayThemes;EnableFontSmoothing;EnableDesktopComposition;CacheBitmaps;RedirectDiskDrives;RedirectPorts;RedirectPrinters;RedirectSmartCards;RedirectSound;RedirectKeys;PreExtApp;PostExtApp;MacAddress;UserField;ExtApp;VNCCompression;VNCEncoding;VNCAuthMode;VNCProxyType;VNCProxyIP;VNCProxyPort;VNCProxyUsername;VNCProxyPassword;VNCColors;VNCSmartSizeMode;VNCViewOnly;RDGatewayUsageMethod;RDGatewayHostname;RDGatewayUseConnectionCredentials;RDGatewayUsername;RDGatewayPassword;RDGatewayDomain;";
|
||||
if (_saveFilter.SaveInheritance)
|
||||
csvHeader += "InheritCacheBitmaps;InheritColors;InheritDescription;InheritDisplayThemes;InheritDisplayWallpaper;InheritEnableFontSmoothing;InheritEnableDesktopComposition;InheritDomain;InheritIcon;InheritPanel;InheritPassword;InheritPort;InheritProtocol;InheritPuttySession;InheritRedirectDiskDrives;InheritRedirectKeys;InheritRedirectPorts;InheritRedirectPrinters;InheritRedirectSmartCards;InheritRedirectSound;InheritResolution;InheritAutomaticResize;InheritUseConsoleSession;InheritUseCredSsp;InheritRenderingEngine;InheritUsername;InheritICAEncryptionStrength;InheritRDPAuthenticationLevel;InheritLoadBalanceInfo;InheritPreExtApp;InheritPostExtApp;InheritMacAddress;InheritUserField;InheritExtApp;InheritVNCCompression;InheritVNCEncoding;InheritVNCAuthMode;InheritVNCProxyType;InheritVNCProxyIP;InheritVNCProxyPort;InheritVNCProxyUsername;InheritVNCProxyPassword;InheritVNCColors;InheritVNCSmartSizeMode;InheritVNCViewOnly;InheritRDGatewayUsageMethod;InheritRDGatewayHostname;InheritRDGatewayUseConnectionCredentials;InheritRDGatewayUsername;InheritRDGatewayPassword;InheritRDGatewayDomain";
|
||||
_csv += csvHeader;
|
||||
}
|
||||
|
||||
private void SerializeNodesRecursive(ConnectionInfo node)
|
||||
{
|
||||
var nodeAsContainer = node as ContainerInfo;
|
||||
if (nodeAsContainer != null)
|
||||
{
|
||||
foreach (var child in nodeAsContainer.Children)
|
||||
{
|
||||
var info = child as ContainerInfo;
|
||||
if (info != null)
|
||||
SerializeNodesRecursive(info);
|
||||
else
|
||||
SerializeConnectionInfo(child);
|
||||
}
|
||||
}
|
||||
else
|
||||
SerializeConnectionInfo(node);
|
||||
}
|
||||
|
||||
private void SerializeConnectionInfo(ConnectionInfo con)
|
||||
{
|
||||
var csvLine = Environment.NewLine;
|
||||
|
||||
csvLine += con.Name + ";" + GetNodePath(con) + ";" + con.Description + ";" + con.Icon + ";" + con.Panel + ";";
|
||||
|
||||
if (_saveFilter.SaveUsername)
|
||||
csvLine += con.Username + ";";
|
||||
|
||||
if (_saveFilter.SavePassword)
|
||||
csvLine += con.Password + ";";
|
||||
|
||||
if (_saveFilter.SaveDomain)
|
||||
csvLine += con.Domain + ";";
|
||||
|
||||
csvLine += con.Hostname + ";" +
|
||||
con.Protocol + ";" +
|
||||
con.PuttySession + ";" +
|
||||
Convert.ToString(con.Port) + ";" +
|
||||
Convert.ToString(con.UseConsoleSession) + ";" +
|
||||
Convert.ToString(con.UseCredSsp) + ";" +
|
||||
con.RenderingEngine + ";" +
|
||||
con.ICAEncryptionStrength + ";" +
|
||||
con.RDPAuthenticationLevel + ";" +
|
||||
con.LoadBalanceInfo + ";" +
|
||||
con.Colors + ";" +
|
||||
con.Resolution + ";" +
|
||||
Convert.ToString(con.AutomaticResize) + ";" +
|
||||
Convert.ToString(con.DisplayWallpaper) + ";" +
|
||||
Convert.ToString(con.DisplayThemes) + ";" +
|
||||
Convert.ToString(con.EnableFontSmoothing) + ";" +
|
||||
Convert.ToString(con.EnableDesktopComposition) + ";" +
|
||||
Convert.ToString(con.CacheBitmaps) + ";" +
|
||||
Convert.ToString(con.RedirectDiskDrives) + ";" +
|
||||
Convert.ToString(con.RedirectPorts) + ";" +
|
||||
Convert.ToString(con.RedirectPrinters) + ";" +
|
||||
Convert.ToString(con.RedirectSmartCards) + ";" +
|
||||
con.RedirectSound + ";" +
|
||||
Convert.ToString(con.RedirectKeys) + ";" +
|
||||
con.PreExtApp + ";" +
|
||||
con.PostExtApp + ";" +
|
||||
con.MacAddress + ";" +
|
||||
con.UserField + ";" +
|
||||
con.ExtApp + ";" +
|
||||
con.VNCCompression + ";" +
|
||||
con.VNCEncoding + ";" +
|
||||
con.VNCAuthMode + ";" +
|
||||
con.VNCProxyType + ";" +
|
||||
con.VNCProxyIP + ";" +
|
||||
Convert.ToString(con.VNCProxyPort) + ";" +
|
||||
con.VNCProxyUsername + ";" +
|
||||
con.VNCProxyPassword + ";" +
|
||||
con.VNCColors + ";" +
|
||||
con.VNCSmartSizeMode + ";" +
|
||||
Convert.ToString(con.VNCViewOnly) + ";" +
|
||||
con.RDGatewayUsageMethod + ";" +
|
||||
con.RDGatewayHostname + ";" +
|
||||
con.RDGatewayUseConnectionCredentials + ";" +
|
||||
con.RDGatewayUsername + ";" +
|
||||
con.RDGatewayPassword + ";" +
|
||||
con.RDGatewayDomain + ";";
|
||||
|
||||
|
||||
if (_saveFilter.SaveInheritance)
|
||||
{
|
||||
csvLine += con.Inheritance.CacheBitmaps + ";" +
|
||||
con.Inheritance.Colors + ";" +
|
||||
con.Inheritance.Description + ";" +
|
||||
con.Inheritance.DisplayThemes + ";" +
|
||||
con.Inheritance.DisplayWallpaper + ";" +
|
||||
con.Inheritance.EnableFontSmoothing + ";" +
|
||||
con.Inheritance.EnableDesktopComposition + ";" +
|
||||
con.Inheritance.Domain + ";" +
|
||||
con.Inheritance.Icon + ";" +
|
||||
con.Inheritance.Panel + ";" +
|
||||
con.Inheritance.Password + ";" +
|
||||
con.Inheritance.Port + ";" +
|
||||
con.Inheritance.Protocol + ";" +
|
||||
con.Inheritance.PuttySession + ";" +
|
||||
con.Inheritance.RedirectDiskDrives + ";" +
|
||||
con.Inheritance.RedirectKeys + ";" +
|
||||
con.Inheritance.RedirectPorts + ";" +
|
||||
con.Inheritance.RedirectPrinters + ";" +
|
||||
con.Inheritance.RedirectSmartCards + ";" +
|
||||
con.Inheritance.RedirectSound + ";" +
|
||||
con.Inheritance.Resolution + ";" +
|
||||
con.Inheritance.AutomaticResize + ";" +
|
||||
con.Inheritance.UseConsoleSession + ";" +
|
||||
con.Inheritance.UseCredSsp + ";" +
|
||||
con.Inheritance.RenderingEngine + ";" +
|
||||
con.Inheritance.Username + ";" +
|
||||
con.Inheritance.ICAEncryptionStrength + ";" +
|
||||
con.Inheritance.RDPAuthenticationLevel + ";" +
|
||||
con.Inheritance.LoadBalanceInfo + ";" +
|
||||
con.Inheritance.PreExtApp + ";" +
|
||||
con.Inheritance.PostExtApp + ";" +
|
||||
con.Inheritance.MacAddress + ";" +
|
||||
con.Inheritance.UserField + ";" +
|
||||
con.Inheritance.ExtApp + ";" +
|
||||
con.Inheritance.VNCCompression + ";" +
|
||||
con.Inheritance.VNCEncoding + ";" +
|
||||
con.Inheritance.VNCAuthMode + ";" +
|
||||
con.Inheritance.VNCProxyType + ";" +
|
||||
con.Inheritance.VNCProxyIP + ";" +
|
||||
con.Inheritance.VNCProxyPort + ";" +
|
||||
con.Inheritance.VNCProxyUsername + ";" +
|
||||
con.Inheritance.VNCProxyPassword + ";" +
|
||||
con.Inheritance.VNCColors + ";" +
|
||||
con.Inheritance.VNCSmartSizeMode + ";" +
|
||||
con.Inheritance.VNCViewOnly +
|
||||
con.Inheritance.RDGatewayUsageMethod + ";" +
|
||||
con.Inheritance.RDGatewayHostname + ";" +
|
||||
con.Inheritance.RDGatewayUseConnectionCredentials + ";" +
|
||||
con.Inheritance.RDGatewayUsername + ";" +
|
||||
con.Inheritance.RDGatewayPassword + ";" +
|
||||
con.Inheritance.RDGatewayDomain + ";";
|
||||
}
|
||||
|
||||
_csv += csvLine;
|
||||
}
|
||||
|
||||
private string GetNodePath(ConnectionInfo connectionInfo)
|
||||
{
|
||||
var nodePath = "";
|
||||
var container = connectionInfo.Parent;
|
||||
if (container == null) return nodePath;
|
||||
while (container != _serializationTarget)
|
||||
{
|
||||
container = container.Parent;
|
||||
nodePath += $@"{container.Name}\";
|
||||
}
|
||||
nodePath = nodePath.TrimEnd('\\');
|
||||
return nodePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
@@ -7,8 +9,6 @@ using mRemoteNG.Connection.Protocol.RDP;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNG.Tree.Root;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
|
||||
namespace mRemoteNG.Config.Serializers
|
||||
@@ -60,7 +60,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
}
|
||||
else
|
||||
{
|
||||
var versionNode = rdcManNode.SelectSingleNode("./version")?.InnerText;
|
||||
var versionNode = rdcManNode?.SelectSingleNode("./version")?.InnerText;
|
||||
if (versionNode != null)
|
||||
{
|
||||
var version = new Version(versionNode);
|
||||
@@ -101,15 +101,16 @@ namespace mRemoteNG.Config.Serializers
|
||||
{
|
||||
if (_schemaVersion == 1)
|
||||
{
|
||||
// Program Verison 2.2 wraps all setting inside the Properties tags
|
||||
// Program Version 2.2 wraps all setting inside the Properties tags
|
||||
containerPropertiesNode = containerPropertiesNode.SelectSingleNode("./properties");
|
||||
}
|
||||
var newContainer = new ContainerInfo();
|
||||
var connectionInfo = ConnectionInfoFromXml(containerPropertiesNode);
|
||||
newContainer.CopyFrom(connectionInfo);
|
||||
|
||||
if (_schemaVersion == 3)
|
||||
{
|
||||
// Program Verison 2.7 wraps these properties
|
||||
// Program Version 2.7 wraps these properties
|
||||
containerPropertiesNode = containerPropertiesNode.SelectSingleNode("./properties");
|
||||
}
|
||||
newContainer.Name = containerPropertiesNode?.SelectSingleNode("./name")?.InnerText ?? Language.strNewFolder;
|
||||
@@ -130,20 +131,22 @@ namespace mRemoteNG.Config.Serializers
|
||||
|
||||
|
||||
var propertiesNode = xmlNode.SelectSingleNode("./properties");
|
||||
if (_schemaVersion == 1) propertiesNode = xmlNode; // Version 2.2 defines the container name at the root instead
|
||||
connectionInfo.Hostname = propertiesNode.SelectSingleNode("./name")?.InnerText;
|
||||
connectionInfo.Name = propertiesNode.SelectSingleNode("./displayName")?.InnerText ?? connectionInfo.Hostname;
|
||||
connectionInfo.Description = propertiesNode.SelectSingleNode("./comment")?.InnerText ?? String.Empty;
|
||||
if (_schemaVersion == 1) propertiesNode = xmlNode; // Version 2.2 defines the container name at the root instead
|
||||
connectionInfo.Hostname = propertiesNode?.SelectSingleNode("./name")?.InnerText ?? "";
|
||||
connectionInfo.Name = propertiesNode?.SelectSingleNode("./displayName")?.InnerText ?? connectionInfo.Hostname;
|
||||
connectionInfo.Description = propertiesNode?.SelectSingleNode("./comment")?.InnerText ?? string.Empty;
|
||||
|
||||
var logonCredentialsNode = xmlNode.SelectSingleNode("./logonCredentials");
|
||||
if (logonCredentialsNode?.Attributes?["inherit"].Value == "None")
|
||||
if (logonCredentialsNode?.Attributes?["inherit"]?.Value == "None")
|
||||
{
|
||||
connectionInfo.Username = logonCredentialsNode.SelectSingleNode("userName")?.InnerText;
|
||||
|
||||
var passwordNode = logonCredentialsNode.SelectSingleNode("./password");
|
||||
if (_schemaVersion == 1) // Version 2.2 allows clear text passwords
|
||||
{
|
||||
connectionInfo.Password = passwordNode?.Attributes?["storeAsClearText"].Value == "True" ? passwordNode.InnerText : DecryptRdcManPassword(passwordNode?.InnerText);
|
||||
connectionInfo.Password = passwordNode?.Attributes?["storeAsClearText"]?.Value == "True"
|
||||
? passwordNode.InnerText
|
||||
: DecryptRdcManPassword(passwordNode?.InnerText);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -160,7 +163,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
}
|
||||
|
||||
var connectionSettingsNode = xmlNode.SelectSingleNode("./connectionSettings");
|
||||
if (connectionSettingsNode?.Attributes?["inherit"].Value == "None")
|
||||
if (connectionSettingsNode?.Attributes?["inherit"]?.Value == "None")
|
||||
{
|
||||
connectionInfo.UseConsoleSession = bool.Parse(connectionSettingsNode.SelectSingleNode("./connectToConsole")?.InnerText ?? "false");
|
||||
// ./startProgram
|
||||
@@ -174,7 +177,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
}
|
||||
|
||||
var gatewaySettingsNode = xmlNode.SelectSingleNode("./gatewaySettings");
|
||||
if (gatewaySettingsNode?.Attributes?["inherit"].Value == "None")
|
||||
if (gatewaySettingsNode?.Attributes?["inherit"]?.Value == "None")
|
||||
{
|
||||
connectionInfo.RDGatewayUsageMethod = gatewaySettingsNode.SelectSingleNode("./enabled")?.InnerText == "True" ? RdpProtocol.RDGatewayUsageMethod.Always : RdpProtocol.RDGatewayUsageMethod.Never;
|
||||
connectionInfo.RDGatewayHostname = gatewaySettingsNode.SelectSingleNode("./hostName")?.InnerText;
|
||||
@@ -198,7 +201,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
}
|
||||
|
||||
var remoteDesktopNode = xmlNode.SelectSingleNode("./remoteDesktop");
|
||||
if (remoteDesktopNode?.Attributes?["inherit"].Value == "None")
|
||||
if (remoteDesktopNode?.Attributes?["inherit"]?.Value == "None")
|
||||
{
|
||||
var resolutionString = remoteDesktopNode.SelectSingleNode("./size")?.InnerText.Replace(" ", "");
|
||||
try
|
||||
@@ -231,7 +234,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
}
|
||||
|
||||
var localResourcesNode = xmlNode.SelectSingleNode("./localResources");
|
||||
if (localResourcesNode?.Attributes?["inherit"].Value == "None")
|
||||
if (localResourcesNode?.Attributes?["inherit"]?.Value == "None")
|
||||
{
|
||||
// ReSharper disable once SwitchStatementMissingSomeCases
|
||||
switch (localResourcesNode.SelectSingleNode("./audioRedirection")?.InnerText)
|
||||
@@ -271,10 +274,10 @@ namespace mRemoteNG.Config.Serializers
|
||||
}
|
||||
|
||||
// ./redirectClipboard
|
||||
connectionInfo.RedirectDiskDrives = bool.Parse(localResourcesNode.SelectSingleNode("./redirectDrives")?.InnerText ?? "false");
|
||||
connectionInfo.RedirectPorts = bool.Parse(localResourcesNode.SelectSingleNode("./redirectPorts")?.InnerText ?? "false");
|
||||
connectionInfo.RedirectPrinters = bool.Parse(localResourcesNode.SelectSingleNode("./redirectPrinters")?.InnerText ?? "false");
|
||||
connectionInfo.RedirectSmartCards = bool.Parse(localResourcesNode.SelectSingleNode("./redirectSmartCards")?.InnerText ?? "false");
|
||||
connectionInfo.RedirectDiskDrives = bool.Parse(localResourcesNode?.SelectSingleNode("./redirectDrives")?.InnerText ?? "false");
|
||||
connectionInfo.RedirectPorts = bool.Parse(localResourcesNode?.SelectSingleNode("./redirectPorts")?.InnerText ?? "false");
|
||||
connectionInfo.RedirectPrinters = bool.Parse(localResourcesNode?.SelectSingleNode("./redirectPrinters")?.InnerText ?? "false");
|
||||
connectionInfo.RedirectSmartCards = bool.Parse(localResourcesNode?.SelectSingleNode("./redirectSmartCards")?.InnerText ?? "false");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -287,7 +290,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
}
|
||||
|
||||
var securitySettingsNode = xmlNode.SelectSingleNode("./securitySettings");
|
||||
if (securitySettingsNode?.Attributes?["inherit"].Value == "None")
|
||||
if (securitySettingsNode?.Attributes?["inherit"]?.Value == "None")
|
||||
{
|
||||
// ReSharper disable once SwitchStatementMissingSomeCases
|
||||
switch (securitySettingsNode.SelectSingleNode("./authentication")?.InnerText)
|
||||
@@ -321,7 +324,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
private static string DecryptRdcManPassword(string ciphertext)
|
||||
{
|
||||
if (string.IsNullOrEmpty(ciphertext))
|
||||
return null;
|
||||
return string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -332,7 +335,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
catch (Exception /*ex*/)
|
||||
{
|
||||
//Runtime.MessageCollector.AddExceptionMessage("RemoteDesktopConnectionManager.DecryptPassword() failed.", ex, logOnly: true);
|
||||
return null;
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using mRemoteNG.Security;
|
||||
using mRemoteNG.Security.Authentication;
|
||||
using mRemoteNG.Security.Factories;
|
||||
using mRemoteNG.Security.SymmetricEncryption;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.Tree.Root;
|
||||
|
||||
namespace mRemoteNG.Config.Serializers
|
||||
@@ -13,7 +14,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
private readonly ICryptographyProvider _cryptographyProvider;
|
||||
private readonly RootNodeInfo _rootNodeInfo;
|
||||
|
||||
public Func<SecureString> AuthenticationRequestor { get; set; }
|
||||
public Func<Optional<SecureString>> AuthenticationRequestor { get; set; }
|
||||
|
||||
public int KeyDerivationIterations
|
||||
{
|
||||
@@ -91,16 +92,14 @@ namespace mRemoteNG.Config.Serializers
|
||||
|
||||
private bool Authenticate(string cipherText, SecureString password)
|
||||
{
|
||||
var authenticator = new PasswordAuthenticator(_cryptographyProvider, cipherText)
|
||||
{
|
||||
AuthenticationRequestor = AuthenticationRequestor
|
||||
};
|
||||
|
||||
var authenticator = new PasswordAuthenticator(_cryptographyProvider, cipherText, AuthenticationRequestor);
|
||||
var authenticated = authenticator.Authenticate(password);
|
||||
|
||||
if (!authenticated) return authenticated;
|
||||
if (!authenticated)
|
||||
return false;
|
||||
|
||||
_rootNodeInfo.PasswordString = authenticator.LastAuthenticatedPassword.ConvertToUnsecureString();
|
||||
return authenticated;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using System.Configuration;
|
||||
#if !PORTABLE
|
||||
using System.Configuration;
|
||||
#endif
|
||||
|
||||
namespace mRemoteNG.Config.Settings.Providers
|
||||
{
|
||||
|
||||
@@ -1,37 +1,37 @@
|
||||
/// The MIT License (MIT)
|
||||
///
|
||||
/// Copyright(c) crdx
|
||||
///
|
||||
/// Permission 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:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be
|
||||
/// included in all copies or substantial portions of the Software.
|
||||
///
|
||||
/// THE 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.
|
||||
///
|
||||
/// https://raw.githubusercontent.com/crdx/PortableSettingsProvider
|
||||
///
|
||||
using System.Linq;
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright(c) crdx
|
||||
//
|
||||
// Permission 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:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE 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.
|
||||
//
|
||||
// https://raw.githubusercontent.com/crdx/PortableSettingsProvider
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Windows.Forms;
|
||||
using System.Collections.Specialized;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
//using mRemoteNG.App;
|
||||
|
||||
namespace mRemoteNG.Config.Settings.Providers
|
||||
{
|
||||
@@ -43,63 +43,34 @@ namespace mRemoteNG.Config.Settings.Providers
|
||||
private const string _className = "PortableSettingsProvider";
|
||||
private XmlDocument _xmlDocument;
|
||||
|
||||
private string _filePath
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path.Combine(Path.GetDirectoryName(Application.ExecutablePath),
|
||||
string.Format("{0}.settings", ApplicationName));
|
||||
}
|
||||
}
|
||||
private string _filePath => Path.Combine(Path.GetDirectoryName(Application.ExecutablePath) ?? throw new InvalidOperationException(), $"{ApplicationName}.settings");
|
||||
|
||||
private XmlNode _localSettingsNode
|
||||
{
|
||||
get
|
||||
{
|
||||
XmlNode settingsNode = GetSettingsNode(_localSettingsNodeName);
|
||||
XmlNode machineNode = settingsNode.SelectSingleNode(Environment.MachineName.ToLowerInvariant());
|
||||
private XmlNode _localSettingsNode => GetSettingsNode(_localSettingsNodeName);
|
||||
|
||||
if (machineNode == null)
|
||||
{
|
||||
machineNode = _rootDocument.CreateElement(Environment.MachineName.ToLowerInvariant());
|
||||
settingsNode.AppendChild(machineNode);
|
||||
}
|
||||
private XmlNode _globalSettingsNode => GetSettingsNode(_globalSettingsNodeName);
|
||||
|
||||
return machineNode;
|
||||
}
|
||||
}
|
||||
|
||||
private XmlNode _globalSettingsNode
|
||||
{
|
||||
get { return GetSettingsNode(_globalSettingsNodeName); }
|
||||
}
|
||||
|
||||
private XmlNode _rootNode
|
||||
{
|
||||
get { return _rootDocument.SelectSingleNode(_rootNodeName); }
|
||||
}
|
||||
private XmlNode _rootNode => _rootDocument.SelectSingleNode(_rootNodeName);
|
||||
|
||||
private XmlDocument _rootDocument
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_xmlDocument == null)
|
||||
if (_xmlDocument != null) return _xmlDocument;
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
_xmlDocument = new XmlDocument();
|
||||
_xmlDocument.Load(_filePath);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if (_xmlDocument.SelectSingleNode(_rootNodeName) != null)
|
||||
return _xmlDocument;
|
||||
|
||||
_xmlDocument = GetBlankXmlDocument();
|
||||
_xmlDocument = new XmlDocument();
|
||||
_xmlDocument.Load(_filePath);
|
||||
}
|
||||
catch (Exception /*ex*/)
|
||||
{
|
||||
// This casues hundreds of unit tests to fail for some reason...
|
||||
//Runtime.MessageCollector.AddExceptionStackTrace("PortableSettingsProvider: Error getting XML", ex);
|
||||
}
|
||||
|
||||
if (_xmlDocument?.SelectSingleNode(_rootNodeName) != null)
|
||||
return _xmlDocument;
|
||||
|
||||
_xmlDocument = GetBlankXmlDocument();
|
||||
|
||||
return _xmlDocument;
|
||||
}
|
||||
@@ -107,14 +78,11 @@ namespace mRemoteNG.Config.Settings.Providers
|
||||
|
||||
public override string ApplicationName
|
||||
{
|
||||
get { return Path.GetFileNameWithoutExtension(Application.ExecutablePath); }
|
||||
get => Path.GetFileNameWithoutExtension(Application.ExecutablePath);
|
||||
set { }
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get { return _className; }
|
||||
}
|
||||
public override string Name => _className;
|
||||
|
||||
public override void Initialize(string name, NameValueCollection config)
|
||||
{
|
||||
@@ -143,7 +111,7 @@ namespace mRemoteNG.Config.Settings.Providers
|
||||
|
||||
public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext context, SettingsPropertyCollection collection)
|
||||
{
|
||||
SettingsPropertyValueCollection values = new SettingsPropertyValueCollection();
|
||||
var values = new SettingsPropertyValueCollection();
|
||||
|
||||
foreach (SettingsProperty property in collection)
|
||||
{
|
||||
@@ -158,11 +126,9 @@ namespace mRemoteNG.Config.Settings.Providers
|
||||
|
||||
private void SetValue(SettingsPropertyValue propertyValue)
|
||||
{
|
||||
XmlNode targetNode = IsGlobal(propertyValue.Property)
|
||||
? _globalSettingsNode
|
||||
: _localSettingsNode;
|
||||
var targetNode = IsGlobal(propertyValue.Property) ? _globalSettingsNode : _localSettingsNode;
|
||||
|
||||
XmlNode settingNode = targetNode.SelectSingleNode(string.Format("setting[@name='{0}']", propertyValue.Name));
|
||||
var settingNode = targetNode.SelectSingleNode($"setting[@name='{propertyValue.Name}']");
|
||||
|
||||
if (settingNode != null)
|
||||
settingNode.InnerText = propertyValue.SerializedValue.ToString();
|
||||
@@ -170,10 +136,10 @@ namespace mRemoteNG.Config.Settings.Providers
|
||||
{
|
||||
settingNode = _rootDocument.CreateElement("setting");
|
||||
|
||||
XmlAttribute nameAttribute = _rootDocument.CreateAttribute("name");
|
||||
var nameAttribute = _rootDocument.CreateAttribute("name");
|
||||
nameAttribute.Value = propertyValue.Name;
|
||||
|
||||
settingNode.Attributes.Append(nameAttribute);
|
||||
settingNode.Attributes?.Append(nameAttribute);
|
||||
settingNode.InnerText = propertyValue.SerializedValue.ToString();
|
||||
|
||||
targetNode.AppendChild(settingNode);
|
||||
@@ -182,8 +148,8 @@ namespace mRemoteNG.Config.Settings.Providers
|
||||
|
||||
private string GetValue(SettingsProperty property)
|
||||
{
|
||||
XmlNode targetNode = IsGlobal(property) ? _globalSettingsNode : _localSettingsNode;
|
||||
XmlNode settingNode = targetNode.SelectSingleNode(string.Format("setting[@name='{0}']", property.Name));
|
||||
var targetNode = IsGlobal(property) ? _globalSettingsNode : _localSettingsNode;
|
||||
var settingNode = targetNode.SelectSingleNode($"setting[@name='{property.Name}']");
|
||||
|
||||
if (settingNode == null)
|
||||
return property.DefaultValue != null ? property.DefaultValue.ToString() : string.Empty;
|
||||
@@ -191,7 +157,7 @@ namespace mRemoteNG.Config.Settings.Providers
|
||||
return settingNode.InnerText;
|
||||
}
|
||||
|
||||
private bool IsGlobal(SettingsProperty property)
|
||||
private static bool IsGlobal(SettingsProperty property)
|
||||
{
|
||||
foreach (DictionaryEntry attribute in property.Attributes)
|
||||
{
|
||||
@@ -204,20 +170,18 @@ namespace mRemoteNG.Config.Settings.Providers
|
||||
|
||||
private XmlNode GetSettingsNode(string name)
|
||||
{
|
||||
XmlNode settingsNode = _rootNode.SelectSingleNode(name);
|
||||
var settingsNode = _rootNode.SelectSingleNode(name);
|
||||
|
||||
if (settingsNode == null)
|
||||
{
|
||||
settingsNode = _rootDocument.CreateElement(name);
|
||||
_rootNode.AppendChild(settingsNode);
|
||||
}
|
||||
if (settingsNode != null) return settingsNode;
|
||||
settingsNode = _rootDocument.CreateElement(name);
|
||||
_rootNode.AppendChild(settingsNode);
|
||||
|
||||
return settingsNode;
|
||||
}
|
||||
|
||||
public XmlDocument GetBlankXmlDocument()
|
||||
private static XmlDocument GetBlankXmlDocument()
|
||||
{
|
||||
XmlDocument blankXmlDocument = new XmlDocument();
|
||||
var blankXmlDocument = new XmlDocument();
|
||||
blankXmlDocument.AppendChild(blankXmlDocument.CreateXmlDeclaration("1.0", "utf-8", string.Empty));
|
||||
blankXmlDocument.AppendChild(blankXmlDocument.CreateElement(_rootNodeName));
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user