private string doSignPKCS12(string xmlInput, PrivateKeyManager key, CertificateX509 certificate, string dSigType, string canonicalizationType, string keyInfoType, string xmlSchemaPath) { if (TransformsWrapperUtils.getTransformsWrapper(dSigType, this.error) != TransformsWrapper.ENVELOPED) { error.setError("DS019", "Not implemented DSigType"); return(""); } if (!certificate.Inicialized) { this.error.setError("DS0220", "Certificate not loaded"); return(""); } if (SecurityUtils.compareStrings(certificate.getPublicKeyAlgorithm(), "ECDSA")) { this.error.setError("DS004", "XML signature with ECDSA keys is not implemented on Net Framework"); return(""); } XmlDocument xmlDoc = SignatureUtils.documentFromString(xmlInput, xmlSchemaPath, this.error); if (this.HasError()) { return(""); } return(Sign(xmlDoc, key, certificate, dSigType, canonicalizationType, keyInfoType, "", "")); }
/******** EXTERNAL OBJECT PUBLIC METHODS - END ********/ private bool doSignFilePKCS12(string xmlFilePath, PrivateKeyManager key, CertificateX509 certificate, string dSigType, string canonicalizationType, string outputPath, string keyInfoType, string xmlSchemaPath) { if (TransformsWrapperUtils.getTransformsWrapper(dSigType, this.error) != TransformsWrapper.ENVELOPED) { error.setError("DS009", "Not implemented DSigType"); return(false); } if (!SignatureUtils.validateExtensionXML(xmlFilePath)) { this.error.setError("DS010", "Not XML file"); return(false); } if (!certificate.Inicialized) { this.error.setError("DS011", "Certificate not loaded"); return(false); } if (SecurityUtils.compareStrings(certificate.getPublicKeyAlgorithm(), "ECDSA")) { this.error.setError("DS004", "XML signature with ECDSA keys is not implemented on Net Framework"); return(false); } XmlDocument xmlDoc = SignatureUtils.documentFromFile(xmlFilePath, xmlSchemaPath, this.error); if (this.HasError()) { return(false); } string result = Sign(xmlDoc, key, certificate, dSigType, canonicalizationType, keyInfoType, "", ""); if (result == null || SecurityUtils.compareStrings("", result)) { this.error.setError("DS012", "Error generating signature"); return(false); } else { // string prefix = "<?xml version=”1.0″ encoding=”UTF-8″ ?>".Trim(); string prefix = ""; return(SignatureUtils.writeToFile(result, outputPath, prefix, this.error)); } }