protected void Page_Load(object sender, EventArgs e) { // Get userfile from query string. var userfile = Request.QueryString["userfile"]; // Our action only works if a userfile is given to work with. if (string.IsNullOrEmpty(userfile)) { // Return "Not Found" HTTP response. Response.StatusCode = 404; Response.End(); return; } // Read document from storage. var fileContent = Storage.GetFile(userfile); // Open an validate signatures with PKI SDK based on the PAdES Basic policy. var signature = Lacuna.Pki.Pades.PadesSignature.Open(fileContent); var policyMapper = PadesPoliciesForGeneration.GetPadesBasic(Util.GetTrustArbitrator()); // Generate a model to be shown on the page from the PadesSignature instance computed from Open() // method above. This class can be inspected on SignatureModels.cs file. In this class, we validate // each signature based on the policy mapper defined above. var model = new PadesSignatureModel(signature, policyMapper); // Set property for rendering on page (see aspx file). this.Model = model; }
protected void Page_Load(object sender, EventArgs e) { // Get verification code from query string. var formattedVerificationCode = Request.QueryString["c"]; // On PrinterFriendlyVersion.aspx, we stored the unformatted version of the verification code // (without hyphens) but used the formatted version (with hyphens) on the printer-friendly PDF. Now, // we remove the hyphens before looking it up. var verificationCode = AlphaCode.Parse(formattedVerificationCode); // Get document associated with verification code. var fileId = Storage.LookupVerificationCode(verificationCode); if (fileId == null) { // Invalid code given! // Small delay to slow down brute-force attacks (if you want to be extra careful you might want // to add a CAPTCHA to the process). Thread.Sleep(TimeSpan.FromSeconds(2)); // Return "Not Found" HTTP response. Response.StatusCode = 404; Response.End(); return; } // Read document from storage. var fileContent = Storage.GetFile(fileId); // Open and validate signatures with PKI SDK based on the PAdES Basic policy. var signature = Lacuna.Pki.Pades.PadesSignature.Open(fileContent); var policyMapper = PadesPoliciesForGeneration.GetPadesBasic(Util.GetTrustArbitrator()); // Generate a model to be shown on the page from the PadesSignature instance computed from Open() // method above. This class can be inspected on SignatureModels.cs file. In this class, we validate // each signature based on the policy mapper defined above. var model = new PadesSignatureModel(signature, policyMapper); // Set properties for rendering on page (see aspx file). this.FileId = fileId; this.Model = model; }