2 * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License
17 * @file client-manager-async-impl.cpp
18 * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
22 #include <client-manager-async-impl.h>
23 #include <ckm/ckm-error.h>
24 #include <message-buffer.h>
25 #include <client-common.h>
30 int ManagerAsync::Impl::m_counter = 0;
32 ManagerAsync::Impl::Impl()
36 ManagerAsync::Impl::~Impl()
40 void ManagerAsync::Impl::saveKey(const ManagerAsync::ObserverPtr& observer,
45 observerCheck(observer);
48 observer->ReceivedError(CKM_API_ERROR_INPUT_PARAM);
51 saveBinaryData(observer, alias, toDBDataType(key->getType()), key->getDER(), policy);
54 void ManagerAsync::Impl::saveBinaryData(const ManagerAsync::ObserverPtr& observer,
57 const RawBuffer& rawData,
60 if (alias.empty() || rawData.empty()) {
61 observer->ReceivedError(CKM_API_ERROR_INPUT_PARAM);
69 Serialization::Serialize(send, static_cast<int>(LogicCommand::SAVE));
70 Serialization::Serialize(send, m_counter);
71 Serialization::Serialize(send, static_cast<int>(dataType));
72 Serialization::Serialize(send, alias);
73 Serialization::Serialize(send, rawData);
74 Serialization::Serialize(send, PolicySerializable(policy));
76 thread()->sendMessage(AsyncRequest(observer,
77 SERVICE_SOCKET_CKM_STORAGE,
81 }, [&observer](int error){ observer->ReceivedError(error); } );
84 void ManagerAsync::Impl::observerCheck(const ManagerAsync::ObserverPtr& observer)
87 throw std::invalid_argument("Empty observer");