Libraries reorganized to limit the number of exported symbols
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Thu, 5 Feb 2015 14:09:19 +0000 (15:09 +0100)
committerMaciej J. Karpiuk <m.karpiuk2@samsung.com>
Tue, 17 Feb 2015 11:12:22 +0000 (12:12 +0100)
[Issue#] N/A
[Feature/Bug] N/A
[Problem] Too much exported symbols
[Cause] Some of the code don't have to be exported or is used by a single binary.
[Solution] Unnecessary exports removed. Part of libkey-manager-common code
moved to client library or key-manager binary

[Verification] Compile key-manager and security-tests. Display the number of
exported symbols before and after with:
nm -g <library>.so | wc -l

Change-Id: Iccb053af2523368d353693247e505a794e783318

35 files changed:
packaging/key-manager.spec
src/CMakeLists.txt
src/manager/CMakeLists.txt
src/manager/client-async/descriptor-set.cpp [moved from src/manager/common/descriptor-set.cpp with 100% similarity]
src/manager/client-async/descriptor-set.h [moved from src/manager/common/descriptor-set.h with 97% similarity]
src/manager/client/client-manager-impl.cpp
src/manager/common/base64.h
src/manager/common/crypto-init.cpp [moved from src/manager/common/crypto.cpp with 93% similarity]
src/manager/common/crypto-init.h [new file with mode: 0644]
src/manager/common/pkcs12-impl.cpp
src/manager/dpl/core/include/dpl/assert.h
src/manager/dpl/core/include/dpl/binary_queue.h
src/manager/dpl/core/include/dpl/char_traits.h [deleted file]
src/manager/dpl/core/include/dpl/colors.h
src/manager/dpl/core/include/dpl/exception.h
src/manager/dpl/core/include/dpl/fstream_accessors.h
src/manager/dpl/core/include/dpl/noncopyable.h [deleted file]
src/manager/dpl/core/include/dpl/string.h [deleted file]
src/manager/dpl/core/src/noncopyable.cpp [deleted file]
src/manager/dpl/core/src/string.cpp [deleted file]
src/manager/dpl/db/include/dpl/db/sql_connection.h
src/manager/dpl/db/src/sql_connection.cpp
src/manager/dpl/log/include/dpl/log/log.h
src/manager/main/smack-check.cpp [moved from src/manager/common/smack-check.cpp with 100% similarity]
src/manager/main/smack-check.h [moved from src/manager/common/smack-check.h with 96% similarity]
src/manager/service/certificate-config.cpp [moved from src/manager/common/certificate-config.cpp with 100% similarity]
src/manager/service/certificate-config.h [moved from src/manager/common/certificate-config.h with 95% similarity]
src/manager/service/certificate-store.cpp [moved from src/manager/common/certificate-store.cpp with 100% similarity]
src/manager/service/certificate-store.h [moved from src/manager/common/certificate-store.h with 96% similarity]
src/manager/service/crypto.h [moved from src/manager/common/crypto.h with 95% similarity]
src/manager/service/digest.cpp [moved from src/manager/common/digest.cpp with 100% similarity]
src/manager/service/digest.h [moved from src/manager/common/digest.h with 93% similarity]
src/manager/service/file-lock.cpp [moved from src/manager/common/file-lock.cpp with 100% similarity]
src/manager/service/file-lock.h [moved from src/manager/common/file-lock.h with 94% similarity]
tests/CMakeLists.txt

index c01a885..5f6571c 100644 (file)
@@ -16,7 +16,6 @@ BuildRequires: pkgconfig(openssl)
 BuildRequires: libattr-devel
 BuildRequires: pkgconfig(libsmack)
 BuildRequires: pkgconfig(libsystemd-daemon)
-BuildRequires: pkgconfig(db-util)
 BuildRequires: pkgconfig(vconf)
 BuildRequires: pkgconfig(libsystemd-journal)
 BuildRequires: boost-devel
index ce4dd6b..87ac08c 100644 (file)
@@ -5,7 +5,6 @@ PKG_CHECK_MODULES(KEY_MANAGER_DEP
     libcrypto
     libsystemd-daemon
     capi-base-common
-    db-util
     vconf
     REQUIRED
     )
@@ -18,6 +17,11 @@ SET(KEY_MANAGER_SOURCES
     ${KEY_MANAGER_PATH}/main/generic-socket-manager.cpp
     ${KEY_MANAGER_PATH}/main/socket-manager.cpp
     ${KEY_MANAGER_PATH}/main/key-manager-main.cpp
+    ${KEY_MANAGER_PATH}/main/smack-check.cpp
+    ${KEY_MANAGER_PATH}/service/certificate-store.cpp
+    ${KEY_MANAGER_PATH}/service/certificate-config.cpp
+    ${KEY_MANAGER_PATH}/service/digest.cpp
+    ${KEY_MANAGER_PATH}/service/file-lock.cpp
     ${KEY_MANAGER_PATH}/service/access-control.cpp
     ${KEY_MANAGER_PATH}/service/ckm-service.cpp
     ${KEY_MANAGER_PATH}/service/ckm-logic.cpp
@@ -29,6 +33,10 @@ SET(KEY_MANAGER_SOURCES
     ${KEY_MANAGER_PATH}/service/db-crypto.cpp
     ${KEY_MANAGER_PATH}/service/ocsp-service.cpp
     ${KEY_MANAGER_PATH}/service/ocsp-logic.cpp
+    ${KEY_MANAGER_PATH}/dpl/core/src/assert.cpp
+    ${KEY_MANAGER_PATH}/dpl/db/src/sql_connection.cpp
+    ${KEY_MANAGER_PATH}/dpl/db/src/naive_synchronization_object.cpp
+    ${KEY_MANAGER_PATH}/sqlcipher/sqlcipher.c
     )
 
 # -fPIE and -pie flag is added for ASLR
@@ -91,6 +99,7 @@ SET(KEY_MANAGER_CLIENT_SOURCES
     ${KEY_MANAGER_CLIENT_ASYNC_SRC_PATH}/service.cpp
     ${KEY_MANAGER_CLIENT_ASYNC_SRC_PATH}/storage-receiver.cpp
     ${KEY_MANAGER_CLIENT_ASYNC_SRC_PATH}/ocsp-receiver.cpp
+    ${KEY_MANAGER_CLIENT_ASYNC_SRC_PATH}/descriptor-set.cpp
     ${KEY_MANAGER_CLIENT_CAPI_SRC_PATH}/ckmc-type.cpp
     ${KEY_MANAGER_CLIENT_CAPI_SRC_PATH}/ckmc-error.cpp
     ${KEY_MANAGER_CLIENT_CAPI_SRC_PATH}/ckmc-manager.cpp
index 8c404f1..3daf79f 100644 (file)
@@ -2,7 +2,6 @@ PKG_CHECK_MODULES(COMMON_DEP
     REQUIRED
     dlog
     openssl
-    db-util
     libsmack
     libcrypto
     libsystemd-journal
@@ -15,18 +14,12 @@ SET(COMMON_PATH ${PROJECT_SOURCE_DIR}/src/manager)
 
 SET(COMMON_SOURCES
     ${COMMON_PATH}/common/base64.cpp
-    ${COMMON_PATH}/common/digest.cpp
-    ${COMMON_PATH}/common/crypto.cpp
+    ${COMMON_PATH}/common/crypto-init.cpp
     ${COMMON_PATH}/common/protocols.cpp
     ${COMMON_PATH}/common/message-buffer.cpp
-    ${COMMON_PATH}/common/smack-check.cpp
     ${COMMON_PATH}/common/certificate-impl.cpp
-    ${COMMON_PATH}/common/certificate-store.cpp
-    ${COMMON_PATH}/common/certificate-config.cpp
     ${COMMON_PATH}/common/key-impl.cpp
     ${COMMON_PATH}/common/pkcs12-impl.cpp
-    ${COMMON_PATH}/common/descriptor-set.cpp
-    ${COMMON_PATH}/common/file-lock.cpp
     ${COMMON_PATH}/dpl/log/src/abstract_log_provider.cpp
     ${COMMON_PATH}/dpl/log/src/dlog_log_provider.cpp
     ${COMMON_PATH}/dpl/log/src/log.cpp
@@ -36,14 +29,9 @@ SET(COMMON_SOURCES
     ${COMMON_PATH}/dpl/core/src/binary_queue.cpp
     ${COMMON_PATH}/dpl/core/src/colors.cpp
     ${COMMON_PATH}/dpl/core/src/exception.cpp
-    ${COMMON_PATH}/dpl/core/src/noncopyable.cpp
     ${COMMON_PATH}/dpl/core/src/serialization.cpp
     ${COMMON_PATH}/dpl/core/src/singleton.cpp
-    ${COMMON_PATH}/dpl/core/src/string.cpp
     ${COMMON_PATH}/dpl/core/src/errno_string.cpp
-    ${COMMON_PATH}/dpl/db/src/sql_connection.cpp
-    ${COMMON_PATH}/dpl/db/src/naive_synchronization_object.cpp
-    ${COMMON_PATH}/sqlcipher/sqlcipher.c
     )
 
 INCLUDE_DIRECTORIES(SYSTEM
similarity index 97%
rename from src/manager/common/descriptor-set.h
rename to src/manager/client-async/descriptor-set.h
index 714d6df..7e166ba 100644 (file)
@@ -26,7 +26,6 @@
 #include <dpl/exception.h>
 #include <poll.h>
 #include <noncopyable.h>
-#include <symbol-visibility.h>
 
 namespace CKM {
 
@@ -47,7 +46,7 @@ protected:
 /**
  * @brief Wrapper for poll()
  */
-class COMMON_API DescriptorSet : public IDescriptorSet
+class DescriptorSet : public IDescriptorSet
 {
 public:
     DescriptorSet();
index 3fa92d9..96afe34 100644 (file)
@@ -23,7 +23,7 @@
 #include <dpl/serialization.h>
 #include <dpl/log/log.h>
 
-#include <crypto.h>
+#include <crypto-init.h>
 #include <client-manager-impl.h>
 #include <client-common.h>
 #include <message-buffer.h>
index cc5f4a5..89e6285 100644 (file)
 #define _BASE64_H_
 
 #include <string>
-#include <dpl/noncopyable.h>
 #include <dpl/exception.h>
 
 #include <ckm/ckm-type.h>
-
+#include <noncopyable.h>
 #include <symbol-visibility.h>
 
 struct bio_st;
@@ -29,9 +28,11 @@ typedef bio_st BIO;
 
 namespace CKM {
 
-class COMMON_API Base64Encoder : public CKM::Noncopyable
+class COMMON_API Base64Encoder
 {
   public:
+    NONCOPYABLE(Base64Encoder)
+
     class Exception
     {
       public:
@@ -53,9 +54,11 @@ class COMMON_API Base64Encoder : public CKM::Noncopyable
     bool m_finalized;
 };
 
-class COMMON_API Base64Decoder : public CKM::Noncopyable
+class COMMON_API Base64Decoder
 {
   public:
+    NONCOPYABLE(Base64Decoder)
+
     class Exception
     {
       public:
similarity index 93%
rename from src/manager/common/crypto.cpp
rename to src/manager/common/crypto-init.cpp
index b601c90..5ae1849 100644 (file)
  *  limitations under the License
  */
 /*
- * @file       crypto.cpp
+ * @file       crypto-init.cpp
  * @author     Maciej Karpiuk (m.karpiuk2@samsung.com)
  * @version    1.0
  */
 
-#include "crypto.h"
+#include "crypto-init.h"
 #include <mutex>
+#include <openssl/evp.h>
 
 namespace CKM {
 
diff --git a/src/manager/common/crypto-init.h b/src/manager/common/crypto-init.h
new file mode 100644 (file)
index 0000000..5845a12
--- /dev/null
@@ -0,0 +1,30 @@
+/* Copyright (c) 2000 - 2013 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.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License
+ *
+ *
+ * @file        crypto-init.h
+ * @author      Bartlomiej Grzelewski (b.grzelewski@samsung.com)
+ * @version     1.0
+ * @brief       Crypto module implementation.
+ */
+#pragma once
+
+#include <symbol-visibility.h>
+
+namespace CKM {
+
+COMMON_API void initCryptoLib();
+
+} // namespace CKM
+
index d9804d0..6c10ff1 100644 (file)
@@ -25,7 +25,7 @@
 
 #include <dpl/log/log.h>
 
-#include <crypto.h>
+#include <crypto-init.h>
 #include <pkcs12-impl.h>
 
 #include <certificate-impl.h>
index 38ecd81..ad0205d 100644 (file)
 
 #include <dpl/noreturn.h>
 #include <string>
-#include <symbol-visibility.h>
 
 namespace CKM {
 // Assertion handler procedure
 // Do not call directly
 // Always use Assert macro
-COMMON_API CENT_KEY_NORETURN void AssertProc(const char *condition,
+CENT_KEY_NORETURN void AssertProc(const char *condition,
                              const char *file,
                              int line,
                              const char *function);
index eff8955..1bb43e3 100644 (file)
 
 //#include <dpl/abstract_input_output.h>
 #include <dpl/exception.h>
-#include <dpl/noncopyable.h>
 #include <memory>
 #include <list>
 #include <symbol-visibility.h>
+#include <noncopyable.h>
 
 namespace CKM {
 /**
@@ -77,9 +77,10 @@ class COMMON_API BinaryQueue
     };
 
   private:
-    struct Bucket :
-        private Noncopyable
+    struct Bucket
     {
+        NONCOPYABLE(Bucket);
+
         const void *buffer;
         const void *ptr;
         size_t size;
diff --git a/src/manager/dpl/core/include/dpl/char_traits.h b/src/manager/dpl/core/include/dpl/char_traits.h
deleted file mode 100644 (file)
index 8b4876d..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2014 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.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/*
- * @file        char_traits.h
- * @author      Piotr Marcinkiewicz (p.marcinkiew@samsung.com)
- * @version     1.0
- * @brief       Char traits are used to create basic_string extended with
- * additional features
- *              Current char traits could be extended in feature to boost
- * performance
- */
-#ifndef CKM_CHAR_TRAITS
-#define CKM_CHAR_TRAITS
-
-#include <cstring>
-#include <string>
-#include <ostream>
-#include <algorithm>
-#include <dpl/exception.h>
-
-namespace CKM {
-typedef std::char_traits<wchar_t> CharTraits;
-} // namespace CKM
-
-#endif // CKM_CHAR_TRAITS
index 0ac301f..5750425 100644 (file)
 #ifndef CKM_COLORS_H
 #define CKM_COLORS_H
 
-#include <symbol-visibility.h>
-
 namespace CKM {
 namespace Colors {
 namespace Text {
-COMMON_API extern const char* BOLD_GREEN_BEGIN;
-COMMON_API extern const char* BOLD_GREEN_END;
-COMMON_API extern const char* PURPLE_BEGIN;
-COMMON_API extern const char* PURPLE_END;
-COMMON_API extern const char* RED_BEGIN;
-COMMON_API extern const char* RED_END;
-COMMON_API extern const char* GREEN_BEGIN;
-COMMON_API extern const char* GREEN_END;
-COMMON_API extern const char* CYAN_BEGIN;
-COMMON_API extern const char* CYAN_END;
-COMMON_API extern const char* BOLD_RED_BEGIN;
-COMMON_API extern const char* BOLD_RED_END;
-COMMON_API extern const char* BOLD_YELLOW_BEGIN;
-COMMON_API extern const char* BOLD_YELLOW_END;
-COMMON_API extern const char* BOLD_GOLD_BEGIN;
-COMMON_API extern const char* BOLD_GOLD_END;
-COMMON_API extern const char* BOLD_WHITE_BEGIN;
-COMMON_API extern const char* BOLD_WHITE_END;
-COMMON_API extern const char* COLOR_END;
+extern const char* BOLD_GREEN_BEGIN;
+extern const char* BOLD_GREEN_END;
+extern const char* PURPLE_BEGIN;
+extern const char* PURPLE_END;
+extern const char* RED_BEGIN;
+extern const char* RED_END;
+extern const char* GREEN_BEGIN;
+extern const char* GREEN_END;
+extern const char* CYAN_BEGIN;
+extern const char* CYAN_END;
+extern const char* BOLD_RED_BEGIN;
+extern const char* BOLD_RED_END;
+extern const char* BOLD_YELLOW_BEGIN;
+extern const char* BOLD_YELLOW_END;
+extern const char* BOLD_GOLD_BEGIN;
+extern const char* BOLD_GOLD_END;
+extern const char* BOLD_WHITE_BEGIN;
+extern const char* BOLD_WHITE_END;
+extern const char* COLOR_END;
 } //namespace Text
 } //namespace Colors
 } //namespace CKM
index 9a2d85d..9aab85b 100644 (file)
@@ -33,9 +33,9 @@
 namespace CKM {
 COMMON_API void LogUnhandledException(const std::string &str);
 COMMON_API void LogUnhandledException(const std::string &str,
-                           const char *filename,
-                           int line,
-                           const char *function);
+                                      const char *filename,
+                                      int line,
+                                      const char *function);
 }
 
 namespace CKM {
index ca0b66d..b1aa17c 100644 (file)
@@ -25,8 +25,6 @@
 #ifndef CENT_KEY_FSTREAM_ACCESSORS_H
 #define CENT_KEY_FSTREAM_ACCESSORS_H
 
-#include <symbol-visibility.h>
-
 namespace CKM {
 
 /*
@@ -37,7 +35,7 @@ namespace CKM {
 */
 
 template<typename T>
-class COMMON_API FstreamAccessors : T::__filebuf_type {
+class FstreamAccessors : T::__filebuf_type {
     typedef FstreamAccessors<T> MyType;
 public:
     static int GetFd(T &strm) {
diff --git a/src/manager/dpl/core/include/dpl/noncopyable.h b/src/manager/dpl/core/include/dpl/noncopyable.h
deleted file mode 100644 (file)
index 138a0aa..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2011 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.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/*
- * @file        noncopyable
- * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version     1.0
- * @brief       This file is the implementation file of noncopyable
- */
-#ifndef CENT_KEY_NONCOPYABLE_H
-#define CENT_KEY_NONCOPYABLE_H
-
-#include <symbol-visibility.h>
-
-namespace CKM {
-class COMMON_API Noncopyable
-{
-  private:
-    Noncopyable(const Noncopyable &);
-    const Noncopyable &operator=(const Noncopyable &);
-
-  public:
-    Noncopyable();
-    virtual ~Noncopyable();
-};
-} // namespace CKM
-
-#endif // CENT_KEY_NONCOPYABLE_H
diff --git a/src/manager/dpl/core/include/dpl/string.h b/src/manager/dpl/core/include/dpl/string.h
deleted file mode 100644 (file)
index bcab67b..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (c) 2014 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.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/*
- * @file        string.h
- * @author      Piotr Marcinkiewicz (p.marcinkiew@samsung.com)
- * @version     1.0
- */
-#ifndef CKM_STRING
-#define CKM_STRING
-
-#include <dpl/exception.h>
-#include <dpl/char_traits.h>
-#include <string>
-#include <ostream>
-#include <numeric>
-
-namespace CKM {
-// @brief CKM string
-typedef std::basic_string<wchar_t, CharTraits> String;
-
-// @brief String exception class
-class StringException
-{
-  public:
-    DECLARE_EXCEPTION_TYPE(CKM::Exception, Base)
-
-    // @brief Invalid init for UTF8 to UTF32 converter
-    DECLARE_EXCEPTION_TYPE(Base, IconvInitErrorUTF8ToUTF32)
-
-    // @brief Invalid taStdContainerinit for UTF32 to UTF32 converter
-    DECLARE_EXCEPTION_TYPE(Base, IconvInitErrorUTF32ToUTF8)
-
-    // @brief Invalid conversion for UTF8 to UTF32 converter
-    DECLARE_EXCEPTION_TYPE(Base, IconvConvertErrorUTF8ToUTF32)
-
-    // @brief Invalid conversion for UTF8 to UTF32 converter
-    DECLARE_EXCEPTION_TYPE(Base, IconvConvertErrorUTF32ToUTF8)
-
-    // @brief Invalid ASCII character detected in FromASCII
-    DECLARE_EXCEPTION_TYPE(Base, InvalidASCIICharacter)
-
-    // @brief Invalid ASCII character detected in FromASCII
-    DECLARE_EXCEPTION_TYPE(Base, ICUInvalidCharacterFound)
-};
-
-//!\brief convert ASCII string to CKM::String
-String FromASCIIString(const std::string& aString);
-
-//!\brief convert UTF32 string to CKM::String
-String FromUTF32String(const std::wstring& aString);
-
-//@brief Returns String object created from UTF8 string
-//@param[in] aString input UTF-8 string
-String FromUTF8String(const std::string& aString);
-
-//@brief Returns String content as std::string
-std::string ToUTF8String(const String& aString);
-
-//@brief Compare two unicode strings
-int StringCompare(const String &left,
-                  const String &right,
-                  bool caseInsensitive = false);
-
-//@brief Splits the string into substrings.
-//@param[in] str Input string
-//@param[in] delimiters array or string containing a sequence of substring
-// delimiters. Can be also a single delimiter character.
-//@param[in] it InserterIterator that is used to save the generated substrings.
-template<typename StringType, typename Delimiters, typename InserterIterator>
-void Tokenize(const StringType& str,
-              const Delimiters& delimiters,
-              InserterIterator it,
-              bool ignoreEmpty = false)
-{
-    typename StringType::size_type nextSearchStart = 0;
-    typename StringType::size_type pos;
-    typename StringType::size_type length;
-
-    while (true) {
-        pos = str.find_first_of(delimiters, nextSearchStart);
-        length =
-            ((pos == StringType::npos) ? str.length() : pos) - nextSearchStart;
-
-        if (!ignoreEmpty || length > 0) {
-            *it = str.substr(nextSearchStart, length);
-            it++;
-        }
-
-        if (pos == StringType::npos) {
-            return;
-        }
-
-        nextSearchStart = pos + 1;
-    }
-}
-
-namespace Utils {
-
-template<typename T> class ConcatFunc : public std::binary_function<T, T, T>
-{
-public:
-    explicit ConcatFunc(const T & val) : m_delim(val) {}
-    T operator()(const T & arg1, const T & arg2) const
-    {
-        return arg1 + m_delim + arg2;
-    }
-private:
-    T m_delim;
-};
-
-}
-
-template<typename ForwardIterator>
-typename ForwardIterator::value_type Join(ForwardIterator begin, ForwardIterator end, typename ForwardIterator::value_type delim)
-{
-    typedef typename ForwardIterator::value_type value;
-    if(begin == end) return value();
-    Utils::ConcatFunc<value> func(delim);
-    ForwardIterator init = begin;
-    return std::accumulate(++begin, end, *init, func);
-}
-
-template<class StringType> void TrimLeft(StringType & obj, typename StringType::const_pointer separators)
-{
-    obj.erase(0, obj.find_first_not_of(separators));
-}
-
-template<class StringType> void TrimRight(StringType & obj, typename StringType::const_pointer separators)
-{
-    obj.erase(obj.find_last_not_of(separators)+1);
-}
-
-template<class StringType> void Trim(StringType & obj, typename StringType::const_pointer separators)
-{
-    TrimLeft(obj, separators);
-    TrimRight(obj, separators);
-}
-
-
-} //namespace CKM
-
-std::ostream& operator<<(std::ostream& aStream, const CKM::String& aString);
-
-#endif // CKM_STRING
diff --git a/src/manager/dpl/core/src/noncopyable.cpp b/src/manager/dpl/core/src/noncopyable.cpp
deleted file mode 100644 (file)
index 8ec5335..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2011 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.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/*
- * @file        noncopyable.cpp
- * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version     1.0
- * @brief       This file is the implementation file of noncopyable
- */
-#include <stddef.h>
-#include <dpl/noncopyable.h>
-
-namespace CKM {
-Noncopyable::Noncopyable()
-{}
-
-Noncopyable::~Noncopyable()
-{}
-} // namespace CKM
diff --git a/src/manager/dpl/core/src/string.cpp b/src/manager/dpl/core/src/string.cpp
deleted file mode 100644 (file)
index 3acbcd2..0000000
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Copyright (c) 2014 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.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/*
- * @file        string.cpp
- * @author      Piotr Marcinkiewicz (p.marcinkiew@samsung.com)
- * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version     1.0
- */
-#include <stddef.h>
-#include <memory>
-#include <dpl/string.h>
-#include <dpl/char_traits.h>
-#include <dpl/errno_string.h>
-#include <dpl/exception.h>
-#include <dpl/log/log.h>
-#include <string>
-#include <vector>
-#include <algorithm>
-#include <cstring>
-#include <errno.h>
-#include <iconv.h>
-#include <unicode/ustring.h>
-
-// TODO: Completely move to ICU
-namespace CKM {
-namespace //anonymous
-{
-class ASCIIValidator
-{
-    const std::string& m_TestedString;
-
-  public:
-    ASCIIValidator(const std::string& aTestedString);
-
-    void operator()(char aCharacter) const;
-};
-
-ASCIIValidator::ASCIIValidator(const std::string& aTestedString) :
-    m_TestedString(aTestedString)
-{}
-
-void ASCIIValidator::operator()(char aCharacter) const
-{
-    // Check for ASCII data range
-    if (aCharacter <= 0) {
-        ThrowMsg(
-            StringException::InvalidASCIICharacter,
-            "invalid character code " << static_cast<int>(aCharacter)
-                                      << " from string [" <<
-            m_TestedString
-                                      << "] passed as ASCII");
-    }
-}
-
-const iconv_t gc_IconvOperError = reinterpret_cast<iconv_t>(-1);
-const size_t gc_IconvConvertError = static_cast<size_t>(-1);
-} // namespace anonymous
-
-String FromUTF8String(const std::string& aIn)
-{
-    if (aIn.empty()) {
-        return String();
-    }
-
-    size_t inbytes = aIn.size();
-
-    // Default iconv UTF-32 module adds BOM (4 bytes) in from of string
-    // The worst case is when 8bit UTF-8 char converts to 32bit UTF-32
-    // newsize = oldsize * 4 + end + bom
-    // newsize - bytes for UTF-32 string
-    // oldsize - letters in UTF-8 string
-    // end - end character for UTF-32 (\0)
-    // bom - Unicode header in front of string (0xfeff)
-    size_t outbytes = sizeof(wchar_t) * (inbytes + 2);
-    std::vector<wchar_t> output(inbytes + 2, 0);
-
-    size_t outbytesleft = outbytes;
-    char* inbuf = const_cast<char*>(aIn.c_str());
-
-    // vector is used to provide buffer for iconv which expects char* buffer
-    // but during conversion from UTF32 uses internaly wchar_t
-    char* outbuf = reinterpret_cast<char*>(&output[0]);
-
-    iconv_t iconvHandle = iconv_open("UTF-32", "UTF-8");
-
-    if (gc_IconvOperError == iconvHandle) {
-        int error = errno;
-
-        ThrowMsg(StringException::IconvInitErrorUTF8ToUTF32,
-                 "iconv_open failed for " << "UTF-32 <- UTF-8" <<
-                 "error: " << GetErrnoString(error));
-    }
-
-    size_t iconvRet = iconv(iconvHandle,
-                            &inbuf,
-                            &inbytes,
-                            &outbuf,
-                            &outbytesleft);
-
-    iconv_close(iconvHandle);
-
-    if (gc_IconvConvertError == iconvRet) {
-        ThrowMsg(StringException::IconvConvertErrorUTF8ToUTF32,
-                 "iconv failed for " << "UTF-32 <- UTF-8" << "error: "
-                                     << GetErrnoString());
-    }
-
-    // Ignore BOM in front of UTF-32
-    return &output[1];
-}
-
-std::string ToUTF8String(const CKM::String& aIn)
-{
-    if (aIn.empty()) {
-        return std::string();
-    }
-
-    size_t inbytes = aIn.size() * sizeof(wchar_t);
-    size_t outbytes = inbytes + sizeof(char);
-
-    // wstring returns wchar_t but iconv expects char*
-    // iconv internally is processing input as wchar_t
-    char* inbuf = reinterpret_cast<char*>(const_cast<wchar_t*>(aIn.c_str()));
-    std::vector<char> output(inbytes, 0);
-    char* outbuf = &output[0];
-
-    size_t outbytesleft = outbytes;
-
-    iconv_t iconvHandle = iconv_open("UTF-8", "UTF-32");
-
-    if (gc_IconvOperError == iconvHandle) {
-        ThrowMsg(StringException::IconvInitErrorUTF32ToUTF8,
-                 "iconv_open failed for " << "UTF-8 <- UTF-32"
-                                          << "error: " << GetErrnoString());
-    }
-
-    size_t iconvRet = iconv(iconvHandle,
-                            &inbuf,
-                            &inbytes,
-                            &outbuf,
-                            &outbytesleft);
-
-    iconv_close(iconvHandle);
-
-    if (gc_IconvConvertError == iconvRet) {
-        ThrowMsg(StringException::IconvConvertErrorUTF32ToUTF8,
-                 "iconv failed for " << "UTF-8 <- UTF-32"
-                                     << "error: " << GetErrnoString());
-    }
-
-    return &output[0];
-}
-
-String FromASCIIString(const std::string& aString)
-{
-    String output;
-
-    std::for_each(aString.begin(), aString.end(), ASCIIValidator(aString));
-    std::copy(aString.begin(), aString.end(), std::back_inserter<String>(output));
-
-    return output;
-}
-
-String FromUTF32String(const std::wstring& aString)
-{
-    return String(&aString[0]);
-}
-
-static UChar *ConvertToICU(const String &inputString)
-{
-    std::unique_ptr<UChar[]> outputString;
-    int32_t size = 0;
-    int32_t convertedSize = 0;
-    UErrorCode error = U_ZERO_ERROR;
-
-    // Calculate size of output string
-    ::u_strFromWCS(NULL,
-                   0,
-                   &size,
-                   inputString.c_str(),
-                   -1,
-                   &error);
-
-    if (error == U_ZERO_ERROR ||
-        error == U_BUFFER_OVERFLOW_ERROR)
-    {
-        // What buffer size is ok ?
-        LogPedantic("ICU: Output buffer size: " << size);
-    } else {
-        ThrowMsg(StringException::ICUInvalidCharacterFound,
-                 "ICU: Failed to retrieve output string size. Error: "
-                 << error);
-    }
-
-    // Allocate proper buffer
-    outputString.reset(new UChar[size + 1]);
-    ::memset(outputString.get(), 0, sizeof(UChar) * (size + 1));
-
-    error = U_ZERO_ERROR;
-
-    // Do conversion
-    ::u_strFromWCS(outputString.get(),
-                   size + 1,
-                   &convertedSize,
-                   inputString.c_str(),
-                   -1,
-                   &error);
-
-    if (!U_SUCCESS(error)) {
-        ThrowMsg(StringException::ICUInvalidCharacterFound,
-                 "ICU: Failed to convert string. Error: " << error);
-    }
-
-    // Done
-    return outputString.release();
-}
-
-int StringCompare(const String &left,
-                  const String &right,
-                  bool caseInsensitive)
-{
-    // Convert input strings
-    std::unique_ptr<UChar[]> leftICU(ConvertToICU(left));
-    std::unique_ptr<UChar[]> rightICU(ConvertToICU(right));
-
-    if (caseInsensitive) {
-        return static_cast<int>(u_strcasecmp(leftICU.get(), rightICU.get(), 0));
-    } else {
-        return static_cast<int>(u_strcmp(leftICU.get(), rightICU.get()));
-    }
-}
-} //namespace CKM
-
-std::ostream& operator<<(std::ostream& aStream, const CKM::String& aString)
-{
-    return aStream << CKM::ToUTF8String(aString);
-}
index e657445..b6aced5 100644 (file)
 #ifndef CKM_SQL_CONNECTION_H
 #define CKM_SQL_CONNECTION_H
 
-#include <dpl/noncopyable.h>
 #include <dpl/exception.h>
 #include <dpl/availability.h>
 #include <memory>
 #include <boost/optional.hpp>
-#include <dpl/string.h>
 #include <dpl/log/log.h>
 #include <sqlcipher.h>
-#include <string>
 #include <dpl/assert.h>
 #include <stdint.h>
 #include <dpl/raw-buffer.h>
-
-#include <symbol-visibility.h>
+#include <noncopyable.h>
 
 namespace CKM {
 namespace DB {
 /**
  * SQL connection class
  */
-class COMMON_API SqlConnection
+class SqlConnection
 {
   public:
     /**
@@ -65,8 +61,7 @@ class COMMON_API SqlConnection
     /*
      * SQL processed data command
      */
-    class DataCommand :
-        private Noncopyable
+    class DataCommand
     {
       private:
         SqlConnection *m_masterConnection;
@@ -80,6 +75,8 @@ class COMMON_API SqlConnection
         friend class SqlConnection;
 
       public:
+        NONCOPYABLE(DataCommand);
+
         virtual ~DataCommand();
 
         /**
@@ -159,14 +156,6 @@ class COMMON_API SqlConnection
          * @param position Index of argument to bind value to
          * @param value Value to bind
          */
-        void BindString(ArgumentIndex position, const String& value);
-
-        /**
-         * Bind string to the prepared statement argument
-         *
-         * @param position Index of argument to bind value to
-         * @param value Value to bind
-         */
         void BindBlob(ArgumentIndex position, const RawBuffer &value);
 
         /**
@@ -239,15 +228,6 @@ class COMMON_API SqlConnection
          * @param position Index of argument to bind value to
          * @param value Value to bind
          */
-        void BindString(ArgumentIndex position, const boost::optional<String> &value);
-
-        /**
-         * Bind optional string to the prepared statement argument.
-         * If optional is not set null will be bound
-         *
-         * @param position Index of argument to bind value to
-         * @param value Value to bind
-         */
         void BindBlob(ArgumentIndex position, const boost::optional<RawBuffer> &value);
 
         /**
@@ -383,13 +363,6 @@ class COMMON_API SqlConnection
         boost::optional<double> GetColumnOptionalDouble(ColumnIndex column);
 
         /**
-         * Get optional string value from column in current row.
-         *
-         * @throw Exception::InvalidColumn
-         */
-        boost::optional<String> GetColumnOptionalString(ColumnIndex column);
-
-        /**
          * Get string value from column in current row.
          *
          * @throw Exception::InvalidColumn
index 8fcbded..59d7877 100644 (file)
 #include <stddef.h>
 #include <dpl/db/sql_connection.h>
 #include <dpl/db/naive_synchronization_object.h>
-#include <dpl/noncopyable.h>
 #include <dpl/assert.h>
 #include <dpl/scoped_ptr.h>
-#include <db-util.h>
 #include <unistd.h>
 #include <cstdio>
 #include <cstdarg>
 #include <memory>
+#include <noncopyable.h>
 
 
 namespace {
@@ -43,13 +42,14 @@ namespace CKM {
 namespace DB {
 namespace // anonymous
 {
-class ScopedNotifyAll :
-    public Noncopyable
+class ScopedNotifyAll
 {
   private:
     SqlConnection::SynchronizationObject *m_synchronizationObject;
 
   public:
+    NONCOPYABLE(ScopedNotifyAll)
+
     explicit ScopedNotifyAll(
         SqlConnection::SynchronizationObject *synchronizationObject) :
         m_synchronizationObject(synchronizationObject)
@@ -251,13 +251,6 @@ void SqlConnection::DataCommand::BindBlob(
                 << position << "] -> " << raw.size());
 }
 
-void SqlConnection::DataCommand::BindString(
-    SqlConnection::ArgumentIndex position,
-    const String &value)
-{
-    BindString(position, ToUTF8String(value).c_str());
-}
-
 void SqlConnection::DataCommand::BindInteger(
     SqlConnection::ArgumentIndex position,
     const boost::optional<int> &value)
@@ -335,17 +328,6 @@ void SqlConnection::DataCommand::BindDouble(
     }
 }
 
-void SqlConnection::DataCommand::BindString(
-    SqlConnection::ArgumentIndex position,
-    const boost::optional<String> &value)
-{
-    if (!!value) {
-        BindString(position, ToUTF8String(*value).c_str());
-    } else {
-        BindNull(position);
-    }
-}
-
 void SqlConnection::DataCommand::BindBlob(
     SqlConnection::ArgumentIndex position,
     const boost::optional<RawBuffer> &value)
@@ -636,22 +618,6 @@ boost::optional<double> SqlConnection::DataCommand::GetColumnOptionalDouble(
     return boost::optional<double>(value);
 }
 
-boost::optional<String> SqlConnection::DataCommand::GetColumnOptionalString(
-    SqlConnection::ColumnIndex column)
-{
-    LogPedantic("SQL data command get column optional string: ["
-                << column << "]");
-    CheckColumnIndex(column);
-    if (sqlcipher3_column_type(m_stmt, column) == SQLCIPHER_NULL) {
-        return boost::optional<String>();
-    }
-    const char *value = reinterpret_cast<const char *>(
-            sqlcipher3_column_text(m_stmt, column));
-    LogPedantic("Value: " << value);
-    String s = FromUTF8String(value);
-    return boost::optional<String>(s);
-}
-
 boost::optional<RawBuffer> SqlConnection::DataCommand::GetColumnOptionalBlob(
     SqlConnection::ColumnIndex column)
 {
index ec93e8f..ac7f23d 100644 (file)
 #define CENT_KEY_LOG_H
 
 #include <dpl/singleton.h>
-#include <dpl/noncopyable.h>
 #include <dpl/log/abstract_log_provider.h>
 #include <sstream>
 #include <list>
 
+#include <noncopyable.h>
 #include <symbol-visibility.h>
 
 namespace CKM {
@@ -35,9 +35,11 @@ namespace Log {
 /**
  * CKM log system
  */
-class COMMON_API LogSystem : private Noncopyable
+class COMMON_API LogSystem
 {
   public:
+    NONCOPYABLE(LogSystem)
+
     LogSystem();
     virtual ~LogSystem();
 
similarity index 96%
rename from src/manager/common/smack-check.h
rename to src/manager/main/smack-check.h
index 8c998f0..942578b 100644 (file)
@@ -21,8 +21,6 @@
 #ifndef _SMACK_CHECK_H_
 #define _SMACK_CHECK_H_
 
-#include <symbol-visibility.h>
-
 namespace CKM {
 
 /*
@@ -37,7 +35,6 @@ int smack_runtime_check(void);
  * Returns 1 if SMACK is present, 0 otherwise. If SMACK_ENABLED is not defined
  * It returns 0.
  */
-COMMON_API
 int smack_check(void);
 
 } // namespace CKM
similarity index 95%
rename from src/manager/common/certificate-config.h
rename to src/manager/service/certificate-config.h
index 3873e7a..b9d053d 100644 (file)
 
 #include <set>
 #include <string>
-#include <symbol-visibility.h>
 
 #pragma once
 
 namespace CKM {
 
-class COMMON_API CertificateConfig
+class CertificateConfig
 {
 public:
     static void addSystemCertificateDir(const std::string& dir) { m_sysCertDirs.insert(dir); }
similarity index 96%
rename from src/manager/common/certificate-store.h
rename to src/manager/service/certificate-store.h
index 05c4265..250e05e 100644 (file)
@@ -19,7 +19,6 @@
  * @brief       Certificate Stack Implmentation.
  */
 #include <certificate-impl.h>
-#include <symbol-visibility.h>
 
 extern "C" {
 struct x509_store_st;
@@ -28,7 +27,7 @@ typedef struct x509_store_st X509_STORE;
 
 namespace CKM {
 
-class COMMON_API CertificateStore {
+class CertificateStore {
 public:
     CertificateStore();
     CertificateStore(const CertificateStore &) = delete;
similarity index 95%
rename from src/manager/common/crypto.h
rename to src/manager/service/crypto.h
index 44b9f0a..a7f7519 100644 (file)
 #include <dpl/exception.h>
 #include <dpl/raw-buffer.h>
 
-#include <symbol-visibility.h>
-
 // TODO move it to static const int
 #define AES_GCM_TAG_SIZE 16
 
 namespace CKM {
 
-COMMON_API void initCryptoLib();
-
 namespace Crypto {
 
 class Exception
@@ -49,7 +45,7 @@ public:
 namespace Cipher {
 
 template<class T>
-struct COMMON_API Base {
+struct Base {
     Base()
       : m_ctx(EVP_CIPHER_CTX_new())
     {
@@ -76,7 +72,7 @@ protected:
 };
 
 template<class T>
-class COMMON_API EvpCipherWrapper : public Base<T> {
+class EvpCipherWrapper : public Base<T> {
 public:
     using Base<T>::m_ctx;
 
@@ -129,7 +125,7 @@ public:
 };
 
 #define DEFINE_CIPHER(__classname, __type, __evpcipher, __encryption) \
-class COMMON_API __classname : public EvpCipherWrapper<__type> {                 \
+class __classname : public EvpCipherWrapper<__type> {                 \
 public:                                                               \
     __classname(const __type &key, const __type &iv)                  \
       : EvpCipherWrapper(__evpcipher, key, iv, __encryption)          \
similarity index 93%
rename from src/manager/common/digest.h
rename to src/manager/service/digest.h
index a07a79f..519521f 100644 (file)
 
 #pragma once
 
-#include <dpl/noncopyable.h>
 #include <dpl/exception.h>
 #include <ckm/ckm-type.h>
-#include <symbol-visibility.h>
 
+#include <noncopyable.h>
 /*
  * Taken from openssl/ossl_typ.h
  */
@@ -31,9 +30,11 @@ typedef env_md_st EVP_MD;
 
 namespace CKM {
 
-class COMMON_API Digest : public CKM::Noncopyable
+class Digest
 {
     public:
+        NONCOPYABLE(Digest)
+
         class Exception
         {
             public:
similarity index 94%
rename from src/manager/common/file-lock.h
rename to src/manager/service/file-lock.h
index b2c3ec3..b56e29a 100644 (file)
 #pragma once
 
 #include <noncopyable.h>
-#include <symbol-visibility.h>
 
 namespace CKM {
 
-class COMMON_API FileLock
+class FileLock
 {
 public:
     explicit FileLock(const char* const file);
index 9725e5a..e56f19c 100644 (file)
@@ -15,6 +15,7 @@ INCLUDE_DIRECTORIES(
     ${KEY_MANAGER_PATH}/sqlcipher
     ${KEY_MANAGER_PATH}/service
     ${KEY_MANAGER_PATH}/common/
+    ${KEY_MANAGER_PATH}/client-async/
     ${KEY_MANAGER_SRC_PATH}/include
     ${KEY_MANAGER_TEST_MERGED_SRC}/
     )
@@ -31,7 +32,12 @@ SET(TEST_MERGED_SOURCES
     ${KEY_MANAGER_TEST_MERGED_SRC}/test_descriptor-set.cpp
     ${KEY_MANAGER_PATH}/service/db-crypto.cpp
     ${KEY_MANAGER_PATH}/service/key-provider.cpp
-    ${KEY_MANAGER_PATH}/common/descriptor-set.cpp
+    ${KEY_MANAGER_PATH}/client-async/descriptor-set.cpp
+    ${KEY_MANAGER_PATH}/dpl/core/src/assert.cpp
+    ${KEY_MANAGER_PATH}/dpl/core/src/colors.cpp
+    ${KEY_MANAGER_PATH}/dpl/db/src/sql_connection.cpp
+    ${KEY_MANAGER_PATH}/dpl/db/src/naive_synchronization_object.cpp
+    ${KEY_MANAGER_PATH}/sqlcipher/sqlcipher.c
     )
 
 ADD_EXECUTABLE(${TARGET_TEST_MERGED} ${TEST_MERGED_SOURCES})