std::bind(&KeyManagerInstance::GetKeyAliasList, this, _1, _2));
RegisterSyncHandler("KeyManager_saveKey",
std::bind(&KeyManagerInstance::SaveKey, this, _1, _2));
+ RegisterSyncHandler("KeyManager_removeKey",
+ std::bind(&KeyManagerInstance::RemoveKey, this, _1, _2));
}
KeyManagerInstance::~KeyManagerInstance() {
PostMessage(res.serialize().c_str());
}
+void KeyManagerInstance::RemoveKey(const picojson::value& args,
+ picojson::object& out) {
+ LoggerD("Enter");
+
+ const std::string& alias = args.get("key").get("name").get<std::string>();
+ int ret = CKM::Manager::create()->removeAlias(alias);
+ if (ret != CKM_API_SUCCESS) {
+ LoggerE("Failed to remove key alias: %d", ret);
+ if (ret == CKM_API_ERROR_DB_ALIAS_UNKNOWN) {
+ ReportError(common::PlatformResult(common::ErrorCode::NOT_FOUND_ERR,
+ "Key alias not found"), &out);
+ } else {
+ ReportError(common::PlatformResult(common::ErrorCode::UNKNOWN_ERR,
+ "Failed to remove key alias"), &out);
+ }
+ } else {
+ ReportSuccess(out);
+ }
+}
+
} // namespace keymanager
} // namespace extension
private:
void GetKeyAliasList(picojson::value const& args, picojson::object& out);
void SaveKey(const picojson::value& args, picojson::object& out);
+ void RemoveKey(const picojson::value& args, picojson::object& out);
CKM::ManagerAsync m_manager;
};