<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
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
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
--- /dev/null
+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
//[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
using Newtonsoft.Json;\r
+using PasswordEncrypter;\r
using System;\r
\r
namespace Maestro.Configuration {\r
}\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
"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
"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
"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
"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
"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
"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
],\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
"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
"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
"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
"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
"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
"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
"$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
"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
"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
"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
<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
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
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
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
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
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
return;\r
notification.BalloonTipText = tooltipText;\r
notification.Visible = true;\r
- notification.ShowBalloonTip(3);\r
+ notification.ShowBalloonTip(1);\r
}\r
\r
public void ShowForm() {\r
// 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
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
/// </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
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
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
\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
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
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
{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
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
--- /dev/null
+<?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
--- /dev/null
+<?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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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