X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fmanager%2Fclient%2Fclient-control.cpp;h=e87658ef79fa44a7407265e996ce14215a7d15f3;hb=cdd6801a81959754bc06546462b50aac2fe7cdc7;hp=1a352ffba099fa736657dce6ee5995769c2e9685;hpb=4a895c8624366e2168c3136f9969f82e62390319;p=platform%2Fcore%2Fsecurity%2Fkey-manager.git diff --git a/src/manager/client/client-control.cpp b/src/manager/client/client-control.cpp index 1a352ff..e87658e 100644 --- a/src/manager/client/client-control.cpp +++ b/src/manager/client/client-control.cpp @@ -28,7 +28,7 @@ namespace CKM { -class Control::ControlImpl { +class ControlImpl : public Control { public: ControlImpl(){} ControlImpl(const ControlImpl &) = delete; @@ -36,14 +36,20 @@ public: ControlImpl& operator=(const ControlImpl &) = delete; ControlImpl& operator=(ControlImpl &&) = delete; - static int unlockUserKey(uid_t user, const std::string &password) { + virtual int unlockUserKey(uid_t user, const std::string &password) const { return try_catch([&] { MessageBuffer send, recv; Serialization::Serialize(send, static_cast(ControlCommand::UNLOCK_USER_KEY)); Serialization::Serialize(send, user); Serialization::Serialize(send, password); + int retCode; - int retCode = sendToServer( + if((int)user < 0) { + retCode = CKM_API_ERROR_INPUT_PARAM; + return retCode; + } + + retCode = sendToServer( SERVICE_SOCKET_CKM_CONTROL, send.Pop(), recv); @@ -58,13 +64,19 @@ public: }); } - static int lockUserKey(uid_t user) { + virtual int lockUserKey(uid_t user) const { return try_catch([&] { MessageBuffer send, recv; Serialization::Serialize(send, static_cast(ControlCommand::LOCK_USER_KEY)); Serialization::Serialize(send, user); + int retCode; - int retCode = sendToServer( + if((int)user < 0) { + retCode = CKM_API_ERROR_INPUT_PARAM; + return retCode; + } + + retCode = sendToServer( SERVICE_SOCKET_CKM_CONTROL, send.Pop(), recv); @@ -79,13 +91,19 @@ public: }); } - static int removeUserData(uid_t user) { + virtual int removeUserData(uid_t user) const { return try_catch([&] { MessageBuffer send, recv; Serialization::Serialize(send, static_cast(ControlCommand::REMOVE_USER_DATA)); Serialization::Serialize(send, user); + int retCode; - int retCode = sendToServer( + if((int)user < 0) { + retCode = CKM_API_ERROR_INPUT_PARAM; + return retCode; + } + + retCode = sendToServer( SERVICE_SOCKET_CKM_CONTROL, send.Pop(), recv); @@ -100,15 +118,21 @@ public: }); } - static int changeUserPassword(uid_t user, const std::string &oldPassword, const std::string &newPassword) { + virtual int changeUserPassword(uid_t user, const std::string &oldPassword, const std::string &newPassword) const { return try_catch([&] { MessageBuffer send, recv; Serialization::Serialize(send, static_cast(ControlCommand::CHANGE_USER_PASSWORD)); Serialization::Serialize(send, user); Serialization::Serialize(send, oldPassword); Serialization::Serialize(send, newPassword); + int retCode; + + if((int)user < 0) { + retCode = CKM_API_ERROR_INPUT_PARAM; + return retCode; + } - int retCode = sendToServer( + retCode = sendToServer( SERVICE_SOCKET_CKM_CONTROL, send.Pop(), recv); @@ -123,14 +147,20 @@ public: }); } - static int resetUserPassword(uid_t user, const std::string &newPassword) { + virtual int resetUserPassword(uid_t user, const std::string &newPassword) const { return try_catch([&] { MessageBuffer send, recv; Serialization::Serialize(send, static_cast(ControlCommand::RESET_USER_PASSWORD)); Serialization::Serialize(send, user); Serialization::Serialize(send, newPassword); + int retCode; + + if((int)user < 0) { + retCode = CKM_API_ERROR_INPUT_PARAM; + return retCode; + } - int retCode = sendToServer( + retCode = sendToServer( SERVICE_SOCKET_CKM_CONTROL, send.Pop(), recv); @@ -146,32 +176,11 @@ public: } virtual ~ControlImpl(){} -}; - -Control::Control() - : m_impl(new ControlImpl) -{} - -Control::~Control(){} - -int Control::unlockUserKey(uid_t user, const std::string &password) const { - return m_impl->unlockUserKey(user, password); -} -int Control::lockUserKey(uid_t user) const { - return m_impl->lockUserKey(user); -} - -int Control::removeUserData(uid_t user) const { - return m_impl->removeUserData(user); -} - -int Control::changeUserPassword(uid_t user, const std::string &oldPassword, const std::string &newPassword) const { - return m_impl->changeUserPassword(user, oldPassword, newPassword); -} +}; -int Control::resetUserPassword(uid_t user, const std::string &newPassword) const { - return m_impl->resetUserPassword(user, newPassword); +ControlShPtr Control::create() { + return ControlShPtr(new ControlImpl()); } } // namespace CKM