Add arbitrary key-value map data interface to pass data between plugins and API clients 49/198949/3 accepted/tizen/unified/20190202.022436 submit/tizen/20190131.135638 submit/tizen/20190201.054001
authorTomasz Swierczek <t.swierczek@samsung.com>
Thu, 31 Jan 2019 07:40:34 +0000 (08:40 +0100)
committerTomasz Swierczek <t.swierczek@samsung.com>
Thu, 31 Jan 2019 11:58:07 +0000 (12:58 +0100)
cert-svc allows to use validator plugins that can have any arbitrary logic embedded.
Installers may need to get special information, characteristic for plugins, from cert-svc.
New SignatureData class methods allow to set (on plugin side) and retrieve (on installer side)
simple string values that can have their meaning defined by plugin logic.

Installer should depend on specific plugin's key name definition (alternative is hard-coding)
and check for values using SignatureData interface.

Change-Id: I098a33b981d2b175ea72ba16cd8c968048ff116d

src/vcore/SignatureData.cpp
src/vcore/SignatureData.h

index cfbcc1e399307e66893e591c7fbe537067b7bb00..466b37cf10728c76edaa7ad56c0c291c6fe80020 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2016 - 2019 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
  *    you may not use this file except in compliance with the License.
@@ -153,4 +153,19 @@ CertificatePtr SignatureData::getRootCaCertificatePtr() const
        return CertificatePtr();
 }
 
+void SignatureData::setExtSignatureParam(const std::string &key, const std::string value)
+{
+       m_extSignatureParams[key] = value;
+}
+
+bool SignatureData::getExtSignatureParam(const std::string &key, std::string &value)
+{
+       std::unordered_map<std::string, std::string>::const_iterator it = m_extSignatureParams.find(key);
+       if (it != m_extSignatureParams.end()) {
+               value = it->second;
+               return true;
+       }
+       return false;
+}
+
 } // ValidationCore
index b3677d4db9b9fecfed60b24898e543882f028dd0..e7bb352021668a29154af2cb92a0f6a38830c5e8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2016 - 2019 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
  *    you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
 #include <list>
 #include <set>
 #include <map>
+#include <unordered_map>
 #include <string>
 
 #include <vcore/Certificate.h>
@@ -75,6 +76,8 @@ public:
        const MEIDList &getMEIDList() const;
        CertificatePtr getEndEntityCertificatePtr() const;
        CertificatePtr getRootCaCertificatePtr() const;
+       void setExtSignatureParam(const std::string &key, const std::string value);
+       bool getExtSignatureParam(const std::string &key, std::string &value);
 
        friend class SignatureReader;
 
@@ -100,6 +103,9 @@ private:
        ObjectList m_objectList;
        CertStoreId::Set m_storeIdSet;
        bool m_certificateSorted;
+
+       //A map that can be used ie. by validator plugins to pass additional information to installer
+       std::unordered_map<std::string, std::string> m_extSignatureParams;
 };
 
 } // ValidationCore