Esempio n. 1
0
        public ResCode Post(TaskInfo taskInfo)
        {
            ResCode res = new ResCode();

            res.obj = taskInfo;
            return(res);
        }
Esempio n. 2
0
        public static void performTest(String method)
        {
            bool         print    = true;
            ResCode      res_code = new ResCode();
            SignResponse resp     = null;

            writeToFile("\nTESTING: " + method);
            switch (method)
            {
            case string t when t == "SignPDF_NOPIN":
                resp     = client.SignPDF_NOPIN(certID, File.ReadAllBytes(fnTestPDF), 1, 0, 0, 150, 150, File.ReadAllBytes(fnSig), "");
                res_code = resp.Result;
                if (resp.SignedBytes != null)
                {
                    saveFile(fnSignedPDF, resp.SignedBytes);
                }
                break;

            case string t when t == "SignPDF_NOPIN_FIELD":
                print = false;
                writeToFile("* " + method + " method was not defined");
                break;

            case string t when t == "SignPDF_PIN_FilePath":
                print = false;
                //String path = Path.GetFullPath(fnTest);
                //String path = fnTest;
                //String path = "/etc/hosts";
                //String path = "C:\\Windows\\System32\\cmd.exe";
                String path = "C:\\inetpub\\wwwroot\\iisstart.htm";
                //String path = "signed.pdf";
                //String path = "C:\\test.pdf";
                res_code = client.SignPDF_PIN_FilePath(certID, path, "aaa.pdf", 1, 0, 0, 150, 150, pinCode, File.ReadAllBytes(fnSig), "").Result;
                writeToFile("Not testing 'SignPDF_PIN_FilePath' functionality as it takes input file paths that are located on the server side.");
                break;

            case string t when t == "SignPDF_PIN":
                resp     = client.SignPDF_PIN(certID, File.ReadAllBytes(fnTestPDF), 1, 0, 0, 150, 150, pinCode, File.ReadAllBytes(fnSig), "");
                res_code = resp.Result;
                if (resp.SignedBytes != null)
                {
                    saveFile(fnSignedPDF, resp.SignedBytes);
                }
                break;

            case string t when t == "SignPDF_SetImage":
                resp     = client.SignPDF_SetImage(File.ReadAllBytes(fnTestPDF), 1, 0, 0, 150, 150, File.ReadAllBytes(fnSig), "");
                res_code = resp.Result;
                if (resp.SignedBytes != null)
                {
                    saveFile(fnPosted, resp.SignedBytes);
                }
                break;

            case string t when t == "Get_PDFSigners":
                print = false;
                String[] strRes = client.Get_PDFSigners(File.ReadAllBytes(fnSignedPDF), "");
                writeToFile("Exspected strRes is: " + "NOT NULL");
                writeToFile("strRes is: " + String.Join("", strRes));
                writeToFile("TEST " + (strRes != null ? "PASSED" : "FAILED"));
                break;

            case string t when t == "VerifyPDF":
                MultiSignValidationResponse msvRes = client.VerifyPDF(File.ReadAllBytes(fnSignedPDF));
                res_code = msvRes.OperationResult;
                break;

            case string t when t == "SignPDF_PIN_Placeholder":
                resp     = client.SignPDF_PIN_Placeholder(certID, File.ReadAllBytes(fnTestPDF), pinCode, "dip", 150, 150, File.ReadAllBytes(fnSig), "");
                res_code = resp.Result;
                if (resp.SignedBytes != null)
                {
                    saveFile(fnSignedPDFPlaceholder, resp.SignedBytes);
                }
                break;

            case string t when t == "EncryptPDF_UserOwnerPasswords":
                resp     = client.EncryptPDF_UserOwnerPasswords(File.ReadAllBytes(fnTestPDF), "tony1", "tony");
                res_code = resp.Result;
                if (resp.SignedBytes != null)
                {
                    saveFile(fnSignedPDFEncrypted, resp.SignedBytes);
                }
                break;

            case string t when t == "SignCMS_PIN":
                resp = client.SignCMS_PIN(certID, digest, pinCode, CTInterfaces.CTDigestAlg.SHA1, "", "");
                if (resp.SignedBytes != null)
                {
                    dygestedContent = resp.SignedBytes;
                }
                res_code = resp.Result;
                break;

            case string t when t == "SignCMS_NOPIN":
                print = false;
                writeToFile("* " + method + " method was not defined");
                break;

            case string t when t == "SignRAW_PIN":
                resp     = client.SignRAW_PIN(certID, CTInterfaces.CTDigestAlg.SHA1, digest, pinCode, "");
                res_code = resp.Result;
                break;

            case string t when t == "VerifyCMS":
                if (dygestedContent != null)
                {
                    resp     = client.VerifyCMS(digest, dygestedContent);
                    res_code = resp.Result;
                }
                else
                {
                    res_code = ResCode.NO_PERM_TOKEN_PROVIDED;
                }
                break;

            case string t when t == "SignXml_PIN":
                resp     = client.SignXml_PIN(certID, File.ReadAllBytes(fnTestXml), pinCode, "");
                res_code = resp.Result;
                if (resp.SignedBytes != null)
                {
                    saveFile(fnSignedXml, resp.SignedBytes);
                }
                else
                {
                    writeToFile("Error: " + res_code);
                }
                break;

            case string t when t == "SignForeclosure":
                resp     = client.SignForeclosure(certID, pinCode, File.ReadAllBytes(fnTestXml), "");
                res_code = resp.Result;
                if (resp.SignedBytes != null)
                {
                    saveFile(fnSignedXmlForeclosure, resp.SignedBytes);
                }
                break;

            case string t when t == "AddIdNumberToIkul":
                resp     = client.AddIdNumberToIkul(File.ReadAllBytes(fnTestXml), idNumber, "");
                res_code = resp.Result;
                if (resp.SignedBytes != null)
                {
                    saveFile(fnSignedXmlIdNumber, resp.SignedBytes);
                }
                break;

            case string t when t == "AddSigningTime":
                resp     = client.AddSigningTime(File.ReadAllBytes(fnTestXml), date, "");
                res_code = resp.Result;
                if (resp.SignedBytes != null)
                {
                    saveFile(fnSignedXmlSigningTime, resp.SignedBytes);
                }
                break;

            case string t when t == "SetCred_Absolute":
                try {
                    res_code = client.SetCred_Absolute(certID, pinCode, new DateTime(2050, 1, 1), "", "");
                }
                catch (Exception e) {
                    print = false;
                    writeToFile("EXCEPRION: " + e.ToString());
                }
                break;

            case string t when t == "SetCred_Sliding":
                try {
                    res_code = client.SetCred_Sliding(certID, pinCode, new TimeSpan(13, 0, 0), "", "");
                }catch (Exception e) {
                    print = false;
                    writeToFile("EXCEPRION: " + e.ToString());
                }
                break;

            case string t when t == "Cred_Verify":
                res_code = client.Cred_Verify(certID, pinCode, "");
                break;

            case string t when t == "Cred_IsAvailable":
                print = false;
                bool boolRes = client.Cred_IsAvailable(certID, "", "");
                writeToFile("Exspected Result is: " + true);
                writeToFile("Result is: " + boolRes.ToString());
                writeToFile("TEST " + (boolRes == true ? "PASSED" : "FAILED"));
                break;

            case string t when t == "Cred_Remove":

                print = false;
                writeToFile("* " + method + " method was not defined");
                break;

            case string t when t == "GetVersion":
                String version = client.GetVersion().ToString();
                if (IsValidVersion(version))
                {
                    res_code = ResCode.SUCCESS;
                    writeToFile("Version is: " + client.GetVersion().ToString());
                }
                else
                {
                    res_code = ResCode.NO_PERM_TOKEN_PROVIDED;
                }
                break;

            case string t when t == "GetCardInfo":
                CardInfoResponse info = client.GetCardInfo(certID, pinCode, "");
                res_code = info.Result;
                break;

            case string t when t == "SignWord_PIN":
                resp     = client.SignWord_PIN(certID, File.ReadAllBytes(fnTestWord), pinCode, "", "");
                res_code = resp.Result;
                if (resp.SignedBytes != null)
                {
                    saveFile(fnSignedWord, resp.SignedBytes);
                }
                break;

            case string t when t == "SignExcel_PIN":
                resp     = client.SignExcel_PIN(certID, File.ReadAllBytes(fnTestExcel), pinCode, "", "");
                res_code = resp.Result;
                if (resp.SignedBytes != null)
                {
                    saveFile(fnSignedExcel, resp.SignedBytes);
                }
                break;

            case string t when t == "SignTiff_PIN":
                resp     = client.SignTiff_PIN(certID, File.ReadAllBytes(fnTestTiff), pinCode, 150, 150, File.ReadAllBytes(fnSig), "", "");
                res_code = resp.Result;
                if (resp.SignedBytes != null)
                {
                    saveFile(fnSignedTiff, resp.SignedBytes);
                }
                break;

            case string t when t == "VerifyTiff":
                MultiSignValidationResponse msvResTiff = client.VerifyTiff(File.ReadAllBytes(fnSignedTiff));
                res_code = msvResTiff.OperationResult;
                break;

            case string t when t == "SignWord_NOPIN":
                print = false;
                writeToFile("* " + method + " method was not defined");
                break;

            case string t when t == "SignExcel_NOPIN":
                print = false;
                writeToFile("* " + method + " method was not defined");
                break;

            case string t when t == "SignTiff_NOPIN":
                print = false;
                writeToFile("* " + method + " method was not defined");
                break;

            case string t when t == "SignMeches_PIN":
                resp     = client.SignMeches_PIN(certID, File.ReadAllBytes(fnTestPDF), "", "pdf", pinCode, "");
                res_code = resp.Result;
                if (resp.SignedBytes != null)
                {
                    saveFile(fnSignedPDFMech, resp.SignedBytes);
                }
                break;
            }

            if (print)
            {
                writeToFile("Exspected ResCode is: " + ResCode.SUCCESS.ToString());
                writeToFile("ResCode is: " + res_code.ToString());
                writeToFile("TEST " + (res_code == ResCode.SUCCESS ? "PASSED" : "FAILED"));
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="pmt"></param>
 /// <param name="msgTime"></param>
 /// <param name="data"></param>
 public WSResModel(ResCode code, string msg = null, object data = null)
 {
     this.Code = code;
     this.Msg  = msg;
     this.Data = data;
 }