From 9950831959b9579e50f9cc855018b55065815383 Mon Sep 17 00:00:00 2001 From: "ARTECH\\sgrampone" Date: Wed, 13 Jul 2022 17:26:40 -0300 Subject: [PATCH] Refactor GeneXusXmlSignature Module issue#97276 --- .../java/com/genexus/dsig/XmlDSigSigner.java | 317 +++++------------- .../utils/AsymmetricSigningAlgorithm.java | 4 +- .../genexus/utils/CanonicalizerWrapper.java | 8 +- .../java/com/genexus/utils/KeyInfoType.java | 4 +- .../utils/MessageDigestAlgorithmWrapper.java | 6 +- .../genexus/utils/SignatureElementType.java | 2 +- .../com/genexus/utils/TransformsWrapper.java | 6 +- .../genexus/utils/XMLSignatureWrapper.java | 6 +- 8 files changed, 111 insertions(+), 242 deletions(-) diff --git a/GeneXusXmlSignature/src/main/java/com/genexus/dsig/XmlDSigSigner.java b/GeneXusXmlSignature/src/main/java/com/genexus/dsig/XmlDSigSigner.java index be9b8ee..05b9959 100644 --- a/GeneXusXmlSignature/src/main/java/com/genexus/dsig/XmlDSigSigner.java +++ b/GeneXusXmlSignature/src/main/java/com/genexus/dsig/XmlDSigSigner.java @@ -2,18 +2,13 @@ import java.io.ByteArrayOutputStream; import java.io.File; -import java.net.MalformedURLException; - +import java.security.PrivateKey; import java.security.PublicKey; import java.security.cert.X509Certificate; -import java.security.PrivateKey; import org.apache.xml.security.algorithms.SignatureAlgorithm; -import org.apache.xml.security.exceptions.XMLSecurityException; import org.apache.xml.security.keys.content.X509Data; import org.apache.xml.security.signature.XMLSignature; -import org.apache.xml.security.signature.XMLSignatureException; -import org.apache.xml.security.transforms.TransformationException; import org.apache.xml.security.transforms.Transforms; import org.apache.xml.security.transforms.params.XPathContainer; import org.apache.xml.security.utils.Constants; @@ -59,221 +54,77 @@ public XmlDSigSigner() { /******** EXTERNAL OBJECT PUBLIC METHODS - BEGIN ********/ - public boolean doSignFile(String xmlFilePath, com.genexus.securityapicommons.commons.PrivateKey key, Certificate certificate, String outputPath, - DSigOptions options) { - this.error.cleanError(); - return doSignFilePKCS12(xmlFilePath, key, certificate, options.getDSigSignatureType(), - options.getCanonicalization(), outputPath, - options.getKeyInfoType(), options.getXmlSchemaPath()); - } - - public boolean doSignFileElement(String xmlFilePath, String xPath, com.genexus.securityapicommons.commons.PrivateKey key, + public boolean doSignFile(String xmlFilePath, com.genexus.securityapicommons.commons.PrivateKey key, Certificate certificate, String outputPath, DSigOptions options) { - this.error.cleanError(); - return doSignFileElementPKCS12(xmlFilePath, xPath, key, certificate, options.getDSigSignatureType(), - options.getCanonicalization(), outputPath, - options.getKeyInfoType(), options.getXmlSchemaPath(), options.getIdentifierAttribute()); + return Boolean.valueOf(axuiliarSign(xmlFilePath, key, certificate, outputPath, options, true, "")); } - public String doSign(String xmlInput, com.genexus.securityapicommons.commons.PrivateKey key, Certificate certificate, DSigOptions options) { - this.error.cleanError(); - return doSignPKCS12(xmlInput, key, certificate, options.getDSigSignatureType(), - options.getCanonicalization(), options.getKeyInfoType(), - options.getXmlSchemaPath()); + public String doSign(String xmlInput, com.genexus.securityapicommons.commons.PrivateKey key, + Certificate certificate, DSigOptions options) { + return axuiliarSign(xmlInput, key, certificate, "", options, false, ""); } - public String doSignElement(String xmlInput, String xPath, com.genexus.securityapicommons.commons.PrivateKey key, Certificate certificate, + public boolean doSignFileElement(String xmlFilePath, String xPath, + com.genexus.securityapicommons.commons.PrivateKey key, Certificate certificate, String outputPath, DSigOptions options) { - this.error.cleanError(); - return doSignElementPKCS12(xmlInput, xPath, key, certificate, options.getDSigSignatureType(), - options.getCanonicalization(), options.getKeyInfoType(), - options.getXmlSchemaPath(), options.getIdentifierAttribute()); + return Boolean.valueOf(axuiliarSign(xmlFilePath, key, certificate, outputPath, options, true, xPath)); + } + + public String doSignElement(String xmlInput, String xPath, com.genexus.securityapicommons.commons.PrivateKey key, + Certificate certificate, DSigOptions options) { + return axuiliarSign(xmlInput, key, certificate, "", options, false, xPath); } public boolean doVerify(String xmlSigned, DSigOptions options) { - this.error.cleanError(); - Document doc = SignatureUtils.documentFromString(xmlSigned, options.getXmlSchemaPath(), this.error); - if (this.hasError()) { - return false; - } - String baseURI = ""; - return verify(doc, baseURI, options.getIdentifierAttribute()); + return auxiliarVerify(xmlSigned, options, false, false, null); } public boolean doVerifyFile(String xmlFilePath, DSigOptions options) { - this.error.cleanError(); - if (!SignatureUtils.validateExtensionXML(xmlFilePath)) { - this.error.setError("DS001", "The file is not an xml file"); - return false; - } - Document doc = SignatureUtils.documentFromFile(xmlFilePath, options.getXmlSchemaPath(), this.error); - if (this.hasError()) { - return false; - } - File f = new File(xmlFilePath); - String baseURI = ""; - try { - baseURI = f.toURI().toURL().toString(); - } catch (MalformedURLException e) { - this.error.setError("DS002", "Error on baseURI"); - return false; - } - return verify(doc, baseURI, options.getIdentifierAttribute()); - + return auxiliarVerify(xmlFilePath, options, true, false, null); } public boolean doVerifyWithCert(String xmlSigned, Certificate certificate, DSigOptions options) { - this.error.cleanError(); - CertificateX509 cert = (CertificateX509) certificate; - if (!cert.Inicialized()) { - this.error.setError("DS003", "Certificate not loaded"); - return false; - } - Document doc = SignatureUtils.documentFromString(xmlSigned, options.getXmlSchemaPath(), this.error); - if (this.hasError()) { - return false; - } - String baseURI = ""; - return verify(doc, baseURI, cert, options.getIdentifierAttribute()); + return auxiliarVerify(xmlSigned, options, false, true, certificate); } public boolean doVerifyFileWithCert(String xmlFilePath, Certificate certificate, DSigOptions options) { - this.error.cleanError(); - if (!SignatureUtils.validateExtensionXML(xmlFilePath)) { - this.error.setError("DS007", "The file is not an xml file"); - return false; - } - CertificateX509 cert = (CertificateX509)certificate; - if (!cert.Inicialized()) { - this.error.setError("DS005", "Certificate not loaded"); - return false; - } - Document doc = SignatureUtils.documentFromFile(xmlFilePath, options.getXmlSchemaPath(), this.error); - if (this.hasError()) { - return false; - } - File f = new File(xmlFilePath); - String baseURI = ""; - try { - baseURI = f.toURI().toURL().toString(); - } catch (MalformedURLException e) { - this.error.setError("DS008", "Error on baseURI"); - return false; - } - - return verify(doc, baseURI, cert, options.getIdentifierAttribute()); + return auxiliarVerify(xmlFilePath, options, true, true, certificate); } /******** EXTERNAL OBJECT PUBLIC METHODS - END ********/ - private boolean doSignFileElementPKCS12(String xmlFilePath, String xPath, com.genexus.securityapicommons.commons.PrivateKey key, - Certificate certificate, String dSigType, String canonicalizationType, String outputPath, String keyInfoType, String xmlSchemaPath, String id) { - if (TransformsWrapper.getTransformsWrapper(dSigType, this.error) != TransformsWrapper.ENVELOPED) { - error.setError("DS013", "Not implemented DSigType"); - return false; - } - if (!SignatureUtils.validateExtensionXML(xmlFilePath)) { - this.error.setError("DS014", "Not XML file"); - return false; - } - CertificateX509 cert = (CertificateX509)certificate; - if (!cert.Inicialized()) { - this.error.setError("DS015", "Certificate not loaded"); - return false; - } - Document xmlDoc = SignatureUtils.documentFromFile(xmlFilePath, xmlSchemaPath, this.error); - if (this.hasError()) { - return false; - } - - String result = Sign(xmlDoc, (PrivateKeyManager)key, cert,dSigType, canonicalizationType, - keyInfoType, xPath, id); - if (result == null || SecurityUtils.compareStrings("", result)) { - this.error.setError("DS016", "Error generating signature"); - return false; - } else { - String prefix = ""; - return SignatureUtils.writeToFile(result, outputPath, prefix, this.error); - } - } - - private String doSignElementPKCS12(String xmlInput, String xPath, com.genexus.securityapicommons.commons.PrivateKey key, - Certificate certificate, String dSigType, String canonicalizationType, - String keyInfoType, String xmlSchemaPath, String id) { - if (TransformsWrapper.getTransformsWrapper(dSigType, this.error) != TransformsWrapper.ENVELOPED) { - error.setError("DS017", "Not implemented DSigType"); - return ""; + private String axuiliarSign(String xmlInput, com.genexus.securityapicommons.commons.PrivateKey key, + Certificate certificate, String outputPath, DSigOptions options, boolean isFile, String xPath) { + if (TransformsWrapper.getTransformsWrapper(options.getDSigSignatureType(), + this.error) != TransformsWrapper.ENVELOPED) { + error.setError("XD001", "Not implemented DSigType"); } - CertificateX509 cert = (CertificateX509)certificate; + CertificateX509 cert = (CertificateX509) certificate; if (!cert.Inicialized()) { - this.error.setError("DS018", "Certificate not loaded"); - return ""; - } - Document xmlDoc = SignatureUtils.documentFromString(xmlInput, xmlSchemaPath, this.error); - if (this.hasError()) { - return ""; + this.error.setError("XD002", "Certificate not loaded"); } - return Sign(xmlDoc, (PrivateKeyManager)key, cert, dSigType, canonicalizationType, keyInfoType, - xPath, id); - } - private String doSignPKCS12(String xmlInput, com.genexus.securityapicommons.commons.PrivateKey key, Certificate certificate, String dSigType, - String canonicalizationType, String keyInfoType, String xmlSchemaPath) { - if (TransformsWrapper.getTransformsWrapper(dSigType, this.error) != TransformsWrapper.ENVELOPED) { - error.setError("DS019", "Not implemented DSigType"); - return ""; - } - CertificateX509 cert = (CertificateX509)certificate; - if (!cert.Inicialized()) { - this.error.setError("DS020", "Certificate not loaded"); - return ""; - } - Document xmlDoc = SignatureUtils.documentFromString(xmlInput, xmlSchemaPath, this.error); + Document xmlDoc = loadDocument(isFile, xmlInput, options); if (this.hasError()) { return ""; } - return Sign(xmlDoc, (PrivateKeyManager)key, cert, dSigType, canonicalizationType, keyInfoType, - "", ""); - } - - private boolean doSignFilePKCS12(String xmlFilePath, com.genexus.securityapicommons.commons.PrivateKey key, Certificate certificate, - String dSigType, String canonicalizationType, String outputPath, - String keyInfoType, String xmlSchemaPath) { - if (TransformsWrapper.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; - } - CertificateX509 cert = (CertificateX509)certificate; - if (!cert.Inicialized()) { - this.error.setError("DS011", "Certificate not loaded"); - } - Document xmlDoc = SignatureUtils.documentFromFile(xmlFilePath, xmlSchemaPath, this.error); - if (this.hasError()) { - return false; - } - String result = Sign(xmlDoc, (PrivateKeyManager)key, cert, dSigType, canonicalizationType, - keyInfoType, "", ""); - if (result == null || SecurityUtils.compareStrings("", result)) { - this.error.setError("DS012", "Error generating signature"); - return false; - } else { + String result = Sign(xmlDoc, (PrivateKeyManager) key, cert, options.getDSigSignatureType(), + options.getCanonicalization(), options.getKeyInfoType(), xPath, options.getIdentifierAttribute()); + if (isFile) { String prefix = ""; - return SignatureUtils.writeToFile(result, outputPath, prefix, this.error); + result = Boolean.toString(SignatureUtils.writeToFile(result, outputPath, prefix, this.error)); } + return result; } - private String Sign(Document xmlInput, PrivateKeyManager key, CertificateX509 certificate, String dSigType, String canonicalizationType, String keyInfoType, String xpath, - String id) { + private String Sign(Document xmlInput, PrivateKeyManager key, CertificateX509 certificate, String dSigType, + String canonicalizationType, String keyInfoType, String xpath, String id) { SignatureElementType signatureElementType; if (!SecurityUtils.compareStrings(xpath, "")) { if (xpath.charAt(0) == '#') { signatureElementType = SignatureElementType.id; if (id == null || SecurityUtils.compareStrings(id, "")) { - this.error.setError("DS021", "identifier attribute name missing"); + this.error.setError("XD003", "Identifier attribute name missing"); return ""; } } else { @@ -313,8 +164,8 @@ private String Sign(Document xmlInput, PrivateKeyManager key, CertificateX509 ce return ""; } sig = new XMLSignature(xmlInput, null, signatureAlgorithm.getElement(), canonElem); - } catch (XMLSecurityException e) { - this.error.setError("DS022", "Error on signature algorithm"); + } catch (Exception e) { + this.error.setError("XD004", e.getMessage()); return null; } @@ -356,8 +207,8 @@ private String Sign(Document xmlInput, PrivateKeyManager key, CertificateX509 ce } sig.addDocument(referenceURI, transforms, MessageDigestAlgorithmWrapper.getDigestMethod(messageDigestAlgorithmWrapper, this.error)); - } catch (TransformationException | XMLSignatureException e) { - this.error.setError("DS024", "Transformation errors"); + } catch (Exception e) { + this.error.setError("XD005", e.getMessage()); return ""; } KeyInfoType kyInfo = KeyInfoType.getKeyInfoType(keyInfoType, this.error); @@ -371,12 +222,12 @@ private String Sign(Document xmlInput, PrivateKeyManager key, CertificateX509 ce try { X509Certificate x509Certificate = certificate.Cert(); X509Data x509data = new X509Data(sig.getDocument()); - x509data.addIssuerSerial(x509Certificate.getIssuerDN().getName(), x509Certificate.getSerialNumber()); + x509data.addIssuerSerial(x509Certificate.getIssuerDN().getName(), x509Certificate.getSerialNumber()); x509data.addSubjectName(x509Certificate); x509data.addCertificate(x509Certificate); sig.getKeyInfo().add(x509data); - } catch (XMLSecurityException e) { - this.error.setError("DS025", "Error adding certificate to signature"); + } catch (Exception e) { + this.error.setError("XD006", e.getMessage()); } break; case KeyValue: @@ -385,13 +236,13 @@ private String Sign(Document xmlInput, PrivateKeyManager key, CertificateX509 ce case NONE: break; default: - this.error.setError("DS026", "Undefined KeyInfo type"); + this.error.setError("XD007", "Undefined KeyInfo type"); return ""; } try { sig.sign(this.privateKey); - } catch (XMLSignatureException e) { - error.setError("DS027", "Error at signing"); + } catch (Exception e) { + error.setError("XD008", e.getMessage()); e.printStackTrace(); return null; @@ -405,7 +256,6 @@ private String Sign(Document xmlInput, PrivateKeyManager key, CertificateX509 ce private boolean inicializeInstanceVariables(PrivateKeyManager key, CertificateX509 certificate) { - this.privateKey = key.getPrivateKeyXML(); this.publicKey = certificate.getPublicKeyXML(); this.digest = certificate.getPublicKeyHash(); @@ -413,7 +263,31 @@ private boolean inicializeInstanceVariables(PrivateKeyManager key, CertificateX5 return true; } - private boolean verify(Document doc, String baseURI, String id) { + private boolean auxiliarVerify(String input, DSigOptions options, boolean isFile, boolean withCert, + Certificate certificate) { + if (TransformsWrapper.getTransformsWrapper(options.getDSigSignatureType(), + this.error) != TransformsWrapper.ENVELOPED) { + error.setError("XD001", "Not implemented DSigType"); + } + Document doc = loadDocument(isFile, input, options); + if (this.hasError()) { + return false; + } + String baseURI = ""; + if (isFile) { + + try { + File f = new File(input); + baseURI = f.toURI().toURL().toString(); + } catch (Exception e) { + this.error.setError("XD009", e.getMessage()); + return false; + } + } + return verify(doc, baseURI, options.getIdentifierAttribute(), withCert, (CertificateX509) certificate); + } + + private boolean verify(Document doc, String baseURI, String id, boolean withCert, CertificateX509 certificate) { Element sigElement = (Element) doc.getElementsByTagNameNS(Constants.SignatureSpecNS, Constants._TAG_SIGNATURE) .item(0); if (id != null && !SecurityUtils.compareStrings(id, "")) { @@ -422,53 +296,48 @@ private boolean verify(Document doc, String baseURI, String id) { .item(0); String sigId = ref.getAttribute(Constants._ATT_URI); if (sigId == null || SecurityUtils.compareStrings(sigId, "")) { - this.error.setError("DS029", "Could not find Reference URI for id"); + this.error.setError("XD010", "Could not find Reference URI for id"); return false; } Element idElement = (Element) SignatureUtils.getNodeFromID(doc, id, sigId, this.error); if (idElement == null) { - this.error.setError("DS030", "Could not find node from ID"); + this.error.setError("XD011", "Could not find node from ID"); return false; } idElement.setIdAttribute(id, true); } + boolean result = false; try { + XMLSignature signature = new XMLSignature(sigElement, baseURI); - return signature.checkSignatureValue(signature.getKeyInfo().getPublicKey()); - } catch (XMLSecurityException e) { + if (withCert) { + PublicKey pk = certificate.getPublicKeyXML(); + result = signature.checkSignatureValue(pk); + } else { + result = signature.checkSignatureValue(signature.getKeyInfo().getPublicKey()); + } + } catch (Exception e) { - this.error.setError("DS031", "Error on signature verification"); + this.error.setError("XD012", e.getMessage()); return false; } + return result; } - private boolean verify(Document doc, String baseURI, CertificateX509 certificate, String id) { - Element sigElement = (Element) doc.getElementsByTagNameNS(Constants.SignatureSpecNS, Constants._TAG_SIGNATURE) - .item(0); - if (id != null && !SecurityUtils.compareStrings(id, "")) { - Element ref = (Element) doc.getElementsByTagNameNS(Constants.SignatureSpecNS, Constants._TAG_REFERENCE) - .item(0); - String sigId = ref.getAttribute(Constants._ATT_URI); - if (sigId == null || SecurityUtils.compareStrings(sigId, "")) { - this.error.setError("DS032", "Could not find Reference URI for id"); - return false; - } - Element idElement = (Element) SignatureUtils.getNodeFromID(doc, id, sigId, this.error); - if (idElement == null) { - this.error.setError("DS033", "Could not find node from ID"); - return false; + private Document loadDocument(boolean isFile, String path, DSigOptions options) { + Document xmlDoc = null; + if (isFile) { + if (!SignatureUtils.validateExtensionXML(path)) { + this.error.setError("XD013", "Not XML file"); + return null; } - idElement.setIdAttribute(id, true); - } + xmlDoc = SignatureUtils.documentFromFile(path, options.getXmlSchemaPath(), this.error); - try { - XMLSignature signature = new XMLSignature(sigElement, baseURI); - PublicKey pk = certificate.getPublicKeyXML(); - return signature.checkSignatureValue(pk); - } catch (XMLSecurityException e) { - this.error.setError("DS034", "Error on verification"); - return false; + } else { + xmlDoc = SignatureUtils.documentFromString(path, options.getXmlSchemaPath(), this.error); } + return xmlDoc; } + } diff --git a/GeneXusXmlSignature/src/main/java/com/genexus/utils/AsymmetricSigningAlgorithm.java b/GeneXusXmlSignature/src/main/java/com/genexus/utils/AsymmetricSigningAlgorithm.java index 39db282..23e7be0 100644 --- a/GeneXusXmlSignature/src/main/java/com/genexus/utils/AsymmetricSigningAlgorithm.java +++ b/GeneXusXmlSignature/src/main/java/com/genexus/utils/AsymmetricSigningAlgorithm.java @@ -28,7 +28,7 @@ public static AsymmetricSigningAlgorithm getAsymmetricSigningAlgorithm(String as case "ECDSA": return AsymmetricSigningAlgorithm.ECDSA; default: - error.setError("AS001", "Unrecognized AsymmetricSigningAlgorithm"); + error.setError("ASA01", "Unrecognized AsymmetricSigningAlgorithm"); return null; } } @@ -47,7 +47,7 @@ public static String valueOf(AsymmetricSigningAlgorithm asymmetricSigningAlgorit case ECDSA: return "ECDSA"; default: - error.setError("AS002", "Unrecognized AsymmetricSigningAlgorithm"); + error.setError("ASA02", "Unrecognized AsymmetricSigningAlgorithm"); return ""; } } diff --git a/GeneXusXmlSignature/src/main/java/com/genexus/utils/CanonicalizerWrapper.java b/GeneXusXmlSignature/src/main/java/com/genexus/utils/CanonicalizerWrapper.java index 3927703..1d1f3ee 100644 --- a/GeneXusXmlSignature/src/main/java/com/genexus/utils/CanonicalizerWrapper.java +++ b/GeneXusXmlSignature/src/main/java/com/genexus/utils/CanonicalizerWrapper.java @@ -32,7 +32,7 @@ public static CanonicalizerWrapper getCanonicalizerWrapper(String canonicalizerW case "exc_C14N_WITH_COMMENTS": return CanonicalizerWrapper.ALGO_ID_C14N_EXCL_WITH_COMMENTS; default: - error.setError("CM001", "Unrecognized CanonicalizationMethod: " + canonicalizerWrapper); + error.setError("CAW01", "Unrecognized CanonicalizationMethod"); return null; } } @@ -55,7 +55,7 @@ public static String valueOf(CanonicalizerWrapper canonicalizerWrapper, Error er case ALGO_ID_C14N_EXCL_WITH_COMMENTS: return "exc_C14N_WITH_COMMENTS"; default: - error.setError("CM002", "Unrecognized CanonicalizationMethod"); + error.setError("CAW02", "Unrecognized CanonicalizationMethod"); return ""; } } @@ -78,7 +78,7 @@ public static String valueOfInternal(CanonicalizerWrapper canonicalizerWrapper, case ALGO_ID_C14N_EXCL_WITH_COMMENTS: return "ALGO_ID_C14N_EXCL_WITH_COMMENTS"; default: - error.setError("CM003", "Unrecognized CanonicalizationMethod"); + error.setError("CAW03", "Unrecognized CanonicalizationMethod"); return ""; } } @@ -94,7 +94,7 @@ public static String getCanonicalizationMethodAlorithm(CanonicalizerWrapper cano case ALGO_ID_C14N_EXCL_OMIT_COMMENTS: return Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS; default: - error.setError("CM004", "Unrecognized CanonicalizationMethod"); + error.setError("CAW04", "Unrecognized CanonicalizationMethod"); return null; } diff --git a/GeneXusXmlSignature/src/main/java/com/genexus/utils/KeyInfoType.java b/GeneXusXmlSignature/src/main/java/com/genexus/utils/KeyInfoType.java index ecf6982..3ceae26 100644 --- a/GeneXusXmlSignature/src/main/java/com/genexus/utils/KeyInfoType.java +++ b/GeneXusXmlSignature/src/main/java/com/genexus/utils/KeyInfoType.java @@ -15,7 +15,7 @@ public static KeyInfoType getKeyInfoType(String keyInfoType, Error error) { case "X509Certificate": return X509Certificate; default: - error.setError("KI001", "Unrecognized KeyInfoType"); + error.setError("KIT01", "Unrecognized KeyInfoType"); return NONE; } @@ -30,7 +30,7 @@ public static String valueOf(KeyInfoType keyInfoType, Error error) { case X509Certificate: return "X509Certificate"; default: - error.setError("KI002", "Unrecognized KeyInfoType"); + error.setError("KIT02", "Unrecognized KeyInfoType"); return ""; } } diff --git a/GeneXusXmlSignature/src/main/java/com/genexus/utils/MessageDigestAlgorithmWrapper.java b/GeneXusXmlSignature/src/main/java/com/genexus/utils/MessageDigestAlgorithmWrapper.java index 476b28c..f18aca7 100644 --- a/GeneXusXmlSignature/src/main/java/com/genexus/utils/MessageDigestAlgorithmWrapper.java +++ b/GeneXusXmlSignature/src/main/java/com/genexus/utils/MessageDigestAlgorithmWrapper.java @@ -28,7 +28,7 @@ public static MessageDigestAlgorithmWrapper getMessageDigestAlgorithmWrapper(Str case "SHA512": return MessageDigestAlgorithmWrapper.SHA512; default: - error.setError("MD001", "Algorithm not found: " + messageDigestAlgorithmWrapper); + error.setError("MDA01", "Not recognized digest algorithm"); return null; } } @@ -49,7 +49,7 @@ public static String valueOf(MessageDigestAlgorithmWrapper messageDigestAlgorith case SHA512: return "SHA512"; default: - error.setError("MD002", "Not recognized digest algorithm"); + error.setError("MDA02", "Not recognized digest algorithm"); return null; } } @@ -63,7 +63,7 @@ public static String getDigestMethod(MessageDigestAlgorithmWrapper messageDigest case SHA512: return MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA512; default: - error.setError("MD003", "Not recognized digest algorithm"); + error.setError("MDA03", "Not recognized digest algorithm"); return null; } } diff --git a/GeneXusXmlSignature/src/main/java/com/genexus/utils/SignatureElementType.java b/GeneXusXmlSignature/src/main/java/com/genexus/utils/SignatureElementType.java index 309804b..8ff3e5a 100644 --- a/GeneXusXmlSignature/src/main/java/com/genexus/utils/SignatureElementType.java +++ b/GeneXusXmlSignature/src/main/java/com/genexus/utils/SignatureElementType.java @@ -14,7 +14,7 @@ public static String valueOf(SignatureElementType signatureElementType, Error er case document: return "document"; default: - error.setError("SE001", "Unrecognized SignatureElementType"); + error.setError("SET01", "Unrecognized SignatureElementType"); return ""; } diff --git a/GeneXusXmlSignature/src/main/java/com/genexus/utils/TransformsWrapper.java b/GeneXusXmlSignature/src/main/java/com/genexus/utils/TransformsWrapper.java index d1fb587..918f6bf 100644 --- a/GeneXusXmlSignature/src/main/java/com/genexus/utils/TransformsWrapper.java +++ b/GeneXusXmlSignature/src/main/java/com/genexus/utils/TransformsWrapper.java @@ -26,7 +26,7 @@ public static TransformsWrapper getTransformsWrapper(String transformsWrapper, E case "DETACHED": return TransformsWrapper.DETACHED; default: - error.setError("TW001", "Unrecognized transformation: " + transformsWrapper); + error.setError("TRW01", "Unrecognized transformation"); return null; } } @@ -47,7 +47,7 @@ public static String valueOf(TransformsWrapper transformsWrapper, Error error) { case DETACHED: return "DETACHED"; default: - error.setError("TW002", "Unrecognized transformation"); + error.setError("TRW02", "Unrecognized transformation"); return null; } } @@ -61,7 +61,7 @@ public static String getSignatureTypeTransform(TransformsWrapper transformsWrapp case DETACHED: return "http://www.w3.org/2000/09/xmldsig#detached-signature"; default: - error.setError("TW003", "Unrecognized transformation"); + error.setError("TRW03", "Unrecognized transformation"); return null; } diff --git a/GeneXusXmlSignature/src/main/java/com/genexus/utils/XMLSignatureWrapper.java b/GeneXusXmlSignature/src/main/java/com/genexus/utils/XMLSignatureWrapper.java index b432602..00cf73a 100644 --- a/GeneXusXmlSignature/src/main/java/com/genexus/utils/XMLSignatureWrapper.java +++ b/GeneXusXmlSignature/src/main/java/com/genexus/utils/XMLSignatureWrapper.java @@ -30,7 +30,7 @@ public static XMLSignatureWrapper getXMLSignatureWrapper(String xMLSignatureWrap case "ECDSA_SHA256": return ECDSA_SHA256; default: - error.setError("XS001", "Unrecognized algorithm: " + xMLSignatureWrapper); + error.setError("XSW01", "Unrecognized algorithm"); return null; } } @@ -55,7 +55,7 @@ public static String valueOf(XMLSignatureWrapper xMLSignatureWrapper, Error erro case ECDSA_SHA256: return "ECDSA_SHA256"; default: - error.setError("XS002", "Unrecognized algorithm"); + error.setError("XSW02", "Unrecognized algorithm"); return null; } } @@ -73,7 +73,7 @@ public static String getSignatureMethodAlgorithm(XMLSignatureWrapper xMLSignatur case ECDSA_SHA256: return XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA256; default: - error.setError("XS003", "Unrecognized algorithm"); + error.setError("XSW03", "Unrecognized algorithm"); return null; } }