/*
- * 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.
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";
} // 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));
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)
{
}
}
-int ODEContext::unsubscribeSignal(int subscriberId)
+int ClientContext::unsubscribeSignal(int subscriberId)
{
return client->unsubscribe(SUBSCRIBER_UNREGISTER, subscriberId);
}
/*
- * 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;
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__
+++ /dev/null
-/*
- * 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__
namespace ode {
-ExtensionEncryptionClient::ExtensionEncryptionClient(ODEControlContext& ctx) :
+ExtensionEncryptionClient::ExtensionEncryptionClient(RmiClientPtr& ctx) :
context(ctx)
{
}
#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);
int getState();
private:
- ODEControlContext& context;
+ RmiClientPtr& context;
};
} // namespace ode
/*
- * 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.
namespace ode {
-ExternalEncryptionClient::ExternalEncryptionClient(ODEControlContext& ctx) :
+ExternalEncryptionClient::ExternalEncryptionClient(RmiClientPtr& ctx) :
context(ctx)
{
}
#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);
unsigned int getSupportedOptions();
private:
- ODEControlContext& context;
+ RmiClientPtr& context;
};
} // namespace ode
/*
- * 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.
namespace ode {
-InternalEncryptionClient::InternalEncryptionClient(ODEControlContext& ctx) :
+InternalEncryptionClient::InternalEncryptionClient(RmiClientPtr& ctx) :
context(ctx)
{
}
#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);
unsigned int getSupportedOptions();
private:
- ODEControlContext& context;
+ RmiClientPtr& context;
};
} // namespace ode
{
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>();
int ode_extension_encryption_mount()
{
- ODEContext client;
+ ClientContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
ExtensionEncryptionClient extension = client.createInterface<ExtensionEncryptionClient>();
int ode_extension_encryption_umount()
{
- ODEContext client;
+ ClientContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
ExtensionEncryptionClient extension = client.createInterface<ExtensionEncryptionClient>();
{
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>();
{
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();
{
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>();
{
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>();
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>();
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);
{
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();
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);
{
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>();
int ode_external_encryption_mount()
{
- ODEContext client;
+ ClientContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
ExternalEncryptionClient external = client.createInterface<ExternalEncryptionClient>();
int ode_external_encryption_umount()
{
- ODEContext client;
+ ClientContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
ExternalEncryptionClient external = client.createInterface<ExternalEncryptionClient>();
{
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>();
{
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>();
int ode_external_encryption_recovery()
{
- ODEContext client;
+ ClientContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
ExternalEncryptionClient external = client.createInterface<ExternalEncryptionClient>();
{
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();
{
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>();
{
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>();
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>();
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);
{
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();
{
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);
{
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>();
int ode_internal_encryption_mount()
{
- ODEContext client;
+ ClientContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
InternalEncryptionClient internal = client.createInterface<InternalEncryptionClient>();
int ode_internal_encryption_umount()
{
- ODEContext client;
+ ClientContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
InternalEncryptionClient internal = client.createInterface<InternalEncryptionClient>();
{
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>();
{
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>();
int ode_internal_encryption_recovery()
{
- ODEContext client;
+ ClientContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
InternalEncryptionClient internal = client.createInterface<InternalEncryptionClient>();
{
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();
{
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>();
{
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>();
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>();
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);
{
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();
{
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);
{
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>();
/*
- * 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.
namespace ode {
-SecureEraseClient::SecureEraseClient(ODEControlContext& ctx) :
+SecureEraseClient::SecureEraseClient(RmiClientPtr& ctx) :
context(ctx)
{
}
#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
+++ /dev/null
-/*
- * 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__
} // 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
}
}
- context.notify("ExtensionEncryptionServer::mount");
+ server.notify("ExtensionEncryptionServer::mount");
return 0;
}
#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 {
class ExtensionEncryptionServer final: public ExtensionEncryption {
public:
- ExtensionEncryptionServer(ODEControlContext& ctxt);
+ ExtensionEncryptionServer(ServerContext& srv);
~ExtensionEncryptionServer();
int setMountPassword(const std::string& password);
bool isOpened() const;
bool isMounted() const;
- ODEControlContext& context;
+ ServerContext& server;
// currently inserted card information, empty if no card:
DevInfo info[DEVICE_MAX];
} // 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,
return -3;
}
- context.notify("ExternalEncryptionServer::mount");
+ server.notify("ExternalEncryptionServer::mount");
return 0;
}
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) {
#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 {
class ExternalEncryptionServer final: public ExternalEncryption {
public:
- ExternalEncryptionServer(ODEControlContext& ctxt);
+ ExternalEncryptionServer(ServerContext& srv);
~ExternalEncryptionServer();
int setMountPassword(const std::string& password);
unsigned int getSupportedOptions();
private:
- ODEControlContext& context;
+ ServerContext& server;
std::unique_ptr<EXTERNAL_ENGINE> engine;
KeyManager::data mountKey;
/*
- * 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.
}
-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();
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);
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();
#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 {
class InternalEncryptionServer final: public InternalEncryption {
public:
- InternalEncryptionServer(ODEControlContext& ctxt);
+ InternalEncryptionServer(ServerContext& srv);
~InternalEncryptionServer();
int setMountPassword(const std::string& password);
unsigned int getSupportedOptions();
private:
- ODEControlContext& context;
+ ServerContext& server;
std::unique_ptr<INTERNAL_ENGINE> engine;
KeyManager::data mountKey;
/*
- * 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.
try {
ScopedGMainLoop gmainloop;
- Server server;
- server.run();
+ ode::ServerContext server;
+ server.start();
} catch (std::exception &e) {
std::cerr << e.what() << std::endl;
return 1;
#include <unistd.h>
#include <mntent.h>
-#include "ext4-tool.h"
#include "secure-erase.h"
namespace ode {
}
} /* 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());
#include <string>
#include <memory>
-#include "context.h"
#include "rmi/secure-erase.h"
#include "engine/erase/mmc-engine.h"
+#include "server.h"
namespace ode {
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;
};
/*
- * 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;
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
/*
- * 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__