modify DebugLogPrint
authorcc1.yim <cc1.yim@samsung.com>
Wed, 26 Jun 2013 09:16:46 +0000 (18:16 +0900)
committercc1.yim <cc1.yim@samsung.com>
Wed, 26 Jun 2013 09:45:50 +0000 (18:45 +0900)
Change-Id: I237151e262503a0758fc4d8e19a42d17402f3e94
Signed-off-by: cc1.yim <cc1.yim@samsung.com>
vcore/src/vcore/SignatureReader.cpp
vcore/src/vcore/XmlsecAdapter.cpp

index 1d2071b..80553b6 100644 (file)
@@ -390,6 +390,7 @@ void SignatureReader::tokenEndX509Certificate(SignatureData &signatureData)
     CertificateLoader loader;
     if (CertificateLoader::NO_ERROR !=
         loader.loadCertificateFromRawData(m_parserSchema.getText())) {
+        fprintf(stderr, "## [validate error]: Certificate could not be loaded\n");
         LogWarning("Certificate could not be loaded!");
         ThrowMsg(ParserSchemaException::CertificateLoaderError,
                  "Certificate could not be loaded.");
@@ -411,6 +412,7 @@ void SignatureReader::tokenEndRSAKeyValue(SignatureData &signatureData)
     if (CertificateLoader::NO_ERROR !=
         loader.loadCertificateBasedOnExponentAndModulus(m_modulus,
                                                         m_exponent)) {
+        fprintf(stderr, "## [validate error]: Certificate could not be loaded\n");
         LogWarning("Certificate could not be loaded!");
         ThrowMsg(ParserSchemaException::CertificateLoaderError,
                  "Certificate could not be loaded.");
@@ -441,6 +443,7 @@ void SignatureReader::tokenEndECKeyValue(SignatureData &signatureData)
     CertificateLoader loader;
     if (CertificateLoader::NO_ERROR !=
         loader.loadCertificateWithECKEY(m_nameCurveURI, m_publicKey)) {
+        fprintf(stderr, "## [validate error]: Certificate could not be loaded\n");
         ThrowMsg(ParserSchemaException::CertificateLoaderError,
                  "Certificate could not be loaded.");
     }
@@ -520,6 +523,7 @@ void SignatureReader::tokenEndDSAKeyValue(SignatureData& signatureData)
                                                    m_dsaKeyJComponent,
                                                    m_dsaKeySeedComponent,
                                                    m_dsaKeyPGenCounter)) {
+        fprintf(stderr, "## [validate error]: Certificate could not be loaded\n");
         LogWarning("Certificate could not be loaded.");
         ThrowMsg(ParserSchemaException::CertificateLoaderError,
                  "Certificate could not be loaded.");
@@ -530,6 +534,7 @@ void SignatureReader::tokenEndDSAKeyValue(SignatureData& signatureData)
 void SignatureReader::tokenRole(SignatureData &signatureData)
 {
     if (!signatureData.m_roleURI.empty()) {
+        fprintf(stderr, "## [validate error]: Multiple definition of Role is not allowed\n");
         LogWarning("Multiple definition of Role is not allowed.");
         ThrowMsg(ParserSchemaException::UnsupportedValue,
                  "Multiple definition of Role is not allowed.");
@@ -540,6 +545,7 @@ void SignatureReader::tokenRole(SignatureData &signatureData)
 void SignatureReader::tokenProfile(SignatureData &signatureData)
 {
     if (!signatureData.m_profileURI.empty()) {
+        fprintf(stderr, "## [validate error]: Multiple definition of Profile is not allowed\n");
         LogWarning("Multiple definition of Profile is not allowed.");
         ThrowMsg(ParserSchemaException::UnsupportedValue,
                  "Multiple definition of Profile is not allowed.");
@@ -550,6 +556,7 @@ void SignatureReader::tokenProfile(SignatureData &signatureData)
 void SignatureReader::tokenEndIdentifier(SignatureData &signatureData)
 {
     if (!signatureData.m_identifier.empty()) {
+        fprintf(stderr, "## [validate error]: Multiple definition of Identifier is not allowed\n");
         LogWarning("Multiple definition of Identifier is not allowed.");
         ThrowMsg(ParserSchemaException::UnsupportedValue,
                  "Multiple definition of Identifier is not allowed.");
@@ -562,6 +569,7 @@ void SignatureReader::tokenObject(SignatureData &signatureData)
     std::string id = m_parserSchema.getReader().attribute(TOKEN_ID);
 
     if (id.empty()) {
+        fprintf(stderr, "## [validate error]: Unsupported value of Attribute Id in Object tag\n");
         LogWarning("Unsupported value of Attribute Id in Object tag.");
         ThrowMsg(ParserSchemaException::UnsupportedValue,
                  "Unsupported value of Attribute Id in Object tag.");
@@ -574,6 +582,7 @@ void SignatureReader::tokenSignatureProperties(SignatureData &signatureData)
 {
     (void)signatureData;
     if (++m_signaturePropertiesCounter > 1) {
+        fprintf(stderr, "## [validate error]: Only one SignatureProperties tag is allowed in Object\n");
         LogWarning("Only one SignatureProperties tag is allowed in Object");
         ThrowMsg(ParserSchemaException::UnsupportedValue,
                  "Only one SignatureProperties tag is allowed in Object");
index 6bc978e..7297ec3 100644 (file)
@@ -36,6 +36,7 @@
 #include <xmlsec/crypto.h>
 #include <xmlsec/io.h>
 #include <xmlsec/keyinfo.h>
+#include <xmlsec/errors.h>
 
 #include <dpl/assert.h>
 #include <dpl/log/log.h>
@@ -123,6 +124,24 @@ void XmlSec::fileExtractPrefix(XmlSecContext *context)
     }
 }
 
+void LogDebugPrint(const char* file, int line, const char* func, 
+       const char* errorObject, const char* errorSubject, 
+       int reason, const char* msg)
+{
+    char total[1024];
+    sprintf(total, "[%s(%d)] : [%s] : [%s] : [%s]", func, line, errorObject, errorSubject, msg);
+
+    if(reason != 256)
+    {
+       fprintf(stderr, "## [validate error]: %s\n", total);
+       LogError(" " << total);
+    }
+    else
+    {
+       LogDebug(" " << total);
+    }
+}
+
 XmlSec::XmlSec() :
     m_initialized(false)
 {
@@ -256,7 +275,9 @@ XmlSec::Result XmlSec::validateFile(XmlSecContext *context,
 
     /*   Verify signature */
     if (xmlSecDSigCtxVerify(dsigCtx, node) < 0) {
-        LogWarning("Signature verify error.");
+         LogError("Signature verify error.");
+         fprintf(stderr, "## [validate error]: Signature verify error\n");
+         res = -1;
         goto done;
     }
 
@@ -273,6 +294,7 @@ XmlSec::Result XmlSec::validateFile(XmlSecContext *context,
         res = 0;
     } else {
         LogDebug("Signature is INVALID");
+        res = -1;
         goto done;
     }
 
@@ -371,6 +393,8 @@ XmlSec::Result XmlSec::validate(XmlSecContext *context)
     Assert(!(context->signatureFile.empty()));
     Assert(context->certificatePtr.Get() || !(context->certificatePath.empty()));
 
+    xmlSecErrorsSetCallback(LogDebugPrint);
+
     if (!m_initialized) {
         LogError("XmlSec is not initialized.");
         ThrowMsg(Exception::InternalError, "XmlSec is not initialized");