├── SFTP_Help.pdf ├── Schema_Validation_help.pdf ├── Signature_Validation_help.pdf ├── Program.cs ├── Helpers ├── ExtensionMethods.cs ├── RSAPKCS1SHA256SignatureDescription.cs ├── ZipManager.cs ├── SFTPManager.cs ├── AesManager.cs └── XmlManager.cs ├── README.md ├── .gitignore ├── Form1.resx ├── LICENSE ├── Form1.cs └── Form1.Designer.cs /SFTP_Help.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IRSgov/IDES-Data-Preparation-Dot-Net/HEAD/SFTP_Help.pdf -------------------------------------------------------------------------------- /Schema_Validation_help.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IRSgov/IDES-Data-Preparation-Dot-Net/HEAD/Schema_Validation_help.pdf -------------------------------------------------------------------------------- /Signature_Validation_help.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IRSgov/IDES-Data-Preparation-Dot-Net/HEAD/Signature_Validation_help.pdf -------------------------------------------------------------------------------- /Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace WindowsFormsApplication1 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// The main entry point for the application. 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new MainForm()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Helpers/ExtensionMethods.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | 4 | namespace WindowsFormsApplication1 5 | { 6 | public static class ExtensionMethods 7 | { 8 | public static string ShowDialogWithFilter(this OpenFileDialog dialog, string filter) 9 | { 10 | dialog.Filter = filter; 11 | 12 | if (dialog.ShowDialog() == DialogResult.OK) 13 | { 14 | return dialog.FileName; 15 | } 16 | 17 | return string.Empty; 18 | } 19 | 20 | public static void DisplayException(this Exception ex, string messageBoxTitle) 21 | { 22 | string errorMessage = ex.GetBaseException().Message; 23 | 24 | if (errorMessage.Contains("password")) 25 | { 26 | // certificate password is incorrect 27 | MessageBox.Show("Specified certificate password is incorrect!", messageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); 28 | return; 29 | } 30 | 31 | // other error 32 | MessageBox.Show(errorMessage, messageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); 33 | } 34 | 35 | 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Helpers/RSAPKCS1SHA256SignatureDescription.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Security.Cryptography; 3 | 4 | namespace WindowsFormsApplication1 5 | { 6 | public sealed class RSAPKCS1SHA256SignatureDescription : SignatureDescription 7 | { 8 | public const string SignatureMethod = "http://" + "www.w3.org/2001/04/xmldsig-more#rsa-sha256"; 9 | public const string ReferenceDigestMethod = "http://" + "www.w3.org/2001/04/xmlenc#sha256"; 10 | 11 | public RSAPKCS1SHA256SignatureDescription() 12 | { 13 | KeyAlgorithm = typeof(RSACryptoServiceProvider).FullName; 14 | DigestAlgorithm = typeof(SHA256Managed).FullName; 15 | FormatterAlgorithm = typeof(RSAPKCS1SignatureFormatter).FullName; 16 | DeformatterAlgorithm = typeof(RSAPKCS1SignatureDeformatter).FullName; 17 | } 18 | 19 | public override AsymmetricSignatureDeformatter CreateDeformatter(AsymmetricAlgorithm key) 20 | { 21 | if (key == null) 22 | { 23 | throw new Exception("Invalid key specified for RSAPKCS1SHA256SignatureDescription!"); 24 | } 25 | 26 | RSAPKCS1SignatureDeformatter deformatter = new RSAPKCS1SignatureDeformatter(key); 27 | deformatter.SetHashAlgorithm("SHA256"); 28 | 29 | return deformatter; 30 | } 31 | 32 | public override AsymmetricSignatureFormatter CreateFormatter(AsymmetricAlgorithm key) 33 | { 34 | if (key == null) 35 | { 36 | throw new Exception("Invalid key specified for RSAPKCS1SHA256SignatureDescription!"); 37 | } 38 | 39 | RSAPKCS1SignatureFormatter formatter = new RSAPKCS1SignatureFormatter(key); 40 | formatter.SetHashAlgorithm("SHA256"); 41 | 42 | return formatter; 43 | } 44 | } 45 | } 46 | 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## IDES-Data-Preparation-Dot-Net 2 | The International Data Exchange Service (IDES) is a secure managed file transfer service that allows financial institutions and foreign tax authorities to securely send information on financial accounts held by U.S. taxpayers in accordance with the Foreign Account Tax Compliance Act (FATCA). 3 | 4 | IDES only accepts encrypted electronic submissions through a data preparation process. The following sample is one of many possible implementations of the data preparation process created for the .NET Framework. 5 | 6 | ## Privacy 7 | Privacy Notice: This service is controlled and operated by a third party and is not an official government website. By interacting with the IRS through this service, you may be providing non-government third parties access to your personal information. The IRS does not keep or share any personally identifiable information that you provide through this service. The IRS strongly discourages you from providing sensitive personally identifiable information (such as your social security number or tax account information) and will delete any comments containing such information without responding. 8 | 9 | [www.irs.gov](http://www.irs.gov) 10 | 11 | [Privacy Policy](http://www.irs.gov/privacy) 12 | 13 | ## Questions 14 | For more information review the [IDES FAQs](http://www.irs.gov/Businesses/Corporations/FATCA-IDES-Technical-FAQs) and IDES Data Preparation Troubleshooting Tips. Data Preparation questions can also be addressed to lbi.fatca.ides@irs.gov. 15 | 16 | ## Copyright and License 17 | Licensed under the [CC0 1.0 Universal](/LICENSE) (the "License"); you may not use this software except in compliance with the License. 18 | Unless expressly stated otherwise, the person who associated a work with this deed makes no warranties about the work, and disclaims liability for all uses of the work, to the fullest extent permitted by applicable law. When using or citing the work, you should not imply endorsement by the author or the affirmer. 19 | 20 | ## More Information 21 | To find out more, please vist the [IDES Data Preparation.Net]( http://irsgov.github.io/IDES-Data-Preparation-Dot-Net) page. 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.sln.docstates 8 | 9 | # Build results 10 | [Dd]ebug/ 11 | [Dd]ebugPublic/ 12 | [Rr]elease/ 13 | [Rr]eleases/ 14 | x64/ 15 | x86/ 16 | build/ 17 | bld/ 18 | [Bb]in/ 19 | [Oo]bj/ 20 | 21 | # Roslyn cache directories 22 | *.ide/ 23 | 24 | # MSTest test Results 25 | [Tt]est[Rr]esult*/ 26 | [Bb]uild[Ll]og.* 27 | 28 | #NUNIT 29 | *.VisualState.xml 30 | TestResult.xml 31 | 32 | # Build Results of an ATL Project 33 | [Dd]ebugPS/ 34 | [Rr]eleasePS/ 35 | dlldata.c 36 | 37 | *_i.c 38 | *_p.c 39 | *_i.h 40 | *.ilk 41 | *.meta 42 | *.obj 43 | *.pch 44 | *.pdb 45 | *.pgc 46 | *.pgd 47 | *.rsp 48 | *.sbr 49 | *.tlb 50 | *.tli 51 | *.tlh 52 | *.tmp 53 | *.tmp_proj 54 | *.log 55 | *.vspscc 56 | *.vssscc 57 | .builds 58 | *.pidb 59 | *.svclog 60 | *.scc 61 | 62 | # Chutzpah Test files 63 | _Chutzpah* 64 | 65 | # Visual C++ cache files 66 | ipch/ 67 | *.aps 68 | *.ncb 69 | *.opensdf 70 | *.sdf 71 | *.cachefile 72 | 73 | # Visual Studio profiler 74 | *.psess 75 | *.vsp 76 | *.vspx 77 | 78 | # TFS 2012 Local Workspace 79 | $tf/ 80 | 81 | # Guidance Automation Toolkit 82 | *.gpState 83 | 84 | # ReSharper is a .NET coding add-in 85 | _ReSharper*/ 86 | *.[Rr]e[Ss]harper 87 | *.DotSettings.user 88 | 89 | # JustCode is a .NET coding addin-in 90 | .JustCode 91 | 92 | # TeamCity is a build add-in 93 | _TeamCity* 94 | 95 | # DotCover is a Code Coverage Tool 96 | *.dotCover 97 | 98 | # NCrunch 99 | _NCrunch_* 100 | .*crunch*.local.xml 101 | 102 | # MightyMoose 103 | *.mm.* 104 | AutoTest.Net/ 105 | 106 | # Web workbench (sass) 107 | .sass-cache/ 108 | 109 | # Installshield output folder 110 | [Ee]xpress/ 111 | 112 | # DocProject is a documentation generator add-in 113 | DocProject/buildhelp/ 114 | DocProject/Help/*.HxT 115 | DocProject/Help/*.HxC 116 | DocProject/Help/*.hhc 117 | DocProject/Help/*.hhk 118 | DocProject/Help/*.hhp 119 | DocProject/Help/Html2 120 | DocProject/Help/html 121 | 122 | # Click-Once directory 123 | publish/ 124 | 125 | # Publish Web Output 126 | *.[Pp]ublish.xml 127 | *.azurePubxml 128 | # TODO: Comment the next line if you want to checkin your web deploy settings 129 | # but database connection strings (with potential passwords) will be unencrypted 130 | *.pubxml 131 | *.publishproj 132 | 133 | # NuGet Packages 134 | *.nupkg 135 | # The packages folder can be ignored because of Package Restore 136 | **/packages/* 137 | # except build/, which is used as an MSBuild target. 138 | !**/packages/build/ 139 | # If using the old MSBuild-Integrated Package Restore, uncomment this: 140 | #!**/packages/repositories.config 141 | 142 | # Windows Azure Build Output 143 | csx/ 144 | *.build.csdef 145 | 146 | # Windows Store app package directory 147 | AppPackages/ 148 | 149 | # Others 150 | sql/ 151 | *.Cache 152 | ClientBin/ 153 | [Ss]tyle[Cc]op.* 154 | ~$* 155 | *~ 156 | *.dbmdl 157 | *.dbproj.schemaview 158 | *.pfx 159 | *.publishsettings 160 | node_modules/ 161 | 162 | # RIA/Silverlight projects 163 | Generated_Code/ 164 | 165 | # Backup & report files from converting an old project file 166 | # to a newer Visual Studio version. Backup files are not needed, 167 | # because we have git ;-) 168 | _UpgradeReport_Files/ 169 | Backup*/ 170 | UpgradeLog*.XML 171 | UpgradeLog*.htm 172 | 173 | # SQL Server files 174 | *.mdf 175 | *.ldf 176 | 177 | # Business Intelligence projects 178 | *.rdl.data 179 | *.bim.layout 180 | *.bim_*.settings 181 | 182 | # Microsoft Fakes 183 | FakesAssemblies/ 184 | -------------------------------------------------------------------------------- /Helpers/ZipManager.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.IO.Compression; 3 | 4 | namespace WindowsFormsApplication1 5 | { 6 | class ZipManager 7 | { 8 | 9 | /// 10 | /// This will create a zip archive 11 | /// 12 | /// The path to the file that will be compressed 13 | /// The name of the zip file that will be created 14 | /// 15 | public static void CreateArchive(string inputFileName, string outputFileName) 16 | { 17 | using (FileStream fs = new FileStream(outputFileName, FileMode.Create, FileAccess.Write)) 18 | { 19 | using (ZipArchive archive = new ZipArchive(fs, ZipArchiveMode.Create)) 20 | { 21 | string entryName = Path.GetFileName(inputFileName); 22 | archive.CreateEntryFromFile(inputFileName, entryName, CompressionLevel.Optimal); 23 | } 24 | } 25 | } 26 | 27 | /// 28 | /// This will add a file to an archive 29 | /// 30 | /// The path to the file that will be compressed 31 | /// The name of the zip file that will be modified 32 | /// 33 | public static void UpdateArchive(string inputFileName, string outputFileName) 34 | { 35 | using (FileStream fs = new FileStream(outputFileName, FileMode.Open, FileAccess.ReadWrite)) 36 | { 37 | using (ZipArchive archive = new ZipArchive(fs, ZipArchiveMode.Update)) 38 | { 39 | string entryName = Path.GetFileName(inputFileName); 40 | archive.CreateEntryFromFile(inputFileName, entryName, CompressionLevel.Optimal); 41 | } 42 | } 43 | } 44 | 45 | /// 46 | /// This will decompress a zip file 47 | /// 48 | /// The path to the file that will be decompressed 49 | /// The path of the folder that will contain the decompressed files 50 | /// The path of the decompressed folder 51 | public static string ExtractArchive(string inputFileName, string outputFolder) 52 | { 53 | string zipFileName = Path.GetFileNameWithoutExtension(inputFileName); 54 | string zipFolderPath = outputFolder + "\\" + zipFileName; 55 | 56 | using (ZipArchive archive = ZipFile.Open(inputFileName, ZipArchiveMode.Update)) 57 | { 58 | 59 | archive.ExtractToDirectory(zipFolderPath); 60 | } 61 | 62 | return zipFolderPath; 63 | 64 | } 65 | 66 | /// 67 | /// This will decompress a zip file, but is used when there is no need to return the decompressed folder name 68 | /// 69 | /// The path to the file that will be decompressed 70 | /// The path of the folder that will contain the decompressed files 71 | /// 72 | public static void ExtractArchive(string inputFileName, string outputFolder, bool noPath) 73 | { 74 | 75 | string zipFileName = Path.GetFileName(inputFileName); 76 | string zipFolderPath = inputFileName.Replace(zipFileName, ""); 77 | 78 | using (ZipArchive archive = ZipFile.Open(inputFileName, ZipArchiveMode.Update)) 79 | { 80 | 81 | archive.ExtractToDirectory(outputFolder); 82 | } 83 | 84 | } 85 | } 86 | 87 | 88 | 89 | 90 | } 91 | -------------------------------------------------------------------------------- /Form1.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | 124 | 116, 17 125 | 126 | 127 | 210, 17 128 | 129 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | CC0 1.0 Universal 2 | 3 | Statement of Purpose 4 | 5 | The laws of most jurisdictions throughout the world automatically confer 6 | exclusive Copyright and Related Rights (defined below) upon the creator and 7 | subsequent owner(s) (each and all, an "owner") of an original work of 8 | authorship and/or a database (each, a "Work"). 9 | 10 | Certain owners wish to permanently relinquish those rights to a Work for the 11 | purpose of contributing to a commons of creative, cultural and scientific 12 | works ("Commons") that the public can reliably and without fear of later 13 | claims of infringement build upon, modify, incorporate in other works, reuse 14 | and redistribute as freely as possible in any form whatsoever and for any 15 | purposes, including without limitation commercial purposes. These owners may 16 | contribute to the Commons to promote the ideal of a free culture and the 17 | further production of creative, cultural and scientific works, or to gain 18 | reputation or greater distribution for their Work in part through the use and 19 | efforts of others. 20 | 21 | For these and/or other purposes and motivations, and without any expectation 22 | of additional consideration or compensation, the person associating CC0 with a 23 | Work (the "Affirmer"), to the extent that he or she is an owner of Copyright 24 | and Related Rights in the Work, voluntarily elects to apply CC0 to the Work 25 | and publicly distribute the Work under its terms, with knowledge of his or her 26 | Copyright and Related Rights in the Work and the meaning and intended legal 27 | effect of CC0 on those rights. 28 | 29 | 1. Copyright and Related Rights. A Work made available under CC0 may be 30 | protected by copyright and related or neighboring rights ("Copyright and 31 | Related Rights"). Copyright and Related Rights include, but are not limited 32 | to, the following: 33 | 34 | i. the right to reproduce, adapt, distribute, perform, display, communicate, 35 | and translate a Work; 36 | 37 | ii. moral rights retained by the original author(s) and/or performer(s); 38 | 39 | iii. publicity and privacy rights pertaining to a person's image or likeness 40 | depicted in a Work; 41 | 42 | iv. rights protecting against unfair competition in regards to a Work, 43 | subject to the limitations in paragraph 4(a), below; 44 | 45 | v. rights protecting the extraction, dissemination, use and reuse of data in 46 | a Work; 47 | 48 | vi. database rights (such as those arising under Directive 96/9/EC of the 49 | European Parliament and of the Council of 11 March 1996 on the legal 50 | protection of databases, and under any national implementation thereof, 51 | including any amended or successor version of such directive); and 52 | 53 | vii. other similar, equivalent or corresponding rights throughout the world 54 | based on applicable law or treaty, and any national implementations thereof. 55 | 56 | 2. Waiver. To the greatest extent permitted by, but not in contravention of, 57 | applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and 58 | unconditionally waives, abandons, and surrenders all of Affirmer's Copyright 59 | and Related Rights and associated claims and causes of action, whether now 60 | known or unknown (including existing as well as future claims and causes of 61 | action), in the Work (i) in all territories worldwide, (ii) for the maximum 62 | duration provided by applicable law or treaty (including future time 63 | extensions), (iii) in any current or future medium and for any number of 64 | copies, and (iv) for any purpose whatsoever, including without limitation 65 | commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes 66 | the Waiver for the benefit of each member of the public at large and to the 67 | detriment of Affirmer's heirs and successors, fully intending that such Waiver 68 | shall not be subject to revocation, rescission, cancellation, termination, or 69 | any other legal or equitable action to disrupt the quiet enjoyment of the Work 70 | by the public as contemplated by Affirmer's express Statement of Purpose. 71 | 72 | 3. Public License Fallback. Should any part of the Waiver for any reason be 73 | judged legally invalid or ineffective under applicable law, then the Waiver 74 | shall be preserved to the maximum extent permitted taking into account 75 | Affirmer's express Statement of Purpose. In addition, to the extent the Waiver 76 | is so judged Affirmer hereby grants to each affected person a royalty-free, 77 | non transferable, non sublicensable, non exclusive, irrevocable and 78 | unconditional license to exercise Affirmer's Copyright and Related Rights in 79 | the Work (i) in all territories worldwide, (ii) for the maximum duration 80 | provided by applicable law or treaty (including future time extensions), (iii) 81 | in any current or future medium and for any number of copies, and (iv) for any 82 | purpose whatsoever, including without limitation commercial, advertising or 83 | promotional purposes (the "License"). The License shall be deemed effective as 84 | of the date CC0 was applied by Affirmer to the Work. Should any part of the 85 | License for any reason be judged legally invalid or ineffective under 86 | applicable law, such partial invalidity or ineffectiveness shall not 87 | invalidate the remainder of the License, and in such case Affirmer hereby 88 | affirms that he or she will not (i) exercise any of his or her remaining 89 | Copyright and Related Rights in the Work or (ii) assert any associated claims 90 | and causes of action with respect to the Work, in either case contrary to 91 | Affirmer's express Statement of Purpose. 92 | 93 | 4. Limitations and Disclaimers. 94 | 95 | a. No trademark or patent rights held by Affirmer are waived, abandoned, 96 | surrendered, licensed or otherwise affected by this document. 97 | 98 | b. Affirmer offers the Work as-is and makes no representations or warranties 99 | of any kind concerning the Work, express, implied, statutory or otherwise, 100 | including without limitation warranties of title, merchantability, fitness 101 | for a particular purpose, non infringement, or the absence of latent or 102 | other defects, accuracy, or the present or absence of errors, whether or not 103 | discoverable, all to the greatest extent permissible under applicable law. 104 | 105 | c. Affirmer disclaims responsibility for clearing rights of other persons 106 | that may apply to the Work or any use thereof, including without limitation 107 | any person's Copyright and Related Rights in the Work. Further, Affirmer 108 | disclaims responsibility for obtaining any necessary consents, permissions 109 | or other rights required for any use of the Work. 110 | 111 | d. Affirmer understands and acknowledges that Creative Commons is not a 112 | party to this document and has no duty or obligation with respect to this 113 | CC0 or use of the Work. 114 | 115 | For more information, please see 116 | 117 | -------------------------------------------------------------------------------- /Helpers/SFTPManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using WinSCP; 7 | 8 | namespace WindowsFormsApplication1 9 | { 10 | class SFTPManager 11 | { 12 | 13 | /// 14 | /// This will create an SFTP Session that can be used to open a connection 15 | /// 16 | /// The URL of the SFTP server 17 | /// The username for the account that will be used on the SFTP server 18 | /// The password for the account that will be used on the SFTP server 19 | /// The sessionOptions object 20 | public static SessionOptions CreateSFTPSession(string server, string username, string password) 21 | { 22 | 23 | if (string.IsNullOrWhiteSpace(username)) 24 | { 25 | // username validation 26 | throw new Exception("The SFTP Username must be set!"); 27 | } 28 | 29 | if (string.IsNullOrWhiteSpace(password)) 30 | { 31 | // password validation 32 | throw new Exception("The SFTP Password must be set!"); 33 | } 34 | 35 | if (string.IsNullOrWhiteSpace(server)) 36 | { 37 | // server validation 38 | throw new Exception("The SFTP Server must be set!"); 39 | } 40 | 41 | var sftpServer = server.Split(':')[1].Trim(); 42 | var serverType = server.Split(':')[0].Trim(); 43 | string fingerprint = ""; 44 | // not currently used - SAT SshHostKeyFingerprint = "ssh-rsa 2048 64:25:44:96:0d:db:cc:10:3b:80:f3:2d:0e:24:bf:75" 45 | if (serverType == "PRODUCTION") { 46 | fingerprint = "ssh-rsa 2048 8a:8e:04:ad:07:7d:e4:20:f0:ba:93:9d:4c:6a:95:50"; 47 | } 48 | else if (serverType == "TEST") 49 | { 50 | fingerprint = "ssh-rsa 2048 ca:8f:be:b4:c6:92:58:ef:3b:b2:d1:fd:63:c0:8e:a5"; 51 | } 52 | else 53 | { 54 | fingerprint = "ssh-rsa 2048 64:25:44:96:0d:db:cc:10:3b:80:f3:2d:0e:24:bf:75"; 55 | } 56 | // Setup session options 57 | SessionOptions sessionOptions = new SessionOptions 58 | { 59 | Protocol = Protocol.Sftp, 60 | HostName = sftpServer, 61 | UserName = username, 62 | Password = password, 63 | PortNumber = 4022, 64 | SshHostKeyFingerprint = fingerprint 65 | }; 66 | 67 | return sessionOptions; 68 | 69 | 70 | } 71 | 72 | /// 73 | /// This will connect to the Inbox/840 folder and download any notifications found there - if not previously downloaded based on our log file 74 | /// 75 | /// This holds the connection information such as server and account credentials 76 | /// This holds our log file information on transfers 77 | /// The folder that will hold the downloaded files 78 | /// 79 | public static void DownloadInbox(SessionOptions sessionOptions, Dictionary transmissions, string downloadFolder) 80 | { 81 | 82 | string folderCheck = downloadFolder.Substring(downloadFolder.Length - 1, 1); 83 | if (folderCheck != "\\") 84 | { 85 | downloadFolder = downloadFolder + "\\"; 86 | } 87 | 88 | using (Session session = new Session()) 89 | { 90 | // Connect 91 | session.Open(sessionOptions); 92 | 93 | RemoteDirectoryInfo directory = session.ListDirectory("/Inbox/840/"); 94 | TransferOptions transferOptions = new TransferOptions(); 95 | transferOptions.TransferMode = TransferMode.Binary; 96 | 97 | 98 | foreach (RemoteFileInfo fileInfo in directory.Files) 99 | { 100 | //if the length is greater than 2, there is a file for download 101 | //we will check our log file to see if this one has already been downloaded and processed 102 | if (fileInfo.Name.Length > 2) 103 | { 104 | 105 | //check to see if this is in our transmission log file 106 | if (transmissions.ContainsKey(fileInfo.Name) == false) 107 | { 108 | //we will download the file and try to match it with 109 | TransferOperationResult transferResult; 110 | transferResult = session.GetFiles("/Inbox/840/" + fileInfo.Name, downloadFolder + fileInfo.Name, false, transferOptions); 111 | 112 | // Throw on any error 113 | transferResult.Check(); 114 | 115 | // SFTP options can be logged here if needed 116 | //foreach (TransferEventArgs transfer in transferResult.Transfers) 117 | //{ 118 | // Console.WriteLine("Download of {0} succeeded", transfer.FileName); 119 | //} 120 | } 121 | 122 | } 123 | 124 | } 125 | session.Close(); 126 | } 127 | } 128 | 129 | /// 130 | /// This will connect to the Outbox/840 folder and upload a data packet 131 | /// 132 | /// This holds the connection information such as server and account credentials 133 | /// The path to the file being uploaded 134 | /// 135 | public static string UploadFile(SessionOptions sessionOptions, string filename) 136 | { 137 | 138 | using (Session session = new Session()) 139 | { 140 | // Connect 141 | session.Open(sessionOptions); 142 | 143 | // Upload files 144 | TransferOptions transferOptions = new TransferOptions(); 145 | transferOptions.TransferMode = TransferMode.Binary; 146 | //transferOptions.ResumeSupport.State = false; 147 | 148 | TransferOperationResult transferResult; 149 | transferResult = session.PutFiles(@filename, "/Outbox/840/", false, transferOptions); 150 | 151 | // Throw on any error 152 | transferResult.Check(); 153 | 154 | // Print results 155 | string thisResult = ""; 156 | foreach (TransferEventArgs transfer in transferResult.Transfers) 157 | { 158 | //SFTP options can be logged here, if needed 159 | //Console.WriteLine("Upload of {0} succeeded", transfer.FileName); 160 | thisResult = "Upload of " + transfer.FileName + " succeeded"; 161 | } 162 | session.Close(); 163 | 164 | return thisResult; 165 | } 166 | } 167 | 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /Helpers/AesManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Security.Cryptography; 4 | using System.Security.Cryptography.X509Certificates; 5 | using System.Linq; 6 | 7 | namespace WindowsFormsApplication1 8 | { 9 | class AesManager 10 | { 11 | private const int bufferSize = 1024 * 8; 12 | private const int keySize = 256; 13 | 14 | /// 15 | /// AES key size 16 | /// 17 | public static int KeySize 18 | { 19 | get 20 | { 21 | return keySize; 22 | } 23 | } 24 | 25 | /// 26 | /// Generates a random key of the specified size 27 | /// 28 | /// The length of the key to generate 29 | /// If true all bytes will contain zeroes 30 | /// A random key represented as byte array 31 | public static byte[] GenerateRandomKey(int length, bool emptyBytes = false) 32 | { 33 | byte[] key = new byte[length]; 34 | 35 | if (emptyBytes) 36 | { 37 | return key; 38 | } 39 | 40 | using (RNGCryptoServiceProvider random = new RNGCryptoServiceProvider()) 41 | { 42 | random.GetBytes(key); 43 | } 44 | 45 | return key; 46 | } 47 | 48 | /// 49 | /// Encrypts a file with AES 50 | /// 51 | /// Full path of the file to be encrypted 52 | /// Full path of the encrypted file 53 | /// AES encryption key 54 | /// AES initialization vector 55 | /// boolean to determine if ECB or CBC mode is used 56 | public static void EncryptFile(string filePath, string outputFilePath, byte[] key, byte[] iv, bool useECBMode) 57 | { 58 | using (AesCryptoServiceProvider aes = new AesCryptoServiceProvider()) 59 | { 60 | if(useECBMode) 61 | aes.Mode = CipherMode.ECB; 62 | else 63 | aes.Mode = CipherMode.CBC; 64 | 65 | aes.Key = key; 66 | aes.IV = iv; 67 | 68 | 69 | using (ICryptoTransform cryptoTransform = aes.CreateEncryptor(aes.Key, aes.IV)) 70 | { 71 | using (FileStream plain = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.Read)) 72 | { 73 | using (FileStream encrypted = File.Open(outputFilePath, FileMode.Create, FileAccess.Write, FileShare.None)) 74 | { 75 | using (CryptoStream cs = new CryptoStream(encrypted, cryptoTransform, CryptoStreamMode.Write)) 76 | { 77 | plain.CopyTo(cs, bufferSize); 78 | } 79 | } 80 | } 81 | } 82 | } 83 | } 84 | 85 | /// 86 | /// Decrypts a file encrypted with AES 87 | /// 88 | /// Full path of the file to be decrypted 89 | /// Full path of the decrypted file 90 | /// AES decryption key 91 | /// AES initialization vector 92 | public static void DecryptFile(string filePath, string outputFilePath, byte[] key, byte[] iv, bool useECBMode) 93 | { 94 | using (AesCryptoServiceProvider aes = new AesCryptoServiceProvider()) 95 | { 96 | if (useECBMode) 97 | aes.Mode = CipherMode.ECB; 98 | else 99 | aes.Mode = CipherMode.CBC; 100 | 101 | aes.Key = key; 102 | aes.IV = iv; 103 | 104 | using (ICryptoTransform cryptoTransform = aes.CreateDecryptor(aes.Key, aes.IV)) 105 | { 106 | using (FileStream encrypted = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.Read)) 107 | { 108 | using (FileStream plain = File.Open(outputFilePath, FileMode.Create, FileAccess.Write, FileShare.None)) 109 | { 110 | using (CryptoStream cs = new CryptoStream(plain, cryptoTransform, CryptoStreamMode.Write)) 111 | { 112 | encrypted.CopyTo(cs, bufferSize); 113 | } 114 | } 115 | } 116 | } 117 | } 118 | } 119 | 120 | /// 121 | /// Encrypts a key using the public key from the specified certificate 122 | /// 123 | /// The data to encrypt 124 | /// The IV to encrypt - ONLY FOR CBC 125 | /// The certificate used for encryption 126 | /// The password for the encryption certificate 127 | /// Full path of the encrypted file 128 | /// boolean to determine if ECB or CBC mode is used 129 | public static void EncryptAesKey(byte[] payload, byte[] payloadIV, string encryptionCert, string encryptionCertPassword, string outputFilePath, bool useECBMode) 130 | { 131 | X509Certificate2 cert = new X509Certificate2(encryptionCert, encryptionCertPassword); 132 | 133 | //If we are not using ECB mode, we need to add the IV to the key before we encrypt 134 | if(useECBMode != true) 135 | { 136 | payload = payload.Concat(payloadIV).ToArray(); 137 | } 138 | 139 | using (RSACryptoServiceProvider rsa = cert.PublicKey.Key as RSACryptoServiceProvider) 140 | { 141 | byte[] encryptedKey = rsa.Encrypt(payload, false); 142 | File.WriteAllBytes(outputFilePath, encryptedKey); 143 | } 144 | } 145 | 146 | /// 147 | /// Decrypts a key using the private key from the specified certificate 148 | /// 149 | /// The data to decrypt 150 | /// The certificate used for decryption 151 | /// The password for the decryption certificate 152 | /// Decrypted key represented as byte array 153 | public static byte[] DecryptAesKey(byte[] payload, string encryptionCert, string encryptionCertPassword) 154 | { 155 | X509Certificate2 cert = new X509Certificate2(encryptionCert, encryptionCertPassword); 156 | 157 | if (!cert.HasPrivateKey) 158 | { 159 | // invalid certificate 160 | throw new Exception("Specified certificate not suitable for decryption!"); 161 | } 162 | 163 | using (RSACryptoServiceProvider rsa = cert.PrivateKey as RSACryptoServiceProvider) 164 | { 165 | 166 | return rsa.Decrypt(payload, false); 167 | } 168 | } 169 | 170 | /// 171 | /// This will decrypt the payload from a downloaded and decompressed notification 172 | /// 173 | /// The path to folder that contains the decompressed notification files 174 | /// The key file used to decrypt the AES key 175 | /// The password to the key file above 176 | /// Determines the cipher mode, CBC or ECB 177 | /// the file path to the decrypted payload file 178 | public static string DecryptNotification(string xmlProcessingFolder, string decryptionKey, string decryptionPass, bool isECB) 179 | { 180 | // select encrypted key file 181 | string encryptedKeyFile = ""; 182 | string encryptedPayloadFile = ""; 183 | string metadataFile = ""; 184 | string[] keyFiles = Directory.GetFiles(xmlProcessingFolder, "*_Key", SearchOption.TopDirectoryOnly); 185 | string[] payloadFiles = Directory.GetFiles(xmlProcessingFolder, "*_Payload", SearchOption.TopDirectoryOnly); 186 | string[] metadataFiles = Directory.GetFiles(xmlProcessingFolder, "*_Metadata*", SearchOption.TopDirectoryOnly); 187 | 188 | if (keyFiles.Length == 0) 189 | { 190 | // key file validation 191 | throw new Exception("There was no file found containing the encrypted AES key!"); 192 | } 193 | if (payloadFiles.Length == 0) 194 | { 195 | // key file validation 196 | throw new Exception("There was no file found containing the encrypted Payload!"); 197 | } 198 | if (metadataFiles.Length == 0) 199 | { 200 | // key file validation 201 | throw new Exception("There was no file found containing the Metadata!"); 202 | } 203 | 204 | encryptedKeyFile = keyFiles[0]; 205 | encryptedPayloadFile = payloadFiles[0]; 206 | metadataFile = metadataFiles[0]; 207 | 208 | //Check the metadata and see what we have 209 | string metadataContentType = XmlManager.CheckMetadataType(metadataFile); 210 | 211 | byte[] encryptedAesKey = null; 212 | byte[] decryptedAesKey = null; 213 | byte[] aesVector = null; 214 | string decryptedPayload = ""; 215 | 216 | // load encrypted AES key 217 | encryptedAesKey = File.ReadAllBytes(encryptedKeyFile); 218 | 219 | // decrypt AES key & generate default (empty) initialization vector 220 | decryptedAesKey = AesManager.DecryptAesKey(encryptedAesKey, decryptionKey, decryptionPass); 221 | aesVector = AesManager.GenerateRandomKey(16, true); 222 | if (isECB != true) 223 | { 224 | aesVector = decryptedAesKey.Skip(32).Take(16).ToArray(); 225 | decryptedAesKey = decryptedAesKey.Take(32).ToArray(); 226 | } 227 | 228 | // decrypt encrypted ZIP file using decrypted AES key 229 | string decryptedFileName = encryptedPayloadFile.Replace("_Payload", "_Payload_decrypted.zip"); 230 | AesManager.DecryptFile(encryptedPayloadFile, decryptedFileName, decryptedAesKey, aesVector, isECB); 231 | 232 | //Deflate the decrypted zip archive 233 | ZipManager.ExtractArchive(decryptedFileName, xmlProcessingFolder, true); 234 | decryptedPayload = decryptedFileName.Replace("_Payload_decrypted.zip", "_Payload.xml"); 235 | 236 | //If the metadata is something other than XML, read the wrapper and rebuild the non-XML file 237 | if (metadataContentType != "XML") 238 | { 239 | //Some non-XML files may not have _Payload in the file name, if not remove it 240 | if (!File.Exists(decryptedPayload)) 241 | { 242 | decryptedPayload = decryptedPayload.Replace("_Payload.xml", ".xml"); 243 | } 244 | 245 | //This will give us the base64 encoded data from the XML file 246 | string encodedData = XmlManager.ExtractXMLImageData(decryptedPayload); 247 | 248 | //We will convert the base64 data back to bytes 249 | byte[] binaryData; 250 | string decodedPayload = decryptedPayload.Replace(".xml", "." + metadataContentType); 251 | binaryData = System.Convert.FromBase64String(encodedData); 252 | 253 | //We can write the bytes back to rebuild the file 254 | FileStream decodedFile; 255 | decodedFile = new FileStream(decodedPayload, System.IO.FileMode.Create, System.IO.FileAccess.Write); 256 | decodedFile.Write(binaryData, 0, binaryData.Length); 257 | decodedFile.Close(); 258 | 259 | } 260 | 261 | return decryptedPayload; 262 | 263 | } 264 | } 265 | } 266 | -------------------------------------------------------------------------------- /Helpers/XmlManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Security.Cryptography; 4 | using System.Security.Cryptography.X509Certificates; 5 | using System.Security.Cryptography.Xml; 6 | using System.Text; 7 | using System.Xml; 8 | using System.Xml.Schema; 9 | using System.Xml.Linq; 10 | using System.Linq; 11 | using System.Collections.Generic; 12 | 13 | namespace WindowsFormsApplication1 14 | { 15 | 16 | public delegate string schemaValidationEventHandler(object sender, ValidationEventArgs e); 17 | /// 18 | /// The type of signature to perform 19 | /// 20 | public enum XmlSignatureType 21 | { 22 | 23 | Enveloping, 24 | NonXML 25 | } 26 | 27 | class XmlManager 28 | { 29 | #region Private methods 30 | /// 31 | /// Creates a KeyInfo object based on information from specified certificate 32 | /// 33 | /// The certificate used to create the KeyInfo from 34 | /// KeyInfo object 35 | private static KeyInfo CreateKeyInfoFromCertificate(X509Certificate2 certificate) 36 | { 37 | // create KeyInfoX509Data object & include certificate subject 38 | KeyInfoX509Data kiData = new KeyInfoX509Data(certificate); 39 | kiData.AddSubjectName(certificate.Subject); 40 | 41 | // create KeyInfo object with specified KeyInfoX509Data 42 | KeyInfo keyInfo = new KeyInfo(); 43 | keyInfo.AddClause(kiData); 44 | 45 | return keyInfo; 46 | } 47 | 48 | /// 49 | /// Gets the RSA private key from the specified signing certificate 50 | /// 51 | /// The certificate used to extract the key from 52 | /// RSACryptoServiceProvider object 53 | private static RSACryptoServiceProvider GetSigningRsaKeyFromCertificate(X509Certificate2 certificate) 54 | { 55 | RSACryptoServiceProvider key = new RSACryptoServiceProvider(new CspParameters(24)); 56 | key.FromXmlString(certificate.PrivateKey.ToXmlString(true)); 57 | 58 | return key; 59 | } 60 | 61 | /// 62 | /// Loads the specified certificate using specific storage flags for SHA-256 63 | /// 64 | /// The certificate file to open 65 | /// The certificate password 66 | /// Sign the document using SHA-256 67 | /// X509Certificate2 object 68 | private static X509Certificate2 LoadSigningCertificate(string certFile, string certPassword, bool signWithSha256) 69 | { 70 | X509Certificate2 certificate = null; 71 | 72 | if (signWithSha256) 73 | { 74 | // register SHA-256 and open certificate with exportable private key 75 | CryptoConfig.AddAlgorithm(typeof(RSAPKCS1SHA256SignatureDescription), RSAPKCS1SHA256SignatureDescription.SignatureMethod); 76 | certificate = new X509Certificate2(certFile, certPassword, X509KeyStorageFlags.Exportable); 77 | } 78 | else 79 | { 80 | // open certificate with password (to be able to access the private key) 81 | certificate = new X509Certificate2(certFile, certPassword); 82 | } 83 | 84 | return certificate; 85 | } 86 | 87 | /// 88 | /// Generates a SignedXml object 89 | /// 90 | /// The XML data to sign represented as XmlDocument object 91 | /// The certificate used for signing represented as X509Certificate2 object 92 | /// Sign the document using SHA-256 93 | /// 94 | private static SignedXml GenerateSignedXml(XmlDocument doc, X509Certificate2 certificate, bool signWithSha256) 95 | { 96 | // create new SignedXml from XmlDocument 97 | SignedXml signed = new SignedXml(doc); 98 | 99 | if (signWithSha256) 100 | { 101 | // set signing key and signature method for SHA-256 102 | signed.SigningKey = GetSigningRsaKeyFromCertificate(certificate); 103 | signed.SignedInfo.SignatureMethod = RSAPKCS1SHA256SignatureDescription.SignatureMethod; 104 | } 105 | else 106 | { 107 | // set signing key and signature method for SHA-1 108 | signed.SigningKey = certificate.PrivateKey; 109 | } 110 | 111 | return signed; 112 | } 113 | 114 | /// 115 | /// Signs a XML file (enveloped signature) using a digital certificate 116 | /// 117 | /// The XML data to sign represented as byte array 118 | /// The certificate file to use for signing 119 | /// The certificate password 120 | /// Sign the document using SHA-256 121 | /// The signed data represented as byte array 122 | private static byte[] SignEnvelopedXml(byte[] xml, string certFile, string certPassword, bool signWithSha256) 123 | { 124 | if (xml == null || xml.Length == 0) 125 | { 126 | // invalid XML array 127 | throw new Exception("Nothing to sign!"); 128 | } 129 | 130 | // load certificate 131 | X509Certificate2 certificate = LoadSigningCertificate(certFile, certPassword, signWithSha256); 132 | 133 | if (!certificate.HasPrivateKey) 134 | { 135 | // invalid certificate 136 | throw new Exception("Specified certificate not suitable for signing!"); 137 | } 138 | 139 | using (MemoryStream stream = new MemoryStream(xml)) 140 | { 141 | // go to the beginning of the stream 142 | stream.Flush(); 143 | stream.Position = 0; 144 | 145 | // create new XmlDocument from stream 146 | XmlDocument doc = new XmlDocument() { PreserveWhitespace = true }; 147 | doc.Load(stream); 148 | 149 | // create new SignedXml from XmlDocument 150 | SignedXml signed = GenerateSignedXml(doc, certificate, signWithSha256); 151 | 152 | // create reference & add enveloped transform 153 | Reference reference = new Reference(string.Empty); 154 | reference.AddTransform(new XmlDsigEnvelopedSignatureTransform()); 155 | 156 | if (signWithSha256) 157 | { 158 | // SHA-256 digest 159 | reference.DigestMethod = RSAPKCS1SHA256SignatureDescription.ReferenceDigestMethod; 160 | } 161 | 162 | // add reference to document 163 | signed.AddReference(reference); 164 | 165 | // include KeyInfo object & compute signature 166 | signed.KeyInfo = CreateKeyInfoFromCertificate(certificate); 167 | signed.ComputeSignature(); 168 | 169 | // get signature & append node 170 | XmlElement xmlDigitalSignature = signed.GetXml(); 171 | doc.DocumentElement.AppendChild(doc.ImportNode(xmlDigitalSignature, true)); 172 | 173 | // returned content as byte array 174 | return Encoding.UTF8.GetBytes(doc.OuterXml); 175 | } 176 | } 177 | 178 | /// 179 | /// Signs a XML file (enveloping signature) using a digital certificate 180 | /// 181 | /// Used for non-xml, the root path of the document being signed, used for temporary encoding file 182 | /// This will be XML or Non-XML 183 | /// The XML data to sign represented as byte array 184 | /// The certificate file to use for signing 185 | /// The certificate password 186 | /// Sign the document using SHA-256 187 | /// The signed data represented as byte array 188 | private static byte[] SignEnvelopingXml(XmlSignatureType signatureType, byte[] xml, string certFile, string certPassword, bool signWithSha256, string encodingPath = "") 189 | { 190 | if (xml == null || xml.Length == 0) 191 | { 192 | // invalid XML array 193 | throw new Exception("Nothing to sign!"); 194 | } 195 | 196 | // load certificate 197 | X509Certificate2 certificate = LoadSigningCertificate(certFile, certPassword, signWithSha256); 198 | 199 | if (!certificate.HasPrivateKey) 200 | { 201 | // invalid certificate 202 | throw new Exception("Specified certificate not suitable for signing!"); 203 | } 204 | 205 | //If this is NOT XML, then we have to convert it and stick it in XML first 206 | if (signatureType == XmlSignatureType.NonXML) 207 | { 208 | //base64 encode it 209 | string strEncodedImage; 210 | strEncodedImage = System.Convert.ToBase64String(xml, 0,xml.Length); 211 | 212 | //create a small xml file and put the encoded Image data inside 213 | // Create an XmlWriterSettings object with the correct options. 214 | XmlWriter writer = null; 215 | XmlWriterSettings settings = new XmlWriterSettings(); 216 | settings.Indent = true; 217 | settings.IndentChars = ("\t"); 218 | settings.OmitXmlDeclaration = false; 219 | settings.NewLineHandling = NewLineHandling.Replace; 220 | settings.CloseOutput = true; 221 | 222 | string metadataFileName = encodingPath + "\\TempEncoded.xml"; 223 | 224 | // Create the XmlWriter object and write some content. 225 | writer = XmlWriter.Create(metadataFileName, settings); 226 | writer.WriteStartElement("Wrapper", ""); 227 | writer.WriteString(strEncodedImage); 228 | writer.WriteEndElement(); 229 | 230 | //Close the XmlTextWriter. 231 | writer.WriteEndDocument(); 232 | writer.Close(); 233 | writer.Flush(); 234 | xml = File.ReadAllBytes(encodingPath + "\\TempEncoded.xml"); 235 | } 236 | 237 | 238 | using (MemoryStream stream = new MemoryStream(xml)) 239 | { 240 | // go to the beginning of the stream 241 | stream.Flush(); 242 | stream.Position = 0; 243 | 244 | // create new XmlDocument from stream 245 | XmlDocument doc = new XmlDocument() { PreserveWhitespace = true }; 246 | doc.Load(stream); 247 | 248 | // create transform (for canonicalization method & reference) 249 | XmlDsigExcC14NTransform transform = new XmlDsigExcC14NTransform(); 250 | 251 | // create new SignedXml from XmlDocument 252 | SignedXml signed = GenerateSignedXml(doc, certificate, signWithSha256); 253 | signed.SignedInfo.CanonicalizationMethod = transform.Algorithm; 254 | 255 | // get nodes (use XPath to include FATCA declaration) 256 | XmlNodeList nodes = doc.DocumentElement.SelectNodes("/*"); 257 | 258 | // define data object 259 | DataObject dataObject = new DataObject() { Data = nodes, Id = "FATCA" }; 260 | 261 | // add the data we are signing as a sub-element (object) of the signature element 262 | signed.AddObject(dataObject); 263 | 264 | // create reference 265 | Reference reference = new Reference(string.Format("#{0}", dataObject.Id)); 266 | reference.AddTransform(transform); 267 | 268 | if (signWithSha256) 269 | { 270 | // SHA-256 digest 271 | reference.DigestMethod = RSAPKCS1SHA256SignatureDescription.ReferenceDigestMethod; 272 | } 273 | 274 | // add reference to document 275 | signed.AddReference(reference); 276 | 277 | // include KeyInfo object & compute signature 278 | signed.KeyInfo = CreateKeyInfoFromCertificate(certificate); 279 | signed.ComputeSignature(); 280 | 281 | // get signature 282 | XmlElement xmlDigitalSignature = signed.GetXml(); 283 | 284 | // XML declaration 285 | string xmlDeclaration = string.Empty; 286 | 287 | if (doc.FirstChild is XmlDeclaration) 288 | { 289 | // include declaration 290 | xmlDeclaration = doc.FirstChild.OuterXml; 291 | } 292 | 293 | // return signature as byte array 294 | return Encoding.UTF8.GetBytes(string.Concat(xmlDeclaration, xmlDigitalSignature.OuterXml)); 295 | } 296 | } 297 | #endregion Private methods 298 | 299 | /// 300 | /// Signs a XML file using a digital certificate 301 | /// 302 | /// The type of signature to perform 303 | /// The XML data to sign represented as byte array 304 | /// The certificate file to use for signing 305 | /// The certificate password 306 | /// Sign the document using SHA-256 307 | /// The signed data represented as byte array 308 | public static byte[] Sign(XmlSignatureType signatureType, byte[] xml, string certFile, string certPassword, string encodingPath, bool signWithSha256 = true) 309 | { 310 | switch (signatureType) 311 | { 312 | 313 | case XmlSignatureType.Enveloping: 314 | return SignEnvelopingXml(signatureType, xml, certFile, certPassword, signWithSha256); 315 | case XmlSignatureType.NonXML: 316 | return SignEnvelopingXml(signatureType, xml, certFile, certPassword, signWithSha256, encodingPath); 317 | default: 318 | throw new Exception("Please use a valid XML signature type!"); 319 | } 320 | } 321 | 322 | /// 323 | /// Verifies if the signature of the file is valid 324 | /// 325 | /// The path to the signed file 326 | /// True if valid or false if not valid 327 | public static bool CheckSignature(string signedXml) 328 | { 329 | byte[] xml = File.ReadAllBytes(signedXml); 330 | using (MemoryStream stream = new MemoryStream(xml)) 331 | { 332 | // go to the beginning of the stream 333 | stream.Flush(); 334 | stream.Position = 0; 335 | 336 | // create new XmlDocument from stream 337 | XmlDocument doc = new XmlDocument() { PreserveWhitespace = true }; 338 | doc.Load(stream); 339 | 340 | // get signature node 341 | XmlNodeList nodeList = doc.GetElementsByTagName("Signature", "*"); 342 | if (nodeList.Count != 1) 343 | { 344 | // invalid file 345 | throw new Exception("Signature is missing or multiple signatures found!"); 346 | } 347 | 348 | // get signature node 349 | XmlNodeList keyInfoNode = doc.GetElementsByTagName("KeyInfo", "*"); 350 | if (keyInfoNode.Count != 1) 351 | { 352 | // invalid file 353 | throw new Exception("KeyInfo element is required to validate signature!"); 354 | } 355 | 356 | // create SignedXml and load it with data 357 | SignedXml signed = new SignedXml(doc); 358 | signed.LoadXml(nodeList[0] as XmlElement); 359 | XmlElement root = doc.DocumentElement; 360 | 361 | // check the reference in the signature 362 | CheckSignatureReference(signed, root); 363 | // check the signature 364 | return signed.CheckSignature(); 365 | } 366 | } 367 | 368 | /// 369 | /// Verifies that there is only one reference in the signature and that the reference in the signature matches the reference in the XML 370 | /// 371 | /// The path to the signed file 372 | /// signature and object data of the signed file 373 | private static void CheckSignatureReference(SignedXml signedXml, XmlElement xmlElement) 374 | { 375 | //if no reference at all is found, there is a problem 376 | if(signedXml.SignedInfo.References.Count == 0) 377 | { 378 | throw new Exception("No reference was found in XML signature"); 379 | } 380 | 381 | //if there is more than one reference, there is a problem 382 | if(signedXml.SignedInfo.References.Count != 1) 383 | { 384 | throw new Exception("Multiple references for XML signatures are not allowed"); 385 | } 386 | 387 | var reference = (Reference)signedXml.SignedInfo.References[0]; 388 | var id = reference.Uri.Substring(1); 389 | var idElement = signedXml.GetIdElement(xmlElement.OwnerDocument, id); 390 | string signedReference = ""; 391 | 392 | //the reference in the XML will be compared to the reference in the signature, if no match, there is a problem 393 | if (idElement == null) 394 | { 395 | XmlNodeList objectNode = xmlElement.GetElementsByTagName("Object", "*"); 396 | //If we dont fine the id above, we will pull the Object element from the file 397 | if (objectNode.Count == 1) 398 | { 399 | //Create a new attribute. 400 | XmlNode testroot = objectNode[0]; 401 | signedReference = testroot.Attributes[0].Value.ToString(); 402 | } 403 | 404 | //Check the reference from the XML and see if it matches the signature, if it still doesn't there is a problem 405 | if (id != signedReference) 406 | { 407 | throw new Exception("The signed reference does not match the XML reference"); 408 | } 409 | } 410 | 411 | } 412 | 413 | 414 | 415 | 416 | /// 417 | /// This will extract the base64 image data from the notification 418 | /// 419 | /// The path to the xml file with the encoded data 420 | /// the encoded image data 421 | public static string ExtractXMLImageData(string signedXml) 422 | { 423 | 424 | string hold = "test"; 425 | byte[] xml = File.ReadAllBytes(signedXml); 426 | 427 | using (MemoryStream stream = new MemoryStream(xml)) 428 | { 429 | // go to the beginning of the stream 430 | stream.Flush(); 431 | stream.Position = 0; 432 | 433 | // create new XmlDocument from stream 434 | XmlDocument doc = new XmlDocument() { PreserveWhitespace = true }; 435 | doc.Load(stream); 436 | 437 | // get signature node 438 | XmlNodeList nodeList = doc.GetElementsByTagName("Wrapper", "*"); 439 | 440 | if (nodeList.Count != 1) 441 | { 442 | // invalid file 443 | throw new Exception("No wrapper element for the image data was found!"); 444 | } 445 | 446 | //This will be the base64 encoded Payload that will need to be converted back to an image file 447 | hold = nodeList[0].InnerText; 448 | 449 | // check 450 | return hold; 451 | } 452 | } 453 | 454 | /// 455 | /// This will check the metadata file to see if there is a FileFormatCd and what it is 456 | /// 457 | /// The path to the metadata file 458 | /// the code from the metadata file 459 | public static string CheckMetadataType(string metadataFile) 460 | { 461 | //Our default value will be XML, and we only need to do something different if it isn't 462 | string codeFromMetadata = "XML"; 463 | byte[] xml = File.ReadAllBytes(metadataFile); 464 | 465 | using (MemoryStream stream = new MemoryStream(xml)) 466 | { 467 | // go to the beginning of the stream 468 | stream.Flush(); 469 | stream.Position = 0; 470 | 471 | // create new XmlDocument from stream 472 | XmlDocument doc = new XmlDocument() { PreserveWhitespace = true }; 473 | doc.Load(stream); 474 | 475 | // get File Format Code node 476 | XmlNodeList nodeList = doc.GetElementsByTagName("FileFormatCd", "*"); 477 | 478 | //If the node is found, we will pull the value so we know if this is something other than XML 479 | if (nodeList.Count == 1) 480 | { 481 | codeFromMetadata = nodeList[0].InnerText; 482 | } 483 | 484 | // check 485 | return codeFromMetadata; 486 | } 487 | } 488 | 489 | /// 490 | /// This will look at a decrypted notification and pull the transmissionID, senderFileId, and the notification error code 491 | /// 492 | /// The path to the notification file 493 | /// notificationValues array with 3 values 494 | public static string[] CheckNotification(string notificationFile) 495 | { 496 | //Our default value will be XML, and we only need to do something different if it isn't 497 | string[] notificationValues = new string[4]; 498 | byte[] xml = File.ReadAllBytes(notificationFile); 499 | 500 | using (MemoryStream stream = new MemoryStream(xml)) 501 | { 502 | // go to the beginning of the stream 503 | stream.Flush(); 504 | stream.Position = 0; 505 | 506 | // create new XmlDocument from stream 507 | XmlDocument doc = new XmlDocument() { PreserveWhitespace = true }; 508 | doc.Load(stream); 509 | 510 | // get IDES transmission ID 511 | XmlNodeList nodeList = doc.GetElementsByTagName("IDESTransmissionId"); 512 | //If the node is found, we will pull the value which will be the IDES transmission ID 513 | if (nodeList.Count == 1) 514 | { 515 | notificationValues[0] = nodeList[0].InnerText; 516 | } 517 | 518 | // get SenderFileId node 519 | nodeList = doc.GetElementsByTagName("SenderFileId"); 520 | //If the node is found, we will pull the value which will be the file name 521 | if (nodeList.Count == 1) 522 | { 523 | notificationValues[1] = nodeList[0].InnerText; 524 | } 525 | 526 | // get FATCANotificationCd node 527 | nodeList = doc.GetElementsByTagName("FATCANotificationCd"); 528 | //If the node is found, we will pull the value which will be the file level error code (NVF, NDM, NSC, etc..) 529 | if (nodeList.Count == 1) 530 | { 531 | notificationValues[2] = nodeList[0].InnerText; 532 | } 533 | 534 | // get FATCARecordErrorFIGrp node 535 | nodeList = doc.GetElementsByTagName("FATCARecordErrorFIGrp", "*"); 536 | //If the node is found, we will pull the count which will be the count of record level errors on the file 537 | if (nodeList.Count > 0) 538 | { 539 | notificationValues[3] = nodeList.Count.ToString(); 540 | } 541 | else 542 | notificationValues[3] = "0"; 543 | // check 544 | return notificationValues; 545 | } 546 | } 547 | 548 | /// 549 | /// This will check the input XML file against the provided schema folder. It will dynamically look for the individual 550 | /// schema files, so it will work for the current schema version and the upcoming version 2. 551 | /// 552 | /// The path to the xml file being validated 553 | /// The path to the folder containing the .xsd files that the XML will be validated against 554 | /// a string that will contain the results of the validation 555 | public static string CheckSchema(string inputFile, string schemaFolder = "") 556 | { 557 | 558 | string folderCheck = schemaFolder.Substring(schemaFolder.Length - 1, 1); 559 | if (folderCheck != "\\") 560 | { 561 | schemaFolder = schemaFolder + "\\"; 562 | } 563 | 564 | // select the schema files from the input folder 565 | string fatcaFile = ""; 566 | string stfFile = ""; 567 | string isoFile = ""; 568 | string oecdFile = ""; 569 | string[] fatcaFiles = Directory.GetFiles(schemaFolder, "*fatcaXML*.xsd", SearchOption.TopDirectoryOnly); 570 | string[] stfFiles = Directory.GetFiles(schemaFolder, "*stffatcatypes*.xsd", SearchOption.TopDirectoryOnly); 571 | string[] isoFiles = Directory.GetFiles(schemaFolder, "*isofatcatypes*.xsd", SearchOption.TopDirectoryOnly); 572 | string[] oecdFiles = Directory.GetFiles(schemaFolder, "*oecdtypes*.xsd", SearchOption.TopDirectoryOnly); 573 | 574 | if (fatcaFiles.Length == 0) 575 | { 576 | // fatca xsd validation 577 | throw new Exception("There was no file found containing the fatca xsd file!"); 578 | } 579 | if (stfFiles.Length == 0) 580 | { 581 | // stf xsd validation 582 | throw new Exception("There was no file found containing the stffatcatypes xsd file!"); 583 | } 584 | if (isoFiles.Length == 0) 585 | { 586 | // iso xsd validation 587 | throw new Exception("There was no file found containing the isofatcatypes xsd file!"); 588 | } 589 | if (oecdFiles.Length == 0) 590 | { 591 | // oecd file validation 592 | throw new Exception("There was no file found containing the oecdtypes xsd file!"); 593 | } 594 | 595 | fatcaFile = fatcaFiles[0]; 596 | stfFile = stfFiles[0]; 597 | isoFile = isoFiles[0]; 598 | oecdFile = oecdFiles[0]; 599 | XmlSchemaSet schemas = new XmlSchemaSet(); 600 | if (fatcaFile.Contains("v2")) 601 | { 602 | 603 | schemas.Add("urn:oecd:ties:fatca:v2", fatcaFile); 604 | schemas.Add("urn:oecd:ties:stffatcatypes:v2", stfFile); 605 | schemas.Add("urn:oecd:ties:isofatcatypes:v1", isoFile); 606 | schemas.Add("urn:oecd:ties:stf:v4", oecdFile); 607 | 608 | } 609 | else 610 | { 611 | schemas.Add("urn:oecd:ties:fatca:v1", fatcaFile); 612 | schemas.Add("urn:oecd:ties:stffatcatypes:v1", stfFile); 613 | schemas.Add("urn:oecd:ties:isofatcatypes:v1", isoFile); 614 | schemas.Add("urn:oecd:ties:stf:v4", oecdFile); 615 | } 616 | 617 | 618 | XDocument doc = XDocument.Load(inputFile); 619 | string msg = ""; 620 | doc.Validate(schemas, (o, e) => 621 | { 622 | msg += e.Message + Environment.NewLine; 623 | }); 624 | Console.WriteLine(msg == "" ? "Document is valid" : "Document invalid: " + msg); 625 | 626 | return msg; 627 | } 628 | 629 | /// 630 | /// This will create a metadata file that will be included in the data packet 631 | /// 632 | /// The path to where the metadata file will be created 633 | /// The extension of the file being encrypted (XML, PDF, TXT, etc...) 634 | /// A boolean indicating whether this is an XML transfer or non-XML 635 | /// The tax year from the drop down box 636 | /// The GIIN of the sender as indicated on the payload 637 | /// The file name of the final data packet in correct UTC format 638 | /// 639 | public static void CreateMetadataFile(string metadataFileName, string fileExtension, bool isXML, string taxYear, string senderGIIN, string senderFile) 640 | { 641 | //Start creating XML metadata 642 | XmlWriter writer = null; 643 | string fileCreationDateTime = ""; 644 | fileCreationDateTime = DateTime.Now.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ssZ"); 645 | 646 | // Create an XmlWriterSettings object with the correct options. 647 | XmlWriterSettings settings = new XmlWriterSettings(); 648 | settings.Indent = true; 649 | settings.IndentChars = ("\t"); 650 | settings.OmitXmlDeclaration = false; 651 | settings.NewLineHandling = NewLineHandling.Replace; 652 | settings.CloseOutput = true; 653 | 654 | // Create the XmlWriter object and write some content. 655 | writer = XmlWriter.Create(metadataFileName, settings); 656 | writer.WriteStartElement("FATCAIDESSenderFileMetadata", "urn:fatca:idessenderfilemetadata"); 657 | writer.WriteAttributeString("xmlns", "xsi", null, "http://www.w3.org/2001/XMLSchema-instance"); 658 | writer.WriteStartElement("FATCAEntitySenderId"); 659 | writer.WriteString(senderGIIN); 660 | writer.WriteEndElement(); 661 | writer.WriteStartElement("FATCAEntityReceiverId"); 662 | writer.WriteString("000000.00000.TA.840"); 663 | writer.WriteEndElement(); 664 | writer.WriteStartElement("FATCAEntCommunicationTypeCd"); 665 | writer.WriteString("RPT"); 666 | writer.WriteEndElement(); 667 | writer.WriteStartElement("SenderFileId"); 668 | writer.WriteString(senderFile); 669 | writer.WriteEndElement(); 670 | writer.WriteStartElement("FileFormatCd"); 671 | writer.WriteString(fileExtension); 672 | writer.WriteEndElement(); 673 | writer.WriteStartElement("BinaryEncodingSchemeCd"); 674 | if (isXML == true) 675 | { 676 | writer.WriteString("NONE"); 677 | } 678 | else 679 | { 680 | writer.WriteString("BASE64"); 681 | } 682 | writer.WriteEndElement(); 683 | writer.WriteStartElement("FileCreateTs"); 684 | writer.WriteString(fileCreationDateTime); 685 | writer.WriteEndElement(); 686 | writer.WriteStartElement("TaxYear"); 687 | writer.WriteString(taxYear); 688 | writer.WriteEndElement(); 689 | writer.WriteStartElement("FileRevisionInd"); 690 | writer.WriteString("false"); 691 | writer.WriteEndElement(); 692 | 693 | //Close the XmlTextWriter. 694 | writer.WriteEndDocument(); 695 | writer.Close(); 696 | writer.Flush(); 697 | } 698 | } 699 | } -------------------------------------------------------------------------------- /Form1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Windows.Forms; 5 | using System.Xml; 6 | using System.Text; 7 | using System.Security.Cryptography; 8 | using System.Security.Cryptography.X509Certificates; 9 | using System.Drawing; 10 | using System.Linq; 11 | using WinSCP; 12 | 13 | namespace WindowsFormsApplication1 14 | { 15 | public partial class MainForm : Form 16 | { 17 | public MainForm() 18 | { 19 | InitializeComponent(); 20 | } 21 | 22 | 23 | 24 | private void btnBrowseXml_Click(object sender, EventArgs e) 25 | { 26 | if (chkSendFolder.Checked == true) 27 | { 28 | // Select folder location that holds all 8966 XML files to process 29 | if (dlgOpenFolder.ShowDialog() == DialogResult.OK) 30 | { 31 | txtXmlFile.Text = dlgOpenFolder.SelectedPath; 32 | } 33 | 34 | } 35 | else 36 | { 37 | 38 | // load XML 39 | txtXmlFile.Text = dlgOpen.ShowDialogWithFilter("XML Files (*.xml, *.pdf)|*.xml;*.pdf"); 40 | 41 | } 42 | } 43 | 44 | private void btnBrowseCert_Click(object sender, EventArgs e) 45 | { 46 | // load certificate 47 | txtCert.Text = dlgOpen.ShowDialogWithFilter("Signing Certificates (*.pfx, *.p12)|*.pfx;*.p12"); 48 | } 49 | 50 | private void btnBrowseKeyCert_Click(object sender, EventArgs e) 51 | { 52 | // load AES key encryption certificate 53 | txtKeyCert.Text = dlgOpen.ShowDialogWithFilter("Certificate Files (*.cer, *.pfx, *.p12)|*.cer;*.pfx;*.p12"); 54 | } 55 | 56 | private void btnSignXML_Click(object sender, EventArgs e) 57 | { 58 | if (string.IsNullOrWhiteSpace(txtXmlFile.Text)) 59 | { 60 | // files validation 61 | MessageBox.Show("The XML file was not specified!", Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); 62 | return; 63 | } 64 | 65 | if (string.IsNullOrWhiteSpace(txtCert.Text)) 66 | { 67 | // files validation 68 | MessageBox.Show("The Signing Certificate was not specified!", Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); 69 | return; 70 | } 71 | 72 | if (string.IsNullOrWhiteSpace(txtCertPass.Text)) 73 | { 74 | // certificate password validation 75 | MessageBox.Show("Signing Certificate password was not specified!", Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); 76 | return; 77 | } 78 | 79 | if (string.IsNullOrWhiteSpace(txtKeyCert.Text)) 80 | { 81 | // files validation 82 | MessageBox.Show("Encryption Certificate was not specified!", Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); 83 | return; 84 | } 85 | 86 | if (chkSchemaValidation.Checked == true && string.IsNullOrWhiteSpace(txtSchemaFolder.Text)) 87 | { 88 | // files validation 89 | MessageBox.Show("Schema Validation selected but Schema Folder was not specified!", Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); 90 | return; 91 | } 92 | 93 | //this will be used as a holder for processed files if a folder is being sent 94 | string processedFolder = ""; 95 | 96 | try 97 | { 98 | 99 | //if we are sending a folder, we will load up the files into an array to process 100 | //otherwise, we will just load our file in the array 101 | string[] filesToProcess; 102 | if (chkSendFolder.Checked == false) 103 | { 104 | filesToProcess = new string[1]; 105 | filesToProcess[0] = txtXmlFile.Text; 106 | } 107 | else 108 | { 109 | // Load all XML files in the folder into an array 110 | filesToProcess = Directory.GetFiles(txtXmlFile.Text, "*.xml", SearchOption.TopDirectoryOnly); 111 | processedFolder = txtXmlFile.Text + "\\Processed"; 112 | 113 | //if the processedFolder doesn't exist, create it 114 | if (!Directory.Exists(processedFolder)) 115 | { 116 | Directory.CreateDirectory(processedFolder); 117 | } 118 | } 119 | 120 | //This will loop through all files in the array 121 | //This will be one file or it could be a set of files in a folder 122 | string currentFileToProcess = ""; 123 | foreach (string fileName in filesToProcess) 124 | { 125 | currentFileToProcess = fileName; 126 | //if the file we are processing has an underscore we will split it off for logging 127 | //this should only happen for bulk sending from a folder 128 | if (currentFileToProcess.Contains("_")) 129 | { 130 | string[] filePart = fileName.Split('_'); 131 | currentFileToProcess = txtXmlFile.Text + "\\" + filePart[1]; 132 | //Rename the file so we can process it 133 | File.Move(fileName, currentFileToProcess); 134 | } 135 | 136 | // perform the schema validation if we have the checkbox checked for it 137 | if (chkSchemaValidation.Checked) 138 | { 139 | string validationError = XmlManager.CheckSchema(currentFileToProcess, txtSchemaFolder.Text); 140 | if (validationError != "") 141 | { 142 | // Show schema validation error(s) 143 | MessageBox.Show("Schema Validation Error:\r\n" + validationError, Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); 144 | return; 145 | } 146 | } 147 | 148 | // load XML file content 149 | byte[] xmlContent = File.ReadAllBytes(currentFileToProcess); 150 | string senderGIIN = Path.GetFileNameWithoutExtension(currentFileToProcess); 151 | string filePath = Path.GetDirectoryName(currentFileToProcess); 152 | string fileExtension = Path.GetExtension(currentFileToProcess.ToUpper()).Replace(".", ""); 153 | bool isXML = true; 154 | 155 | if (fileExtension != "XML") 156 | { 157 | isXML = false; 158 | } 159 | 160 | // perform signature 161 | byte[] envelopingSignature; 162 | string envelopingFileName = ""; 163 | 164 | //if the file is XML we will use the enveloping digital signature for the XML 165 | if (isXML == true) 166 | { 167 | envelopingSignature = XmlManager.Sign(XmlSignatureType.Enveloping, xmlContent, txtCert.Text, txtCertPass.Text, filePath); 168 | envelopingFileName = currentFileToProcess.Replace(".xml", "_Payload.xml"); 169 | } 170 | //if the file is NOT XML, we will convert the file data to base64 and put in XML and sign it 171 | else 172 | { 173 | envelopingSignature = XmlManager.Sign(XmlSignatureType.NonXML, xmlContent, txtCert.Text, txtCertPass.Text, filePath); 174 | envelopingFileName = currentFileToProcess.ToUpper().Replace(".PDF", "_Payload.xml"); 175 | } 176 | 177 | string zipFileName = envelopingFileName.Replace(".xml", ".zip"); 178 | 179 | // save enveloping version to disk 180 | File.WriteAllBytes(envelopingFileName, envelopingSignature); 181 | 182 | // add enveloping signature to ZIP file 183 | ZipManager.CreateArchive(envelopingFileName, zipFileName); 184 | 185 | // generate AES key (32 bytes) & default initialization vector (empty) 186 | byte[] aesEncryptionKey = AesManager.GenerateRandomKey(AesManager.KeySize / 8); 187 | byte[] aesEncryptionVector = AesManager.GenerateRandomKey(16, radECB.Checked); 188 | 189 | // encrypt file & save to disk 190 | string encryptedFileName = zipFileName.Replace(".zip", ""); 191 | string encryptedHCTAFileName = zipFileName.Replace(".zip", ""); 192 | string payloadFileName = encryptedFileName + ""; 193 | AesManager.EncryptFile(zipFileName, encryptedFileName, aesEncryptionKey, aesEncryptionVector, radECB.Checked); 194 | 195 | // encrypt key with public key of certificate & save to disk 196 | encryptedFileName = Path.GetDirectoryName(zipFileName) + "\\000000.00000.TA.840_Key"; ; 197 | AesManager.EncryptAesKey(aesEncryptionKey, aesEncryptionVector, txtKeyCert.Text, txtKeyCertPassword.Text, encryptedFileName, radECB.Checked); 198 | //For Model1 Option2 Only, encrypt the AES Key with the HCTA Public Key 199 | if (chkM1O2.Checked) 200 | { 201 | encryptedHCTAFileName = Path.GetDirectoryName(zipFileName) + "\\000000.00000.TA." + txtHCTACode.Text + "_Key"; 202 | AesManager.EncryptAesKey(aesEncryptionKey, aesEncryptionVector, txtHCTACert.Text, txtHCTACertPassword.Text, encryptedHCTAFileName, radECB.Checked); 203 | } 204 | 205 | // cleanup 206 | envelopingSignature = null; 207 | aesEncryptionKey = aesEncryptionVector = null; 208 | 209 | 210 | 211 | try 212 | { 213 | DateTime uDat = new DateTime(); 214 | uDat = DateTime.UtcNow; 215 | string senderFile = uDat.ToString("yyyyMMddTHHmmssfffZ") + "_" + senderGIIN; 216 | string metadataFileName = filePath + "\\" + senderGIIN + "_Metadata.xml"; 217 | XmlManager.CreateMetadataFile(metadataFileName, fileExtension, isXML, cmbTaxYear.SelectedItem.ToString(), senderGIIN, senderFile); 218 | 219 | //Check the signature to make sure it is valid, this requires the KeyInfo to be present 220 | //This is controlled using the checkbox on the form 221 | //This should be commented out or not selected if not using the KeyInfo in the XmlManager class 222 | if (chkSignatureValidation.Checked) 223 | { 224 | bool result = XmlManager.CheckSignature(envelopingFileName); 225 | if (result == false) 226 | { 227 | MessageBox.Show("Signature is not valid!", Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); 228 | return; 229 | } 230 | } 231 | 232 | //Add the metadata, payload, and key files to the final zip package 233 | // add enveloping signature to ZIP file 234 | ZipManager.CreateArchive(metadataFileName, filePath + "\\" + senderFile + ".zip"); 235 | ZipManager.UpdateArchive(encryptedFileName, filePath + "\\" + senderFile + ".zip"); 236 | ZipManager.UpdateArchive(payloadFileName, filePath + "\\" + senderFile + ".zip"); 237 | //Add the HCTA Key file for a M1O2 packet 238 | if (chkM1O2.Checked) 239 | { 240 | ZipManager.UpdateArchive(encryptedHCTAFileName, filePath + "\\" + senderFile + ".zip"); 241 | } 242 | 243 | 244 | 245 | if (chkAutoSendSFTP.Checked == true) 246 | { 247 | SessionOptions currentSFTPSession = SFTPManager.CreateSFTPSession(cmbSFTPServers.SelectedItem.ToString(), username.Text, password.Text); 248 | string sftpUpName = filePath + "\\" + senderFile + ".zip"; 249 | string transferResult = SFTPManager.UploadFile(currentSFTPSession, sftpUpName); 250 | //This can be commented out if there is no desire to see an upload confirmation 251 | MessageBox.Show(transferResult, Text, MessageBoxButtons.OK, MessageBoxIcon.Information); 252 | 253 | //write to log 254 | string path = @"simplelog.csv"; 255 | // This text is added only once to the file. 256 | string lineToLog = fileName + "," + currentFileToProcess + "," + senderFile + ",IDESTRANSID,NOTIFICATIONID,NULL,ERRORCOUNT"; 257 | if (!File.Exists(path)) 258 | { 259 | // Create a file to write to. 260 | using (StreamWriter sw = File.CreateText(path)) 261 | { 262 | sw.WriteLine(lineToLog); 263 | } 264 | } 265 | else 266 | { 267 | // This text is always added, making the file longer over time 268 | // if it is not deleted. 269 | using (StreamWriter sw = File.AppendText(path)) 270 | { 271 | sw.WriteLine(lineToLog); 272 | } 273 | } 274 | } 275 | if (chkSendFolder.Checked == true) 276 | { 277 | //Move the file to a processed folder so we can move on to the next 278 | //This is only used when sending an entire folder 279 | File.Move(currentFileToProcess, processedFolder + "\\" + Path.GetFileName(fileName)); 280 | } 281 | 282 | 283 | } 284 | catch (Exception ex) 285 | { 286 | ex.DisplayException(Text); 287 | return; 288 | } 289 | finally 290 | { 291 | 292 | } 293 | 294 | } 295 | // success 296 | MessageBox.Show("XML Signing and Encryption process is complete!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information); 297 | 298 | } 299 | catch (Exception ex) 300 | { 301 | ex.DisplayException(Text); 302 | } 303 | } 304 | 305 | private void btnBrowseNotificationZip_Click(object sender, EventArgs e) 306 | { 307 | // load Notification Zip file 308 | txtNotificationZip.Text = dlgOpen.ShowDialogWithFilter("ZIP Files (*.zip)|*.zip"); 309 | } 310 | 311 | private void btnBrowseRecCert_Click(object sender, EventArgs e) 312 | { 313 | // load Notification Receiver key 314 | txtReceiverCert.Text = dlgOpen.ShowDialogWithFilter("Certificate Files (*.cer, *.pfx, *.p12)|*.cer;*.pfx;*.p12"); 315 | } 316 | 317 | private void btnDecryptZip_Click(object sender, EventArgs e) 318 | { 319 | 320 | if (string.IsNullOrWhiteSpace(txtNotificationZip.Text) || string.IsNullOrWhiteSpace(txtReceiverCert.Text)) 321 | { 322 | // files validation 323 | MessageBox.Show("Either the ZIP file or certificate was not specified!", Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); 324 | return; 325 | } 326 | 327 | string zipFolder = ""; 328 | try 329 | { 330 | //Deflate the zip archive 331 | zipFolder = ZipManager.ExtractArchive(txtNotificationZip.Text, txtNotificationFolder.Text); 332 | 333 | } 334 | catch (Exception ex) 335 | { 336 | ex.DisplayException(Text); 337 | return; 338 | } 339 | 340 | //Decrypt the Payload 341 | string decryptedPayload = ""; 342 | try 343 | { 344 | decryptedPayload = AesManager.DecryptNotification(zipFolder, txtReceiverCert.Text, txtRecKeyPassword.Text, radECB.Checked); 345 | } 346 | catch (Exception ex) 347 | { 348 | ex.DisplayException("Decryption Failed:" + Text); 349 | return; 350 | } 351 | 352 | // success 353 | MessageBox.Show("Decryption process is complete!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information); 354 | 355 | 356 | 357 | } 358 | 359 | private void btnBrowseOutput_Click(object sender, EventArgs e) 360 | { 361 | // load AES key encryption certificate 362 | if (dlgOpenFolder.ShowDialog() == DialogResult.OK) 363 | { 364 | txtNotificationFolder.Text = dlgOpenFolder.SelectedPath; 365 | } 366 | } 367 | 368 | private void button1_Click(object sender, EventArgs e) 369 | { 370 | Application.Exit(); 371 | } 372 | 373 | 374 | 375 | private void MainForm_Load(object sender, EventArgs e) 376 | { 377 | lblHCTAKey.Visible = false; 378 | txtHCTACert.Visible = false; 379 | btnBrowseHCTACert.Visible = false; 380 | lblEncryptionHCTAPassword.Visible = false; 381 | txtHCTACertPassword.Visible = false; 382 | lblHCTACode.Visible = false; 383 | txtHCTACode.Visible = false; 384 | 385 | //Populate tax year combo box, this will contain the current year back to the first reporting year of 2014 386 | for (int i = DateTime.Now.Year; i >= 2014; i--) 387 | { 388 | cmbTaxYear.Items.Add(i); 389 | } 390 | cmbTaxYear.SelectedItem = DateTime.Now.Year - 1; 391 | 392 | //Default the CBC checkbox to on 393 | radCBC.Checked = true; 394 | 395 | 396 | //Add the SFTP Servers 397 | cmbSFTPServers.Items.Add("PRODUCTION: WWW.IDESGATEWAY.COM"); 398 | cmbSFTPServers.Items.Add("TEST: WWWPSE.IDESGATEWAY.COM"); 399 | cmbSFTPServers.Items.Add("SAT: WWWSAT.IDESGATEWAY.COM"); 400 | cmbSFTPServers.SelectedItem = "PRODUCTION: WWW.IDESGATEWAY.COM"; 401 | } 402 | 403 | 404 | 405 | 406 | 407 | private void chkM1O2_CheckedChanged(object sender, EventArgs e) 408 | { 409 | if (chkM1O2.Checked) 410 | { 411 | this.lblHCTAKey.Location = new Point( 412 | this.lblHCTAKey.Location.X, 413 | this.lblHCTAKey.Location.Y - 40 414 | ); 415 | this.btnBrowseHCTACert.Location = new Point( 416 | this.btnBrowseHCTACert.Location.X, 417 | this.btnBrowseHCTACert.Location.Y - 40 418 | ); 419 | this.txtHCTACert.Location = new Point( 420 | this.txtHCTACert.Location.X, 421 | this.txtHCTACert.Location.Y - 40 422 | ); 423 | this.lblEncryptionHCTAPassword.Location = new Point( 424 | this.lblEncryptionHCTAPassword.Location.X, 425 | this.lblEncryptionHCTAPassword.Location.Y - 40 426 | ); 427 | this.txtHCTACertPassword.Location = new Point( 428 | this.txtHCTACertPassword.Location.X, 429 | this.txtHCTACertPassword.Location.Y - 40 430 | ); 431 | this.lblHCTACode.Location = new Point( 432 | this.lblHCTACode.Location.X, 433 | this.lblHCTACode.Location.Y - 40 434 | ); 435 | this.txtHCTACode.Location = new Point( 436 | this.txtHCTACode.Location.X, 437 | this.txtHCTACode.Location.Y - 40 438 | ); 439 | this.btnSignXML.Location = new Point( 440 | this.btnSignXML.Location.X, 441 | this.btnSignXML.Location.Y + 140 442 | ); 443 | 444 | 445 | lblHCTAKey.Visible = true; 446 | txtHCTACert.Visible = true; 447 | btnBrowseHCTACert.Visible = true; 448 | lblEncryptionHCTAPassword.Visible = true; 449 | txtHCTACertPassword.Visible = true; 450 | lblHCTACode.Visible = true; 451 | txtHCTACode.Visible = true; 452 | } 453 | else 454 | { 455 | this.lblHCTAKey.Location = new Point( 456 | this.lblHCTAKey.Location.X, 457 | this.lblHCTAKey.Location.Y + 40 458 | ); 459 | this.btnBrowseHCTACert.Location = new Point( 460 | this.btnBrowseHCTACert.Location.X, 461 | this.btnBrowseHCTACert.Location.Y + 40 462 | ); 463 | this.txtHCTACert.Location = new Point( 464 | this.txtHCTACert.Location.X, 465 | this.txtHCTACert.Location.Y + 40 466 | ); 467 | this.lblEncryptionHCTAPassword.Location = new Point( 468 | this.lblEncryptionHCTAPassword.Location.X, 469 | this.lblEncryptionHCTAPassword.Location.Y + 40 470 | ); 471 | this.txtHCTACertPassword.Location = new Point( 472 | this.txtHCTACertPassword.Location.X, 473 | this.txtHCTACertPassword.Location.Y + 40 474 | ); 475 | this.lblHCTACode.Location = new Point( 476 | this.lblHCTACode.Location.X, 477 | this.lblHCTACode.Location.Y + 40 478 | ); 479 | this.txtHCTACode.Location = new Point( 480 | this.txtHCTACode.Location.X, 481 | this.txtHCTACode.Location.Y + 40 482 | ); 483 | this.btnSignXML.Location = new Point( 484 | this.btnSignXML.Location.X, 485 | this.btnSignXML.Location.Y - 140 486 | ); 487 | 488 | lblHCTAKey.Visible = false; 489 | txtHCTACert.Visible = false; 490 | btnBrowseHCTACert.Visible = false; 491 | lblEncryptionHCTAPassword.Visible = false; 492 | txtHCTACertPassword.Visible = false; 493 | lblHCTACode.Visible = false; 494 | txtHCTACode.Visible = false; 495 | } 496 | 497 | } 498 | 499 | private void btnBrowseHCTACert_Click(object sender, EventArgs e) 500 | { 501 | // load AES key encryption certificate 502 | txtHCTACert.Text = dlgOpen.ShowDialogWithFilter("Certificate Files (*.cer, *.pfx, *.p12)|*.cer;*.pfx;*.p12"); 503 | } 504 | 505 | 506 | 507 | private void cmdCheckSignature_Click(object sender, EventArgs e) 508 | { 509 | if (string.IsNullOrWhiteSpace(txtSignedPayloadFile.Text)) 510 | { 511 | // files validation 512 | MessageBox.Show("The Signed Payload File was not specified!", Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); 513 | return; 514 | } 515 | 516 | // register SHA-256 and open certificate with exportable private key 517 | CryptoConfig.AddAlgorithm(typeof(RSAPKCS1SHA256SignatureDescription), RSAPKCS1SHA256SignatureDescription.SignatureMethod); 518 | 519 | //Check the signature to make sure it is valid, this requires the KeyInfo to be present 520 | //This should be commented out if not using the KeyInfo in the XmlManager class 521 | 522 | try{ 523 | bool result = XmlManager.CheckSignature(txtSignedPayloadFile.Text); 524 | if (result == false) 525 | { 526 | MessageBox.Show("Signature is not valid!", Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); 527 | } 528 | else 529 | { 530 | MessageBox.Show("Signature is valid!", Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); 531 | } 532 | } 533 | catch (Exception ex) 534 | { 535 | ex.DisplayException(Text); 536 | return; 537 | } 538 | 539 | } 540 | 541 | private void btnBrowsePayload_Click(object sender, EventArgs e) 542 | { 543 | { 544 | // load Signed Payload file, must be unencrypted and have KeyInfo element 545 | txtSignedPayloadFile.Text = dlgOpen.ShowDialogWithFilter("Signed Payload File (*.xml)|*.xml;"); 546 | } 547 | } 548 | 549 | //this can be used to autopopulate these boxes during test periods 550 | private void cmdPopulateSettings_Click(object sender, EventArgs e) 551 | { 552 | txtXmlFile.Text = ""; 553 | txtCert.Text = ""; 554 | txtCertPass.Text = ""; 555 | txtKeyCert.Text = ""; 556 | } 557 | 558 | 559 | 560 | private void btnSchemaFile_Click(object sender, EventArgs e) 561 | { 562 | { 563 | // load Signed Payload file, must be unencrypted and have KeyInfo element 564 | txtSchemaFile.Text = dlgOpen.ShowDialogWithFilter("8966 XML File (*.xml)|*.xml;"); 565 | } 566 | } 567 | 568 | private void btnSchemaFolder_Click(object sender, EventArgs e) 569 | { 570 | // Select folder location that holds all 8966 schema files 571 | if (dlgOpenFolder.ShowDialog() == DialogResult.OK) 572 | { 573 | txtSchemaFolder.Text = dlgOpenFolder.SelectedPath; 574 | } 575 | } 576 | 577 | private void btnCheckSchema_Click(object sender, EventArgs e) 578 | { 579 | if (string.IsNullOrWhiteSpace(txtSchemaFile.Text)) 580 | { 581 | // files validation 582 | MessageBox.Show("The XML File To Validate was not specified!", Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); 583 | return; 584 | } 585 | 586 | if (string.IsNullOrWhiteSpace(txtSchemaFolder.Text)) 587 | { 588 | // files validation 589 | MessageBox.Show("The Schema Folder location was not specified!", Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); 590 | return; 591 | } 592 | try 593 | { 594 | string validationError = XmlManager.CheckSchema(txtSchemaFile.Text, txtSchemaFolder.Text); 595 | if (validationError != "") 596 | { 597 | // files validation 598 | MessageBox.Show("Schema Validation Error:\r\n" + validationError, Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); 599 | 600 | } 601 | else 602 | { 603 | // files validation 604 | MessageBox.Show("Validation Successful", Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); 605 | 606 | } 607 | } 608 | catch (Exception ex) 609 | { 610 | ex.DisplayException("Schema Validation Failure: " + Text); 611 | return; 612 | } 613 | } 614 | 615 | 616 | private void chkSendFolder_CheckedChanged(object sender, EventArgs e) 617 | { 618 | if (chkSendFolder.Checked) 619 | { 620 | lblLoadXML.Text = "XML Folder"; 621 | } 622 | else 623 | { 624 | lblLoadXML.Text = "XML File"; 625 | } 626 | } 627 | 628 | private void btnCheckNotification_Click(object sender, EventArgs e) 629 | { 630 | if (string.IsNullOrWhiteSpace(txtDecryptKey.Text)) 631 | { 632 | // files validation 633 | MessageBox.Show("The Receiver's key for decryption must be set!", Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); 634 | return; 635 | } 636 | 637 | Char delimiter = ','; 638 | Dictionary transmissions = new Dictionary(); 639 | 640 | try 641 | { // Open the text file using a stream reader. 642 | using (StreamReader sr = new StreamReader("simplelog.csv")) 643 | { 644 | while (sr.Peek() >= 0) 645 | { 646 | String line = sr.ReadLine(); 647 | string[] strLineArray = line.Split(delimiter); 648 | 649 | //if there is no notification id, we will store the file name 650 | if (strLineArray[4] == "NOTIFICATIONID") 651 | { 652 | transmissions.Add(strLineArray[2], line); 653 | } 654 | else 655 | // otherwise, we store the notification id, and we can ignore this file if it is in the inbox 656 | { 657 | transmissions.Add(strLineArray[4], line); 658 | } 659 | Console.WriteLine(line); 660 | } 661 | } 662 | 663 | 664 | } 665 | catch (Exception ex) 666 | { 667 | ex.DisplayException(Text); 668 | return; 669 | } 670 | 671 | //Connect to the Inbox and see if there are any files 672 | try 673 | { 674 | // Setup session options 675 | SessionOptions currentSFTPSession = SFTPManager.CreateSFTPSession(cmbSFTPServers.SelectedItem.ToString(), username.Text, password.Text); 676 | SFTPManager.DownloadInbox(currentSFTPSession, transmissions, txtDownFolder.Text); 677 | 678 | } 679 | catch (Exception ex) 680 | { 681 | ex.DisplayException(Text); 682 | return; 683 | } 684 | 685 | //loop through the files we have downloaded and process them 686 | //these files will be matched to our log file to see if we have any matches 687 | 688 | string[] filesToProcess; 689 | string xmlProcessedFolder = ""; 690 | string xmlProcessingFolder = ""; 691 | string xmlProcessedUnmatchedFolder = ""; 692 | string destinationFolder = ""; 693 | 694 | // Load all XML files in the folder into the array 695 | filesToProcess = Directory.GetFiles(txtDownFolder.Text, "*.zip", SearchOption.TopDirectoryOnly); 696 | xmlProcessedFolder = txtDownFolder.Text + "\\Processed"; 697 | xmlProcessingFolder = txtDownFolder.Text + "\\Processing"; 698 | xmlProcessedUnmatchedFolder = txtDownFolder.Text + "\\Processed\\Unmatched"; 699 | 700 | //if the processedFolder doesn't exist, create it 701 | if (!Directory.Exists(xmlProcessedFolder)) 702 | { 703 | Directory.CreateDirectory(xmlProcessedFolder); 704 | } 705 | //if the processedUnmatchedFolder doesn't exist, create it 706 | if (!Directory.Exists(xmlProcessedUnmatchedFolder)) 707 | { 708 | Directory.CreateDirectory(xmlProcessedUnmatchedFolder); 709 | } 710 | //if the processingFolder doesn't exist, create it 711 | if (!Directory.Exists(xmlProcessingFolder)) 712 | { 713 | Directory.CreateDirectory(xmlProcessingFolder); 714 | } 715 | 716 | //loop through the downloaded files 717 | int matchCounter = 0; 718 | int unmatchCounter = 0; 719 | foreach (string fileName in filesToProcess) 720 | { 721 | try 722 | { 723 | //clean out the processing folder, the current file will be unzipped into it 724 | DirectoryInfo dir = new DirectoryInfo(xmlProcessingFolder); 725 | foreach (FileInfo fi in dir.GetFiles()) 726 | { 727 | fi.Delete(); 728 | } 729 | //Deflate the zip archive 730 | ZipManager.ExtractArchive(fileName, xmlProcessingFolder, false); 731 | } 732 | catch (Exception ex) 733 | { 734 | ex.DisplayException(Text); 735 | return; 736 | } 737 | 738 | string decryptedPayload = ""; 739 | try 740 | { 741 | decryptedPayload = AesManager.DecryptNotification(xmlProcessingFolder, txtDecryptKey.Text, txtDecryptPassword.Text, radECB.Checked); 742 | } 743 | catch (Exception ex) 744 | { 745 | ex.DisplayException("Decryption Failed:" + Text); 746 | return; 747 | } 748 | 749 | //take a look at the decrypted payload and see if this notification matches anything we are looking for 750 | string[] notificationID = new string[3]; 751 | string notificationFileName = Path.GetFileNameWithoutExtension(fileName); 752 | bool isFileMatched = false; 753 | 754 | //This will return three values 755 | //0 Ides Transmission ID 756 | //1 Sender FIle Id 757 | //2 Return Code 758 | notificationID = XmlManager.CheckNotification(decryptedPayload); 759 | 760 | //Check our log file dictionary and see if we can find a match 761 | if (transmissions.ContainsKey(notificationID[1]) == true) 762 | { 763 | isFileMatched = true; 764 | 765 | //we will add a new record to reflect the updated information and remove the old record 766 | //make sure the filename is in our transmissions and return the current log data for it 767 | string currentNotificationData = ""; 768 | transmissions.TryGetValue(notificationID[1],out currentNotificationData); 769 | 770 | //update the current notification Data before we add the new record 771 | //we will take fields from the decrypted notification and insert it back in 772 | currentNotificationData = currentNotificationData.Replace("NOTIFICATIONID", Path.GetFileName(fileName)); 773 | currentNotificationData = currentNotificationData.Replace("IDESTRANSID", notificationID[0]); 774 | currentNotificationData = currentNotificationData.Replace("NULL", notificationID[2]); 775 | currentNotificationData = currentNotificationData.Replace("ERRORCOUNT", notificationID[3]); 776 | 777 | //add new record with updated information 778 | transmissions.Add(Path.GetFileName(fileName), string.Join(",", currentNotificationData)); 779 | 780 | //we can remove the old record now 781 | transmissions.Remove(notificationID[1]); 782 | 783 | //we will write the current transmissions back into the log file so we keep it updated with the latest information 784 | //write to log 785 | string filePath = @"simplelog.csv"; 786 | using (FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate)) 787 | { 788 | using (TextWriter tw = new StreamWriter(fs)) 789 | 790 | foreach (KeyValuePair kvp in transmissions) 791 | { 792 | tw.WriteLine(string.Format("{0}", kvp.Value)); 793 | } 794 | } 795 | //processing of the file is complete 796 | 797 | } 798 | //the decrypted files will be moved to the Processed folder for safekeeping 799 | //if no match is found, it moves to the Unmatched subfolder 800 | DirectoryInfo dirProcessing = new DirectoryInfo(xmlProcessingFolder); 801 | if (isFileMatched == true) 802 | { 803 | destinationFolder = xmlProcessedFolder; 804 | if (!Directory.Exists(xmlProcessedFolder + "\\" + notificationFileName)) 805 | { 806 | Directory.CreateDirectory(xmlProcessedFolder + "\\" + notificationFileName); 807 | } 808 | matchCounter = matchCounter + 1; 809 | } 810 | else{ 811 | destinationFolder = xmlProcessedUnmatchedFolder; 812 | //if this non-matching file has already been pulled, remove the old and replace with the new 813 | if (Directory.Exists(xmlProcessedUnmatchedFolder + "\\" + notificationFileName)) 814 | { 815 | //clean out the folder, it will get the current decrypted contents 816 | DirectoryInfo dir = new DirectoryInfo(xmlProcessedUnmatchedFolder + "\\" + notificationFileName); 817 | foreach (FileInfo fi in dir.GetFiles()) 818 | { 819 | fi.Delete(); 820 | } 821 | } 822 | else 823 | { 824 | Directory.CreateDirectory(xmlProcessedUnmatchedFolder + "\\" + notificationFileName); 825 | } 826 | unmatchCounter = unmatchCounter + 1; 827 | } 828 | 829 | //move from the processing folder 830 | foreach (FileInfo fi in dirProcessing.GetFiles()) 831 | { 832 | File.Move(fi.FullName, Path.Combine(destinationFolder, notificationFileName, fi.Name)); 833 | } 834 | //Rename the file so we can process it 835 | File.Move(fileName, Path.Combine(destinationFolder, notificationFileName, Path.GetFileName(fileName))); 836 | } 837 | MessageBox.Show(matchCounter + " matching files found\n" + unmatchCounter + " non-matching files found"); 838 | } 839 | 840 | private void btnBrowseDecKey_Click(object sender, EventArgs e) 841 | { 842 | // load Notification Receiver key 843 | txtDecryptKey.Text = dlgOpen.ShowDialogWithFilter("Certificate Files (*.cer, *.pfx, *.p12)|*.cer;*.pfx;*.p12"); 844 | } 845 | 846 | private void btnBrowseDownloadFolder_Click(object sender, EventArgs e) 847 | { 848 | // Select folder location that holds all 8966 XML files to process 849 | if (dlgOpenFolder.ShowDialog() == DialogResult.OK) 850 | { 851 | txtDownFolder.Text = dlgOpenFolder.SelectedPath; 852 | } 853 | } 854 | 855 | 856 | } 857 | } 858 | -------------------------------------------------------------------------------- /Form1.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace WindowsFormsApplication1 2 | { 3 | partial class MainForm 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.dlgOpen = new System.Windows.Forms.OpenFileDialog(); 32 | this.dlgSave = new System.Windows.Forms.SaveFileDialog(); 33 | this.dlgOpenFolder = new System.Windows.Forms.FolderBrowserDialog(); 34 | this.button1 = new System.Windows.Forms.Button(); 35 | this.tabControl1 = new System.Windows.Forms.TabControl(); 36 | this.tabPage1 = new System.Windows.Forms.TabPage(); 37 | this.cmbTaxYear = new System.Windows.Forms.ComboBox(); 38 | this.lblTaxYear = new System.Windows.Forms.Label(); 39 | this.chkAutoSendSFTP = new System.Windows.Forms.CheckBox(); 40 | this.chkSendFolder = new System.Windows.Forms.CheckBox(); 41 | this.chkSignatureValidation = new System.Windows.Forms.CheckBox(); 42 | this.chkSchemaValidation = new System.Windows.Forms.CheckBox(); 43 | this.radCBC = new System.Windows.Forms.RadioButton(); 44 | this.radECB = new System.Windows.Forms.RadioButton(); 45 | this.chkM1O2 = new System.Windows.Forms.CheckBox(); 46 | this.cmdPopulateSettings = new System.Windows.Forms.Button(); 47 | this.btnBrowseHCTACert = new System.Windows.Forms.Button(); 48 | this.txtHCTACode = new System.Windows.Forms.TextBox(); 49 | this.lblHCTACode = new System.Windows.Forms.Label(); 50 | this.txtHCTACertPassword = new System.Windows.Forms.TextBox(); 51 | this.lblEncryptionHCTAPassword = new System.Windows.Forms.Label(); 52 | this.txtHCTACert = new System.Windows.Forms.TextBox(); 53 | this.lblHCTAKey = new System.Windows.Forms.Label(); 54 | this.btnSignXML = new System.Windows.Forms.Button(); 55 | this.txtKeyCertPassword = new System.Windows.Forms.TextBox(); 56 | this.lblKeyEncryptionCertPassword = new System.Windows.Forms.Label(); 57 | this.btnBrowseKeyCert = new System.Windows.Forms.Button(); 58 | this.txtKeyCert = new System.Windows.Forms.TextBox(); 59 | this.label3 = new System.Windows.Forms.Label(); 60 | this.txtCertPass = new System.Windows.Forms.TextBox(); 61 | this.lblCertPass = new System.Windows.Forms.Label(); 62 | this.btnBrowseCert = new System.Windows.Forms.Button(); 63 | this.txtCert = new System.Windows.Forms.TextBox(); 64 | this.lblCert = new System.Windows.Forms.Label(); 65 | this.btnBrowseXml = new System.Windows.Forms.Button(); 66 | this.txtXmlFile = new System.Windows.Forms.TextBox(); 67 | this.lblLoadXML = new System.Windows.Forms.Label(); 68 | this.tabPage2 = new System.Windows.Forms.TabPage(); 69 | this.btnBrowseOutput = new System.Windows.Forms.Button(); 70 | this.txtNotificationFolder = new System.Windows.Forms.TextBox(); 71 | this.lblOutput = new System.Windows.Forms.Label(); 72 | this.btnDecryptZip = new System.Windows.Forms.Button(); 73 | this.txtRecKeyPassword = new System.Windows.Forms.TextBox(); 74 | this.lblRecPass = new System.Windows.Forms.Label(); 75 | this.btnBrowseRecCert = new System.Windows.Forms.Button(); 76 | this.txtReceiverCert = new System.Windows.Forms.TextBox(); 77 | this.lblReceiverCert = new System.Windows.Forms.Label(); 78 | this.btnBrowseNotificationZip = new System.Windows.Forms.Button(); 79 | this.txtNotificationZip = new System.Windows.Forms.TextBox(); 80 | this.lblZipFile = new System.Windows.Forms.Label(); 81 | this.tabPage3 = new System.Windows.Forms.TabPage(); 82 | this.cmdCheckSignature = new System.Windows.Forms.Button(); 83 | this.lblSchemaFolder = new System.Windows.Forms.Label(); 84 | this.btnSchemaFolder = new System.Windows.Forms.Button(); 85 | this.txtSchemaFolder = new System.Windows.Forms.TextBox(); 86 | this.btnSchemaFile = new System.Windows.Forms.Button(); 87 | this.txtSchemaFile = new System.Windows.Forms.TextBox(); 88 | this.lblSchemaFile = new System.Windows.Forms.Label(); 89 | this.btnCheckSchema = new System.Windows.Forms.Button(); 90 | this.btnBrowsePayload = new System.Windows.Forms.Button(); 91 | this.txtSignedPayloadFile = new System.Windows.Forms.TextBox(); 92 | this.lblSignedPayloadFile = new System.Windows.Forms.Label(); 93 | this.tabPage4 = new System.Windows.Forms.TabPage(); 94 | this.btnBrowseDownloadFolder = new System.Windows.Forms.Button(); 95 | this.label6 = new System.Windows.Forms.Label(); 96 | this.txtDownFolder = new System.Windows.Forms.TextBox(); 97 | this.cmbSFTPServers = new System.Windows.Forms.ComboBox(); 98 | this.label5 = new System.Windows.Forms.Label(); 99 | this.label4 = new System.Windows.Forms.Label(); 100 | this.txtDecryptPassword = new System.Windows.Forms.TextBox(); 101 | this.lblDecryptPassword = new System.Windows.Forms.Label(); 102 | this.btnBrowseDecKey = new System.Windows.Forms.Button(); 103 | this.txtDecryptKey = new System.Windows.Forms.TextBox(); 104 | this.lblDecryptKey = new System.Windows.Forms.Label(); 105 | this.label2 = new System.Windows.Forms.Label(); 106 | this.label1 = new System.Windows.Forms.Label(); 107 | this.password = new System.Windows.Forms.TextBox(); 108 | this.username = new System.Windows.Forms.TextBox(); 109 | this.btnCheckNotification = new System.Windows.Forms.Button(); 110 | this.tabControl1.SuspendLayout(); 111 | this.tabPage1.SuspendLayout(); 112 | this.tabPage2.SuspendLayout(); 113 | this.tabPage3.SuspendLayout(); 114 | this.tabPage4.SuspendLayout(); 115 | this.SuspendLayout(); 116 | // 117 | // dlgOpen 118 | // 119 | this.dlgOpen.Title = "Open File"; 120 | // 121 | // dlgSave 122 | // 123 | this.dlgSave.Filter = "XML Files (*.xml)|*.xml"; 124 | this.dlgSave.Title = "Save File"; 125 | // 126 | // dlgOpenFolder 127 | // 128 | this.dlgOpenFolder.RootFolder = System.Environment.SpecialFolder.MyComputer; 129 | // 130 | // button1 131 | // 132 | this.button1.Location = new System.Drawing.Point(902, 438); 133 | this.button1.Name = "button1"; 134 | this.button1.Size = new System.Drawing.Size(75, 23); 135 | this.button1.TabIndex = 30; 136 | this.button1.Text = "EXIT"; 137 | this.button1.UseVisualStyleBackColor = true; 138 | this.button1.Click += new System.EventHandler(this.button1_Click); 139 | // 140 | // tabControl1 141 | // 142 | this.tabControl1.Controls.Add(this.tabPage1); 143 | this.tabControl1.Controls.Add(this.tabPage2); 144 | this.tabControl1.Controls.Add(this.tabPage3); 145 | this.tabControl1.Controls.Add(this.tabPage4); 146 | this.tabControl1.Location = new System.Drawing.Point(12, 1); 147 | this.tabControl1.Name = "tabControl1"; 148 | this.tabControl1.SelectedIndex = 0; 149 | this.tabControl1.Size = new System.Drawing.Size(860, 464); 150 | this.tabControl1.TabIndex = 63; 151 | // 152 | // tabPage1 153 | // 154 | this.tabPage1.BackColor = System.Drawing.Color.Gainsboro; 155 | this.tabPage1.Controls.Add(this.cmbTaxYear); 156 | this.tabPage1.Controls.Add(this.lblTaxYear); 157 | this.tabPage1.Controls.Add(this.chkAutoSendSFTP); 158 | this.tabPage1.Controls.Add(this.chkSendFolder); 159 | this.tabPage1.Controls.Add(this.chkSignatureValidation); 160 | this.tabPage1.Controls.Add(this.chkSchemaValidation); 161 | this.tabPage1.Controls.Add(this.radCBC); 162 | this.tabPage1.Controls.Add(this.radECB); 163 | this.tabPage1.Controls.Add(this.chkM1O2); 164 | this.tabPage1.Controls.Add(this.cmdPopulateSettings); 165 | this.tabPage1.Controls.Add(this.btnBrowseHCTACert); 166 | this.tabPage1.Controls.Add(this.txtHCTACode); 167 | this.tabPage1.Controls.Add(this.lblHCTACode); 168 | this.tabPage1.Controls.Add(this.txtHCTACertPassword); 169 | this.tabPage1.Controls.Add(this.lblEncryptionHCTAPassword); 170 | this.tabPage1.Controls.Add(this.txtHCTACert); 171 | this.tabPage1.Controls.Add(this.lblHCTAKey); 172 | this.tabPage1.Controls.Add(this.btnSignXML); 173 | this.tabPage1.Controls.Add(this.txtKeyCertPassword); 174 | this.tabPage1.Controls.Add(this.lblKeyEncryptionCertPassword); 175 | this.tabPage1.Controls.Add(this.btnBrowseKeyCert); 176 | this.tabPage1.Controls.Add(this.txtKeyCert); 177 | this.tabPage1.Controls.Add(this.label3); 178 | this.tabPage1.Controls.Add(this.txtCertPass); 179 | this.tabPage1.Controls.Add(this.lblCertPass); 180 | this.tabPage1.Controls.Add(this.btnBrowseCert); 181 | this.tabPage1.Controls.Add(this.txtCert); 182 | this.tabPage1.Controls.Add(this.lblCert); 183 | this.tabPage1.Controls.Add(this.btnBrowseXml); 184 | this.tabPage1.Controls.Add(this.txtXmlFile); 185 | this.tabPage1.Controls.Add(this.lblLoadXML); 186 | this.tabPage1.Location = new System.Drawing.Point(4, 22); 187 | this.tabPage1.Name = "tabPage1"; 188 | this.tabPage1.Padding = new System.Windows.Forms.Padding(3); 189 | this.tabPage1.Size = new System.Drawing.Size(852, 438); 190 | this.tabPage1.TabIndex = 0; 191 | this.tabPage1.Text = "Create Data Packet"; 192 | // 193 | // cmbTaxYear 194 | // 195 | this.cmbTaxYear.FormattingEnabled = true; 196 | this.cmbTaxYear.Location = new System.Drawing.Point(529, 36); 197 | this.cmbTaxYear.Name = "cmbTaxYear"; 198 | this.cmbTaxYear.Size = new System.Drawing.Size(78, 21); 199 | this.cmbTaxYear.TabIndex = 104; 200 | // 201 | // lblTaxYear 202 | // 203 | this.lblTaxYear.AutoSize = true; 204 | this.lblTaxYear.Location = new System.Drawing.Point(526, 18); 205 | this.lblTaxYear.Name = "lblTaxYear"; 206 | this.lblTaxYear.Size = new System.Drawing.Size(50, 13); 207 | this.lblTaxYear.TabIndex = 103; 208 | this.lblTaxYear.Text = "Tax Year"; 209 | // 210 | // chkAutoSendSFTP 211 | // 212 | this.chkAutoSendSFTP.AutoSize = true; 213 | this.chkAutoSendSFTP.Location = new System.Drawing.Point(706, 146); 214 | this.chkAutoSendSFTP.Name = "chkAutoSendSFTP"; 215 | this.chkAutoSendSFTP.Size = new System.Drawing.Size(97, 17); 216 | this.chkAutoSendSFTP.TabIndex = 102; 217 | this.chkAutoSendSFTP.Text = "Auto SFTP File"; 218 | this.chkAutoSendSFTP.UseVisualStyleBackColor = true; 219 | // 220 | // chkSendFolder 221 | // 222 | this.chkSendFolder.AutoSize = true; 223 | this.chkSendFolder.Location = new System.Drawing.Point(706, 169); 224 | this.chkSendFolder.Name = "chkSendFolder"; 225 | this.chkSendFolder.Size = new System.Drawing.Size(113, 17); 226 | this.chkSendFolder.TabIndex = 101; 227 | this.chkSendFolder.Text = "Send Entire Folder"; 228 | this.chkSendFolder.UseVisualStyleBackColor = true; 229 | this.chkSendFolder.CheckedChanged += new System.EventHandler(this.chkSendFolder_CheckedChanged); 230 | // 231 | // chkSignatureValidation 232 | // 233 | this.chkSignatureValidation.AutoSize = true; 234 | this.chkSignatureValidation.Location = new System.Drawing.Point(706, 120); 235 | this.chkSignatureValidation.Name = "chkSignatureValidation"; 236 | this.chkSignatureValidation.Size = new System.Drawing.Size(120, 17); 237 | this.chkSignatureValidation.TabIndex = 100; 238 | this.chkSignatureValidation.Text = "Signature Validation"; 239 | this.chkSignatureValidation.UseVisualStyleBackColor = true; 240 | // 241 | // chkSchemaValidation 242 | // 243 | this.chkSchemaValidation.AutoSize = true; 244 | this.chkSchemaValidation.Location = new System.Drawing.Point(706, 95); 245 | this.chkSchemaValidation.Name = "chkSchemaValidation"; 246 | this.chkSchemaValidation.Size = new System.Drawing.Size(114, 17); 247 | this.chkSchemaValidation.TabIndex = 99; 248 | this.chkSchemaValidation.Text = "Schema Validation"; 249 | this.chkSchemaValidation.UseVisualStyleBackColor = true; 250 | // 251 | // radCBC 252 | // 253 | this.radCBC.AutoSize = true; 254 | this.radCBC.Location = new System.Drawing.Point(706, 45); 255 | this.radCBC.Name = "radCBC"; 256 | this.radCBC.Size = new System.Drawing.Size(76, 17); 257 | this.radCBC.TabIndex = 98; 258 | this.radCBC.Text = "CBC Mode"; 259 | this.radCBC.UseVisualStyleBackColor = true; 260 | // 261 | // radECB 262 | // 263 | this.radECB.AutoSize = true; 264 | this.radECB.Checked = true; 265 | this.radECB.Location = new System.Drawing.Point(706, 62); 266 | this.radECB.Name = "radECB"; 267 | this.radECB.Size = new System.Drawing.Size(76, 17); 268 | this.radECB.TabIndex = 97; 269 | this.radECB.TabStop = true; 270 | this.radECB.Text = "ECB Mode"; 271 | this.radECB.UseVisualStyleBackColor = true; 272 | // 273 | // chkM1O2 274 | // 275 | this.chkM1O2.AutoSize = true; 276 | this.chkM1O2.Location = new System.Drawing.Point(706, 20); 277 | this.chkM1O2.Name = "chkM1O2"; 278 | this.chkM1O2.Size = new System.Drawing.Size(93, 17); 279 | this.chkM1O2.TabIndex = 96; 280 | this.chkM1O2.Text = "Model 1 Opt 2"; 281 | this.chkM1O2.UseVisualStyleBackColor = true; 282 | this.chkM1O2.CheckedChanged += new System.EventHandler(this.chkM1O2_CheckedChanged); 283 | // 284 | // cmdPopulateSettings 285 | // 286 | this.cmdPopulateSettings.Location = new System.Drawing.Point(207, 12); 287 | this.cmdPopulateSettings.Name = "cmdPopulateSettings"; 288 | this.cmdPopulateSettings.Size = new System.Drawing.Size(75, 23); 289 | this.cmdPopulateSettings.TabIndex = 68; 290 | this.cmdPopulateSettings.Text = "Populate"; 291 | this.cmdPopulateSettings.UseVisualStyleBackColor = true; 292 | this.cmdPopulateSettings.Visible = false; 293 | // 294 | // btnBrowseHCTACert 295 | // 296 | this.btnBrowseHCTACert.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 297 | this.btnBrowseHCTACert.Location = new System.Drawing.Point(294, 312); 298 | this.btnBrowseHCTACert.Name = "btnBrowseHCTACert"; 299 | this.btnBrowseHCTACert.Size = new System.Drawing.Size(28, 23); 300 | this.btnBrowseHCTACert.TabIndex = 67; 301 | this.btnBrowseHCTACert.Text = "..."; 302 | this.btnBrowseHCTACert.UseVisualStyleBackColor = true; 303 | this.btnBrowseHCTACert.Click += new System.EventHandler(this.btnBrowseHCTACert_Click); 304 | // 305 | // txtHCTACode 306 | // 307 | this.txtHCTACode.Location = new System.Drawing.Point(23, 396); 308 | this.txtHCTACode.Name = "txtHCTACode"; 309 | this.txtHCTACode.Size = new System.Drawing.Size(78, 20); 310 | this.txtHCTACode.TabIndex = 66; 311 | // 312 | // lblHCTACode 313 | // 314 | this.lblHCTACode.AutoSize = true; 315 | this.lblHCTACode.Location = new System.Drawing.Point(23, 380); 316 | this.lblHCTACode.Name = "lblHCTACode"; 317 | this.lblHCTACode.Size = new System.Drawing.Size(64, 13); 318 | this.lblHCTACode.TabIndex = 65; 319 | this.lblHCTACode.Text = "HCTA Code"; 320 | // 321 | // txtHCTACertPassword 322 | // 323 | this.txtHCTACertPassword.Location = new System.Drawing.Point(23, 353); 324 | this.txtHCTACertPassword.Name = "txtHCTACertPassword"; 325 | this.txtHCTACertPassword.Size = new System.Drawing.Size(259, 20); 326 | this.txtHCTACertPassword.TabIndex = 64; 327 | this.txtHCTACertPassword.Visible = false; 328 | // 329 | // lblEncryptionHCTAPassword 330 | // 331 | this.lblEncryptionHCTAPassword.AutoSize = true; 332 | this.lblEncryptionHCTAPassword.Location = new System.Drawing.Point(23, 337); 333 | this.lblEncryptionHCTAPassword.Name = "lblEncryptionHCTAPassword"; 334 | this.lblEncryptionHCTAPassword.Size = new System.Drawing.Size(261, 13); 335 | this.lblEncryptionHCTAPassword.TabIndex = 63; 336 | this.lblEncryptionHCTAPassword.Text = "Encryption Key Certificate HCTA password (if needed)"; 337 | this.lblEncryptionHCTAPassword.Visible = false; 338 | // 339 | // txtHCTACert 340 | // 341 | this.txtHCTACert.Location = new System.Drawing.Point(23, 312); 342 | this.txtHCTACert.Name = "txtHCTACert"; 343 | this.txtHCTACert.Size = new System.Drawing.Size(259, 20); 344 | this.txtHCTACert.TabIndex = 62; 345 | this.txtHCTACert.Visible = false; 346 | // 347 | // lblHCTAKey 348 | // 349 | this.lblHCTAKey.AutoSize = true; 350 | this.lblHCTAKey.Location = new System.Drawing.Point(23, 296); 351 | this.lblHCTAKey.Name = "lblHCTAKey"; 352 | this.lblHCTAKey.Size = new System.Drawing.Size(219, 13); 353 | this.lblHCTAKey.TabIndex = 61; 354 | this.lblHCTAKey.Text = "Encryption Key Certificate (HCTA Public Key)"; 355 | this.lblHCTAKey.Visible = false; 356 | // 357 | // btnSignXML 358 | // 359 | this.btnSignXML.Location = new System.Drawing.Point(23, 256); 360 | this.btnSignXML.Name = "btnSignXML"; 361 | this.btnSignXML.Size = new System.Drawing.Size(173, 23); 362 | this.btnSignXML.TabIndex = 60; 363 | this.btnSignXML.Text = "Sign and Encrypt XML"; 364 | this.btnSignXML.UseVisualStyleBackColor = true; 365 | this.btnSignXML.Click += new System.EventHandler(this.btnSignXML_Click); 366 | // 367 | // txtKeyCertPassword 368 | // 369 | this.txtKeyCertPassword.Location = new System.Drawing.Point(23, 225); 370 | this.txtKeyCertPassword.Name = "txtKeyCertPassword"; 371 | this.txtKeyCertPassword.Size = new System.Drawing.Size(259, 20); 372 | this.txtKeyCertPassword.TabIndex = 59; 373 | // 374 | // lblKeyEncryptionCertPassword 375 | // 376 | this.lblKeyEncryptionCertPassword.AutoSize = true; 377 | this.lblKeyEncryptionCertPassword.Location = new System.Drawing.Point(23, 209); 378 | this.lblKeyEncryptionCertPassword.Name = "lblKeyEncryptionCertPassword"; 379 | this.lblKeyEncryptionCertPassword.Size = new System.Drawing.Size(229, 13); 380 | this.lblKeyEncryptionCertPassword.TabIndex = 58; 381 | this.lblKeyEncryptionCertPassword.Text = "Encryption Key Certificate password (if needed)"; 382 | // 383 | // btnBrowseKeyCert 384 | // 385 | this.btnBrowseKeyCert.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 386 | this.btnBrowseKeyCert.Location = new System.Drawing.Point(294, 177); 387 | this.btnBrowseKeyCert.Name = "btnBrowseKeyCert"; 388 | this.btnBrowseKeyCert.Size = new System.Drawing.Size(28, 23); 389 | this.btnBrowseKeyCert.TabIndex = 57; 390 | this.btnBrowseKeyCert.Text = "..."; 391 | this.btnBrowseKeyCert.UseVisualStyleBackColor = true; 392 | this.btnBrowseKeyCert.Click += new System.EventHandler(this.btnBrowseKeyCert_Click); 393 | // 394 | // txtKeyCert 395 | // 396 | this.txtKeyCert.Location = new System.Drawing.Point(23, 179); 397 | this.txtKeyCert.Name = "txtKeyCert"; 398 | this.txtKeyCert.Size = new System.Drawing.Size(259, 20); 399 | this.txtKeyCert.TabIndex = 56; 400 | // 401 | // label3 402 | // 403 | this.label3.AutoSize = true; 404 | this.label3.Location = new System.Drawing.Point(23, 163); 405 | this.label3.Name = "label3"; 406 | this.label3.Size = new System.Drawing.Size(240, 13); 407 | this.label3.TabIndex = 55; 408 | this.label3.Text = "Encryption Key Certificate (Receiver\'s Public Key)"; 409 | // 410 | // txtCertPass 411 | // 412 | this.txtCertPass.Location = new System.Drawing.Point(23, 135); 413 | this.txtCertPass.Name = "txtCertPass"; 414 | this.txtCertPass.PasswordChar = '*'; 415 | this.txtCertPass.Size = new System.Drawing.Size(259, 20); 416 | this.txtCertPass.TabIndex = 54; 417 | // 418 | // lblCertPass 419 | // 420 | this.lblCertPass.AutoSize = true; 421 | this.lblCertPass.Location = new System.Drawing.Point(23, 119); 422 | this.lblCertPass.Name = "lblCertPass"; 423 | this.lblCertPass.Size = new System.Drawing.Size(141, 13); 424 | this.lblCertPass.TabIndex = 53; 425 | this.lblCertPass.Text = "Signing Certificate Password"; 426 | // 427 | // btnBrowseCert 428 | // 429 | this.btnBrowseCert.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 430 | this.btnBrowseCert.Location = new System.Drawing.Point(294, 88); 431 | this.btnBrowseCert.Name = "btnBrowseCert"; 432 | this.btnBrowseCert.Size = new System.Drawing.Size(28, 23); 433 | this.btnBrowseCert.TabIndex = 52; 434 | this.btnBrowseCert.Text = "..."; 435 | this.btnBrowseCert.UseVisualStyleBackColor = true; 436 | this.btnBrowseCert.Click += new System.EventHandler(this.btnBrowseCert_Click); 437 | // 438 | // txtCert 439 | // 440 | this.txtCert.Location = new System.Drawing.Point(23, 92); 441 | this.txtCert.Name = "txtCert"; 442 | this.txtCert.Size = new System.Drawing.Size(259, 20); 443 | this.txtCert.TabIndex = 51; 444 | // 445 | // lblCert 446 | // 447 | this.lblCert.AutoSize = true; 448 | this.lblCert.Location = new System.Drawing.Point(23, 76); 449 | this.lblCert.Name = "lblCert"; 450 | this.lblCert.Size = new System.Drawing.Size(199, 13); 451 | this.lblCert.TabIndex = 50; 452 | this.lblCert.Text = "Signing Certificate (Sender\'s Private Key)"; 453 | // 454 | // btnBrowseXml 455 | // 456 | this.btnBrowseXml.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 457 | this.btnBrowseXml.Location = new System.Drawing.Point(294, 38); 458 | this.btnBrowseXml.Name = "btnBrowseXml"; 459 | this.btnBrowseXml.Size = new System.Drawing.Size(28, 23); 460 | this.btnBrowseXml.TabIndex = 49; 461 | this.btnBrowseXml.Text = "..."; 462 | this.btnBrowseXml.UseVisualStyleBackColor = true; 463 | this.btnBrowseXml.Click += new System.EventHandler(this.btnBrowseXml_Click); 464 | // 465 | // txtXmlFile 466 | // 467 | this.txtXmlFile.Location = new System.Drawing.Point(23, 41); 468 | this.txtXmlFile.Name = "txtXmlFile"; 469 | this.txtXmlFile.Size = new System.Drawing.Size(259, 20); 470 | this.txtXmlFile.TabIndex = 48; 471 | // 472 | // lblLoadXML 473 | // 474 | this.lblLoadXML.AutoSize = true; 475 | this.lblLoadXML.Location = new System.Drawing.Point(23, 25); 476 | this.lblLoadXML.Name = "lblLoadXML"; 477 | this.lblLoadXML.Size = new System.Drawing.Size(48, 13); 478 | this.lblLoadXML.TabIndex = 47; 479 | this.lblLoadXML.Text = "XML File"; 480 | // 481 | // tabPage2 482 | // 483 | this.tabPage2.BackColor = System.Drawing.Color.Gainsboro; 484 | this.tabPage2.Controls.Add(this.btnBrowseOutput); 485 | this.tabPage2.Controls.Add(this.txtNotificationFolder); 486 | this.tabPage2.Controls.Add(this.lblOutput); 487 | this.tabPage2.Controls.Add(this.btnDecryptZip); 488 | this.tabPage2.Controls.Add(this.txtRecKeyPassword); 489 | this.tabPage2.Controls.Add(this.lblRecPass); 490 | this.tabPage2.Controls.Add(this.btnBrowseRecCert); 491 | this.tabPage2.Controls.Add(this.txtReceiverCert); 492 | this.tabPage2.Controls.Add(this.lblReceiverCert); 493 | this.tabPage2.Controls.Add(this.btnBrowseNotificationZip); 494 | this.tabPage2.Controls.Add(this.txtNotificationZip); 495 | this.tabPage2.Controls.Add(this.lblZipFile); 496 | this.tabPage2.Location = new System.Drawing.Point(4, 22); 497 | this.tabPage2.Name = "tabPage2"; 498 | this.tabPage2.Padding = new System.Windows.Forms.Padding(3); 499 | this.tabPage2.Size = new System.Drawing.Size(852, 438); 500 | this.tabPage2.TabIndex = 1; 501 | this.tabPage2.Text = "Decrypt Notification"; 502 | // 503 | // btnBrowseOutput 504 | // 505 | this.btnBrowseOutput.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 506 | this.btnBrowseOutput.Location = new System.Drawing.Point(246, 172); 507 | this.btnBrowseOutput.Name = "btnBrowseOutput"; 508 | this.btnBrowseOutput.Size = new System.Drawing.Size(29, 23); 509 | this.btnBrowseOutput.TabIndex = 74; 510 | this.btnBrowseOutput.Text = "..."; 511 | this.btnBrowseOutput.UseVisualStyleBackColor = true; 512 | this.btnBrowseOutput.Click += new System.EventHandler(this.btnBrowseOutput_Click); 513 | // 514 | // txtNotificationFolder 515 | // 516 | this.txtNotificationFolder.Location = new System.Drawing.Point(22, 172); 517 | this.txtNotificationFolder.Name = "txtNotificationFolder"; 518 | this.txtNotificationFolder.Size = new System.Drawing.Size(212, 20); 519 | this.txtNotificationFolder.TabIndex = 73; 520 | // 521 | // lblOutput 522 | // 523 | this.lblOutput.AutoSize = true; 524 | this.lblOutput.Location = new System.Drawing.Point(22, 156); 525 | this.lblOutput.Name = "lblOutput"; 526 | this.lblOutput.Size = new System.Drawing.Size(127, 13); 527 | this.lblOutput.TabIndex = 72; 528 | this.lblOutput.Text = "Notification Output Folder"; 529 | // 530 | // btnDecryptZip 531 | // 532 | this.btnDecryptZip.Location = new System.Drawing.Point(22, 200); 533 | this.btnDecryptZip.Name = "btnDecryptZip"; 534 | this.btnDecryptZip.Size = new System.Drawing.Size(173, 23); 535 | this.btnDecryptZip.TabIndex = 71; 536 | this.btnDecryptZip.Text = "Decrypt Notification"; 537 | this.btnDecryptZip.UseVisualStyleBackColor = true; 538 | this.btnDecryptZip.Click += new System.EventHandler(this.btnDecryptZip_Click); 539 | // 540 | // txtRecKeyPassword 541 | // 542 | this.txtRecKeyPassword.Location = new System.Drawing.Point(22, 133); 543 | this.txtRecKeyPassword.Name = "txtRecKeyPassword"; 544 | this.txtRecKeyPassword.PasswordChar = '*'; 545 | this.txtRecKeyPassword.Size = new System.Drawing.Size(212, 20); 546 | this.txtRecKeyPassword.TabIndex = 70; 547 | // 548 | // lblRecPass 549 | // 550 | this.lblRecPass.AutoSize = true; 551 | this.lblRecPass.Location = new System.Drawing.Point(25, 117); 552 | this.lblRecPass.Name = "lblRecPass"; 553 | this.lblRecPass.Size = new System.Drawing.Size(155, 13); 554 | this.lblRecPass.TabIndex = 69; 555 | this.lblRecPass.Text = "Certificate password (if needed)"; 556 | // 557 | // btnBrowseRecCert 558 | // 559 | this.btnBrowseRecCert.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 560 | this.btnBrowseRecCert.Location = new System.Drawing.Point(246, 87); 561 | this.btnBrowseRecCert.Name = "btnBrowseRecCert"; 562 | this.btnBrowseRecCert.Size = new System.Drawing.Size(30, 23); 563 | this.btnBrowseRecCert.TabIndex = 68; 564 | this.btnBrowseRecCert.Text = "..."; 565 | this.btnBrowseRecCert.UseVisualStyleBackColor = true; 566 | this.btnBrowseRecCert.Click += new System.EventHandler(this.btnBrowseRecCert_Click); 567 | // 568 | // txtReceiverCert 569 | // 570 | this.txtReceiverCert.Location = new System.Drawing.Point(22, 90); 571 | this.txtReceiverCert.Name = "txtReceiverCert"; 572 | this.txtReceiverCert.Size = new System.Drawing.Size(212, 20); 573 | this.txtReceiverCert.TabIndex = 67; 574 | // 575 | // lblReceiverCert 576 | // 577 | this.lblReceiverCert.AutoSize = true; 578 | this.lblReceiverCert.Location = new System.Drawing.Point(25, 74); 579 | this.lblReceiverCert.Name = "lblReceiverCert"; 580 | this.lblReceiverCert.Size = new System.Drawing.Size(209, 13); 581 | this.lblReceiverCert.TabIndex = 66; 582 | this.lblReceiverCert.Text = "Receiver Certificate (Receiver Private Key)"; 583 | // 584 | // btnBrowseNotificationZip 585 | // 586 | this.btnBrowseNotificationZip.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 587 | this.btnBrowseNotificationZip.Location = new System.Drawing.Point(246, 40); 588 | this.btnBrowseNotificationZip.Name = "btnBrowseNotificationZip"; 589 | this.btnBrowseNotificationZip.Size = new System.Drawing.Size(30, 23); 590 | this.btnBrowseNotificationZip.TabIndex = 65; 591 | this.btnBrowseNotificationZip.Text = "..."; 592 | this.btnBrowseNotificationZip.UseVisualStyleBackColor = true; 593 | this.btnBrowseNotificationZip.Click += new System.EventHandler(this.btnBrowseNotificationZip_Click); 594 | // 595 | // txtNotificationZip 596 | // 597 | this.txtNotificationZip.Location = new System.Drawing.Point(22, 40); 598 | this.txtNotificationZip.Name = "txtNotificationZip"; 599 | this.txtNotificationZip.Size = new System.Drawing.Size(212, 20); 600 | this.txtNotificationZip.TabIndex = 64; 601 | // 602 | // lblZipFile 603 | // 604 | this.lblZipFile.AutoSize = true; 605 | this.lblZipFile.Location = new System.Drawing.Point(22, 24); 606 | this.lblZipFile.Name = "lblZipFile"; 607 | this.lblZipFile.Size = new System.Drawing.Size(41, 13); 608 | this.lblZipFile.TabIndex = 63; 609 | this.lblZipFile.Text = "Zip File"; 610 | // 611 | // tabPage3 612 | // 613 | this.tabPage3.BackColor = System.Drawing.Color.Gainsboro; 614 | this.tabPage3.Controls.Add(this.cmdCheckSignature); 615 | this.tabPage3.Controls.Add(this.lblSchemaFolder); 616 | this.tabPage3.Controls.Add(this.btnSchemaFolder); 617 | this.tabPage3.Controls.Add(this.txtSchemaFolder); 618 | this.tabPage3.Controls.Add(this.btnSchemaFile); 619 | this.tabPage3.Controls.Add(this.txtSchemaFile); 620 | this.tabPage3.Controls.Add(this.lblSchemaFile); 621 | this.tabPage3.Controls.Add(this.btnCheckSchema); 622 | this.tabPage3.Controls.Add(this.btnBrowsePayload); 623 | this.tabPage3.Controls.Add(this.txtSignedPayloadFile); 624 | this.tabPage3.Controls.Add(this.lblSignedPayloadFile); 625 | this.tabPage3.Location = new System.Drawing.Point(4, 22); 626 | this.tabPage3.Name = "tabPage3"; 627 | this.tabPage3.Size = new System.Drawing.Size(852, 438); 628 | this.tabPage3.TabIndex = 2; 629 | this.tabPage3.Text = "Utilities"; 630 | // 631 | // cmdCheckSignature 632 | // 633 | this.cmdCheckSignature.Location = new System.Drawing.Point(25, 66); 634 | this.cmdCheckSignature.Name = "cmdCheckSignature"; 635 | this.cmdCheckSignature.Size = new System.Drawing.Size(103, 23); 636 | this.cmdCheckSignature.TabIndex = 101; 637 | this.cmdCheckSignature.Text = "Check Signature"; 638 | this.cmdCheckSignature.UseVisualStyleBackColor = true; 639 | this.cmdCheckSignature.Click += new System.EventHandler(this.cmdCheckSignature_Click); 640 | // 641 | // lblSchemaFolder 642 | // 643 | this.lblSchemaFolder.AutoSize = true; 644 | this.lblSchemaFolder.Location = new System.Drawing.Point(516, 24); 645 | this.lblSchemaFolder.Name = "lblSchemaFolder"; 646 | this.lblSchemaFolder.Size = new System.Drawing.Size(78, 13); 647 | this.lblSchemaFolder.TabIndex = 95; 648 | this.lblSchemaFolder.Text = "Schema Folder"; 649 | // 650 | // btnSchemaFolder 651 | // 652 | this.btnSchemaFolder.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 653 | this.btnSchemaFolder.Location = new System.Drawing.Point(740, 39); 654 | this.btnSchemaFolder.Name = "btnSchemaFolder"; 655 | this.btnSchemaFolder.Size = new System.Drawing.Size(29, 23); 656 | this.btnSchemaFolder.TabIndex = 94; 657 | this.btnSchemaFolder.Text = "..."; 658 | this.btnSchemaFolder.UseVisualStyleBackColor = true; 659 | this.btnSchemaFolder.Click += new System.EventHandler(this.btnSchemaFolder_Click); 660 | // 661 | // txtSchemaFolder 662 | // 663 | this.txtSchemaFolder.Location = new System.Drawing.Point(516, 42); 664 | this.txtSchemaFolder.Name = "txtSchemaFolder"; 665 | this.txtSchemaFolder.Size = new System.Drawing.Size(212, 20); 666 | this.txtSchemaFolder.TabIndex = 93; 667 | // 668 | // btnSchemaFile 669 | // 670 | this.btnSchemaFile.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 671 | this.btnSchemaFile.Location = new System.Drawing.Point(740, 82); 672 | this.btnSchemaFile.Name = "btnSchemaFile"; 673 | this.btnSchemaFile.Size = new System.Drawing.Size(29, 23); 674 | this.btnSchemaFile.TabIndex = 92; 675 | this.btnSchemaFile.Text = "..."; 676 | this.btnSchemaFile.UseVisualStyleBackColor = true; 677 | this.btnSchemaFile.Click += new System.EventHandler(this.btnSchemaFile_Click); 678 | // 679 | // txtSchemaFile 680 | // 681 | this.txtSchemaFile.Location = new System.Drawing.Point(516, 82); 682 | this.txtSchemaFile.Name = "txtSchemaFile"; 683 | this.txtSchemaFile.Size = new System.Drawing.Size(212, 20); 684 | this.txtSchemaFile.TabIndex = 91; 685 | // 686 | // lblSchemaFile 687 | // 688 | this.lblSchemaFile.AutoSize = true; 689 | this.lblSchemaFile.Location = new System.Drawing.Point(516, 66); 690 | this.lblSchemaFile.Name = "lblSchemaFile"; 691 | this.lblSchemaFile.Size = new System.Drawing.Size(105, 13); 692 | this.lblSchemaFile.TabIndex = 90; 693 | this.lblSchemaFile.Text = "XML File To Validate"; 694 | // 695 | // btnCheckSchema 696 | // 697 | this.btnCheckSchema.Location = new System.Drawing.Point(516, 108); 698 | this.btnCheckSchema.Name = "btnCheckSchema"; 699 | this.btnCheckSchema.Size = new System.Drawing.Size(100, 25); 700 | this.btnCheckSchema.TabIndex = 89; 701 | this.btnCheckSchema.Text = "Check Schema"; 702 | this.btnCheckSchema.UseVisualStyleBackColor = true; 703 | this.btnCheckSchema.Click += new System.EventHandler(this.btnCheckSchema_Click); 704 | // 705 | // btnBrowsePayload 706 | // 707 | this.btnBrowsePayload.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 708 | this.btnBrowsePayload.Location = new System.Drawing.Point(249, 40); 709 | this.btnBrowsePayload.Name = "btnBrowsePayload"; 710 | this.btnBrowsePayload.Size = new System.Drawing.Size(29, 23); 711 | this.btnBrowsePayload.TabIndex = 85; 712 | this.btnBrowsePayload.Text = "..."; 713 | this.btnBrowsePayload.UseVisualStyleBackColor = true; 714 | this.btnBrowsePayload.Click += new System.EventHandler(this.btnBrowsePayload_Click); 715 | // 716 | // txtSignedPayloadFile 717 | // 718 | this.txtSignedPayloadFile.Location = new System.Drawing.Point(25, 40); 719 | this.txtSignedPayloadFile.Name = "txtSignedPayloadFile"; 720 | this.txtSignedPayloadFile.Size = new System.Drawing.Size(212, 20); 721 | this.txtSignedPayloadFile.TabIndex = 84; 722 | // 723 | // lblSignedPayloadFile 724 | // 725 | this.lblSignedPayloadFile.AutoSize = true; 726 | this.lblSignedPayloadFile.Location = new System.Drawing.Point(25, 24); 727 | this.lblSignedPayloadFile.Name = "lblSignedPayloadFile"; 728 | this.lblSignedPayloadFile.Size = new System.Drawing.Size(100, 13); 729 | this.lblSignedPayloadFile.TabIndex = 83; 730 | this.lblSignedPayloadFile.Text = "Signed Payload File"; 731 | // 732 | // tabPage4 733 | // 734 | this.tabPage4.BackColor = System.Drawing.Color.Gainsboro; 735 | this.tabPage4.Controls.Add(this.btnBrowseDownloadFolder); 736 | this.tabPage4.Controls.Add(this.label6); 737 | this.tabPage4.Controls.Add(this.txtDownFolder); 738 | this.tabPage4.Controls.Add(this.cmbSFTPServers); 739 | this.tabPage4.Controls.Add(this.label5); 740 | this.tabPage4.Controls.Add(this.label4); 741 | this.tabPage4.Controls.Add(this.txtDecryptPassword); 742 | this.tabPage4.Controls.Add(this.lblDecryptPassword); 743 | this.tabPage4.Controls.Add(this.btnBrowseDecKey); 744 | this.tabPage4.Controls.Add(this.txtDecryptKey); 745 | this.tabPage4.Controls.Add(this.lblDecryptKey); 746 | this.tabPage4.Controls.Add(this.label2); 747 | this.tabPage4.Controls.Add(this.label1); 748 | this.tabPage4.Controls.Add(this.password); 749 | this.tabPage4.Controls.Add(this.username); 750 | this.tabPage4.Controls.Add(this.btnCheckNotification); 751 | this.tabPage4.Location = new System.Drawing.Point(4, 22); 752 | this.tabPage4.Name = "tabPage4"; 753 | this.tabPage4.Size = new System.Drawing.Size(852, 438); 754 | this.tabPage4.TabIndex = 3; 755 | this.tabPage4.Text = "SFTP Settings"; 756 | // 757 | // btnBrowseDownloadFolder 758 | // 759 | this.btnBrowseDownloadFolder.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 760 | this.btnBrowseDownloadFolder.Location = new System.Drawing.Point(245, 257); 761 | this.btnBrowseDownloadFolder.Name = "btnBrowseDownloadFolder"; 762 | this.btnBrowseDownloadFolder.Size = new System.Drawing.Size(30, 23); 763 | this.btnBrowseDownloadFolder.TabIndex = 127; 764 | this.btnBrowseDownloadFolder.Text = "..."; 765 | this.btnBrowseDownloadFolder.UseVisualStyleBackColor = true; 766 | this.btnBrowseDownloadFolder.Click += new System.EventHandler(this.btnBrowseDownloadFolder_Click); 767 | // 768 | // label6 769 | // 770 | this.label6.AutoSize = true; 771 | this.label6.Location = new System.Drawing.Point(21, 243); 772 | this.label6.Name = "label6"; 773 | this.label6.Size = new System.Drawing.Size(143, 13); 774 | this.label6.TabIndex = 126; 775 | this.label6.Text = "Notification Download Folder"; 776 | // 777 | // txtDownFolder 778 | // 779 | this.txtDownFolder.Location = new System.Drawing.Point(21, 259); 780 | this.txtDownFolder.Name = "txtDownFolder"; 781 | this.txtDownFolder.Size = new System.Drawing.Size(212, 20); 782 | this.txtDownFolder.TabIndex = 125; 783 | // 784 | // cmbSFTPServers 785 | // 786 | this.cmbSFTPServers.FormattingEnabled = true; 787 | this.cmbSFTPServers.Location = new System.Drawing.Point(21, 34); 788 | this.cmbSFTPServers.Name = "cmbSFTPServers"; 789 | this.cmbSFTPServers.Size = new System.Drawing.Size(254, 21); 790 | this.cmbSFTPServers.TabIndex = 124; 791 | // 792 | // label5 793 | // 794 | this.label5.AutoSize = true; 795 | this.label5.Location = new System.Drawing.Point(18, 18); 796 | this.label5.Name = "label5"; 797 | this.label5.Size = new System.Drawing.Size(68, 13); 798 | this.label5.TabIndex = 123; 799 | this.label5.Text = "SFTP Server"; 800 | // 801 | // label4 802 | // 803 | this.label4.AutoSize = true; 804 | this.label4.Location = new System.Drawing.Point(21, 233); 805 | this.label4.Name = "label4"; 806 | this.label4.Size = new System.Drawing.Size(0, 13); 807 | this.label4.TabIndex = 122; 808 | // 809 | // txtDecryptPassword 810 | // 811 | this.txtDecryptPassword.Location = new System.Drawing.Point(21, 210); 812 | this.txtDecryptPassword.Name = "txtDecryptPassword"; 813 | this.txtDecryptPassword.PasswordChar = '*'; 814 | this.txtDecryptPassword.Size = new System.Drawing.Size(212, 20); 815 | this.txtDecryptPassword.TabIndex = 121; 816 | // 817 | // lblDecryptPassword 818 | // 819 | this.lblDecryptPassword.AutoSize = true; 820 | this.lblDecryptPassword.Location = new System.Drawing.Point(21, 194); 821 | this.lblDecryptPassword.Name = "lblDecryptPassword"; 822 | this.lblDecryptPassword.Size = new System.Drawing.Size(155, 13); 823 | this.lblDecryptPassword.TabIndex = 120; 824 | this.lblDecryptPassword.Text = "Certificate password (if needed)"; 825 | // 826 | // btnBrowseDecKey 827 | // 828 | this.btnBrowseDecKey.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 829 | this.btnBrowseDecKey.Location = new System.Drawing.Point(245, 164); 830 | this.btnBrowseDecKey.Name = "btnBrowseDecKey"; 831 | this.btnBrowseDecKey.Size = new System.Drawing.Size(30, 23); 832 | this.btnBrowseDecKey.TabIndex = 119; 833 | this.btnBrowseDecKey.Text = "..."; 834 | this.btnBrowseDecKey.UseVisualStyleBackColor = true; 835 | this.btnBrowseDecKey.Click += new System.EventHandler(this.btnBrowseDecKey_Click); 836 | // 837 | // txtDecryptKey 838 | // 839 | this.txtDecryptKey.Location = new System.Drawing.Point(21, 167); 840 | this.txtDecryptKey.Name = "txtDecryptKey"; 841 | this.txtDecryptKey.Size = new System.Drawing.Size(212, 20); 842 | this.txtDecryptKey.TabIndex = 118; 843 | // 844 | // lblDecryptKey 845 | // 846 | this.lblDecryptKey.AutoSize = true; 847 | this.lblDecryptKey.Location = new System.Drawing.Point(21, 151); 848 | this.lblDecryptKey.Name = "lblDecryptKey"; 849 | this.lblDecryptKey.Size = new System.Drawing.Size(209, 13); 850 | this.lblDecryptKey.TabIndex = 117; 851 | this.lblDecryptKey.Text = "Receiver Certificate (Receiver Private Key)"; 852 | // 853 | // label2 854 | // 855 | this.label2.AutoSize = true; 856 | this.label2.Location = new System.Drawing.Point(21, 101); 857 | this.label2.Name = "label2"; 858 | this.label2.Size = new System.Drawing.Size(83, 13); 859 | this.label2.TabIndex = 116; 860 | this.label2.Text = "SFTP Password"; 861 | // 862 | // label1 863 | // 864 | this.label1.AutoSize = true; 865 | this.label1.Location = new System.Drawing.Point(21, 58); 866 | this.label1.Name = "label1"; 867 | this.label1.Size = new System.Drawing.Size(85, 13); 868 | this.label1.TabIndex = 115; 869 | this.label1.Text = "SFTP Username"; 870 | // 871 | // password 872 | // 873 | this.password.Location = new System.Drawing.Point(21, 117); 874 | this.password.Name = "password"; 875 | this.password.PasswordChar = '*'; 876 | this.password.Size = new System.Drawing.Size(100, 20); 877 | this.password.TabIndex = 114; 878 | // 879 | // username 880 | // 881 | this.username.Location = new System.Drawing.Point(21, 74); 882 | this.username.Name = "username"; 883 | this.username.Size = new System.Drawing.Size(100, 20); 884 | this.username.TabIndex = 113; 885 | // 886 | // btnCheckNotification 887 | // 888 | this.btnCheckNotification.Location = new System.Drawing.Point(21, 290); 889 | this.btnCheckNotification.Name = "btnCheckNotification"; 890 | this.btnCheckNotification.Size = new System.Drawing.Size(114, 23); 891 | this.btnCheckNotification.TabIndex = 112; 892 | this.btnCheckNotification.Text = "Check Notification"; 893 | this.btnCheckNotification.UseVisualStyleBackColor = true; 894 | this.btnCheckNotification.Click += new System.EventHandler(this.btnCheckNotification_Click); 895 | // 896 | // MainForm 897 | // 898 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 899 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 900 | this.ClientSize = new System.Drawing.Size(996, 488); 901 | this.Controls.Add(this.tabControl1); 902 | this.Controls.Add(this.button1); 903 | this.Name = "MainForm"; 904 | this.Load += new System.EventHandler(this.MainForm_Load); 905 | this.tabControl1.ResumeLayout(false); 906 | this.tabPage1.ResumeLayout(false); 907 | this.tabPage1.PerformLayout(); 908 | this.tabPage2.ResumeLayout(false); 909 | this.tabPage2.PerformLayout(); 910 | this.tabPage3.ResumeLayout(false); 911 | this.tabPage3.PerformLayout(); 912 | this.tabPage4.ResumeLayout(false); 913 | this.tabPage4.PerformLayout(); 914 | this.ResumeLayout(false); 915 | 916 | } 917 | 918 | #endregion 919 | 920 | private System.Windows.Forms.OpenFileDialog dlgOpen; 921 | private System.Windows.Forms.SaveFileDialog dlgSave; 922 | private System.Windows.Forms.FolderBrowserDialog dlgOpenFolder; 923 | private System.Windows.Forms.Button button1; 924 | private System.Windows.Forms.TabControl tabControl1; 925 | private System.Windows.Forms.TabPage tabPage1; 926 | private System.Windows.Forms.CheckBox chkAutoSendSFTP; 927 | private System.Windows.Forms.CheckBox chkSendFolder; 928 | private System.Windows.Forms.CheckBox chkSignatureValidation; 929 | private System.Windows.Forms.CheckBox chkSchemaValidation; 930 | private System.Windows.Forms.RadioButton radCBC; 931 | private System.Windows.Forms.RadioButton radECB; 932 | private System.Windows.Forms.CheckBox chkM1O2; 933 | private System.Windows.Forms.Button cmdPopulateSettings; 934 | private System.Windows.Forms.Button btnBrowseHCTACert; 935 | private System.Windows.Forms.TextBox txtHCTACode; 936 | private System.Windows.Forms.Label lblHCTACode; 937 | private System.Windows.Forms.TextBox txtHCTACertPassword; 938 | private System.Windows.Forms.Label lblEncryptionHCTAPassword; 939 | private System.Windows.Forms.TextBox txtHCTACert; 940 | private System.Windows.Forms.Label lblHCTAKey; 941 | private System.Windows.Forms.Button btnSignXML; 942 | private System.Windows.Forms.TextBox txtKeyCertPassword; 943 | private System.Windows.Forms.Label lblKeyEncryptionCertPassword; 944 | private System.Windows.Forms.Button btnBrowseKeyCert; 945 | private System.Windows.Forms.TextBox txtKeyCert; 946 | private System.Windows.Forms.Label label3; 947 | private System.Windows.Forms.TextBox txtCertPass; 948 | private System.Windows.Forms.Label lblCertPass; 949 | private System.Windows.Forms.Button btnBrowseCert; 950 | private System.Windows.Forms.TextBox txtCert; 951 | private System.Windows.Forms.Label lblCert; 952 | private System.Windows.Forms.Button btnBrowseXml; 953 | private System.Windows.Forms.TextBox txtXmlFile; 954 | private System.Windows.Forms.Label lblLoadXML; 955 | private System.Windows.Forms.TabPage tabPage2; 956 | private System.Windows.Forms.Button btnBrowseOutput; 957 | private System.Windows.Forms.TextBox txtNotificationFolder; 958 | private System.Windows.Forms.Label lblOutput; 959 | private System.Windows.Forms.Button btnDecryptZip; 960 | private System.Windows.Forms.TextBox txtRecKeyPassword; 961 | private System.Windows.Forms.Label lblRecPass; 962 | private System.Windows.Forms.Button btnBrowseRecCert; 963 | private System.Windows.Forms.TextBox txtReceiverCert; 964 | private System.Windows.Forms.Label lblReceiverCert; 965 | private System.Windows.Forms.Button btnBrowseNotificationZip; 966 | private System.Windows.Forms.TextBox txtNotificationZip; 967 | private System.Windows.Forms.Label lblZipFile; 968 | private System.Windows.Forms.ComboBox cmbTaxYear; 969 | private System.Windows.Forms.Label lblTaxYear; 970 | private System.Windows.Forms.TabPage tabPage3; 971 | private System.Windows.Forms.Label lblSchemaFolder; 972 | private System.Windows.Forms.Button btnSchemaFolder; 973 | private System.Windows.Forms.TextBox txtSchemaFolder; 974 | private System.Windows.Forms.Button btnSchemaFile; 975 | private System.Windows.Forms.TextBox txtSchemaFile; 976 | private System.Windows.Forms.Label lblSchemaFile; 977 | private System.Windows.Forms.Button btnCheckSchema; 978 | private System.Windows.Forms.Button btnBrowsePayload; 979 | private System.Windows.Forms.TextBox txtSignedPayloadFile; 980 | private System.Windows.Forms.Label lblSignedPayloadFile; 981 | private System.Windows.Forms.Button cmdCheckSignature; 982 | private System.Windows.Forms.TabPage tabPage4; 983 | private System.Windows.Forms.ComboBox cmbSFTPServers; 984 | private System.Windows.Forms.Label label5; 985 | private System.Windows.Forms.Label label4; 986 | private System.Windows.Forms.TextBox txtDecryptPassword; 987 | private System.Windows.Forms.Label lblDecryptPassword; 988 | private System.Windows.Forms.Button btnBrowseDecKey; 989 | private System.Windows.Forms.TextBox txtDecryptKey; 990 | private System.Windows.Forms.Label lblDecryptKey; 991 | private System.Windows.Forms.Label label2; 992 | private System.Windows.Forms.Label label1; 993 | private System.Windows.Forms.TextBox password; 994 | private System.Windows.Forms.TextBox username; 995 | private System.Windows.Forms.Button btnCheckNotification; 996 | private System.Windows.Forms.Button btnBrowseDownloadFolder; 997 | private System.Windows.Forms.Label label6; 998 | private System.Windows.Forms.TextBox txtDownFolder; 999 | } 1000 | } 1001 | 1002 | --------------------------------------------------------------------------------