namespace CKM {
namespace {
-template <class F>
-void tryCatch(const ManagerAsync::ObserverPtr &observer, F &&f)
-{
- static_assert(std::is_same_v<void, decltype(std::forward<F>(f)())>);
- try_catch_async(std::forward<F>(f),
- [&](int error) { observer->ReceivedError(error); });
-}
-
template <class T>
bool paramEmpty(const T &t) {
return t.empty();
const RawBuffer &rawData,
const Policy &policy)
{
- tryCatch(observer, [&] {
+ tryCatch(*observer, [&] {
AliasSupport helper(alias);
sendToStorage(LogicCommand::SAVE, observer,
const Policy &keyPolicy,
const Policy &certPolicy)
{
- tryCatch(observer, [&] {
+ tryCatch(*observer, [&] {
AliasSupport helper(alias);
sendToStorage(LogicCommand::SAVE_PKCS12, observer,
helper.getName(), helper.getOwner(), PKCS12Serializable(*pkcs.get()),
if (anyParamEmpty(observer, alias))
return;
- tryCatch(observer, [&] {
+ tryCatch(*observer, [&] {
AliasSupport helper(alias);
sendToStorage(LogicCommand::REMOVE, observer,
helper.getName(), helper.getOwner());
if (anyParamEmpty(observer, alias))
return;
- tryCatch(observer, [&] {
+ tryCatch(*observer, [&] {
AliasSupport helper(alias);
sendToStorage(LogicCommand::GET, observer,
if (anyParamEmpty(observer, alias))
return;
- tryCatch(observer, [&] {
+ tryCatch(*observer, [&] {
AliasSupport helper(alias);
sendToStorage(LogicCommand::GET_PKCS12, observer,
if (anyParamEmpty(observer, privateKeyAlias, message))
return;
- tryCatch(observer, [&] {
+ tryCatch(*observer, [&] {
AliasSupport helper(privateKeyAlias);
sendToStorage(LogicCommand::CREATE_SIGNATURE, observer,
helper.getName(), helper.getOwner(), password, message,
if (anyParamEmpty(observer, publicKeyOrCertAlias, message, signature))
return;
- tryCatch(observer, [&] {
+ tryCatch(*observer, [&] {
AliasSupport helper(publicKeyOrCertAlias);
sendToStorage(LogicCommand::VERIFY_SIGNATURE, observer,
if (anyParamEmpty(observer, certificateChainVector))
return;
- tryCatch(observer, [&] {
+ tryCatch(*observer, [&] {
RawBufferVector rawCertChain;
for (auto &e : certificateChainVector) {
if (anyParamEmpty(observer, alias, accessor))
return;
- tryCatch(observer, [&] {
+ tryCatch(*observer, [&] {
AliasSupport helper(alias);
sendToStorage(LogicCommand::SET_PERMISSION, observer,
DataType dataType)
{
observerCheck(observer);
- tryCatch(observer, [&] {
+ tryCatch(*observer, [&] {
sendToStorage(LogicCommand::GET_LIST, observer, dataType);
});
}
return;
}
- tryCatch(observer, [&] {
+ tryCatch(*observer, [&] {
AliasSupport prvHelper(privateKeyAlias);
AliasSupport pubHelper(publicKeyAlias);
if (anyParamEmpty(observer, keyAlias))
return;
- tryCatch(observer, [&] {
+ tryCatch(*observer, [&] {
AliasSupport aliasHelper(keyAlias);
sendToStorage(LogicCommand::CREATE_KEY_AES, observer,
if (anyParamEmpty(observer, input, keyAlias))
return;
- tryCatch(observer, [&] {
+ tryCatch(*observer, [&] {
AliasSupport helper(keyAlias);
CryptoAlgorithmSerializable cas(algo);
m_counter++;
/*
- * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2000-2020 Samsung Electronics Co., Ltd. All rights reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* @version 1.0
*/
+#include <cxxabi.h>
+
#include <ckm/ckm-manager-async.h>
#include <client-manager-async-impl.h>
+#include <dpl/log/log.h>
#include <exception.h>
namespace CKM {
{
Impl::observerCheck(observer);
- try_catch_async([&]() {
+ tryCatch(*observer, [&] {
m_impl->getCertChain(observer,
LogicCommand::GET_CHAIN_CERT,
certificate,
toRawBufferVector(untrustedCertificates),
toRawBufferVector(trustedCertificates),
useSystemTrustedCertificates);
- }, [&observer](int error) {
- observer->ReceivedError(error);
});
}
{
Impl::observerCheck(observer);
- try_catch_async([&]() {
+ tryCatch(*observer, [&] {
m_impl->getCertChain(observer,
LogicCommand::GET_CHAIN_ALIAS,
certificate,
toOwnerNameVector(untrustedCertificates),
toOwnerNameVector(trustedCertificates),
useSystemTrustedCertificates);
- }, [&observer](int error) {
- observer->ReceivedError(error);
});
}
m_impl->crypt(observer, algo, keyAlias, password, encrypted, false);
}
+void ManagerAsync::tryCatchHelper(Observer &observer,
+ const std::function<void()> &func)
+{
+ try {
+ func();
+ } catch (const MessageBuffer::Exception::Base &e) {
+ LogError("CKM::MessageBuffer::Exception " << e.DumpToString());
+ observer.ReceivedError(CKM_API_ERROR_BAD_REQUEST);
+ } catch (const Exc::Exception &e) {
+ LogError("Exception: " << e.what());
+ observer.ReceivedError(e.error());
+ } catch (const std::exception &e) {
+ LogError("STD exception " << e.what());
+ observer.ReceivedError(CKM_API_ERROR_UNKNOWN);
+ } catch (const abi::__forced_unwind &) {
+ LogDebug("abi::__forced_unwind caught. Thread cancelation.");
+ throw;
+ } catch (...) {
+ LogError("Unknown exception occured");
+ observer.ReceivedError(CKM_API_ERROR_UNKNOWN);
+ }
+}
+
} // namespace CKM
/*
- * Copyright (c) 2000 - 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2000-2020 Samsung Electronics Co., Ltd. All rights reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
}
}
-void try_catch_async(const std::function<void()> &func,
- const std::function<void(int)> &error)
-{
- try {
- func();
- } catch (const MessageBuffer::Exception::Base &e) {
- LogError("CKM::MessageBuffer::Exception " << e.DumpToString());
- error(CKM_API_ERROR_BAD_REQUEST);
- } catch (const Exc::Exception &e) {
- LogError("Exception: " << e.what());
- error(e.error());
- } catch (const std::exception &e) {
- LogError("STD exception " << e.what());
- error(CKM_API_ERROR_UNKNOWN);
- } catch (const abi::__forced_unwind &) {
- LogDebug("abi::__forced_unwind caught. Thread cancelation.");
- throw;
- } catch (...) {
- LogError("Unknown exception occured");
- error(CKM_API_ERROR_UNKNOWN);
- }
-}
-
} // namespace CKM
static void init_lib(void) __attribute__((constructor));