Refactor client and server side contexts 79/151679/7
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Thu, 21 Sep 2017 12:16:35 +0000 (14:16 +0200)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Thu, 12 Oct 2017 13:37:57 +0000 (15:37 +0200)
- Get rid of files and typedefs with identical names
- Simplify client & server side context

Change-Id: Ib6580b228fd6b9d8771eb81adc06d2b2fef2775b

27 files changed:
lib/client.cpp
lib/client.h
lib/context.h [deleted file]
lib/extension-encryption.cpp
lib/extension-encryption.h
lib/external-encryption.cpp
lib/external-encryption.h
lib/internal-encryption.cpp
lib/internal-encryption.h
lib/ode/extension-encryption.cpp
lib/ode/external-encryption.cpp
lib/ode/internal-encryption.cpp
lib/ode/secure-erase.cpp
lib/secure-erase.cpp
lib/secure-erase.h
server/context.h [deleted file]
server/extension-encryption.cpp
server/extension-encryption.h
server/external-encryption.cpp
server/external-encryption.h
server/internal-encryption.cpp
server/internal-encryption.h
server/main.cpp
server/secure-erase.cpp
server/secure-erase.h
server/server.cpp
server/server.h

index 25d8cb29e1c748ebd7c6828e411d139c73892d4f..a548f1aef0276911bfacf86d853598e795499226 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *  Copyright (c) 2015-2017 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.
@@ -18,8 +18,8 @@
 
 namespace {
 
-const std::string SUBSCRIBER_REGISTER = "Server::registerNotificationSubscriber";
-const std::string SUBSCRIBER_UNREGISTER = "Server::unregisterNotificationSubscriber";
+const std::string SUBSCRIBER_REGISTER = "ServerContext::registerNotificationSubscriber";
+const std::string SUBSCRIBER_UNREGISTER = "ServerContext::unregisterNotificationSubscriber";
 
 
 const std::string ODE_MANAGER_ADDRESS = "/tmp/.ode.sock";
@@ -27,16 +27,16 @@ const std::string ODE_MANAGER_ADDRESS = "/tmp/.ode.sock";
 } // namespace
 
 
-ODEContext::ODEContext() noexcept
+ClientContext::ClientContext() noexcept
 {
 }
 
-ODEContext::~ODEContext() noexcept
+ClientContext::~ClientContext() noexcept
 {
        disconnect();
 }
 
-int ODEContext::connect(const std::string& address) noexcept
+int ClientContext::connect(const std::string& address) noexcept
 {
        try {
                client.reset(new rmi::Client(address));
@@ -48,17 +48,17 @@ int ODEContext::connect(const std::string& address) noexcept
        return 0;
 }
 
-int ODEContext::connect() noexcept
+int ClientContext::connect() noexcept
 {
        return connect(ODE_MANAGER_ADDRESS);
 }
 
-void ODEContext::disconnect() noexcept
+void ClientContext::disconnect() noexcept
 {
        client.reset();
 }
 
-int ODEContext::subscribeSignal(const std::string& name,
+int ClientContext::subscribeSignal(const std::string& name,
                                                                        const SignalListener& listener,
                                                                        void* data)
 {
@@ -75,7 +75,7 @@ int ODEContext::subscribeSignal(const std::string& name,
        }
 }
 
-int ODEContext::unsubscribeSignal(int subscriberId)
+int ClientContext::unsubscribeSignal(int subscriberId)
 {
        return client->unsubscribe(SUBSCRIBER_UNREGISTER, subscriberId);
 }
index 70d73690d151e5d432b14848faa9e8e4bc3eceae..7da3a6e11288dfedb5a0f559894c20fd95751467 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *  Copyright (c) 2015-2017 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.
 
 typedef std::function<void(void*)> SignalListener;
 
-class ODEContext final {
-public:
-       typedef std::unique_ptr<rmi::Client> ODEControlContext;
+typedef std::unique_ptr<rmi::Client> RmiClientPtr;
 
-       ODEContext() noexcept;
-       ~ODEContext() noexcept;
+class ClientContext final {
+public:
+       ClientContext() noexcept;
+       ~ClientContext() noexcept;
 
        int connect() noexcept;
        int connect(const std::string& address) noexcept;
@@ -42,17 +42,11 @@ public:
        template<typename Interface, typename... Args>
        Interface createInterface(Args&&... args) noexcept
        {
-               return Interface(getODEControlContext(), std::forward<Args>(args)...);
+               return Interface(client, std::forward<Args>(args)...);
        }
 
 private:
-       ODEControlContext& getODEControlContext()
-       {
-               return client;
-       }
-
-       ODEControlContext client;
+       RmiClientPtr client;
 };
 
-ODEContext& GetODEContext(void* handle);
 #endif //__ODE_CLIENT_H__
diff --git a/lib/context.h b/lib/context.h
deleted file mode 100644 (file)
index a1bc546..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- *  Copyright (c) 2015 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
- */
-
-#ifndef __ODE_CONTEXT__
-#define __ODE_CONTEXT__
-
-#include "client.h"
-
-using ODEControlContext = ::ODEContext::ODEControlContext;
-
-#endif //!__ODE_CONTEXT__
index 40c399afc613bdf04d01d32d0af3565da431da31..9ab36daba271e388d326a16b50b0e73068a5d65a 100644 (file)
@@ -17,7 +17,7 @@
 
 namespace ode {
 
-ExtensionEncryptionClient::ExtensionEncryptionClient(ODEControlContext& ctx) :
+ExtensionEncryptionClient::ExtensionEncryptionClient(RmiClientPtr& ctx) :
        context(ctx)
 {
 }
index 328f6836c5cb9a4bedb4dad5f0c5cff21be6f6c6..7c3cdd583c75b4c6d0817dcab08e42aa5e437508 100644 (file)
 #include <string>
 
 #include "rmi/extension-encryption.h"
-#include "context.h"
+#include "client.h"
 
 namespace ode {
 
 class ExtensionEncryptionClient final: public ExtensionEncryption {
 public:
-       ExtensionEncryptionClient(ODEControlContext& ctxt);
+       ExtensionEncryptionClient(RmiClientPtr& ctxt);
        ~ExtensionEncryptionClient();
 
        int setMountPassword(const std::string& password);
@@ -45,7 +45,7 @@ public:
        int getState();
 
 private:
-       ODEControlContext& context;
+       RmiClientPtr& context;
 };
 
 } // namespace ode
index 08b89cdc1c25bce8c83ec644dd82d8e0212c18c7..9870b8c20ab4c1778e4aaa34b5de1bf1bffb4cc8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *  Copyright (c) 2015-2017 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.
@@ -17,7 +17,7 @@
 
 namespace ode {
 
-ExternalEncryptionClient::ExternalEncryptionClient(ODEControlContext& ctx) :
+ExternalEncryptionClient::ExternalEncryptionClient(RmiClientPtr& ctx) :
        context(ctx)
 {
 }
index e50f60b08237b62e422d696fe6f0148bbdac6735..705b7407454fc21101fa8d9059b07cd977ec1caa 100644 (file)
 #include <string>
 
 #include "rmi/external-encryption.h"
-#include "context.h"
+#include "client.h"
 
 namespace ode {
 
 class ExternalEncryptionClient final: public ExternalEncryption {
 public:
-       ExternalEncryptionClient(ODEControlContext& ctxt);
+       ExternalEncryptionClient(RmiClientPtr& ctxt);
        ~ExternalEncryptionClient();
 
        int setMountPassword(const std::string& password);
@@ -50,7 +50,7 @@ public:
        unsigned int getSupportedOptions();
 
 private:
-       ODEControlContext& context;
+       RmiClientPtr& context;
 };
 
 } // namespace ode
index 77d556a1fa42edc0443bba586060701ef0ee1256..614e023a0b69aaa9ff6fed157ed02f7d8d932524 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *  Copyright (c) 2015-2017 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.
@@ -17,7 +17,7 @@
 
 namespace ode {
 
-InternalEncryptionClient::InternalEncryptionClient(ODEControlContext& ctx) :
+InternalEncryptionClient::InternalEncryptionClient(RmiClientPtr& ctx) :
        context(ctx)
 {
 }
index 1cff27602b69df334734dce97f40ff60e4df88dc..fe68ee5aa1d30c92750cd3b9a821f7789950a58f 100644 (file)
 #include <string>
 
 #include "rmi/internal-encryption.h"
-#include "context.h"
+#include "client.h"
 
 namespace ode {
 
 class InternalEncryptionClient final: public InternalEncryption {
 public:
-       InternalEncryptionClient(ODEControlContext& ctxt);
+       InternalEncryptionClient(RmiClientPtr& ctxt);
        ~InternalEncryptionClient();
 
        int setMountPassword(const std::string& password);
@@ -50,7 +50,7 @@ public:
        unsigned int getSupportedOptions();
 
 private:
-       ODEControlContext& context;
+       RmiClientPtr& context;
 };
 
 } // namespace ode
index abaf4c5cd6b3fa30718484f92ed060970c172d8e..39ac413f35ff7863ca539ff34a4f8408c8b12269 100644 (file)
@@ -26,7 +26,7 @@ int ode_extension_encryption_set_mount_password(const char* password)
 {
        RET_ON_FAILURE(password, ODE_ERROR_INVALID_PARAMETER);
 
-       ODEContext client;
+       ClientContext client;
        RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        ExtensionEncryptionClient extension = client.createInterface<ExtensionEncryptionClient>();
 
@@ -35,7 +35,7 @@ int ode_extension_encryption_set_mount_password(const char* password)
 
 int ode_extension_encryption_mount()
 {
-       ODEContext client;
+       ClientContext client;
        RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        ExtensionEncryptionClient extension = client.createInterface<ExtensionEncryptionClient>();
 
@@ -44,7 +44,7 @@ int ode_extension_encryption_mount()
 
 int ode_extension_encryption_umount()
 {
-       ODEContext client;
+       ClientContext client;
        RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        ExtensionEncryptionClient extension = client.createInterface<ExtensionEncryptionClient>();
 
@@ -55,7 +55,7 @@ int ode_extension_encryption_format(const char* password)
 {
        RET_ON_FAILURE(password, ODE_ERROR_INVALID_PARAMETER);
 
-       ODEContext client;
+       ClientContext client;
        RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        ExtensionEncryptionClient extension = client.createInterface<ExtensionEncryptionClient>();
 
@@ -66,7 +66,7 @@ int ode_extension_encryption_is_password_initialized(bool* result)
 {
        RET_ON_FAILURE(result, ODE_ERROR_INVALID_PARAMETER);
 
-       ODEContext client;
+       ClientContext client;
        RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        ExtensionEncryptionClient extension = client.createInterface<ExtensionEncryptionClient>();
        int ret = extension.isPasswordInitialized();
@@ -81,7 +81,7 @@ int ode_extension_encryption_init_password(const char* password)
 {
        RET_ON_FAILURE(password, ODE_ERROR_INVALID_PARAMETER);
 
-       ODEContext client;
+       ClientContext client;
        RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        ExtensionEncryptionClient extension = client.createInterface<ExtensionEncryptionClient>();
 
@@ -92,7 +92,7 @@ int ode_extension_encryption_clean_password(const char* password)
 {
        RET_ON_FAILURE(password, ODE_ERROR_INVALID_PARAMETER);
 
-       ODEContext client;
+       ClientContext client;
        RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        ExtensionEncryptionClient extension = client.createInterface<ExtensionEncryptionClient>();
 
@@ -105,7 +105,7 @@ int ode_extension_encryption_change_password(const char* old_password,
        RET_ON_FAILURE(old_password, ODE_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(new_password, ODE_ERROR_INVALID_PARAMETER);
 
-       ODEContext client;
+       ClientContext client;
        RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        ExtensionEncryptionClient extension = client.createInterface<ExtensionEncryptionClient>();
 
@@ -117,7 +117,7 @@ int ode_extension_encryption_verify_password(const char* password, bool* result)
        RET_ON_FAILURE(password, ODE_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(result, ODE_ERROR_INVALID_PARAMETER);
 
-       ODEContext client;
+       ClientContext client;
        RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        ExtensionEncryptionClient extension = client.createInterface<ExtensionEncryptionClient>();
        int ret = extension.verifyPassword(password);
@@ -132,7 +132,7 @@ int ode_extension_encryption_get_state(int* state)
 {
        RET_ON_FAILURE(state, ODE_ERROR_INVALID_PARAMETER);
 
-       ODEContext client;
+       ClientContext client;
        RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        ExtensionEncryptionClient extension = client.createInterface<ExtensionEncryptionClient>();
        int ret = extension.getState();
@@ -143,13 +143,13 @@ int ode_extension_encryption_get_state(int* state)
        return ODE_ERROR_NONE;
 }
 
-static std::unique_ptr<ODEContext> mountEventCallbackContext;
+static std::unique_ptr<ClientContext> mountEventCallbackContext;
 
 int ode_extension_encryption_set_mount_event_cb(ode_mount_event_cb callback, void *user_data)
 {
        RET_ON_FAILURE(callback, ODE_ERROR_INVALID_PARAMETER);
 
-       mountEventCallbackContext.reset(new ODEContext);
+       mountEventCallbackContext.reset(new ClientContext);
        RET_ON_FAILURE(mountEventCallbackContext->connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
 
        int ret = mountEventCallbackContext->subscribeSignal("ExtensionEncryption::mount", callback, user_data);
index 7a4c014ed3e07fa284988c7b03fe399a5b1fb7c7..f10b7e800aad3a3202ecf08490e1112db5ee3446 100644 (file)
@@ -26,7 +26,7 @@ int ode_external_encryption_set_mount_password(const char* password)
 {
        RET_ON_FAILURE(password, ODE_ERROR_INVALID_PARAMETER);
 
-       ODEContext client;
+       ClientContext client;
        RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        ExternalEncryptionClient external = client.createInterface<ExternalEncryptionClient>();
 
@@ -35,7 +35,7 @@ int ode_external_encryption_set_mount_password(const char* password)
 
 int ode_external_encryption_mount()
 {
-       ODEContext client;
+       ClientContext client;
        RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        ExternalEncryptionClient external = client.createInterface<ExternalEncryptionClient>();
 
@@ -44,7 +44,7 @@ int ode_external_encryption_mount()
 
 int ode_external_encryption_umount()
 {
-       ODEContext client;
+       ClientContext client;
        RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        ExternalEncryptionClient external = client.createInterface<ExternalEncryptionClient>();
 
@@ -55,7 +55,7 @@ int ode_external_encryption_encrypt(const char* password, unsigned int options)
 {
        RET_ON_FAILURE(password, ODE_ERROR_INVALID_PARAMETER);
 
-       ODEContext client;
+       ClientContext client;
        RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        ExternalEncryptionClient external = client.createInterface<ExternalEncryptionClient>();
 
@@ -66,7 +66,7 @@ int ode_external_encryption_decrypt(const char* password)
 {
        RET_ON_FAILURE(password, ODE_ERROR_INVALID_PARAMETER);
 
-       ODEContext client;
+       ClientContext client;
        RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        ExternalEncryptionClient external = client.createInterface<ExternalEncryptionClient>();
 
@@ -75,7 +75,7 @@ int ode_external_encryption_decrypt(const char* password)
 
 int ode_external_encryption_recovery()
 {
-       ODEContext client;
+       ClientContext client;
        RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        ExternalEncryptionClient external = client.createInterface<ExternalEncryptionClient>();
 
@@ -86,7 +86,7 @@ int ode_external_encryption_is_password_initialized(bool* result)
 {
        RET_ON_FAILURE(result, ODE_ERROR_INVALID_PARAMETER);
 
-       ODEContext client;
+       ClientContext client;
        RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        ExternalEncryptionClient external = client.createInterface<ExternalEncryptionClient>();
        int ret = external.isPasswordInitialized();
@@ -101,7 +101,7 @@ int ode_external_encryption_init_password(const char* password)
 {
        RET_ON_FAILURE(password, ODE_ERROR_INVALID_PARAMETER);
 
-       ODEContext client;
+       ClientContext client;
        RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        ExternalEncryptionClient external = client.createInterface<ExternalEncryptionClient>();
 
@@ -112,7 +112,7 @@ int ode_external_encryption_clean_password(const char* password)
 {
        RET_ON_FAILURE(password, ODE_ERROR_INVALID_PARAMETER);
 
-       ODEContext client;
+       ClientContext client;
        RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        ExternalEncryptionClient external = client.createInterface<ExternalEncryptionClient>();
 
@@ -125,7 +125,7 @@ int ode_external_encryption_change_password(const char* old_password,
        RET_ON_FAILURE(old_password, ODE_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(new_password, ODE_ERROR_INVALID_PARAMETER);
 
-       ODEContext client;
+       ClientContext client;
        RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        ExternalEncryptionClient external = client.createInterface<ExternalEncryptionClient>();
 
@@ -137,7 +137,7 @@ int ode_external_encryption_verify_password(const char* password, bool* result)
        RET_ON_FAILURE(password, ODE_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(result, ODE_ERROR_INVALID_PARAMETER);
 
-       ODEContext client;
+       ClientContext client;
        RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        ExternalEncryptionClient external = client.createInterface<ExternalEncryptionClient>();
        int ret = external.verifyPassword(password);
@@ -152,7 +152,7 @@ int ode_external_encryption_get_state(int* state)
 {
        RET_ON_FAILURE(state, ODE_ERROR_INVALID_PARAMETER);
 
-       ODEContext client;
+       ClientContext client;
        RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        ExternalEncryptionClient external = client.createInterface<ExternalEncryptionClient>();
        int ret = external.getState();
@@ -167,20 +167,20 @@ int ode_external_encryption_get_supported_options(unsigned int* options)
 {
        RET_ON_FAILURE(options, ODE_ERROR_INVALID_PARAMETER);
 
-       ODEContext client;
+       ClientContext client;
        RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        ExternalEncryptionClient external = client.createInterface<ExternalEncryptionClient>();
        *options = external.getSupportedOptions();
        return ODE_ERROR_NONE;
 }
 
-static std::unique_ptr<ODEContext> mountEventCallbackContext;
+static std::unique_ptr<ClientContext> mountEventCallbackContext;
 
 int ode_external_encryption_set_mount_event_cb(ode_mount_event_cb callback, void *user_data)
 {
        RET_ON_FAILURE(callback, ODE_ERROR_INVALID_PARAMETER);
 
-       mountEventCallbackContext.reset(new ODEContext);
+       mountEventCallbackContext.reset(new ClientContext);
        RET_ON_FAILURE(mountEventCallbackContext->connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
 
        int ret = mountEventCallbackContext->subscribeSignal("ExternalEncryption::mount", callback, user_data);
index 624b269cb072b92ad45415b5ab836ff724e0243c..8364cbfe719f6544504b82c47272324b75812989 100644 (file)
@@ -26,7 +26,7 @@ int ode_internal_encryption_set_mount_password(const char* password)
 {
        RET_ON_FAILURE(password, ODE_ERROR_INVALID_PARAMETER);
 
-       ODEContext client;
+       ClientContext client;
        RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        InternalEncryptionClient internal = client.createInterface<InternalEncryptionClient>();
 
@@ -35,7 +35,7 @@ int ode_internal_encryption_set_mount_password(const char* password)
 
 int ode_internal_encryption_mount()
 {
-       ODEContext client;
+       ClientContext client;
        RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        InternalEncryptionClient internal = client.createInterface<InternalEncryptionClient>();
 
@@ -44,7 +44,7 @@ int ode_internal_encryption_mount()
 
 int ode_internal_encryption_umount()
 {
-       ODEContext client;
+       ClientContext client;
        RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        InternalEncryptionClient internal = client.createInterface<InternalEncryptionClient>();
 
@@ -55,7 +55,7 @@ int ode_internal_encryption_encrypt(const char* password, unsigned int options)
 {
        RET_ON_FAILURE(password, ODE_ERROR_INVALID_PARAMETER);
 
-       ODEContext client;
+       ClientContext client;
        RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        InternalEncryptionClient internal = client.createInterface<InternalEncryptionClient>();
 
@@ -66,7 +66,7 @@ int ode_internal_encryption_decrypt(const char* password)
 {
        RET_ON_FAILURE(password, ODE_ERROR_INVALID_PARAMETER);
 
-       ODEContext client;
+       ClientContext client;
        RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        InternalEncryptionClient internal = client.createInterface<InternalEncryptionClient>();
 
@@ -75,7 +75,7 @@ int ode_internal_encryption_decrypt(const char* password)
 
 int ode_internal_encryption_recovery()
 {
-       ODEContext client;
+       ClientContext client;
        RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        InternalEncryptionClient internal = client.createInterface<InternalEncryptionClient>();
 
@@ -86,7 +86,7 @@ int ode_internal_encryption_is_password_initialized(bool* result)
 {
     RET_ON_FAILURE(result, ODE_ERROR_INVALID_PARAMETER);
 
-    ODEContext client;
+    ClientContext client;
     RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        InternalEncryptionClient internal = client.createInterface<InternalEncryptionClient>();
        int ret = internal.isPasswordInitialized();
@@ -101,7 +101,7 @@ int ode_internal_encryption_init_password(const char* password)
 {
     RET_ON_FAILURE(password, ODE_ERROR_INVALID_PARAMETER);
 
-    ODEContext client;
+    ClientContext client;
     RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        InternalEncryptionClient internal = client.createInterface<InternalEncryptionClient>();
 
@@ -112,7 +112,7 @@ int ode_internal_encryption_clean_password(const char* password)
 {
     RET_ON_FAILURE(password, ODE_ERROR_INVALID_PARAMETER);
 
-    ODEContext client;
+    ClientContext client;
     RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        InternalEncryptionClient internal = client.createInterface<InternalEncryptionClient>();
 
@@ -125,7 +125,7 @@ int ode_internal_encryption_change_password(const char* old_password,
        RET_ON_FAILURE(old_password, ODE_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(new_password, ODE_ERROR_INVALID_PARAMETER);
 
-       ODEContext client;
+       ClientContext client;
        RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        InternalEncryptionClient internal = client.createInterface<InternalEncryptionClient>();
 
@@ -137,7 +137,7 @@ int ode_internal_encryption_verify_password(const char* password, bool* result)
     RET_ON_FAILURE(password, ODE_ERROR_INVALID_PARAMETER);
     RET_ON_FAILURE(result, ODE_ERROR_INVALID_PARAMETER);
 
-    ODEContext client;
+    ClientContext client;
     RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        InternalEncryptionClient internal = client.createInterface<InternalEncryptionClient>();
        int ret = internal.verifyPassword(password);
@@ -152,7 +152,7 @@ int ode_internal_encryption_get_state(int* state)
 {
        RET_ON_FAILURE(state, ODE_ERROR_INVALID_PARAMETER);
 
-       ODEContext client;
+       ClientContext client;
        RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        InternalEncryptionClient internal = client.createInterface<InternalEncryptionClient>();
        int ret = internal.getState();
@@ -167,20 +167,20 @@ int ode_internal_encryption_get_supported_options(unsigned int* options)
 {
        RET_ON_FAILURE(options, ODE_ERROR_INVALID_PARAMETER);
 
-       ODEContext client;
+       ClientContext client;
        RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        InternalEncryptionClient internal = client.createInterface<InternalEncryptionClient>();
        *options = internal.getSupportedOptions();
        return ODE_ERROR_NONE;
 }
 
-static std::unique_ptr<ODEContext> mountEventCallbackContext;
+static std::unique_ptr<ClientContext> mountEventCallbackContext;
 
 int ode_internal_encryption_set_mount_event_cb(ode_mount_event_cb callback, void *user_data)
 {
        RET_ON_FAILURE(callback, ODE_ERROR_INVALID_PARAMETER);
 
-       mountEventCallbackContext.reset(new ODEContext);
+       mountEventCallbackContext.reset(new ClientContext);
        RET_ON_FAILURE(mountEventCallbackContext->connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
 
     int ret = mountEventCallbackContext->subscribeSignal("InternalEncryptionServer::mount", callback, user_data);
index 5bda353a343f30754bb85c0e2f7ad7d14668fe37..64d97f8e2b4c0ba12d750a7432f9242617dbadfc 100644 (file)
@@ -26,7 +26,7 @@ int ode_secure_clean(const char* name)
 {
        RET_ON_FAILURE(name, ODE_ERROR_INVALID_PARAMETER);
 
-       ODEContext client;
+       ClientContext client;
        RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
        SecureEraseClient secure = client.createInterface<SecureEraseClient>();
 
index 579437e4f45469e38995b79f988d4eb52527586f..f582efae040781d32be6809f6dfe22a0c4abdc3b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *  Copyright (c) 2015-2017 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.
@@ -17,7 +17,7 @@
 
 namespace ode {
 
-SecureEraseClient::SecureEraseClient(ODEControlContext& ctx) :
+SecureEraseClient::SecureEraseClient(RmiClientPtr& ctx) :
        context(ctx)
 {
 }
index 0434a51ecbf371bd6a7fd1def8cc8171a925aea5..e4fa9187f00fd03f09a8beec8703a5cfb782e740 100644 (file)
 #include <string>
 
 #include "rmi/secure-erase.h"
-#include "context.h"
+#include "client.h"
 
 namespace ode {
 
 class SecureEraseClient final: public SecureErase {
 public:
-       SecureEraseClient(ODEControlContext& ctxt);
+       SecureEraseClient(RmiClientPtr& ctxt);
        ~SecureEraseClient();
 
        int clean(const std::string& name);
 
 private:
-       ODEControlContext& context;
+       RmiClientPtr& context;
 };
 
 } // namespace ode
diff --git a/server/context.h b/server/context.h
deleted file mode 100644 (file)
index 718bbab..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- *  Copyright (c) 2015 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
- */
-
-#ifndef __ODE_CONTEXT_H__
-#define __ODE_CONTEXT_H__
-
-#include "server.h"
-
-using ODEControlContext = Server;
-
-#endif //__ODE_CONTEXT_H__
index e085d05a33f965e7b6ad8892a7f61524ed56c885..3f091fc488cfd9941a661ddb01d36f81256726c8 100644 (file)
@@ -73,22 +73,22 @@ bool findKillAndUmount(const std::string &devPath)
 
 } // namsepace
 
-ExtensionEncryptionServer::ExtensionEncryptionServer(ODEControlContext &ctx) :
-       context(ctx),
+ExtensionEncryptionServer::ExtensionEncryptionServer(ServerContext &srv) :
+       server(srv),
        currentReq(Request::NONE)
 {
-       context.expose(this, PRIVILEGE_PLATFORM, (int)(ExtensionEncryptionServer::setMountPassword)(std::string));
-       context.expose(this, PRIVILEGE_PLATFORM, (int)(ExtensionEncryptionServer::mount)());
-       context.expose(this, PRIVILEGE_PLATFORM, (int)(ExtensionEncryptionServer::umount)());
-       context.expose(this, PRIVILEGE_PLATFORM, (int)(ExtensionEncryptionServer::format)(std::string));
-       context.expose(this, "", (int)(ExtensionEncryptionServer::isPasswordInitialized)());
-       context.expose(this, PRIVILEGE_PLATFORM, (int)(ExtensionEncryptionServer::initPassword)(std::string));
-       context.expose(this, PRIVILEGE_PLATFORM, (int)(ExtensionEncryptionServer::cleanPassword)(std::string));
-       context.expose(this, PRIVILEGE_PLATFORM, (int)(ExtensionEncryptionServer::changePassword)(std::string, std::string));
-       context.expose(this, PRIVILEGE_PLATFORM, (int)(ExtensionEncryptionServer::verifyPassword)(std::string));
-       context.expose(this, "", (int)(ExtensionEncryptionServer::getState)());
-
-       context.createNotification("ExtensionEncryptionServer::mount");
+       server.expose(this, PRIVILEGE_PLATFORM, (int)(ExtensionEncryptionServer::setMountPassword)(std::string));
+       server.expose(this, PRIVILEGE_PLATFORM, (int)(ExtensionEncryptionServer::mount)());
+       server.expose(this, PRIVILEGE_PLATFORM, (int)(ExtensionEncryptionServer::umount)());
+       server.expose(this, PRIVILEGE_PLATFORM, (int)(ExtensionEncryptionServer::format)(std::string));
+       server.expose(this, "", (int)(ExtensionEncryptionServer::isPasswordInitialized)());
+       server.expose(this, PRIVILEGE_PLATFORM, (int)(ExtensionEncryptionServer::initPassword)(std::string));
+       server.expose(this, PRIVILEGE_PLATFORM, (int)(ExtensionEncryptionServer::cleanPassword)(std::string));
+       server.expose(this, PRIVILEGE_PLATFORM, (int)(ExtensionEncryptionServer::changePassword)(std::string, std::string));
+       server.expose(this, PRIVILEGE_PLATFORM, (int)(ExtensionEncryptionServer::verifyPassword)(std::string));
+       server.expose(this, "", (int)(ExtensionEncryptionServer::getState)());
+
+       server.createNotification("ExtensionEncryptionServer::mount");
 
        // TODO: think about handling more than one card / more than one engine
        // it would require global API change to select which card is handled atm
@@ -165,7 +165,7 @@ int ExtensionEncryptionServer::mount()
                }
        }
 
-       context.notify("ExtensionEncryptionServer::mount");
+       server.notify("ExtensionEncryptionServer::mount");
        return 0;
 }
 
index 5f2a08fe806abacffbfa612d0381801dc9ac11ab..ede4249f25d704d5b07f8314f25fae8407628c43 100644 (file)
 #include <memory>
 #include <condition_variable>
 
-#include "context.h"
 #include "rmi/extension-encryption.h"
 #include "key-manager/key-manager.h"
 #include "engine/encryption/cryptsetup-engine.h"
+#include "server.h"
 
 namespace ode {
 
@@ -33,7 +33,7 @@ typedef CryptsetupEngine EXTENSION_ENGINE;
 
 class ExtensionEncryptionServer final: public ExtensionEncryption {
 public:
-       ExtensionEncryptionServer(ODEControlContext& ctxt);
+       ExtensionEncryptionServer(ServerContext& srv);
        ~ExtensionEncryptionServer();
 
        int setMountPassword(const std::string& password);
@@ -110,7 +110,7 @@ private:
        bool isOpened() const;
        bool isMounted() const;
 
-       ODEControlContext& context;
+       ServerContext& server;
 
        // currently inserted card information, empty if no card:
        DevInfo info[DEVICE_MAX];
index 41648a783071b8e38deb0025c40ae3997d8d3ca9..886ce6b45c757696ccc5786836a3669e8421451c 100644 (file)
@@ -188,23 +188,23 @@ void setOptions(unsigned int options)
 
 } // namsepace
 
-ExternalEncryptionServer::ExternalEncryptionServer(ODEControlContext &ctx) :
-       context(ctx)
+ExternalEncryptionServer::ExternalEncryptionServer(ServerContext &srv) :
+       server(srv)
 {
-       context.expose(this, PRIVILEGE_PLATFORM, (int)(ExternalEncryptionServer::setMountPassword)(std::string));
-       context.expose(this, PRIVILEGE_PLATFORM, (int)(ExternalEncryptionServer::mount)());
-       context.expose(this, PRIVILEGE_PLATFORM, (int)(ExternalEncryptionServer::umount)());
-       context.expose(this, PRIVILEGE_PLATFORM, (int)(ExternalEncryptionServer::encrypt)(std::string, unsigned int));
-       context.expose(this, PRIVILEGE_PLATFORM, (int)(ExternalEncryptionServer::decrypt)(std::string));
-       context.expose(this, "", (int)(ExternalEncryptionServer::isPasswordInitialized)());
-       context.expose(this, PRIVILEGE_PLATFORM, (int)(ExternalEncryptionServer::initPassword)(std::string));
-       context.expose(this, PRIVILEGE_PLATFORM, (int)(ExternalEncryptionServer::cleanPassword)(std::string));
-       context.expose(this, PRIVILEGE_PLATFORM, (int)(ExternalEncryptionServer::changePassword)(std::string, std::string));
-       context.expose(this, PRIVILEGE_PLATFORM, (int)(ExternalEncryptionServer::verifyPassword)(std::string));
-       context.expose(this, "", (int)(ExternalEncryptionServer::getState)());
-       context.expose(this, "", (unsigned int)(ExternalEncryptionServer::getSupportedOptions)());
-
-       context.createNotification("ExternalEncryptionServer::mount");
+       server.expose(this, PRIVILEGE_PLATFORM, (int)(ExternalEncryptionServer::setMountPassword)(std::string));
+       server.expose(this, PRIVILEGE_PLATFORM, (int)(ExternalEncryptionServer::mount)());
+       server.expose(this, PRIVILEGE_PLATFORM, (int)(ExternalEncryptionServer::umount)());
+       server.expose(this, PRIVILEGE_PLATFORM, (int)(ExternalEncryptionServer::encrypt)(std::string, unsigned int));
+       server.expose(this, PRIVILEGE_PLATFORM, (int)(ExternalEncryptionServer::decrypt)(std::string));
+       server.expose(this, "", (int)(ExternalEncryptionServer::isPasswordInitialized)());
+       server.expose(this, PRIVILEGE_PLATFORM, (int)(ExternalEncryptionServer::initPassword)(std::string));
+       server.expose(this, PRIVILEGE_PLATFORM, (int)(ExternalEncryptionServer::cleanPassword)(std::string));
+       server.expose(this, PRIVILEGE_PLATFORM, (int)(ExternalEncryptionServer::changePassword)(std::string, std::string));
+       server.expose(this, PRIVILEGE_PLATFORM, (int)(ExternalEncryptionServer::verifyPassword)(std::string));
+       server.expose(this, "", (int)(ExternalEncryptionServer::getState)());
+       server.expose(this, "", (unsigned int)(ExternalEncryptionServer::getSupportedOptions)());
+
+       server.createNotification("ExternalEncryptionServer::mount");
 
        engine.reset(new EXTERNAL_ENGINE(
                EXTERNAL_PATH, EXTERNAL_PATH,
@@ -255,7 +255,7 @@ int ExternalEncryptionServer::mount()
                return -3;
        }
 
-       context.notify("ExternalEncryptionServer::mount");
+       server.notify("ExternalEncryptionServer::mount");
 
        return 0;
 }
@@ -307,7 +307,7 @@ int ExternalEncryptionServer::encrypt(const std::string &password, unsigned int
                        setOptions(options & getSupportedOptions());
                        INFO(SINK, "Encryption completed");
                        ::vconf_set_str(EXTERNAL_STATE_VCONF_KEY, "encrypted");
-                       context.notify("ExternalEncryptionServer::mount");
+                       server.notify("ExternalEncryptionServer::mount");
                        INFO(SINK, "Sync disk...");
                        sync();
                } catch (runtime::Exception &e) {
index 0ec5dd450060c7a9c339f8a6392de08641859ba6..15ba9760d39ec1e4a5775281992448f6cc488fa1 100644 (file)
 
 #include <klay/dbus/connection.h>
 
-#include "context.h"
 #include "rmi/external-encryption.h"
 #include "key-manager/key-manager.h"
 #include "engine/encryption/ecryptfs-engine.h"
+#include "server.h"
 
 namespace ode {
 
@@ -34,7 +34,7 @@ typedef EcryptfsEngine EXTERNAL_ENGINE;
 
 class ExternalEncryptionServer final: public ExternalEncryption {
 public:
-       ExternalEncryptionServer(ODEControlContext& ctxt);
+       ExternalEncryptionServer(ServerContext& srv);
        ~ExternalEncryptionServer();
 
        int setMountPassword(const std::string& password);
@@ -58,7 +58,7 @@ public:
        unsigned int getSupportedOptions();
 
 private:
-       ODEControlContext& context;
+       ServerContext& server;
 
        std::unique_ptr<EXTERNAL_ENGINE> engine;
        KeyManager::data mountKey;
index 30ff4a0b1276f74a899703572f7c371ddfb48983..f03b006af67f01bb0ce5b91fb7eb8c62fac0d761 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *  Copyright (c) 2015-2017 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.
@@ -228,23 +228,23 @@ void setOptions(unsigned int options)
 
 }
 
-InternalEncryptionServer::InternalEncryptionServer(ODEControlContext& ctx) :
-       context(ctx)
+InternalEncryptionServer::InternalEncryptionServer(ServerContext& srv) :
+       server(srv)
 {
-       context.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryptionServer::setMountPassword)(std::string));
-       context.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryptionServer::mount)());
-       context.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryptionServer::umount)());
-       context.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryptionServer::encrypt)(std::string, unsigned int));
-       context.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryptionServer::decrypt)(std::string));
-       context.expose(this, "", (int)(InternalEncryptionServer::isPasswordInitialized)());
-       context.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryptionServer::initPassword)(std::string));
-       context.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryptionServer::cleanPassword)(std::string));
-       context.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryptionServer::changePassword)(std::string, std::string));
-       context.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryptionServer::verifyPassword)(std::string));
-       context.expose(this, "", (int)(InternalEncryptionServer::getState)());
-       context.expose(this, "", (unsigned int)(InternalEncryptionServer::getSupportedOptions)());
-
-       context.createNotification("InternalEncryptionServer::mount");
+       server.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryptionServer::setMountPassword)(std::string));
+       server.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryptionServer::mount)());
+       server.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryptionServer::umount)());
+       server.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryptionServer::encrypt)(std::string, unsigned int));
+       server.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryptionServer::decrypt)(std::string));
+       server.expose(this, "", (int)(InternalEncryptionServer::isPasswordInitialized)());
+       server.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryptionServer::initPassword)(std::string));
+       server.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryptionServer::cleanPassword)(std::string));
+       server.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryptionServer::changePassword)(std::string, std::string));
+       server.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryptionServer::verifyPassword)(std::string));
+       server.expose(this, "", (int)(InternalEncryptionServer::getState)());
+       server.expose(this, "", (unsigned int)(InternalEncryptionServer::getSupportedOptions)());
+
+       server.createNotification("InternalEncryptionServer::mount");
 
        std::string source = findDevPath();
 
@@ -290,7 +290,7 @@ int InternalEncryptionServer::mount()
                engine->mount(mountKey, getOptions());
                mountKey.clear();
 
-               context.notify("InternalEncryptionServer::mount");
+               server.notify("InternalEncryptionServer::mount");
 
                runtime::File("/tmp/.lazy_mount").create(O_WRONLY);
                runtime::File("/tmp/.unlock_mnt").create(O_WRONLY);
@@ -371,7 +371,7 @@ int InternalEncryptionServer::encrypt(const std::string& password, unsigned int
 
                        INFO(SINK, "Encryption completed");
                        ::vconf_set_str(VCONFKEY_ODE_CRYPTO_STATE, "encrypted");
-                       context.notify("InternalEncryptionServer::mount");
+                       server.notify("InternalEncryptionServer::mount");
 
                        INFO(SINK, "Syncing disk and rebooting...");
                        ::sync();
index ea48de3c079dc463e9c35ff76dc290999803179b..57de876c1f8e2ec8cb9b5c9ba0225e711f8392ed 100644 (file)
 #include <string>
 #include <memory>
 
-#include "context.h"
 #include "rmi/internal-encryption.h"
 #include "key-manager/key-manager.h"
 #include "engine/encryption/dmcrypt-engine.h"
+#include "server.h"
 
 namespace ode {
 
@@ -31,7 +31,7 @@ typedef DMCryptEngine INTERNAL_ENGINE;
 
 class InternalEncryptionServer final: public InternalEncryption {
 public:
-       InternalEncryptionServer(ODEControlContext& ctxt);
+       InternalEncryptionServer(ServerContext& srv);
        ~InternalEncryptionServer();
 
        int setMountPassword(const std::string& password);
@@ -55,7 +55,7 @@ public:
        unsigned int getSupportedOptions();
 
 private:
-       ODEControlContext& context;
+       ServerContext& server;
 
        std::unique_ptr<INTERNAL_ENGINE> engine;
        KeyManager::data mountKey;
index 8c152753e761d17235b542b32ef1858d4d61bc95..1a85a3cb879d92ce046c3169ccb2e2282f313a7d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *  Copyright (c) 2015-2017 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.
@@ -42,8 +42,8 @@ int main(int argc, char *argv[])
 
        try {
                ScopedGMainLoop gmainloop;
-               Server server;
-               server.run();
+               ode::ServerContext server;
+               server.start();
        } catch (std::exception &e) {
                std::cerr << e.what() << std::endl;
                return 1;
index f4d036e06c03a707ce4d697d53c73e14abea1efa..d11af7ed1455bd53c6e5a705db588a21e93d7c1f 100644 (file)
@@ -19,7 +19,6 @@
 #include <unistd.h>
 #include <mntent.h>
 
-#include "ext4-tool.h"
 #include "secure-erase.h"
 
 namespace ode {
@@ -47,10 +46,10 @@ std::string findDevPath(const std::string &mntPath)
 }
 } /* namespace */
 
-SecureEraseServer::SecureEraseServer(ODEControlContext &ctx) :
-       context(ctx)
+SecureEraseServer::SecureEraseServer(ServerContext &srv) :
+       server(srv)
 {
-       context.expose(this, PRIVILEGE_PLATFORM, (int)(SecureEraseServer::clean)(std::string));
+       server.expose(this, PRIVILEGE_PLATFORM, (int)(SecureEraseServer::clean)(std::string));
 
        engine.reset(new ERASE_ENGINE(ProgressBar([](int v) {
                        ::vconf_set_str(VCONFKEY_ODE_ERASE_PROGRESS, std::to_string(v).c_str());
index acfd91fa80909e6db4e2ac5e656dd23e0760bb21..339dbbfe8a8b161db25a52962a2f9a1360b5b697 100644 (file)
@@ -20,9 +20,9 @@
 #include <string>
 #include <memory>
 
-#include "context.h"
 #include "rmi/secure-erase.h"
 #include "engine/erase/mmc-engine.h"
+#include "server.h"
 
 namespace ode {
 
@@ -30,14 +30,14 @@ typedef MMCEraseEngine ERASE_ENGINE;
 
 class SecureEraseServer final: public SecureErase {
 public:
-       SecureEraseServer(ODEControlContext& ctxt);
+       SecureEraseServer(ServerContext& srv);
        ~SecureEraseServer();
 
        int erase(const std::string& name);
        int clean(const std::string& name);
 
 private:
-       ODEControlContext& context;
+       ServerContext& server;
 
        std::unique_ptr<ERASE_ENGINE> engine;
 };
index 5baf9f7f5c1be349483dcfdafada1f88ccd9a02f..2d60439ae0634b518a41627dcd07175df7081776 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *  Copyright (c) 2015-2017 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.
 #include "external-encryption.h"
 #include "extension-encryption.h"
 #include "key-manager/key-generator.h"
-
 #include "server.h"
 
 using namespace std::placeholders;
 
+audit::LogSink *SINK = nullptr;
+
+namespace ode {
+
 namespace {
 
 const std::string ODE_MANAGER_ADDRESS = "/tmp/.ode.sock";
-
-std::unique_ptr<ode::SecureEraseServer> secureErase;
-std::unique_ptr<ode::InternalEncryptionServer> internalEncryption;
-std::unique_ptr<ode::ExternalEncryptionServer> externalEncryption;
-std::unique_ptr<ode::ExtensionEncryptionServer> extensionEncryption;
 std::unique_ptr<audit::DlogLogSink> _sink = nullptr;
 
 } // namespace
 
 audit::LogSink *SINK = nullptr;
 
-Server::Server()
+ServerContext::ServerContext() : rmi::Service(ODE_MANAGER_ADDRESS)
 {
        _sink.reset(new audit::DlogLogSink("ODE"));
-       SINK = dynamic_cast<audit::LogSink*>((_sink).get());
+       SINK = _sink.get();
 
        INFO(SINK, "ODE server starting.");
 
-       service.reset(new rmi::Service(ODE_MANAGER_ADDRESS));
-
-       service->setPrivilegeChecker(std::bind(&Server::checkPeerPrivilege, this, _1, _2));
+       setPrivilegeChecker(std::bind(&ServerContext::checkPeerPrivilege, this, _1, _2));
 
-       service->expose(this, "", (runtime::FileDescriptor)(Server::registerNotificationSubscriber)(std::string));
-       service->expose(this, "", (int)(Server::unregisterNotificationSubscriber)(std::string, int));
+       expose(this, "", (runtime::FileDescriptor)(ServerContext::registerNotificationSubscriber)(std::string));
+       expose(this, "", (int)(ServerContext::unregisterNotificationSubscriber)(std::string, int));
 
-       secureErase.reset(new ode::SecureEraseServer(*this));
-       internalEncryption.reset(new ode::InternalEncryptionServer(*this));
-       externalEncryption.reset(new ode::ExternalEncryptionServer(*this));
-       extensionEncryption.reset(new ode::ExtensionEncryptionServer(*this));
+       secureErase.reset(new SecureEraseServer(*this));
+       internalEncryption.reset(new InternalEncryptionServer(*this));
+       externalEncryption.reset(new ExternalEncryptionServer(*this));
+       extensionEncryption.reset(new ExtensionEncryptionServer(*this));
 
-       ode::KeyGenerator::init();
+       KeyGenerator::init();
 }
 
-Server::~Server()
+ServerContext::~ServerContext()
 {
-       ode::KeyGenerator::cleanup();
+       KeyGenerator::cleanup();
 }
 
-void Server::run()
-{
-       // Prepare execution environment
-       service->start();
-}
-
-void Server::terminate()
-{
-       service->stop();
-}
-
-bool Server::checkPeerPrivilege(const rmi::Credentials& cred, const std::string& privilege)
+bool ServerContext::checkPeerPrivilege(const rmi::Credentials& cred, const std::string& privilege)
 {
        cynara *p_cynara;
 
@@ -107,14 +92,16 @@ bool Server::checkPeerPrivilege(const rmi::Credentials& cred, const std::string&
        return true;
 }
 
-runtime::FileDescriptor Server::registerNotificationSubscriber(const std::string& name)
+runtime::FileDescriptor ServerContext::registerNotificationSubscriber(const std::string& name)
 {
        INFO(SINK, "registerNotificationSubscriber");
        INFO(SINK, name);
-       return runtime::FileDescriptor(service->subscribeNotification(name), true);
+       return runtime::FileDescriptor(subscribeNotification(name), true);
 }
 
-int Server::unregisterNotificationSubscriber(const std::string& name, int id)
+int ServerContext::unregisterNotificationSubscriber(const std::string& name, int id)
 {
-       return service->unsubscribeNotification(name, id);
+       return unsubscribeNotification(name, id);
 }
+
+} // namespace ode
index d7a439dec3ebcaf52418bd94c6139a5346a1e2d7..fb12ab03830c85f90e0d385228ddaf6ddff8b7f4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *  Copyright (c) 2015-2017 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.
 #include <string>
 #include <memory>
 
-#include <klay/filesystem.h>
 #include <klay/file-descriptor.h>
 #include <klay/rmi/service.h>
 
-class Server final {
-public:
-       Server();
-       ~Server();
-
-       void run();
-       void terminate();
-
-       template<typename Type, typename... Args>
-       void setMethodHandler(const std::string& privilege, const std::string& method,
-                                                 const typename rmi::MethodHandler<Type, Args...>::type& handler)
-       {
-               service->setMethodHandler<Type, Args...>(privilege, method, handler);
-       }
-
-       template <typename... Args>
-       void notify(const std::string& name, Args&&... args)
-       {
-               service->notify<Args...>(name, std::forward<Args>(args)...);
-       }
-
-       uid_t getPeerUid() const
-       {
-               return service->getPeerUid();
-       }
+namespace ode {
 
-       gid_t getPeerGid() const
-       {
-               return service->getPeerGid();
-       }
+class SecureEraseServer;
+class InternalEncryptionServer;
+class ExternalEncryptionServer;
+class ExtensionEncryptionServer;
 
-       pid_t getPeerPid() const
-       {
-               return service->getPeerPid();
-       }
+class ServerContext final: public rmi::Service {
+public:
+       ServerContext();
+       ~ServerContext();
 
        bool checkPeerPrivilege(const rmi::Credentials& cred, const std::string& privilege);
 
-
-       void createNotification(const std::string& name)
-       {
-               service->createNotification(name);
-       }
-
        runtime::FileDescriptor registerNotificationSubscriber(const std::string& name);
        int unregisterNotificationSubscriber(const std::string& name, int id);
 
 private:
-       std::string securityLabel;
-       std::unique_ptr<rmi::Service> service;
+       std::unique_ptr<SecureEraseServer> secureErase;
+       std::unique_ptr<InternalEncryptionServer> internalEncryption;
+       std::unique_ptr<ExternalEncryptionServer> externalEncryption;
+       std::unique_ptr<ExtensionEncryptionServer> extensionEncryption;
 };
 
+} // namespace ode
+
 #endif //__ODE_SERVER_H__