tizen 2.4 release
[framework/security/key-manager.git] / src / manager / client / client-control.cpp
index 37cbf66..f29ba0a 100644 (file)
  *  See the License for the specific language governing permissions and
  *  limitations under the License
  *
- * @file        client-common.cpp
+ * @file        client-control.cpp
  * @author      Bartlomiej Grzelewski (b.grzelewski@samsung.com)
  * @version     1.0
- * @brief       This file is implementation of client-common functions.
+ * @brief       This file is implementation of client-control functions.
  */
 #include <dpl/log/log.h>
 
@@ -38,15 +38,15 @@ public:
     ControlImpl& operator=(const ControlImpl &) = delete;
     ControlImpl& operator=(ControlImpl &&) = delete;
 
-    virtual int unlockUserKey(uid_t user, const Password &password) {
+    virtual int unlockUserKey(const ClientInfo &clientInfo, const Password &password) {
         return try_catch([&] {
-            if((int)user < 0) {
+            if((int)clientInfo.getUID() < 0) {
                 return CKM_API_ERROR_INPUT_PARAM;
             }
 
             MessageBuffer recv;
             auto send = MessageBuffer::Serialize(static_cast<int>(ControlCommand::UNLOCK_USER_KEY),
-                                                 user,
+                                                 clientInfo.getClientID(),
                                                  password);
 
             int retCode = m_controlConnection.processRequest(send.Pop(), recv);
@@ -59,14 +59,15 @@ public:
         });
     }
 
-    virtual int lockUserKey(uid_t user) {
+    virtual int lockUserKey(const ClientInfo &clientInfo) {
         return try_catch([&] {
-            if((int)user < 0) {
+            if((int)clientInfo.getUID() < 0) {
                 return CKM_API_ERROR_INPUT_PARAM;
             }
 
             MessageBuffer recv;
-            auto send = MessageBuffer::Serialize(static_cast<int>(ControlCommand::LOCK_USER_KEY), user);
+            auto send = MessageBuffer::Serialize(static_cast<int>(ControlCommand::LOCK_USER_KEY),
+                                                 clientInfo.getClientID());
 
             int retCode = m_controlConnection.processRequest(send.Pop(), recv);
             if (CKM_API_SUCCESS != retCode)
@@ -77,15 +78,15 @@ public:
             return retCode;
         });
     }
-
-    virtual int removeUserData(uid_t user) {
+    virtual int removeUserData(const ClientInfo &clientInfo) {
         return try_catch([&] {
-            if((int)user < 0) {
+            if((int)clientInfo.getUID() < 0) {
                 return CKM_API_ERROR_INPUT_PARAM;
             }
 
             MessageBuffer recv;
-            auto send = MessageBuffer::Serialize(static_cast<int>(ControlCommand::REMOVE_USER_DATA), user);
+            auto send = MessageBuffer::Serialize(static_cast<int>(ControlCommand::REMOVE_USER_DATA),
+                                                 clientInfo.getClientID());
 
             int retCode = m_controlConnection.processRequest(send.Pop(), recv);
             if (CKM_API_SUCCESS != retCode)
@@ -96,17 +97,16 @@ public:
             return retCode;
         });
     }
-
-    virtual int changeUserPassword(uid_t user, const Password &oldPassword, const Password &newPassword) {
+    virtual int changeUserPassword(const ClientInfo &clientInfo, const Password &oldPassword, const Password &newPassword) {
         return try_catch([&] {
-            if((int)user < 0) {
+            if((int)clientInfo.getUID() < 0) {
                 return CKM_API_ERROR_INPUT_PARAM;
             }
 
             MessageBuffer recv;
             auto send = MessageBuffer::Serialize(
                     static_cast<int>(ControlCommand::CHANGE_USER_PASSWORD),
-                    user,
+                    clientInfo.getClientID(),
                     oldPassword,
                     newPassword);
 
@@ -120,16 +120,16 @@ public:
         });
     }
 
-    virtual int resetUserPassword(uid_t user, const Password &newPassword) {
+    virtual int resetUserPassword(const ClientInfo &clientInfo, const Password &newPassword) {
         return try_catch([&] {
-            if((int)user < 0) {
+            if((int)clientInfo.getUID() < 0) {
                 return CKM_API_ERROR_INPUT_PARAM;
             }
 
             MessageBuffer recv;
             auto send = MessageBuffer::Serialize(
                     static_cast<int>(ControlCommand::RESET_USER_PASSWORD),
-                    user,
+                    clientInfo.getClientID(),
                     newPassword);
 
             int retCode = m_controlConnection.processRequest(send.Pop(), recv);
@@ -142,14 +142,16 @@ public:
         });
     }
 
-    virtual int removeApplicationData(const Label &smackLabel) {
+    virtual int removeApplicationData(const std::string &zone, const Label &smackLabel) {
         return try_catch([&] {
             if (smackLabel.empty()) {
                 return CKM_API_ERROR_INPUT_PARAM;
             }
 
             MessageBuffer recv;
-            auto send = MessageBuffer::Serialize(static_cast<int>(ControlCommand::REMOVE_APP_DATA), smackLabel);
+            auto send = MessageBuffer::Serialize(static_cast<int>(ControlCommand::REMOVE_APP_DATA),
+                                                 zone,
+                                                 smackLabel);
 
             int retCode = m_controlConnection.processRequest(send.Pop(), recv);
             if (CKM_API_SUCCESS != retCode)
@@ -176,7 +178,7 @@ public:
         });
     }
 
-    virtual int setPermission(uid_t user,
+    virtual int setPermission(const ClientInfo &clientInfo,
                               const Alias &alias,
                               const Label &accessor,
                               PermissionMask permissionMask)
@@ -185,7 +187,7 @@ public:
             MessageBuffer recv;
             AliasSupport helper(alias);
             auto send = MessageBuffer::Serialize(static_cast<int>(ControlCommand::SET_PERMISSION),
-                                                 static_cast<int>(user),
+                                                 clientInfo.getClientID(),
                                                  helper.getName(),
                                                  helper.getLabel(),
                                                  accessor,