git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube...
authorVásáry Dániel <daniel.vasary@userrendszerhaz.hu>
Tue, 17 Oct 2017 15:58:50 +0000 (15:58 +0000)
committerVásáry Dániel <daniel.vasary@userrendszerhaz.hu>
Tue, 17 Oct 2017 15:58:50 +0000 (15:58 +0000)
22 files changed:
client/IntegrationTests/IntegrationTests.csproj
client/IntegrationTests/MaestroIT.cs
client/IntegrationTests/UNCAccessWithCredentials.cs [new file with mode: 0644]
client/Maestro/Configuration/ConfigurationInfo.cs
client/Maestro/Configuration/KeysJsonConverter.cs
client/Maestro/Configuration/configuration-editor.json
client/Maestro/Configuration/configuration-nle.json
client/Maestro/Configuration/configuration-playout.json
client/Maestro/Configuration/configuration-studio.json
client/Maestro/Configuration/configuration-sxs.json
client/Maestro/Maestro.csproj
client/Maestro/MaestroForm.Target.cs
client/Maestro/MeastroFormNotifyIcon.cs
client/Maestro/Metadata/ArchiveMetadata.cs
client/Maestro/Program.cs
client/Maestro/Targets/FXPTargetProcessor.cs
client/MediaCube.sln
client/PasswordEncrypter/App.config [new file with mode: 0644]
client/PasswordEncrypter/PasswordEncrypter.csproj [new file with mode: 0644]
client/PasswordEncrypter/Program.cs [new file with mode: 0644]
client/PasswordEncrypter/Properties/AssemblyInfo.cs [new file with mode: 0644]
client/PasswordEncrypter/StringCipher.cs [new file with mode: 0644]

index de381e8a793e7046d3e1f1c6ae1779dc49dca7cf..d507334acdc8d8aca998d6acbfe57f5d881ee060 100644 (file)
     <Compile Include="TimecodeTests.cs" />\r
     <Compile Include="Db2JsonIT.cs" />\r
     <Compile Include="Properties\AssemblyInfo.cs" />\r
+    <Compile Include="UNCAccessWithCredentials.cs" />\r
   </ItemGroup>\r
   <ItemGroup>\r
     <None Include="App.config" />\r
index e669ea94b31746c2974914fca0b9cff5870d39fd..35ee458ee00d9cc1ee2c7b690db391d43359946a 100644 (file)
@@ -11,8 +11,8 @@ using System.Runtime.InteropServices;
 using Microsoft.Win32.SafeHandles;\r
 using System.Runtime.ConstrainedExecution;\r
 using System.Security;\r
-using System.Security.Permissions;\r
-using System.Security.Principal;\r
+using BethesdaConsentFormWCFSvc;\r
+using System.IO;\r
 \r
 namespace IntegrationTests {\r
     public sealed class SafeTokenHandle : SafeHandleZeroOrMinusOneIsInvalid {\r
@@ -97,68 +97,80 @@ namespace IntegrationTests {
             Debug.WriteLine(result);\r
         }\r
 \r
-        [DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode)]\r
-        public static extern bool LogonUser(String lpszUsername, String lpszDomain, String lpszPassword,\r
-                int dwLogonType, int dwLogonProvider, out SafeTokenHandle phToken);\r
+        /*******************************/\r
+        [DllImport("Mpr.dll", EntryPoint = "WNetAddConnection2", CallingConvention = CallingConvention.Winapi)]\r
+        private static extern int WNetAddConnection2(NETRESOURCE lpNetResource, string lpPassword,\r
+                                             string lpUsername, System.UInt32 dwFlags);\r
+\r
+        [StructLayout(LayoutKind.Sequential)]\r
+        private class NETRESOURCE {\r
+            public ResourceScope dwScope = 0;\r
+            public ResourceType dwType = 0;\r
+            public ResourceDisplayType dwDisplayType = 0;\r
+            public ResourceUsage dwUsage = 0;\r
+            public string lpLocalName = null;\r
+            public string lpRemoteName = null;\r
+            public string lpComment = null;\r
+            public string lpProvider = null;\r
+        };\r
+\r
+        public enum ResourceScope {\r
+            RESOURCE_CONNECTED = 1,\r
+            RESOURCE_GLOBALNET,\r
+            RESOURCE_REMEMBERED,\r
+            RESOURCE_RECENT,\r
+            RESOURCE_CONTEXT\r
+        };\r
+\r
+        public enum ResourceType {\r
+            RESOURCETYPE_ANY,\r
+            RESOURCETYPE_DISK,\r
+            RESOURCETYPE_PRINT,\r
+            RESOURCETYPE_RESERVED\r
+        };\r
+\r
+        public enum ResourceUsage {\r
+            RESOURCEUSAGE_CONNECTABLE = 0x00000001,\r
+            RESOURCEUSAGE_CONTAINER = 0x00000002,\r
+            RESOURCEUSAGE_NOLOCALDEVICE = 0x00000004,\r
+            RESOURCEUSAGE_SIBLING = 0x00000008,\r
+            RESOURCEUSAGE_ATTACHED = 0x00000010,\r
+            RESOURCEUSAGE_ALL = (RESOURCEUSAGE_CONNECTABLE | RESOURCEUSAGE_CONTAINER | RESOURCEUSAGE_ATTACHED),\r
+        };\r
+\r
+        public enum ResourceDisplayType {\r
+            RESOURCEDISPLAYTYPE_GENERIC,\r
+            RESOURCEDISPLAYTYPE_DOMAIN,\r
+            RESOURCEDISPLAYTYPE_SERVER,\r
+            RESOURCEDISPLAYTYPE_SHARE,\r
+            RESOURCEDISPLAYTYPE_FILE,\r
+            RESOURCEDISPLAYTYPE_GROUP,\r
+            RESOURCEDISPLAYTYPE_NETWORK,\r
+            RESOURCEDISPLAYTYPE_ROOT,\r
+            RESOURCEDISPLAYTYPE_SHAREADMIN,\r
+            RESOURCEDISPLAYTYPE_DIRECTORY,\r
+            RESOURCEDISPLAYTYPE_TREE,\r
+            RESOURCEDISPLAYTYPE_NDSCONTAINER\r
+        };\r
 \r
-        [DllImport("kernel32.dll", CharSet = CharSet.Auto)]\r
-        public extern static bool CloseHandle(IntPtr handle);\r
 \r
-\r
-\r
-        [PermissionSetAttribute(SecurityAction.Demand, Name = "FullTrust")]\r
         [TestMethod]\r
-        public void TestImpersonate() {\r
-            SafeTokenHandle safeTokenHandle;\r
-            try {\r
-                string userName, domainName, password;\r
-                // Get the user token for the specified user, domain, and password using the\r
-                // unmanaged LogonUser method.\r
-                // The local machine name can be used for the domain name to impersonate a user on this machine.\r
-                domainName = ".";\r
-                userName = "mediacube";\r
-                password = "Broadca5T";\r
-                const int LOGON32_PROVIDER_DEFAULT = 0;\r
-                //This parameter causes LogonUser to create a primary token.\r
-                const int LOGON32_LOGON_INTERACTIVE = 2;\r
-\r
-                // Call LogonUser to obtain a handle to an access token.\r
-                bool returnValue = LogonUser(userName, domainName, password,\r
-                    LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT,\r
-                    out safeTokenHandle);\r
-\r
-                Console.WriteLine("LogonUser called.");\r
-\r
-                if (false == returnValue) {\r
-                    int ret = Marshal.GetLastWin32Error();\r
-                    Console.WriteLine("LogonUser failed with error code : {0}", ret);\r
-                    throw new System.ComponentModel.Win32Exception(ret);\r
-                }\r
-                using (safeTokenHandle) {\r
-                    Console.WriteLine("Did LogonUser Succeed? " + (returnValue ? "Yes" : "No"));\r
-                    Console.WriteLine("Value of Windows NT token: " + safeTokenHandle);\r
-\r
-                    // Check the identity.\r
-                    Console.WriteLine("Before impersonation: "\r
-                        + WindowsIdentity.GetCurrent().Name);\r
-                    // Use the token handle returned by LogonUser.\r
-                    using (WindowsIdentity newId = new WindowsIdentity(safeTokenHandle.DangerousGetHandle())) {\r
-                        using (WindowsImpersonationContext impersonatedUser = newId.Impersonate()) {\r
-\r
-                            // Check the identity.\r
-                            Console.WriteLine("After impersonation: "\r
-                                + WindowsIdentity.GetCurrent().Name);\r
-                        }\r
-                    }\r
-                    // Releasing the context object stops the impersonation\r
-                    // Check the identity.\r
-                    Console.WriteLine("After closing the context: " + WindowsIdentity.GetCurrent().Name);\r
-                }\r
-            }\r
-            catch (Exception ex) {\r
-                Console.WriteLine("Exception occurred. " + ex.Message);\r
-            }\r
-\r
+        public void TestUNC() {\r
+            //using (UNCAccessWithCredentials unc = new UNCAccessWithCredentials()) {\r
+            //    if (unc.NetUseWithCredentials("\\\\10.10.1.100\\BRAAVOS", "mediacube", null, "Broadca5T")) {\r
+            //        string[] files = Directory.GetFiles("\\\\10.10.1.100\\BRAAVOS\\Archive"); \r
+\r
+            //    }\r
+            //}\r
+\r
+            NETRESOURCE nr = new NETRESOURCE();\r
+            nr.dwType = ResourceType.RESOURCETYPE_DISK;\r
+            nr.lpLocalName = null;\r
+            nr.lpRemoteName = "\\\\10.10.1.100\\BRAAVOS";\r
+            nr.lpProvider = null;\r
+\r
+            int result = WNetAddConnection2(nr, "Broadca5T", "mediacube", 0);\r
+            string[] files = Directory.GetFiles("\\\\10.10.1.100\\BRAAVOS\\Archive");\r
         }\r
 \r
 \r
diff --git a/client/IntegrationTests/UNCAccessWithCredentials.cs b/client/IntegrationTests/UNCAccessWithCredentials.cs
new file mode 100644 (file)
index 0000000..6d8d050
--- /dev/null
@@ -0,0 +1,119 @@
+using System;\r
+using System.Runtime.InteropServices;\r
+\r
+namespace BethesdaConsentFormWCFSvc {\r
+    public class UNCAccessWithCredentials : IDisposable {\r
+        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]\r
+        internal struct USE_INFO_2 {\r
+            internal String ui2_local;\r
+            internal String ui2_remote;\r
+            internal String ui2_password;\r
+            internal UInt32 ui2_status;\r
+            internal UInt32 ui2_asg_type;\r
+            internal UInt32 ui2_refcount;\r
+            internal UInt32 ui2_usecount;\r
+            internal String ui2_username;\r
+            internal String ui2_domainname;\r
+        }\r
+\r
+        [DllImport("NetApi32.dll", SetLastError = true, CharSet = CharSet.Unicode)]\r
+        internal static extern UInt32 NetUseAdd(\r
+            String UncServerName,\r
+            UInt32 Level,\r
+            ref USE_INFO_2 Buf,\r
+            out UInt32 ParmError);\r
+\r
+        [DllImport("NetApi32.dll", SetLastError = true, CharSet = CharSet.Unicode)]\r
+        internal static extern UInt32 NetUseDel(\r
+            String UncServerName,\r
+            String UseName,\r
+            UInt32 ForceCond);\r
+\r
+        private bool _disposed = false;\r
+\r
+        private string _sUncPath;\r
+        private string _sUser;\r
+        private string _sPassword;\r
+        private string _sDomain;\r
+        private int _iLastError;\r
+\r
+        /// <summary>\r
+        /// A disposeable class that allows access to a UNC resource with credentials.\r
+        /// </summary>\r
+        public UNCAccessWithCredentials() {\r
+        }\r
+\r
+        /// <summary>\r
+        /// The last system error code returned from NetUseAdd or NetUseDel.  Success = 0\r
+        /// </summary>\r
+        public int LastError {\r
+            get { return _iLastError; }\r
+        }\r
+\r
+        public void Dispose() {\r
+            if (!_disposed) {\r
+                NetUseDelete();\r
+            }\r
+            _disposed = true;\r
+            GC.SuppressFinalize(this);\r
+        }\r
+\r
+        /// <summary>\r
+        /// Connects to a UNC path using the credentials supplied.\r
+        /// </summary>\r
+        /// <param name="uncPath">Fully qualified domain name UNC path</param>\r
+        /// <param name="user">A user with sufficient rights to access the path.</param>\r
+        /// <param name="domain">Domain of User.</param>\r
+        /// <param name="password">Password of User</param>\r
+        /// <returns>True if mapping succeeds.  Use LastError to get the system error code.</returns>\r
+        public bool NetUseWithCredentials(string uncPath, string user, string domain, string password) {\r
+            _sUncPath = uncPath;\r
+            _sUser = user;\r
+            _sPassword = password;\r
+            _sDomain = domain;\r
+            return NetUseWithCredentials();\r
+        }\r
+\r
+        private bool NetUseWithCredentials() {\r
+            try {\r
+                var useinfo = new USE_INFO_2 {\r
+                    ui2_remote = _sUncPath,\r
+                    ui2_username = _sUser,\r
+                    ui2_domainname = _sDomain,\r
+                    ui2_password = _sPassword,\r
+                    ui2_asg_type = 0,\r
+                    ui2_usecount = 1\r
+                };\r
+\r
+                uint paramErrorIndex;\r
+                uint returncode = NetUseAdd(null, 2, ref useinfo, out paramErrorIndex);\r
+                _iLastError = (int)returncode;\r
+                return returncode == 0;\r
+            }\r
+            catch {\r
+                _iLastError = Marshal.GetLastWin32Error();\r
+                return false;\r
+            }\r
+        }\r
+\r
+        /// <summary>\r
+        /// Ends the connection to the remote resource\r
+        /// </summary>\r
+        /// <returns>True if it succeeds.  Use LastError to get the system error code</returns>\r
+        public bool NetUseDelete() {\r
+            try {\r
+                uint returncode = NetUseDel(null, _sUncPath, 2);\r
+                _iLastError = (int)returncode;\r
+                return (returncode == 0);\r
+            }\r
+            catch {\r
+                _iLastError = Marshal.GetLastWin32Error();\r
+                return false;\r
+            }\r
+        }\r
+\r
+        ~UNCAccessWithCredentials() {\r
+            Dispose();\r
+        }\r
+    }\r
+}\r
index bc2dc1a83bc5a02740d68f496642bb7be5dcf0a3..b09fc8a32db886b3b98d6e53270c1a50ffabdb63 100644 (file)
@@ -64,6 +64,7 @@ namespace Maestro.Configuration {
         //[JsonConverter(typeof(KeysJsonConverter))]\r
         public Uri Address { get; set; }\r
         public string UserName { get; set; }\r
+        [JsonConverter(typeof(KeysJsonConverter))]\r
         public string Password { get; set; }\r
         public int Timeout { get; set; }\r
     }\r
index c65c2bd8c28db6c60267f11ce197d603704ae1e0..e24d68724d52709c2b08964acb5f65c1eba9c015 100644 (file)
@@ -1,4 +1,5 @@
 using Newtonsoft.Json;\r
+using PasswordEncrypter;\r
 using System;\r
 \r
 namespace Maestro.Configuration {\r
@@ -7,7 +8,8 @@ namespace Maestro.Configuration {
         }\r
 \r
         public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) {\r
-            return new Uri(serializer.Deserialize(reader, objectType)?.ToString());\r
+            string result = serializer.Deserialize(reader, objectType)?.ToString();\r
+            return StringCipher.Decrypt(result);\r
         }\r
 \r
         public override bool CanConvert(Type objectType) {\r
index 4b210961902a41f6f9050e82c18d9bf3a9f17243..466af5f5b11cb2814ee8146d2be2497e0ba458e3 100644 (file)
@@ -28,7 +28,7 @@
       "server": {\r
         "address": "Data Source=10.10.1.45\\sql16;Initial Catalog=PA_Echo;Persist Security Info=True;",\r
         "userName": "MAM",\r
-        "password": "Echotv.hu",\r
+        "password": "7RKZYBzumKjL40SJwuwiFCvX57xuCN8zay6OttUm2wbrgImyYZBHyZTUUYrXX31Ge2Uwew07HYsqh2uzdJeDBDwcVntxaHg3nIpv9Dyq/odVoiC4tUF/K+lgvKWANcrZ",\r
         "timeout": 1000\r
       }\r
     },\r
@@ -50,6 +50,8 @@
       "killDateDays": 7,\r
       "remote": {\r
         "address": "file://10.10.1.100/BRAAVOS/OCTOPUS",\r
+        "userName": "mediacube",\r
+        "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy",\r
         "timeout": 1000\r
       }\r
     },\r
@@ -62,8 +64,8 @@
       "killDateDays": 7,\r
       "remote": {\r
         "address": "ftp://10.10.1.56:2098",\r
-        "userName": "administaror",\r
-        "password": "system",\r
+        "userName": "administrator",\r
+        "password": "+QtkeQdCTiOvZOgK/kUND4pO4/D+//r7ZIyluwMMdiqMEgO8iJErAG10ooWhPfiljQeXrdeyMzo7gWEZtcWpNSomGeDIbdMyQwtpqmMo1VEM3A27ZfzigY09YD46ECRh",\r
         "timeout": 1000\r
       }\r
     },\r
@@ -77,6 +79,8 @@
       "useMetadata": false,\r
       "remote": {\r
         "address": "file://10.10.1.100/BRAAVOS/OCTOPUS",\r
+        "userName": "mediacube",\r
+        "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy",\r
         "timeout": 1000\r
       }\r
     },\r
@@ -90,6 +94,8 @@
       "useMetadata": false,\r
       "remote": {\r
         "address": "file://10.10.1.100/BRAAVOS/PLAYOUT_NLE",\r
+        "userName": "mediacube",\r
+        "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy",\r
         "timeout": 1000\r
       }\r
     },\r
       "killDateDays": 7,\r
       "remote": {\r
         "address": "file://10.10.1.100/BRAAVOS/PLAYOUT_CHECK",\r
+        "userName": "mediacube",\r
+        "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy",\r
         "timeout": 1000\r
       }\r
     },\r
       "useMetadata": true,\r
       "remote": {\r
         "address": "file://10.10.1.100/BRAAVOS/ARCHIVE",\r
+        "userName": "mediacube",\r
+        "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy",\r
         "timeout": 1000\r
       }\r
     }\r
index a5d171938ae4f1279fddd739c18a78d1d097f923..28c548c553603972bd4aa3ea56d0ead152df5246 100644 (file)
@@ -28,7 +28,7 @@
       "server": {\r
         "address": "Data Source=10.10.1.45\\sql16;Initial Catalog=PA_Echo;Persist Security Info=True;",\r
         "userName": "MAM",\r
-        "password": "Echotv.hu",\r
+        "password": "7RKZYBzumKjL40SJwuwiFCvX57xuCN8zay6OttUm2wbrgImyYZBHyZTUUYrXX31Ge2Uwew07HYsqh2uzdJeDBDwcVntxaHg3nIpv9Dyq/odVoiC4tUF/K+lgvKWANcrZ",\r
         "timeout": 1000\r
       }\r
     },\r
@@ -42,7 +42,7 @@
   ],\r
   "targets": [\r
     {\r
-      "label": "Nyersanyag betöltés",\r
+      "label": "Hír nyersanyag betöltés",\r
       "processor": "UNCTargetProcessor",\r
       "outputFormat": "%ID%-%SOURCENAME%",\r
       "tag": "Betöltés",\r
@@ -50,6 +50,8 @@
       "killDateDays": 7,\r
       "remote": {\r
         "address": "file://10.10.1.100/BRAAVOS/OCTOPUS",\r
+        "userName": "mediacube",\r
+        "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy",\r
         "timeout": 1000\r
       }\r
     },\r
       "nexioServer": true,\r
       "agency": "NLE UPLOAD",\r
       "killDateDays": 7,\r
+      "reference": "Hír nyersanyag betöltés",\r
       "remote": {\r
         "address": "ftp://10.10.1.56:2098",\r
-        "userName": "administaror",\r
-        "password": "system",\r
+        "userName": "administrator",\r
+        "password": "+QtkeQdCTiOvZOgK/kUND4pO4/D+//r7ZIyluwMMdiqMEgO8iJErAG10ooWhPfiljQeXrdeyMzo7gWEZtcWpNSomGeDIbdMyQwtpqmMo1VEM3A27ZfzigY09YD46ECRh",\r
         "timeout": 1000\r
       }\r
     },\r
@@ -76,6 +79,8 @@
       "killDateDays": 7,\r
       "remote": {\r
         "address": "file://10.10.1.100/BRAAVOS/PLAYOUT_CHECK",\r
+        "userName": "mediacube",\r
+        "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy",\r
         "timeout": 1000\r
       }\r
     },\r
@@ -87,6 +92,8 @@
       "useMetadata": true,\r
       "remote": {\r
         "address": "file://10.10.1.100/BRAAVOS/ARCHIVE",\r
+        "userName": "mediacube",\r
+        "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy",\r
         "timeout": 1000\r
       }\r
     }\r
index fd0ad3b2b7dc6e73eb1d3ad1da53fb74ae3adefe..e61d9a050bf39a91b8de582dc247d07d954f9d2e 100644 (file)
   "source": {\r
     "$type": "UNCSource",\r
     "local": {\r
-      "address": "file://10.10.1.100/BRAAVOS/PLAYOUT_CHECK"\r
+      "address": "file://10.10.1.100/BRAAVOS/PLAYOUT_CHECK",\r
+      "userName": "mediacube",\r
+      "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy",\r
+      "timeout": 1000\r
+    },\r
+    "remote": {\r
+      "address": "ftp://10.10.1.100/PLAYOUT_CHECK",\r
+      "userName": "mediacube",\r
+      "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy",\r
+      "timeout": 1000\r
     }\r
   },\r
   "metadatas": [\r
@@ -27,7 +36,7 @@
       "server": {\r
         "address": "Data Source=10.10.1.45\\sql16;Initial Catalog=PA_Echo;Persist Security Info=True;",\r
         "userName": "MAM",\r
-        "password": "Echotv.hu",\r
+        "password": "7RKZYBzumKjL40SJwuwiFCvX57xuCN8zay6OttUm2wbrgImyYZBHyZTUUYrXX31Ge2Uwew07HYsqh2uzdJeDBDwcVntxaHg3nIpv9Dyq/odVoiC4tUF/K+lgvKWANcrZ",\r
         "timeout": 1000\r
       }\r
     },\r
       "outputFormat": "%ID%",\r
       "saveSegments": true,\r
       "tag": "Adáskész",\r
+      "reference": "Archiválás",\r
       "remote": {\r
-        "address": "file://10.10.1.100/BRAAVOS/PLAYOUT/IceGateway"\r
+        "address": "file://10.10.1.100/BRAAVOS/PLAYOUT/IceGateway",\r
+        "userName": "mediacube",\r
+        "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy",\r
+        "timeout": 1000\r
       }\r
     },\r
     {\r
       "outputFormat": "%ID%",\r
       "tag": "Újravágás",\r
       "remote": {\r
-        "address": "file://10.10.1.100/BRAAVOS/PLAYOUT_NLE"\r
+        "address": "file://10.10.1.100/BRAAVOS/PLAYOUT_NLE",\r
+        "userName": "mediacube",\r
+        "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy",\r
+        "timeout": 1000\r
+      },\r
+      "sendSEmailOnSuccess": true,\r
+      "successEmailRecipient": "vasary@elgekko.net",\r
+      "successEmailPattern": "A %TARGETNAME% újravágása szükséges."\r
+    },\r
+    {\r
+      "label": "Újravágás FXP",\r
+      "processor": "FXPTargetProcessor",\r
+      "outputFormat": "%ID%",\r
+      "tag": "Újravágás FXP",\r
+      "remote": {\r
+        "address": "ftp://10.10.1.100/PLAYOUT_NLE",\r
+        "userName": "mediacube",\r
+        "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy",\r
+        "timeout": 1000\r
       },\r
-      "sendSEmailOnSuccess" : true, \r
+      "sendSEmailOnSuccess": false,\r
       "successEmailRecipient": "vasary@elgekko.net",\r
       "successEmailPattern": "A %TARGETNAME% újravágása szükséges."\r
     },\r
       "createMetadata": true,\r
       "remote": {\r
         "address": "file://10.10.1.100/BRAAVOS/ARCHIVE",\r
+        "userName": "mediacube",\r
+        "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy",\r
         "timeout": 1000\r
       }\r
     }\r
index 2933e81373c347caef3ee457334de1b35992b665..60518050b9d4e48a956644709aa3fac111ba9a2d 100644 (file)
@@ -14,7 +14,7 @@
     "remote": {\r
       "address": "ftp://10.10.1.56:2098",\r
       "userName": "administrator",\r
-      "password": "system"\r
+      "password": "+QtkeQdCTiOvZOgK/kUND4pO4/D+//r7ZIyluwMMdiqMEgO8iJErAG10ooWhPfiljQeXrdeyMzo7gWEZtcWpNSomGeDIbdMyQwtpqmMo1VEM3A27ZfzigY09YD46ECRh"\r
     }\r
   },\r
   "metadatas": [\r
@@ -30,7 +30,7 @@
       "server": {\r
         "address": "Data Source=10.10.1.45\\sql16;Initial Catalog=PA_Echo;Persist Security Info=True;",\r
         "userName": "MAM",\r
-        "password": "Echotv.hu",\r
+        "password": "7RKZYBzumKjL40SJwuwiFCvX57xuCN8zay6OttUm2wbrgImyYZBHyZTUUYrXX31Ge2Uwew07HYsqh2uzdJeDBDwcVntxaHg3nIpv9Dyq/odVoiC4tUF/K+lgvKWANcrZ",\r
         "timeout": 1000\r
       }\r
     },\r
@@ -38,6 +38,8 @@
       "$type": "MediaCubeMetadata",\r
       "server": {\r
         "address": "http://10.10.1.28/services/rest/jobengine",\r
+        "userName": "mediacube",\r
+        "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy",\r
         "timeout": 1000\r
       }\r
     }\r
       "remote": {\r
         "address": "ftp://10.10.1.100:21/PLAYOUT_CHECK",\r
         "userName": "mediacube",\r
-        "password":  "Broadca5T"\r
+        "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy",\r
+        "timeout": 1000\r
       }\r
     },\r
     {\r
       "label": "Archiválás",\r
-      "processor": "UNCTargetProcessor",\r
+      "processor": "FXPTargetProcessor",\r
       "outputFormat": "%ID%",\r
       "tag": "Archiválás",\r
       "createMetadata": true,\r
       "remote": {\r
-        "address": "file://10.10.1.100/BRAAVOS/ARCHIVE"\r
+        "address": "ftp://10.10.1.100:21/BRAAVOS/ARCHIVE",\r
+        "userName": "mediacube",\r
+        "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy",\r
+        "timeout": 1000\r
       }\r
     }\r
   ]\r
index 40127a920999b88317ab580ed82462cc92141a67..407b1d75666112a062be4c2ceeb453e66e353177 100644 (file)
@@ -28,7 +28,7 @@
       "server": {\r
         "address": "Data Source=10.10.1.45\\sql16;Initial Catalog=PA_Echo;Persist Security Info=True;",\r
         "userName": "MAM",\r
-        "password": "Echotv.hu",\r
+        "password": "7RKZYBzumKjL40SJwuwiFCvX57xuCN8zay6OttUm2wbrgImyYZBHyZTUUYrXX31Ge2Uwew07HYsqh2uzdJeDBDwcVntxaHg3nIpv9Dyq/odVoiC4tUF/K+lgvKWANcrZ",\r
         "timeout": 1000\r
       }\r
     },\r
@@ -51,6 +51,8 @@
       "useMetadata": false,\r
       "remote": {\r
         "address": "file://10.10.1.100/BRAAVOS/OCTOPUS",\r
+        "userName": "mediacube",\r
+        "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy",\r
         "timeout": 1000\r
       }\r
     },\r
@@ -64,6 +66,8 @@
       "useMetadata": false,\r
       "remote": {\r
         "address": "file://10.10.1.100/BRAAVOS/PLAYOUT_NLE",\r
+        "userName": "mediacube",\r
+        "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy",\r
         "timeout": 1000\r
       }\r
     },\r
@@ -75,6 +79,8 @@
       "killDateDays": 7,\r
       "remote": {\r
         "address": "file://10.10.1.100/BRAAVOS/PLAYOUT_CHECK",\r
+        "userName": "mediacube",\r
+        "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy",\r
         "timeout": 1000\r
       }\r
     },\r
@@ -86,6 +92,8 @@
       "useMetadata": true,\r
       "remote": {\r
         "address": "file://10.10.1.100/BRAAVOS/ARCHIVE",\r
+        "userName": "mediacube",\r
+        "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy",\r
         "timeout": 1000\r
       }\r
     }\r
index 5c057d7c3b543cfbb4bae15370542b28c9bedb14..6fa4b0a3a75b46e7f1efe31459cf0493e04d61ae 100644 (file)
       <Project>{8CC7C930-9DBF-487B-AED5-776937A649D5}</Project>\r
       <Name>OctopusClient</Name>\r
     </ProjectReference>\r
+    <ProjectReference Include="..\PasswordEncrypter\PasswordEncrypter.csproj">\r
+      <Project>{8c51d508-1759-4c10-84a4-80965fd074ff}</Project>\r
+      <Name>PasswordEncrypter</Name>\r
+    </ProjectReference>\r
     <ProjectReference Include="..\PlanAIRClient\TrafficClient.csproj">\r
       <Project>{a7a21311-cb0e-465f-8ad6-829faf093f00}</Project>\r
       <Name>TrafficClient</Name>\r
index 46128517e765bb5f2e861e73b5f404d8a471018c..d47e79def358031fe88d29a15885c52f19fc755e 100644 (file)
@@ -56,61 +56,87 @@ namespace Maestro {
                 Dock = DockStyle.Top,\r
                 Tag = target\r
             };\r
-            checkBox.CheckStateChanged += (s, e) => {\r
-                OnChecked(checkBox, target);\r
-            };\r
-\r
+            checkBox.CheckStateChanged += (s, e) => OnChecked(checkBox, target);\r
             panelActions.Controls.Add(checkBox);\r
             panelActions.RowCount = panelActions.Controls.Count;\r
-\r
         }\r
 \r
-        private void OnChecked(object sender, Target target) {\r
-            CheckBox checkBox = sender as CheckBox;\r
-            if (checkBox == null)\r
-                return;\r
+        private void OnChecked(CheckBox checkBox, Target target) {\r
             if (checkBox.Checked) {\r
-                List<ITargetProcessor> processors = new List<ITargetProcessor>();\r
-                foreach (DataGridViewRow actualRow in selectedSourceRows) {\r
-                    ISourceItem sourceItem = actualRow.DataBoundItem as ISourceItem;\r
-                    if (sourceItem == null)\r
-                        continue;\r
-                    string typeName = string.Format("{0}.{1}", typeof(ITargetProcessor).Namespace, target.Processor);\r
-                    Type type = Type.GetType(typeName);\r
-                    string id = selectedMetadata == null ? textSelectedMetadata.Text : selectedMetadata.ID;\r
-                    if (segments == null) {\r
-                        if (target.SaveSegments) {\r
-                            segments = trafficIDSelector.trafficAPI.GetSegments(selectedMetadata.VariantID);\r
-                            if (segments == null) {\r
-                                //todo error report küldés?\r
-                            }\r
-                        } else segments = new List<Segment>();\r
-                    }\r
-                    TargetProcessorParameter processorParameter = new TargetProcessorParameter() {\r
-                        ArchiveMetadata = ArchiveMetadata.DeepClone(archiveMetadatamodel),\r
-                        Client = trafficIDSelector.trafficAPI,\r
-                        ID = id,\r
-                        InputFileName = sourceItem.Name,\r
-                        MediaCubeApi = mediaCubeApi,\r
-                        Segments = new List<Segment>(segments),\r
-                        SourceConfig = Configuration.Source,\r
-                        TargetConfig = target,\r
-                        VariantID = selectedMetadata == null ? 0 : selectedMetadata.VariantID\r
-                    };\r
-                    object[] parameters = new object[] { this, processorParameter };\r
-                    ITargetProcessor processor = (ITargetProcessor)Activator.CreateInstance(type, parameters);\r
-                    processors.Add(processor);\r
-                    if (!String.IsNullOrEmpty(target.Reference))\r
-                        SetCheckBoxReferences(target.Reference, true);\r
-                }\r
+                List<ITargetProcessor> processors = CreateProcessors(target, checkBox);\r
                 currentProcessors.Add(checkBox, processors);\r
             } else {\r
-                SetCheckBoxReferences(target.Reference, false);\r
+                HandleCheckBoxReferences(target.Reference, false);\r
                 currentProcessors.Remove(checkBox);\r
             }\r
             btnExecute.Enabled = currentProcessors.Count > 0;\r
         }\r
 \r
+        private List<ITargetProcessor> CreateProcessors(Target target, CheckBox checkBox) {\r
+            List<ITargetProcessor> result = null;\r
+            foreach (DataGridViewRow actualRow in selectedSourceRows) {\r
+                ISourceItem sourceItem = actualRow.DataBoundItem as ISourceItem;\r
+                if (sourceItem == null)\r
+                    continue;\r
+                if (!EnsureSegments(target)) {\r
+                    checkBox.Checked = false;\r
+                    continue;\r
+                }\r
+                if (!EnsureMetadata(target)) {\r
+                    checkBox.Checked = false;\r
+                    continue;\r
+                }\r
+                TargetProcessorParameter processorParameter = CreateProcessorParameter(target, sourceItem);\r
+                ITargetProcessor processor = CreateProcessor(target, processorParameter);\r
+                if (result == null)\r
+                    result = new List<ITargetProcessor>();\r
+                result.Add(processor);\r
+                HandleCheckBoxReferences(target.Reference, true);\r
+            }\r
+            return result;\r
+        }\r
+\r
+        private bool EnsureSegments(Target target) {\r
+            if (target.SaveSegments && segments == null) {\r
+                segments = trafficIDSelector.trafficAPI.GetSegments(selectedMetadata.VariantID);\r
+                if (segments == null) {\r
+                    MessageBox.Show("A {0} folyamat nem futtatható szegmens adatok nélkül.");\r
+                    return false;\r
+                }\r
+            }\r
+            return true;\r
+        }\r
+\r
+        private bool EnsureMetadata(Target target) {\r
+            if (target.CreateMetadata && (archiveMetadatamodel == null || !archiveMetadatamodel.IsFilled)) {\r
+                segments = trafficIDSelector.trafficAPI.GetSegments(selectedMetadata.VariantID);\r
+                if (segments == null) {\r
+                    MessageBox.Show("A {0} folyamat nem futtatható kísérő adatok nélkül.");\r
+                    return false;\r
+                }\r
+            }\r
+            return true;\r
+        }\r
+\r
+        private ITargetProcessor CreateProcessor(Target target, TargetProcessorParameter processorParameter) {\r
+            string typeName = string.Format("{0}.{1}", typeof(ITargetProcessor).Namespace, target.Processor);\r
+            return (ITargetProcessor)Activator.CreateInstance(Type.GetType(typeName), new object[] { this, processorParameter });\r
+        }\r
+\r
+        private TargetProcessorParameter CreateProcessorParameter(Target target, ISourceItem sourceItem) {\r
+            return new TargetProcessorParameter() {\r
+                ArchiveMetadata = ArchiveMetadata.DeepClone(archiveMetadatamodel),\r
+                Client = trafficIDSelector.trafficAPI,\r
+                ID = selectedMetadata == null ? textSelectedMetadata.Text : selectedMetadata.ID,\r
+                InputFileName = sourceItem.Name,\r
+                MediaCubeApi = mediaCubeApi,\r
+                Segments = segments == null ? null : new List<Segment>(segments),\r
+                SourceConfig = Configuration.Source,\r
+                TargetConfig = target,\r
+                VariantID = selectedMetadata == null ? 0 : selectedMetadata.VariantID\r
+            };\r
+        }\r
+\r
         private bool IsOffCheckAble(String text) {\r
             List<CheckBox> checkBoxes = new List<CheckBox>(currentProcessors.Keys);\r
             foreach (CheckBox actual in checkBoxes) {\r
@@ -121,7 +147,9 @@ namespace Maestro {
             return true;\r
         }\r
 \r
-        private void SetCheckBoxReferences(string reference, bool check) {\r
+        private void HandleCheckBoxReferences(string reference, bool check) {\r
+            if (String.IsNullOrEmpty(reference))\r
+                return;\r
             var controlls = panelActions.Controls;\r
             foreach (Control actual in controlls) {\r
                 CheckBox actualCheckbox = actual as CheckBox;\r
@@ -193,14 +221,14 @@ namespace Maestro {
                 Cursor.Current = Cursors.WaitCursor;\r
                 IDTypes idType = GetTypeOfSelectedMetadata();\r
                 if (idType == IDTypes.OctopusID)\r
-                    FillTheModelFromOctopus(archiveMetadatamodel);\r
+                    GetOctopusMetadata(archiveMetadatamodel);\r
                 else //if (idType == IDTypes.TrafficID)\r
-                    FillTheModelFromTraffic(archiveMetadatamodel);\r
+                    GetTrafficMetadata(archiveMetadatamodel);\r
             } else\r
                 archiveMetadatamodel = null;\r
         }\r
 \r
-        private void FillTheModelFromTraffic(ArchiveMetadata model) {\r
+        private void GetTrafficMetadata(ArchiveMetadata model) {\r
             string id = selectedMetadata.ID;\r
             TrafficAPI api = trafficIDSelector.trafficAPI;\r
             List<ArchiveMatadataWrapper> result = null;\r
@@ -223,7 +251,7 @@ namespace Maestro {
             model.mediaDescription = actualResult.EpisodeDescription;\r
         }\r
 \r
-        private void FillTheModelFromOctopus(ArchiveMetadata model) {\r
+        private void GetOctopusMetadata(ArchiveMetadata model) {\r
             string id = selectedMetadata.ID;\r
             OctopusAPI api = octopusIDSelector.GetClient();\r
             IEnumerable<Story> storyEnum = api.GetStoriesById(id);\r
index 3fa7ac9b2b544eb43ffbcf0363b040e9fde8991d..4182c2e6e7d493c8d735a2aa08b98ad95e92565e 100644 (file)
@@ -29,19 +29,19 @@ namespace Maestro {
         private void OnFileCreated(FileActionMsg m) {\r
             if (!form.Equals(m.Source))\r
                 return;\r
-            Show(String.Format("File {0} created in source {1}", m.FileName, m.Source.Text));\r
+            Show(String.Format("Új fájl a {1} forrásban: {0}", m.FileName, m.Source.Text));\r
         }\r
 \r
         private void OnFileModified(FileActionMsg m) {\r
             if (!form.Equals(m.Source))\r
                 return;\r
-            Show(String.Format("File {0} modified in source {1}", m.FileName, m.Source.Text));\r
+            Show(String.Format("Módosult fájl a {1} forrásban: {0}", m.FileName, m.Source.Text));\r
         }\r
 \r
         private void OnFileRemoved(FileActionMsg m) {\r
             if (!form.Equals(m.Source))\r
                 return;\r
-            Show(String.Format("File {0} removed in source {1}", m.FileName, m.Source.Text));\r
+            Show(String.Format("Törölt fájl a {1} forrásban: {0}", m.FileName, m.Source.Text));\r
         }\r
 \r
         public void Show(string tooltipText) {\r
@@ -49,7 +49,7 @@ namespace Maestro {
                 return;\r
             notification.BalloonTipText = tooltipText;\r
             notification.Visible = true;\r
-            notification.ShowBalloonTip(3);\r
+            notification.ShowBalloonTip(1);\r
         }\r
 \r
         public void ShowForm() {\r
index 3226d64c9e567a9c1fbc2482a9cbf80e58928df3..d3a4d13879eab451aed127a080c8cae328e03a3a 100644 (file)
@@ -22,6 +22,16 @@ namespace Maestro.Metadata {
             //    StuffID, StuffTitle, StuffDescription, MediaID, MediaTitle, MediaDescription);\r
         }\r
 \r
+        public bool IsFilled {\r
+            get {\r
+                return\r
+                    !String.IsNullOrEmpty(itemHouseId) &&\r
+                    !String.IsNullOrEmpty(itemTitle) &&\r
+                    !String.IsNullOrEmpty(mediaHouseId) &&\r
+                    !String.IsNullOrEmpty(mediaTitle);\r
+            }\r
+        }\r
+\r
         public static ArchiveMetadata DeepClone(ArchiveMetadata obj) {\r
             if (obj == null)\r
                 return null;\r
index 718fcd0a84784869df7fe2bf1d35f16c3e288cbb..1c75e6cd9fd3e32a0acdddd67cf69f127eba83f0 100644 (file)
@@ -10,6 +10,9 @@ using System.Collections.Generic;
 using System.Drawing;\r
 using System.IO;\r
 using System.Reflection;\r
+using System.Runtime.InteropServices;\r
+using System.Security.AccessControl;\r
+using System.Security.Principal;\r
 using System.Threading;\r
 using System.Threading.Tasks;\r
 using System.Windows.Forms;\r
@@ -23,9 +26,33 @@ namespace Maestro {
         /// </summary>\r
         [STAThread]\r
         static void Main() {\r
-            Application.EnableVisualStyles();\r
-            Application.SetCompatibleTextRenderingDefault(false);\r
-            Application.Run(new TrayApplicationContext());\r
+            string appGuid = ((GuidAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(GuidAttribute), false).GetValue(0)).Value.ToString();\r
+            string mutexId = string.Format("Global\\{{{0}}}", appGuid);\r
+            bool createdNew;\r
+            var allowEveryoneRule = new MutexAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), MutexRights.FullControl, AccessControlType.Allow);\r
+            var securitySettings = new MutexSecurity();\r
+            securitySettings.AddAccessRule(allowEveryoneRule);\r
+            using (var mutex = new Mutex(false, mutexId, out createdNew, securitySettings)) {\r
+                var hasHandle = false;\r
+                try {\r
+                    try {\r
+                        hasHandle = mutex.WaitOne(500, false);\r
+                        if (hasHandle == false)\r
+                            MessageBox.Show("A MediaCube Maestro alkalmazás már fut egy példányban.");\r
+                    }\r
+                    catch (AbandonedMutexException) {\r
+                        hasHandle = true;\r
+                    }\r
+                }\r
+                finally {\r
+                    if (hasHandle) {\r
+                        Application.EnableVisualStyles();\r
+                        Application.SetCompatibleTextRenderingDefault(false);\r
+                        Application.Run(new TrayApplicationContext());\r
+                        mutex.ReleaseMutex();\r
+                    }\r
+                }\r
+            }\r
         }\r
     }\r
 \r
@@ -63,6 +90,8 @@ namespace Maestro {
         private void CreateForm(string file) {\r
             try {\r
                 ConfigurationInfo config = Loader.Get(file);\r
+                //string decryptedstring = StringCipher.Decrypt(encryptedstring, password);\r
+\r
                 if (!config.Active)\r
                     return;\r
                 MeastroFormNotifyIcon form = new MeastroFormNotifyIcon(config, messageBus);\r
@@ -100,7 +129,7 @@ namespace Maestro {
                 ContextMenu = new ContextMenu(menuItems.ToArray()),\r
                 Visible = true\r
             };\r
-            trayIcon.Click += TrayIcon_Click;\r
+            //trayIcon.Click += TrayIcon_Click;\r
         }\r
 \r
         private void TrayIcon_Click(object sender, EventArgs e) {\r
index 11831ea05ad86d188b394bfdf0f3070d9b9e0ad6..bf7fd7423b5275b8e017bf41b374cc36563b6802 100644 (file)
@@ -27,7 +27,10 @@ namespace Maestro.Targets {
 \r
             try {\r
                 sourceFTP = CreateClient(sourceConfig.Remote);\r
-                long ilength = sourceFTP.GetFileSize(inputUri.AbsolutePath) / 2;\r
+\r
+                long ilength = sourceFTP.GetFileSize(inputUri.AbsolutePath);\r
+                if (parameters.TargetConfig.NexioServer)\r
+                    ilength = ilength / 2;\r
 \r
                 FtpReply replyPASV = targetFTP.Execute("PASV");\r
                 if (!replyPASV.Success)\r
@@ -46,7 +49,7 @@ namespace Maestro.Targets {
                 if (!sourceReplyTYPE.Success)\r
                     throw new Exception(sourceReplyTYPE.ErrorMessage);\r
 \r
-                FtpReply replyRETR = sourceFTP.Execute("RETR " + inputUri.AbsolutePath.Replace("/", ""));\r
+                FtpReply replyRETR = sourceFTP.Execute("RETR " + inputUri.AbsolutePath);\r
                 if (!replyRETR.Success) {\r
 \r
                     replyRETR = sourceFTP.Execute("RETR " + inputUri.Segments[inputUri.Segments.Length - 1]);\r
index 5664709896c5278f6c8b157145484171a53ec2f9..f7e2b958affd4e3c727f116d6c8cb4324799280a 100644 (file)
@@ -16,6 +16,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AudioRecorder", "AudioRecor
 EndProject\r
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrafficClient", "PlanAIRClient\TrafficClient.csproj", "{A7A21311-CB0E-465F-8AD6-829FAF093F00}"\r
 EndProject\r
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PasswordEncrypter", "PasswordEncrypter\PasswordEncrypter.csproj", "{8C51D508-1759-4C10-84A4-80965FD074FF}"\r
+EndProject\r
 Global\r
        GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
                Debug|Any CPU = Debug|Any CPU\r
@@ -108,12 +110,24 @@ Global
                {A7A21311-CB0E-465F-8AD6-829FAF093F00}.Release|x64.Build.0 = Release|Any CPU\r
                {A7A21311-CB0E-465F-8AD6-829FAF093F00}.Release|x86.ActiveCfg = Release|Any CPU\r
                {A7A21311-CB0E-465F-8AD6-829FAF093F00}.Release|x86.Build.0 = Release|Any CPU\r
+               {8C51D508-1759-4C10-84A4-80965FD074FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
+               {8C51D508-1759-4C10-84A4-80965FD074FF}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
+               {8C51D508-1759-4C10-84A4-80965FD074FF}.Debug|x64.ActiveCfg = Debug|Any CPU\r
+               {8C51D508-1759-4C10-84A4-80965FD074FF}.Debug|x64.Build.0 = Debug|Any CPU\r
+               {8C51D508-1759-4C10-84A4-80965FD074FF}.Debug|x86.ActiveCfg = Debug|Any CPU\r
+               {8C51D508-1759-4C10-84A4-80965FD074FF}.Debug|x86.Build.0 = Debug|Any CPU\r
+               {8C51D508-1759-4C10-84A4-80965FD074FF}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
+               {8C51D508-1759-4C10-84A4-80965FD074FF}.Release|Any CPU.Build.0 = Release|Any CPU\r
+               {8C51D508-1759-4C10-84A4-80965FD074FF}.Release|x64.ActiveCfg = Release|Any CPU\r
+               {8C51D508-1759-4C10-84A4-80965FD074FF}.Release|x64.Build.0 = Release|Any CPU\r
+               {8C51D508-1759-4C10-84A4-80965FD074FF}.Release|x86.ActiveCfg = Release|Any CPU\r
+               {8C51D508-1759-4C10-84A4-80965FD074FF}.Release|x86.Build.0 = Release|Any CPU\r
        EndGlobalSection\r
        GlobalSection(SolutionProperties) = preSolution\r
                HideSolutionNode = FALSE\r
        EndGlobalSection\r
        GlobalSection(TeamFoundationVersionControl) = preSolution\r
-               SccNumberOfProjects = 8\r
+               SccNumberOfProjects = 9\r
                SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}\r
                SccTeamFoundationServer = https://tfs.userrendszerhaz.hu/tfs/defaultcollection\r
                SccLocalPath0 = .\r
@@ -138,5 +152,8 @@ Global
                SccProjectUniqueName7 = Maestro\\Maestro.csproj\r
                SccProjectName7 = Maestro\r
                SccLocalPath7 = Maestro\r
+               SccProjectUniqueName8 = PasswordEncrypter\\PasswordEncrypter.csproj\r
+               SccProjectName8 = PasswordEncrypter\r
+               SccLocalPath8 = PasswordEncrypter\r
        EndGlobalSection\r
 EndGlobal\r
diff --git a/client/PasswordEncrypter/App.config b/client/PasswordEncrypter/App.config
new file mode 100644 (file)
index 0000000..00bfd11
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>\r
+<configuration>\r
+    <startup> \r
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />\r
+    </startup>\r
+</configuration>
\ No newline at end of file
diff --git a/client/PasswordEncrypter/PasswordEncrypter.csproj b/client/PasswordEncrypter/PasswordEncrypter.csproj
new file mode 100644 (file)
index 0000000..0d11f91
--- /dev/null
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />\r
+  <PropertyGroup>\r
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
+    <ProjectGuid>{8C51D508-1759-4C10-84A4-80965FD074FF}</ProjectGuid>\r
+    <OutputType>Exe</OutputType>\r
+    <RootNamespace>PasswordEncrypter</RootNamespace>\r
+    <AssemblyName>PasswordEncrypter</AssemblyName>\r
+    <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>\r
+    <FileAlignment>512</FileAlignment>\r
+    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>\r
+    <SccProjectName>SAK</SccProjectName>\r
+    <SccLocalPath>SAK</SccLocalPath>\r
+    <SccAuxPath>SAK</SccAuxPath>\r
+    <SccProvider>SAK</SccProvider>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
+    <PlatformTarget>AnyCPU</PlatformTarget>\r
+    <DebugSymbols>true</DebugSymbols>\r
+    <DebugType>full</DebugType>\r
+    <Optimize>false</Optimize>\r
+    <OutputPath>bin\Debug\</OutputPath>\r
+    <DefineConstants>DEBUG;TRACE</DefineConstants>\r
+    <ErrorReport>prompt</ErrorReport>\r
+    <WarningLevel>4</WarningLevel>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
+    <PlatformTarget>AnyCPU</PlatformTarget>\r
+    <DebugType>pdbonly</DebugType>\r
+    <Optimize>true</Optimize>\r
+    <OutputPath>bin\Release\</OutputPath>\r
+    <DefineConstants>TRACE</DefineConstants>\r
+    <ErrorReport>prompt</ErrorReport>\r
+    <WarningLevel>4</WarningLevel>\r
+  </PropertyGroup>\r
+  <ItemGroup>\r
+    <Reference Include="System" />\r
+    <Reference Include="System.Core" />\r
+    <Reference Include="System.Windows.Forms" />\r
+    <Reference Include="System.Xml.Linq" />\r
+    <Reference Include="System.Data.DataSetExtensions" />\r
+    <Reference Include="Microsoft.CSharp" />\r
+    <Reference Include="System.Data" />\r
+    <Reference Include="System.Net.Http" />\r
+    <Reference Include="System.Xml" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <Compile Include="Program.cs" />\r
+    <Compile Include="Properties\AssemblyInfo.cs" />\r
+    <Compile Include="StringCipher.cs" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <None Include="App.config" />\r
+  </ItemGroup>\r
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
+</Project>
\ No newline at end of file
diff --git a/client/PasswordEncrypter/Program.cs b/client/PasswordEncrypter/Program.cs
new file mode 100644 (file)
index 0000000..37cb21e
--- /dev/null
@@ -0,0 +1,23 @@
+using System;\r
+using System.Windows.Forms;\r
+\r
+namespace PasswordEncrypter {\r
+    class Program {\r
+\r
+        [STAThread]\r
+        static void Main(string[] args) {\r
+            Console.WriteLine("Eredeti jelszó:");\r
+            string password = Console.ReadLine();\r
+\r
+            Console.WriteLine("Kódolt jelszó a vágólapon:");\r
+            string encryptedstring = StringCipher.Encrypt(password);\r
+            Console.WriteLine(encryptedstring);\r
+            Clipboard.SetText(encryptedstring);\r
+\r
+            string originalstring = StringCipher.Decrypt(encryptedstring);\r
+            Console.WriteLine("Ellenőrzés:");\r
+            Console.WriteLine(originalstring);\r
+            Console.ReadLine();\r
+        }\r
+    }\r
+}\r
diff --git a/client/PasswordEncrypter/Properties/AssemblyInfo.cs b/client/PasswordEncrypter/Properties/AssemblyInfo.cs
new file mode 100644 (file)
index 0000000..92fde9a
--- /dev/null
@@ -0,0 +1,36 @@
+using System.Reflection;\r
+using System.Runtime.CompilerServices;\r
+using System.Runtime.InteropServices;\r
+\r
+// General Information about an assembly is controlled through the following\r
+// set of attributes. Change these attribute values to modify the information\r
+// associated with an assembly.\r
+[assembly: AssemblyTitle("PasswordEncrypter")]\r
+[assembly: AssemblyDescription("")]\r
+[assembly: AssemblyConfiguration("")]\r
+[assembly: AssemblyCompany("")]\r
+[assembly: AssemblyProduct("PasswordEncrypter")]\r
+[assembly: AssemblyCopyright("Copyright ©  2017")]\r
+[assembly: AssemblyTrademark("")]\r
+[assembly: AssemblyCulture("")]\r
+\r
+// Setting ComVisible to false makes the types in this assembly not visible\r
+// to COM components.  If you need to access a type in this assembly from\r
+// COM, set the ComVisible attribute to true on that type.\r
+[assembly: ComVisible(false)]\r
+\r
+// The following GUID is for the ID of the typelib if this project is exposed to COM\r
+[assembly: Guid("8c51d508-1759-4c10-84a4-80965fd074ff")]\r
+\r
+// Version information for an assembly consists of the following four values:\r
+//\r
+//      Major Version\r
+//      Minor Version\r
+//      Build Number\r
+//      Revision\r
+//\r
+// You can specify all the values or you can default the Build and Revision Numbers\r
+// by using the '*' as shown below:\r
+// [assembly: AssemblyVersion("1.0.*")]\r
+[assembly: AssemblyVersion("1.0.0.0")]\r
+[assembly: AssemblyFileVersion("1.0.0.0")]\r
diff --git a/client/PasswordEncrypter/StringCipher.cs b/client/PasswordEncrypter/StringCipher.cs
new file mode 100644 (file)
index 0000000..eb06e39
--- /dev/null
@@ -0,0 +1,107 @@
+using System;\r
+using System.Text;\r
+using System.Security.Cryptography;\r
+using System.IO;\r
+using System.Linq;\r
+\r
+namespace PasswordEncrypter {\r
+\r
+    public static class StringCipher\r
+    {\r
+        public static string helper = "Tetszőleges";\r
+\r
+        // This constant is used to determine the keysize of the encryption algorithm in bits.\r
+        // We divide this by 8 within the code below to get the equivalent number of bytes.\r
+        private const int Keysize = 256;\r
+\r
+        // This constant determines the number of iterations for the password bytes generation function.\r
+        private const int DerivationIterations = 1000;\r
+\r
+        public static string Encrypt(string plainText)\r
+        {\r
+            // Salt and IV is randomly generated each time, but is preprended to encrypted cipher text\r
+            // so that the same Salt and IV values can be used when decrypting.  \r
+            var saltStringBytes = Generate256BitsOfRandomEntropy();\r
+            var ivStringBytes = Generate256BitsOfRandomEntropy();\r
+            var plainTextBytes = Encoding.UTF8.GetBytes(plainText);\r
+            using (var password = new Rfc2898DeriveBytes(helper, saltStringBytes, DerivationIterations))\r
+            {\r
+                var keyBytes = password.GetBytes(Keysize / 8);\r
+                using (var symmetricKey = new RijndaelManaged())\r
+                {\r
+                    symmetricKey.BlockSize = 256;\r
+                    symmetricKey.Mode = CipherMode.CBC;\r
+                    symmetricKey.Padding = PaddingMode.PKCS7;\r
+                    using (var encryptor = symmetricKey.CreateEncryptor(keyBytes, ivStringBytes))\r
+                    {\r
+                        using (var memoryStream = new MemoryStream())\r
+                        {\r
+                            using (var cryptoStream = new CryptoStream(memoryStream, encryptor, CryptoStreamMode.Write))\r
+                            {\r
+                                cryptoStream.Write(plainTextBytes, 0, plainTextBytes.Length);\r
+                                cryptoStream.FlushFinalBlock();\r
+                                // Create the final bytes as a concatenation of the random salt bytes, the random iv bytes and the cipher bytes.\r
+                                var cipherTextBytes = saltStringBytes;\r
+                                cipherTextBytes = cipherTextBytes.Concat(ivStringBytes).ToArray();\r
+                                cipherTextBytes = cipherTextBytes.Concat(memoryStream.ToArray()).ToArray();\r
+                                memoryStream.Close();\r
+                                cryptoStream.Close();\r
+                                return Convert.ToBase64String(cipherTextBytes);\r
+                                //return Encoding.UTF8.GetString(cipherTextBytes);\r
+                            }\r
+                        }\r
+                    }\r
+                }\r
+            }\r
+        }\r
+\r
+        public static string Decrypt(string cipherText)\r
+        {\r
+            // Get the complete stream of bytes that represent:\r
+            // [32 bytes of Salt] + [32 bytes of IV] + [n bytes of CipherText]\r
+            var cipherTextBytesWithSaltAndIv = Convert.FromBase64String(cipherText);\r
+            // Get the saltbytes by extracting the first 32 bytes from the supplied cipherText bytes.\r
+            var saltStringBytes = cipherTextBytesWithSaltAndIv.Take(Keysize / 8).ToArray();\r
+            // Get the IV bytes by extracting the next 32 bytes from the supplied cipherText bytes.\r
+            var ivStringBytes = cipherTextBytesWithSaltAndIv.Skip(Keysize / 8).Take(Keysize / 8).ToArray();\r
+            // Get the actual cipher text bytes by removing the first 64 bytes from the cipherText string.\r
+            var cipherTextBytes = cipherTextBytesWithSaltAndIv.Skip((Keysize / 8) * 2).Take(cipherTextBytesWithSaltAndIv.Length - ((Keysize / 8) * 2)).ToArray();\r
+\r
+            using (var password = new Rfc2898DeriveBytes(helper, saltStringBytes, DerivationIterations))\r
+            {\r
+                var keyBytes = password.GetBytes(Keysize / 8);\r
+                using (var symmetricKey = new RijndaelManaged())\r
+                {\r
+                    symmetricKey.BlockSize = 256;\r
+                    symmetricKey.Mode = CipherMode.CBC;\r
+                    symmetricKey.Padding = PaddingMode.PKCS7;\r
+                    using (var decryptor = symmetricKey.CreateDecryptor(keyBytes, ivStringBytes))\r
+                    {\r
+                        using (var memoryStream = new MemoryStream(cipherTextBytes))\r
+                        {\r
+                            using (var cryptoStream = new CryptoStream(memoryStream, decryptor, CryptoStreamMode.Read))\r
+                            {\r
+                                var plainTextBytes = new byte[cipherTextBytes.Length];\r
+                                var decryptedByteCount = cryptoStream.Read(plainTextBytes, 0, plainTextBytes.Length);\r
+                                memoryStream.Close();\r
+                                cryptoStream.Close();\r
+                                return Encoding.UTF8.GetString(plainTextBytes, 0, decryptedByteCount);\r
+                            }\r
+                        }\r
+                    }\r
+                }\r
+            }\r
+        }\r
+\r
+        private static byte[] Generate256BitsOfRandomEntropy()\r
+        {\r
+            var randomBytes = new byte[32]; // 32 Bytes will give us 256 bits.\r
+            using (var rngCsp = new RNGCryptoServiceProvider())\r
+            {\r
+                // Fill the array with cryptographically secure random bytes.\r
+                rngCsp.GetBytes(randomBytes);\r
+            }\r
+            return randomBytes;\r
+        }\r
+    }\r
+}\r