{
public:
// decrypt user key with password
- virtual int unlockUserKey(uid_t user, const Password &password) const = 0;
+ virtual int unlockUserKey(uid_t user, const Password &password) = 0;
// remove user key from memory
- virtual int lockUserKey(uid_t user) const = 0;
+ virtual int lockUserKey(uid_t user) = 0;
// remove user data from Store and erase key used for encryption
- virtual int removeUserData(uid_t user) const = 0;
+ virtual int removeUserData(uid_t user) = 0;
// change password for user
- virtual int changeUserPassword(uid_t user, const Password &oldPassword, const Password &newPassword) const = 0;
+ virtual int changeUserPassword(uid_t user, const Password &oldPassword, const Password &newPassword) = 0;
// This is work around for security-server api - resetPassword that may be called without passing oldPassword.
// This api should not be supported on tizen 3.0
// User must be already logged in and his DKEK is already loaded into memory in plain text form.
// The service will use DKEK in plain text and encrypt it in encrypted form (using new password).
- virtual int resetUserPassword(uid_t user, const Password &newPassword) const = 0;
+ virtual int resetUserPassword(uid_t user, const Password &newPassword) = 0;
virtual ~Control(){}
ControlImpl& operator=(const ControlImpl &) = delete;
ControlImpl& operator=(ControlImpl &&) = delete;
- virtual int unlockUserKey(uid_t user, const Password &password) const {
+ virtual int unlockUserKey(uid_t user, const Password &password) {
return try_catch([&] {
+ if((int)user < 0) {
+ return CKM_API_ERROR_INPUT_PARAM;
+ }
+
MessageBuffer send, recv;
Serialization::Serialize(send, static_cast<int>(ControlCommand::UNLOCK_USER_KEY));
Serialization::Serialize(send, user);
Serialization::Serialize(send, password);
- int retCode;
- if((int)user < 0) {
- retCode = CKM_API_ERROR_INPUT_PARAM;
- return retCode;
- }
-
- retCode = sendToServer(
+ int retCode = sendToServer(
SERVICE_SOCKET_CKM_CONTROL,
send.Pop(),
recv);
});
}
- virtual int lockUserKey(uid_t user) const {
+ virtual int lockUserKey(uid_t user) {
return try_catch([&] {
+ if((int)user < 0) {
+ return CKM_API_ERROR_INPUT_PARAM;
+ }
+
MessageBuffer send, recv;
Serialization::Serialize(send, static_cast<int>(ControlCommand::LOCK_USER_KEY));
Serialization::Serialize(send, user);
- int retCode;
- if((int)user < 0) {
- retCode = CKM_API_ERROR_INPUT_PARAM;
- return retCode;
- }
-
- retCode = sendToServer(
+ int retCode = sendToServer(
SERVICE_SOCKET_CKM_CONTROL,
send.Pop(),
recv);
});
}
- virtual int removeUserData(uid_t user) const {
+ virtual int removeUserData(uid_t user) {
return try_catch([&] {
+ if((int)user < 0) {
+ return CKM_API_ERROR_INPUT_PARAM;
+ }
+
MessageBuffer send, recv;
Serialization::Serialize(send, static_cast<int>(ControlCommand::REMOVE_USER_DATA));
Serialization::Serialize(send, user);
- int retCode;
- if((int)user < 0) {
- retCode = CKM_API_ERROR_INPUT_PARAM;
- return retCode;
- }
-
- retCode = sendToServer(
+ int retCode = sendToServer(
SERVICE_SOCKET_CKM_CONTROL,
send.Pop(),
recv);
});
}
- virtual int changeUserPassword(uid_t user, const Password &oldPassword, const Password &newPassword) const {
+ virtual int changeUserPassword(uid_t user, const Password &oldPassword, const Password &newPassword) {
return try_catch([&] {
+ if((int)user < 0) {
+ return CKM_API_ERROR_INPUT_PARAM;
+ }
+
MessageBuffer send, recv;
Serialization::Serialize(send, static_cast<int>(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;
- }
- retCode = sendToServer(
+ int retCode = sendToServer(
SERVICE_SOCKET_CKM_CONTROL,
send.Pop(),
recv);
});
}
- virtual int resetUserPassword(uid_t user, const Password &newPassword) const {
+ virtual int resetUserPassword(uid_t user, const Password &newPassword) {
return try_catch([&] {
+ if((int)user < 0) {
+ return CKM_API_ERROR_INPUT_PARAM;
+ }
+
MessageBuffer send, recv;
Serialization::Serialize(send, static_cast<int>(ControlCommand::RESET_USER_PASSWORD));
Serialization::Serialize(send, user);
Serialization::Serialize(send, newPassword);
- int retCode;
- if((int)user < 0) {
- retCode = CKM_API_ERROR_INPUT_PARAM;
+ int retCode = sendToServer(
+ SERVICE_SOCKET_CKM_CONTROL,
+ send.Pop(),
+ recv);
+
+ if (CKM_API_SUCCESS != retCode) {
return retCode;
}
return true;
} Catch (MessageBuffer::Exception::Base) {
LogError("Broken protocol. Closing socket.");
+ } Catch (Exception::BrokenProtocol) {
+ LogError("Broken protocol. Closing socket.");
} catch (const std::string &e) {
LogError("String exception(" << e << "). Closing socket");
} catch (...) {
Deserialization::Deserialize(buffer, newPass);
return m_logic->resetUserPassword(user, newPass);
default:
- // TODO
- throw 1; // broken protocol
+ Throw(Exception::BrokenProtocol);
}
}
static_cast<const RSAPaddingAlgorithm>(padding));
}
default:
- // TODO
- throw 1; // broken protocol
+ Throw(Exception::BrokenProtocol);
}
}