From 6208ba9ed1302bdc71c0f72083206afb5497041a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E4=BD=99?= <1459392684@qq.com> Date: Wed, 9 Oct 2024 10:11:42 +0800 Subject: [PATCH 1/3] =?UTF-8?q?Revert=20"=E5=91=8A=E8=AD=A6=E6=B8=85?= =?UTF-8?q?=E7=90=86=E5=8F=8A=E5=A2=9E=E5=8A=A0throws"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 65a112752b520742d7538db2030559919468be26. Signed-off-by: 张余 <1459392684@qq.com> Change-Id: Id988cd1573f901f7edde87e6486b82e80b227c5f --- .../napi/include/dialog/cm_napi_open_dialog.h | 3 ++- .../kits/napi/src/dialog/cm_napi_open_dialog.cpp | 16 ++++------------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/interfaces/kits/napi/include/dialog/cm_napi_open_dialog.h b/interfaces/kits/napi/include/dialog/cm_napi_open_dialog.h index e7fb028..54734e1 100644 --- a/interfaces/kits/napi/include/dialog/cm_napi_open_dialog.h +++ b/interfaces/kits/napi/include/dialog/cm_napi_open_dialog.h @@ -52,7 +52,8 @@ struct CommonAsyncContext { struct CmUIExtensionRequestContext : public CommonAsyncContext { explicit CmUIExtensionRequestContext(napi_env env) : CommonAsyncContext(env) {}; std::shared_ptr context = nullptr; - uint32_t pageType = 0; + OHOS::AAFwk::Want want; + uint32_t pageType; }; class CmUIExtensionCallback { diff --git a/interfaces/kits/napi/src/dialog/cm_napi_open_dialog.cpp b/interfaces/kits/napi/src/dialog/cm_napi_open_dialog.cpp index 654a08a..c44628c 100644 --- a/interfaces/kits/napi/src/dialog/cm_napi_open_dialog.cpp +++ b/interfaces/kits/napi/src/dialog/cm_napi_open_dialog.cpp @@ -34,7 +34,6 @@ const std::string CERT_MANAGER_PAGE_TYPE = "pageType"; constexpr int32_t PARAM0 = 0; constexpr int32_t PARAM1 = 1; constexpr int32_t PARAM_SIZE_TWO = 2; -constexpr int32_t ERROR_STR_LEN = 256; } // namespace CommonAsyncContext::CommonAsyncContext(napi_env env) @@ -106,13 +105,6 @@ void CmUIExtensionCallback::OnError(const int32_t errorCode, const std::string& if (SetErrorCode(errorCode)) { SendMessageBack(); } - char errStr[ERROR_STR_LEN] = { 0 }; - if (sprintf_s(errStr, ERROR_STR_LEN, "UIExtensionComponent OnError(), errorCode = %d, name = %s, message = %s", - errorCode, name.c_str(), message.c_str()) < 0) { - CM_LOG_E("copy error str failed"); - return; - } - ThrowError(this->reqContext_->env, PARAM_ERROR, errStr); } void CmUIExtensionCallback::OnRemoteReady(const std::shared_ptr& uiProxy) @@ -191,8 +183,7 @@ bool ParseCmUIAbilityContextReq( return true; } -static void StartUIExtensionAbility(std::shared_ptr asyncContext, - OHOS::AAFwk::Want want) +static void StartUIExtensionAbility(std::shared_ptr asyncContext) { CM_LOG_D("begin StartUIExtensionAbility"); if (asyncContext == nullptr) { @@ -228,7 +219,7 @@ static void StartUIExtensionAbility(std::shared_ptr OHOS::Ace::ModalUIExtensionConfig uiExtConfig; uiExtConfig.isProhibitBack = false; - int32_t sessionId = uiContent->CreateModalUIExtension(want, extensionCallbacks, uiExtConfig); + int32_t sessionId = uiContent->CreateModalUIExtension(asyncContext->want, extensionCallbacks, uiExtConfig); CM_LOG_I("end CreateModalUIExtension sessionId = %d", sessionId); if (sessionId == 0) { CM_LOG_E("CreateModalUIExtension failed, sessionId is %d", sessionId); @@ -275,10 +266,11 @@ napi_value CMNapiOpenCertManagerDialog(napi_env env, napi_callback_info info) want.SetElementName(CERT_MANAGER_BUNDLENAME, CERT_MANAGER_ABILITYNAME); want.SetParam(CERT_MANAGER_PAGE_TYPE, static_cast(asyncContext->pageType)); want.SetParam(PARAM_UI_EXTENSION_TYPE, SYS_COMMON_UI); + asyncContext->want = want; NAPI_CALL(env, napi_create_promise(env, &asyncContext->deferred, &result)); // Start ui extension by context. - StartUIExtensionAbility(asyncContext, want); + StartUIExtensionAbility(asyncContext); CM_LOG_D("cert manager dialog end"); return result; } -- Gitee From 6c2c895744e164cda4901794a78480d7059acd4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E4=BD=99?= <1459392684@qq.com> Date: Wed, 9 Oct 2024 10:11:50 +0800 Subject: [PATCH 2/3] =?UTF-8?q?Revert=20"=E6=8F=90=E4=BE=9B=E5=B9=B6?= =?UTF-8?q?=E5=BC=80=E6=94=BE=E6=8B=89=E8=B5=B7=E8=AF=81=E4=B9=A6=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E7=95=8C=E9=9D=A2=E7=9A=84API=E6=8E=A5=E5=8F=A3"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit f89339ca447b1ed6cc3f117eec9e066dbbfe9531. Signed-off-by: 张余 <1459392684@qq.com> Change-Id: I33a0cc79bc9bca17604a5f012e5219b200c06e5a --- BUILD.gn | 5 +- bundle.json | 2 - interfaces/kits/napi/BUILD.gn | 52 ---- .../napi/include/dialog/cm_napi_open_dialog.h | 81 ----- .../kits/napi/src/dialog/cm_napi_dialog.cpp | 86 ------ .../napi/src/dialog/cm_napi_open_dialog.cpp | 278 ------------------ 6 files changed, 1 insertion(+), 503 deletions(-) delete mode 100644 interfaces/kits/napi/include/dialog/cm_napi_open_dialog.h delete mode 100644 interfaces/kits/napi/src/dialog/cm_napi_dialog.cpp delete mode 100644 interfaces/kits/napi/src/dialog/cm_napi_open_dialog.cpp diff --git a/BUILD.gn b/BUILD.gn index 5ab61f4..717e547 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -27,10 +27,7 @@ group("cert_manager_sdk_test") { group("cert_manager_napi") { if (os_level == "standard") { if (support_jsapi) { - deps = [ - "./interfaces/kits/napi:certmanager", - "./interfaces/kits/napi:certmanagerdialog", - ] + deps = [ "./interfaces/kits/napi:certmanager" ] } } } diff --git a/bundle.json b/bundle.json index df29991..4e657fe 100644 --- a/bundle.json +++ b/bundle.json @@ -35,8 +35,6 @@ "deps": { "components": [ "ability_base", - "ace_engine", - "ability_runtime", "access_token", "bounds_checking_function", "bundle_framework", diff --git a/interfaces/kits/napi/BUILD.gn b/interfaces/kits/napi/BUILD.gn index d2ec35d..2e4b4b2 100644 --- a/interfaces/kits/napi/BUILD.gn +++ b/interfaces/kits/napi/BUILD.gn @@ -68,55 +68,3 @@ ohos_shared_library("certmanager") { subsystem_name = "security" part_name = "certificate_manager" } - -ohos_shared_library("certmanagerdialog") { - branch_protector_ret = "pac_ret" - sanitize = { - cfi = true - cfi_cross_dso = true - boundary_sanitize = true - debug = false - integer_overflow = true - ubsan = true - } - defines = [ - "L2_STANDARD", - "_HARDWARE_ROOT_KEY_", - "_CM_LOG_ENABLE_", - ] - - include_dirs = [ - "../../../frameworks/cert_manager_standard/main/common/include", - "include", - "include/dialog", - ] - - sources = [ - "src/cm_napi_common.cpp", - "src/dialog/cm_napi_dialog.cpp", - "src/dialog/cm_napi_open_dialog.cpp", - ] - - external_deps = [ - "ability_base:base", - "ability_base:want", - "ability_runtime:ability_context_native", - "ability_runtime:ability_manager", - "ability_runtime:abilitykit_native", - "ability_runtime:app_context", - "ability_runtime:napi_base_context", - "ability_runtime:napi_common", - "ace_engine:ace_uicontent", - "c_utils:utils", - "napi:ace_napi", - ] - cflags_cc = [ - "-Wall", - "-Werror", - ] - deps = [ "../../innerkits/cert_manager_standard/main:cert_manager_sdk" ] - - relative_install_dir = "module/security" - subsystem_name = "security" - part_name = "certificate_manager" -} diff --git a/interfaces/kits/napi/include/dialog/cm_napi_open_dialog.h b/interfaces/kits/napi/include/dialog/cm_napi_open_dialog.h deleted file mode 100644 index 54734e1..0000000 --- a/interfaces/kits/napi/include/dialog/cm_napi_open_dialog.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef CM_NAPI_OPEN_DIALOG_H -#define CM_NAPI_OPEN_DIALOG_H - -#include "ability_context.h" -#include "napi/native_api.h" -#include "napi/native_node_api.h" -#include "napi_base_context.h" -#include "napi_common_want.h" -#include "ui_content.h" - -#include "cm_napi_common.h" - -namespace CMNapi { -napi_value CMNapiOpenCertManagerDialog(napi_env env, napi_callback_info info); - -enum CmDialogErrorCode { - DIALOG_ERROR_GENERIC = 29700001, - DIALOG_ERROR_OPERATION_CANCELED = 29700002, -}; - -enum CmDialogPageType { - PAGE_MAIN = 1, - PAGE_CA_CERTIFICATE = 2, - PAGE_CREDENTIAL = 3, - PAGE_INSTALL_CERTIFICATE = 4 -}; - -struct CommonAsyncContext { - explicit CommonAsyncContext(napi_env env); - virtual ~CommonAsyncContext(); - napi_env env = nullptr; - napi_status status = napi_invalid_arg; - int32_t errCode = 0; - napi_deferred deferred = nullptr; // promise handle -}; - -struct CmUIExtensionRequestContext : public CommonAsyncContext { - explicit CmUIExtensionRequestContext(napi_env env) : CommonAsyncContext(env) {}; - std::shared_ptr context = nullptr; - OHOS::AAFwk::Want want; - uint32_t pageType; -}; - -class CmUIExtensionCallback { -public: - explicit CmUIExtensionCallback(std::shared_ptr& reqContext); - void SetSessionId(const int32_t sessionId); - void OnRelease(const int32_t releaseCode); - void OnResult(const int32_t resultCode, const OHOS::AAFwk::Want& result); - void OnReceive(const OHOS::AAFwk::WantParams& request); - void OnError(const int32_t code, const std::string& name, const std::string& message); - void OnRemoteReady(const std::shared_ptr& uiProxy); - void OnDestroy(); - void SendMessageBack(); - -private: - bool SetErrorCode(int32_t errCode); - int32_t sessionId_ = 0; - int32_t resultCode_ = 0; - OHOS::AAFwk::Want resultWant_; - std::shared_ptr reqContext_ = nullptr; - bool alreadyCallback_ = false; -}; - -} // namespace CertManagerNapi -#endif // CM_NAPI_OPEN_DIALOG_H diff --git a/interfaces/kits/napi/src/dialog/cm_napi_dialog.cpp b/interfaces/kits/napi/src/dialog/cm_napi_dialog.cpp deleted file mode 100644 index 6c839cc..0000000 --- a/interfaces/kits/napi/src/dialog/cm_napi_dialog.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "napi/native_api.h" -#include "napi/native_node_api.h" - -#include "cm_napi_common.h" - -#include "cm_napi_open_dialog.h" - -namespace CMNapi { -inline void AddInt32Property(napi_env env, napi_value object, const char *name, int32_t value) -{ - napi_value property = nullptr; - NAPI_CALL_RETURN_VOID(env, napi_create_int32(env, value, &property)); - NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, object, name, property)); -} - -static napi_value CreateCmErrorCode(napi_env env) -{ - napi_value dialogErrorCode = nullptr; - NAPI_CALL(env, napi_create_object(env, &dialogErrorCode)); - - AddInt32Property(env, dialogErrorCode, "ERROR_GENERIC", DIALOG_ERROR_GENERIC); - AddInt32Property(env, dialogErrorCode, "ERROR_OPERATION_CANCELED", DIALOG_ERROR_OPERATION_CANCELED); - - return dialogErrorCode; -} - -static napi_value CreateCmDialogPageType(napi_env env) -{ - napi_value dialogPageType = nullptr; - NAPI_CALL(env, napi_create_object(env, &dialogPageType)); - - AddInt32Property(env, dialogPageType, "PAGE_MAIN", PAGE_MAIN); - AddInt32Property(env, dialogPageType, "PAGE_CA_CERTIFICATE", PAGE_CA_CERTIFICATE); - AddInt32Property(env, dialogPageType, "PAGE_CREDENTIAL", PAGE_CREDENTIAL); - AddInt32Property(env, dialogPageType, "PAGE_INSTALL_CERTIFICATE", PAGE_INSTALL_CERTIFICATE); - - return dialogPageType; -} -} // namespace CertManagerNapi - -using namespace CMNapi; - -extern "C" { -static napi_value CMDialogNapiRegister(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - DECLARE_NAPI_PROPERTY("CertificateDialogErrorCode", CreateCmErrorCode(env)), - DECLARE_NAPI_PROPERTY("CertificateDialogPageType", CreateCmDialogPageType(env)), - - /* dialog */ - DECLARE_NAPI_FUNCTION("openCertificateManagerDialog", CMNapiOpenCertManagerDialog), - }; - NAPI_CALL(env, napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc)); - return exports; -} - -static napi_module g_module = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = CMDialogNapiRegister, - .nm_modname = "security.certManagerDialog", - .nm_priv = nullptr, - .reserved = { nullptr }, -}; - -__attribute__((constructor)) void CMDialogNapiRegister(void) -{ - napi_module_register(&g_module); -} -} diff --git a/interfaces/kits/napi/src/dialog/cm_napi_open_dialog.cpp b/interfaces/kits/napi/src/dialog/cm_napi_open_dialog.cpp deleted file mode 100644 index c44628c..0000000 --- a/interfaces/kits/napi/src/dialog/cm_napi_open_dialog.cpp +++ /dev/null @@ -1,278 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "cm_napi_open_dialog.h" - -#include "securec.h" - -#include "cert_manager_api.h" -#include "cm_log.h" - -#include "cm_napi_common.h" -#include "want.h" -#include "want_params_wrapper.h" - -namespace CMNapi { -namespace { -const std::string PARAM_UI_EXTENSION_TYPE = "ability.want.params.uiExtensionType"; -const std::string SYS_COMMON_UI = "sys/commonUI"; -const std::string CERT_MANAGER_BUNDLENAME = "com.ohos.certmanager"; -const std::string CERT_MANAGER_ABILITYNAME = "CertPickerUIExtAbility"; -const std::string CERT_MANAGER_PAGE_TYPE = "pageType"; -constexpr int32_t PARAM0 = 0; -constexpr int32_t PARAM1 = 1; -constexpr int32_t PARAM_SIZE_TWO = 2; -} // namespace - -CommonAsyncContext::CommonAsyncContext(napi_env env) -{ - CM_LOG_D("CommonAsyncContext"); - this->env = env; -} - -CommonAsyncContext::~CommonAsyncContext() -{ - CM_LOG_D("~CommonAsyncContext"); -} - -CmUIExtensionCallback::CmUIExtensionCallback(std::shared_ptr& reqContext) -{ - this->reqContext_ = reqContext; -} - -void CmUIExtensionCallback::SetSessionId(const int32_t sessionId) -{ - this->sessionId_ = sessionId; -} - -bool CmUIExtensionCallback::SetErrorCode(int32_t code) -{ - if (this->reqContext_ == nullptr) { - CM_LOG_E("OnError reqContext is nullptr"); - return false; - } - if (this->alreadyCallback_) { - CM_LOG_D("alreadyCallback"); - return false; - } - this->alreadyCallback_ = true; - this->reqContext_->errCode = code; - return true; -} - -void CmUIExtensionCallback::OnRelease(const int32_t releaseCode) -{ - CM_LOG_D("UIExtensionComponent OnRelease(), releaseCode = %d", releaseCode); - if (SetErrorCode(releaseCode)) { - SendMessageBack(); - } -} - -void CmUIExtensionCallback::OnResult(const int32_t resultCode, const OHOS::AAFwk::Want& result) -{ - CM_LOG_D("UIExtensionComponent OnResult(), resultCode = %d", resultCode); - this->resultCode_ = resultCode; - this->resultWant_ = result; - if (SetErrorCode(0)) { - SendMessageBack(); - } -} - -void CmUIExtensionCallback::OnReceive(const OHOS::AAFwk::WantParams& request) -{ - CM_LOG_D("UIExtensionComponent OnReceive()"); - if (SetErrorCode(0)) { - SendMessageBack(); - } -} - -void CmUIExtensionCallback::OnError(const int32_t errorCode, const std::string& name, const std::string& message) -{ - CM_LOG_E("UIExtensionComponent OnError(), errorCode = %d, name = %s, message = %s", - errorCode, name.c_str(), message.c_str()); - if (SetErrorCode(errorCode)) { - SendMessageBack(); - } -} - -void CmUIExtensionCallback::OnRemoteReady(const std::shared_ptr& uiProxy) -{ - CM_LOG_D("UIExtensionComponent OnRemoteReady()"); -} - -void CmUIExtensionCallback::OnDestroy() -{ - CM_LOG_D("UIExtensionComponent OnDestroy()"); - if (SetErrorCode(0)) { - SendMessageBack(); - } -} - -void ProcessCallback(napi_env env, const CommonAsyncContext* asyncContext) -{ - napi_value args[PARAM_SIZE_TWO] = {nullptr}; - - if (asyncContext->errCode == CM_SUCCESS) { - NAPI_CALL_RETURN_VOID(env, napi_create_uint32(env, 0, &args[PARAM0])); - NAPI_CALL_RETURN_VOID(env, napi_get_boolean(env, true, &args[PARAM1])); - } else { - args[PARAM0] = GenerateBusinessError(env, asyncContext->errCode); - NAPI_CALL_RETURN_VOID(env, napi_get_undefined(env, &args[PARAM1])); - } - - if (asyncContext->deferred != nullptr) { - GeneratePromise(env, asyncContext->deferred, asyncContext->errCode, args, CM_ARRAY_SIZE(args)); - } -} - -void CmUIExtensionCallback::SendMessageBack() -{ - CM_LOG_I("start SendMessageBack"); - if (this->reqContext_ == nullptr) { - CM_LOG_E("reqContext is nullptr"); - return; - } - - auto abilityContext = this->reqContext_->context; - if (abilityContext != nullptr) { - auto uiContent = abilityContext->GetUIContent(); - if (uiContent != nullptr) { - CM_LOG_D("CloseModalUIExtension"); - uiContent->CloseModalUIExtension(this->sessionId_); - } - } - - CM_LOG_D("ProcessCallback"); - ProcessCallback(this->reqContext_->env, this->reqContext_.get()); -} - -bool ParseCmUIAbilityContextReq( - napi_env env, const napi_value& obj, std::shared_ptr& abilityContext) -{ - bool stageMode = false; - napi_status status = OHOS::AbilityRuntime::IsStageContext(env, obj, stageMode); - if (status != napi_ok || !stageMode) { - CM_LOG_E("not stage mode"); - return false; - } - - auto context = OHOS::AbilityRuntime::GetStageModeContext(env, obj); - if (context == nullptr) { - CM_LOG_E("get context failed"); - return false; - } - - abilityContext = OHOS::AbilityRuntime::Context::ConvertTo(context); - if (abilityContext == nullptr) { - CM_LOG_E("get abilityContext failed"); - return false; - } - CM_LOG_I("end ParseUIAbilityContextReq"); - return true; -} - -static void StartUIExtensionAbility(std::shared_ptr asyncContext) -{ - CM_LOG_D("begin StartUIExtensionAbility"); - if (asyncContext == nullptr) { - CM_LOG_E("asyncContext is null"); - ThrowError(asyncContext->env, PARAM_ERROR, "asyncContext is null"); - return; - } - auto abilityContext = asyncContext->context; - if (abilityContext == nullptr) { - CM_LOG_E("abilityContext is null"); - ThrowError(asyncContext->env, PARAM_ERROR, "abilityContext is null"); - return; - } - auto uiContent = abilityContext->GetUIContent(); - if (uiContent == nullptr) { - CM_LOG_E("uiContent is null"); - ThrowError(asyncContext->env, PARAM_ERROR, "uiContent is null"); - return; - } - - auto uiExtCallback = std::make_shared(asyncContext); - OHOS::Ace::ModalUIExtensionCallbacks extensionCallbacks = { - [uiExtCallback](int32_t releaseCode) { uiExtCallback->OnRelease(releaseCode); }, - [uiExtCallback](int32_t resultCode, const OHOS::AAFwk::Want& result) { - uiExtCallback->OnResult(resultCode, result); }, - [uiExtCallback](const OHOS::AAFwk::WantParams& request) { uiExtCallback->OnReceive(request); }, - [uiExtCallback](int32_t errorCode, const std::string& name, const std::string& message) { - uiExtCallback->OnError(errorCode, name, message); }, - [uiExtCallback](const std::shared_ptr& uiProxy) { - uiExtCallback->OnRemoteReady(uiProxy); }, - [uiExtCallback]() { uiExtCallback->OnDestroy(); } - }; - - OHOS::Ace::ModalUIExtensionConfig uiExtConfig; - uiExtConfig.isProhibitBack = false; - int32_t sessionId = uiContent->CreateModalUIExtension(asyncContext->want, extensionCallbacks, uiExtConfig); - CM_LOG_I("end CreateModalUIExtension sessionId = %d", sessionId); - if (sessionId == 0) { - CM_LOG_E("CreateModalUIExtension failed, sessionId is %d", sessionId); - ThrowError(asyncContext->env, PARAM_ERROR, "CreateModalUIExtension failed"); - } - uiExtCallback->SetSessionId(sessionId); - return; -} - -napi_value CMNapiOpenCertManagerDialog(napi_env env, napi_callback_info info) -{ - CM_LOG_I("cert manager dialog enter"); - size_t argc = PARAM_SIZE_TWO; - napi_value argv[PARAM_SIZE_TWO] = { nullptr }; - napi_value result = nullptr; - NAPI_CALL(env, napi_get_undefined(env, &result)); - NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr)); - if (argc != PARAM_SIZE_TWO) { - CM_LOG_E("params number mismatch"); - std::string errMsg = "Parameter Error. Params number mismatch, need " + std::to_string(PARAM_SIZE_TWO) - + ", given " + std::to_string(argc); - ThrowError(env, PARAM_ERROR, errMsg); - return result; - } - - // Parse first argument for context. - auto asyncContext = std::make_shared(env); - if (!ParseCmUIAbilityContextReq(env, argv[PARAM0], asyncContext->context)) { - CM_LOG_E("ParseUIAbilityContextReq failed"); - ThrowError(env, PARAM_ERROR, "Get context failed."); - return result; - } - - // Parse second argument for page type. - result = ParseUint32(env, argv[PARAM1], asyncContext->pageType); - if (result == nullptr) { - CM_LOG_E("parse type failed"); - ThrowError(env, PARAM_ERROR, "parse type failed"); - return result; - } - - asyncContext->env = env; - OHOS::AAFwk::Want want; - want.SetElementName(CERT_MANAGER_BUNDLENAME, CERT_MANAGER_ABILITYNAME); - want.SetParam(CERT_MANAGER_PAGE_TYPE, static_cast(asyncContext->pageType)); - want.SetParam(PARAM_UI_EXTENSION_TYPE, SYS_COMMON_UI); - asyncContext->want = want; - NAPI_CALL(env, napi_create_promise(env, &asyncContext->deferred, &result)); - - // Start ui extension by context. - StartUIExtensionAbility(asyncContext); - CM_LOG_D("cert manager dialog end"); - return result; -} -} // namespace CMNapi - -- Gitee From 5077602cf044526e5d498e4feeda810d7b4a15c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E4=BD=99?= <1459392684@qq.com> Date: Wed, 9 Oct 2024 10:12:32 +0800 Subject: [PATCH 3/3] =?UTF-8?q?Revert=20"=E6=96=B0=E5=A2=9E=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=BA=94=E7=94=A8=E7=A7=81=E6=9C=89=E5=87=AD=E6=8D=AE?= =?UTF-8?q?=E5=88=97=E8=A1=A8API=E6=8E=A5=E5=8F=A3"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit c775476f5762a479a77b670037637ba9f1cf11a0. Signed-off-by: 张余 <1459392684@qq.com> Change-Id: I474f9d69c812889911f930592ff59c6b085b2f4e --- .../cert_manager_service_ipc_interface_code.h | 1 - .../cm_ipc/include/cm_ipc_client.h | 2 - .../os_dependency/cm_ipc/src/cm_ipc_client.c | 5 -- .../main/include/cert_manager_api.h | 2 - .../main/src/cert_manager_api.c | 10 --- .../napi/include/cm_napi_get_app_cert_list.h | 2 - .../cm_napi_get_app_cert_list_common.h | 4 - interfaces/kits/napi/src/cm_napi.cpp | 1 - .../napi/src/cm_napi_get_app_cert_list.cpp | 5 -- .../src/cm_napi_get_app_cert_list_common.cpp | 77 ------------------- .../main/core/include/cert_manager.h | 3 - .../main/core/include/cert_manager_check.h | 2 - .../main/core/src/cert_manager.c | 51 ------------ .../main/core/src/cert_manager_check.c | 33 -------- .../os_dependency/idl/cm_ipc/cm_ipc_service.c | 50 ------------ .../os_dependency/idl/cm_ipc/cm_ipc_service.h | 3 - .../main/os_dependency/sa/cm_sa.cpp | 1 - test/unittest/src/cm_app_cert_test.cpp | 43 ----------- 18 files changed, 295 deletions(-) diff --git a/frameworks/cert_manager_standard/main/common/include/cert_manager_service_ipc_interface_code.h b/frameworks/cert_manager_standard/main/common/include/cert_manager_service_ipc_interface_code.h index 91b6a2e..ceb40b3 100644 --- a/frameworks/cert_manager_standard/main/common/include/cert_manager_service_ipc_interface_code.h +++ b/frameworks/cert_manager_standard/main/common/include/cert_manager_service_ipc_interface_code.h @@ -32,7 +32,6 @@ enum CertManagerInterfaceCode { CM_MSG_UNINSTALL_APP_CERTIFICATE, CM_MSG_UNINSTALL_ALL_APP_CERTIFICATE, CM_MSG_GET_APP_CERTIFICATE_LIST, - CM_MSG_GET_CALLING_APP_CERTIFICATE_LIST, CM_MSG_GET_APP_CERTIFICATE, CM_MSG_GRANT_APP_CERT, CM_MSG_GET_AUTHED_LIST, diff --git a/frameworks/cert_manager_standard/main/os_dependency/cm_ipc/include/cm_ipc_client.h b/frameworks/cert_manager_standard/main/os_dependency/cm_ipc/include/cm_ipc_client.h index d1cff5d..2c49f34 100755 --- a/frameworks/cert_manager_standard/main/os_dependency/cm_ipc/include/cm_ipc_client.h +++ b/frameworks/cert_manager_standard/main/os_dependency/cm_ipc/include/cm_ipc_client.h @@ -41,8 +41,6 @@ int32_t CmClientUninstallAllAppCert(enum CertManagerInterfaceCode type); int32_t CmClientGetAppCertList(const uint32_t store, struct CredentialList *certificateList); -int32_t CmClientGetCallingAppCertList(const uint32_t store, struct CredentialList *certificateList); - int32_t CmClientGetAppCert(const struct CmBlob *keyUri, const uint32_t store, struct Credential *certificate); int32_t CmClientGrantAppCertificate(const struct CmBlob *keyUri, uint32_t appUid, struct CmBlob *authUri); diff --git a/frameworks/cert_manager_standard/main/os_dependency/cm_ipc/src/cm_ipc_client.c b/frameworks/cert_manager_standard/main/os_dependency/cm_ipc/src/cm_ipc_client.c index 756a791..5c99be2 100644 --- a/frameworks/cert_manager_standard/main/os_dependency/cm_ipc/src/cm_ipc_client.c +++ b/frameworks/cert_manager_standard/main/os_dependency/cm_ipc/src/cm_ipc_client.c @@ -432,11 +432,6 @@ int32_t CmClientGetAppCertList(const uint32_t store, struct CredentialList *cert return GetAppCertList(CM_MSG_GET_APP_CERTIFICATE_LIST, store, certificateList); } -int32_t CmClientGetCallingAppCertList(const uint32_t store, struct CredentialList *certificateList) -{ - return GetAppCertList(CM_MSG_GET_CALLING_APP_CERTIFICATE_LIST, store, certificateList); -} - static int32_t GetAppCertInitBlob(struct CmBlob *outBlob) { uint32_t buffSize = sizeof(uint32_t) + sizeof(uint32_t) + MAX_LEN_SUBJECT_NAME + diff --git a/interfaces/innerkits/cert_manager_standard/main/include/cert_manager_api.h b/interfaces/innerkits/cert_manager_standard/main/include/cert_manager_api.h index b0843a0..0198f40 100644 --- a/interfaces/innerkits/cert_manager_standard/main/include/cert_manager_api.h +++ b/interfaces/innerkits/cert_manager_standard/main/include/cert_manager_api.h @@ -39,8 +39,6 @@ CM_API_EXPORT int32_t CmUninstallAllAppCert(void); CM_API_EXPORT int32_t CmGetAppCertList(const uint32_t store, struct CredentialList *certificateList); -CM_API_EXPORT int32_t CmCallingGetAppCertList(const uint32_t store, struct CredentialList *certificateList); - CM_API_EXPORT int32_t CmGetAppCert(const struct CmBlob *keyUri, const uint32_t store, struct Credential *certificate); CM_API_EXPORT int32_t CmGrantAppCertificate(const struct CmBlob *keyUri, uint32_t appUid, struct CmBlob *authUri); diff --git a/interfaces/innerkits/cert_manager_standard/main/src/cert_manager_api.c b/interfaces/innerkits/cert_manager_standard/main/src/cert_manager_api.c index 36d549a..fc0b316 100644 --- a/interfaces/innerkits/cert_manager_standard/main/src/cert_manager_api.c +++ b/interfaces/innerkits/cert_manager_standard/main/src/cert_manager_api.c @@ -128,16 +128,6 @@ CM_API_EXPORT int32_t CmGetAppCertList(const uint32_t store, struct CredentialLi return ret; } -CM_API_EXPORT int32_t CmCallingGetAppCertList(const uint32_t store, struct CredentialList *certificateList) -{ - if (certificateList == NULL || CM_STORE_CHECK(store)) { - return CMR_ERROR_INVALID_ARGUMENT; - } - - int32_t ret = CmClientGetCallingAppCertList(store, certificateList); - return ret; -} - CM_API_EXPORT int32_t CmGetAppCert(const struct CmBlob *keyUri, const uint32_t store, struct Credential *certificate) { diff --git a/interfaces/kits/napi/include/cm_napi_get_app_cert_list.h b/interfaces/kits/napi/include/cm_napi_get_app_cert_list.h index 55ba141..1ca4281 100644 --- a/interfaces/kits/napi/include/cm_napi_get_app_cert_list.h +++ b/interfaces/kits/napi/include/cm_napi_get_app_cert_list.h @@ -25,8 +25,6 @@ napi_value CMNapiGetAllPublicCertList(napi_env env, napi_callback_info info); napi_value CMNapiGetPrivateAppCertList(napi_env env, napi_callback_info info); napi_value CMNapiGetSystemAppCertList(napi_env env, napi_callback_info info); - -napi_value CMNapiGetCallingPrivateAppCertList(napi_env env, napi_callback_info info); } // namespace CertManagerNapi #endif // CM_NAPI_GET_APP_CERTIFICATE_LIST_H \ No newline at end of file diff --git a/interfaces/kits/napi/include/cm_napi_get_app_cert_list_common.h b/interfaces/kits/napi/include/cm_napi_get_app_cert_list_common.h index c9396b1..b95a206 100755 --- a/interfaces/kits/napi/include/cm_napi_get_app_cert_list_common.h +++ b/interfaces/kits/napi/include/cm_napi_get_app_cert_list_common.h @@ -43,11 +43,7 @@ napi_value GetAppCertListWriteResult(napi_env env, GetAppCertListAsyncContext co napi_value GetAppCertListAsyncWork(napi_env env, GetAppCertListAsyncContext asyncContext); -napi_value GetCallingAppCertListAsyncWork(napi_env env, GetAppCertListAsyncContext asyncContext); - napi_value CMNapiGetAppCertListCommon(napi_env env, napi_callback_info info, uint32_t store); - -napi_value CMNapiGetCallingAppCertListCommon(napi_env env, napi_callback_info info, uint32_t store); } // namespace CertManagerNapi #endif // CM_NAPI_GET_APP_CERTIFICATE_LIST_COMMON_H \ No newline at end of file diff --git a/interfaces/kits/napi/src/cm_napi.cpp b/interfaces/kits/napi/src/cm_napi.cpp index 99e8aa0..41e7f94 100644 --- a/interfaces/kits/napi/src/cm_napi.cpp +++ b/interfaces/kits/napi/src/cm_napi.cpp @@ -136,7 +136,6 @@ extern "C" { DECLARE_NAPI_FUNCTION("uninstallPrivateCertificate", CMNapiUninstallPrivateAppCert), DECLARE_NAPI_FUNCTION("getAllAppPrivateCertificates", CMNapiGetPrivateAppCertList), DECLARE_NAPI_FUNCTION("getPrivateCertificate", CMNapiGetPrivateAppCertInfo), - DECLARE_NAPI_FUNCTION("getPrivateCertificates", CMNapiGetCallingPrivateAppCertList), /* grant, sign and verify */ DECLARE_NAPI_FUNCTION("grantPublicCertificate", CMNapiGrantPublicCertificate), diff --git a/interfaces/kits/napi/src/cm_napi_get_app_cert_list.cpp b/interfaces/kits/napi/src/cm_napi_get_app_cert_list.cpp index b455529..1bee2fe 100644 --- a/interfaces/kits/napi/src/cm_napi_get_app_cert_list.cpp +++ b/interfaces/kits/napi/src/cm_napi_get_app_cert_list.cpp @@ -33,9 +33,4 @@ napi_value CMNapiGetSystemAppCertList(napi_env env, napi_callback_info info) { return CMNapiGetAppCertListCommon(env, info, APPLICATION_SYSTEM_CERTIFICATE_STORE); } - -napi_value CMNapiGetCallingPrivateAppCertList(napi_env env, napi_callback_info info) -{ - return CMNapiGetCallingAppCertListCommon(env, info, APPLICATION_PRIVATE_CERTIFICATE_STORE); -} } // namespace CertManagerNapi diff --git a/interfaces/kits/napi/src/cm_napi_get_app_cert_list_common.cpp b/interfaces/kits/napi/src/cm_napi_get_app_cert_list_common.cpp index a9f1093..4e91104 100644 --- a/interfaces/kits/napi/src/cm_napi_get_app_cert_list_common.cpp +++ b/interfaces/kits/napi/src/cm_napi_get_app_cert_list_common.cpp @@ -160,58 +160,6 @@ napi_value GetAppCertListAsyncWork(napi_env env, GetAppCertListAsyncContext asyn return promise; } -napi_value GetCallingAppCertListAsyncWork(napi_env env, GetAppCertListAsyncContext asyncContext) -{ - napi_value promise = nullptr; - GenerateNapiPromise(env, asyncContext->callback, &asyncContext->deferred, &promise); - - napi_value resourceName = nullptr; - NAPI_CALL(env, napi_create_string_latin1(env, "GetCallingAppCertListAsyncWork", NAPI_AUTO_LENGTH, &resourceName)); - - NAPI_CALL(env, napi_create_async_work( - env, - nullptr, - resourceName, - [](napi_env env, void *information) { - GetAppCertListAsyncContext mcontext = static_cast(information); - - mcontext->credentialList = static_cast(CmMalloc(sizeof(struct CredentialList))); - if (mcontext->credentialList != nullptr) { - InitAppCertList(mcontext->credentialList); - } - mcontext->result = CmCallingGetAppCertList(mcontext->store, mcontext->credentialList); - }, - [](napi_env env, napi_status status, void *information) { - GetAppCertListAsyncContext mcontext = static_cast(information); - napi_value res[RESULT_NUMBER] = { nullptr }; - if (mcontext->result == CM_SUCCESS) { - NAPI_CALL_RETURN_VOID(env, napi_create_uint32(env, 0, &res[0])); - res[1] = GetAppCertListWriteResult(env, mcontext); - } else { - res[0] = GenerateBusinessError(env, mcontext->result); - NAPI_CALL_RETURN_VOID(env, napi_get_undefined(env, &res[1])); - } - if (mcontext->deferred != nullptr) { - GeneratePromise(env, mcontext->deferred, mcontext->result, res, CM_ARRAY_SIZE(res)); - } else { - GenerateCallback(env, mcontext->callback, res, CM_ARRAY_SIZE(res), mcontext->result); - } - DeleteGetAppCertListAsyncContext(env, mcontext); - CM_LOG_D("get calling app cert list end"); - }, - static_cast(asyncContext), - &asyncContext->asyncWork)); - - napi_status status = napi_queue_async_work(env, asyncContext->asyncWork); - if (status != napi_ok) { - GET_AND_THROW_LAST_ERROR((env)); - DeleteGetAppCertListAsyncContext(env, asyncContext); - CM_LOG_E("get calling app cert list could not queue async work"); - return nullptr; - } - return promise; -} - napi_value CMNapiGetAppCertListCommon(napi_env env, napi_callback_info info, uint32_t store) { GetAppCertListAsyncContext context = CreateGetAppCertListAsyncContext(); @@ -236,29 +184,4 @@ napi_value CMNapiGetAppCertListCommon(napi_env env, napi_callback_info info, uin } return result; } - -napi_value CMNapiGetCallingAppCertListCommon(napi_env env, napi_callback_info info, uint32_t store) -{ - GetAppCertListAsyncContext context = CreateGetAppCertListAsyncContext(); - if (context == nullptr) { - CM_LOG_E("could not create context"); - return nullptr; - } - - context->store = store; - - napi_value result = GetAppCertListParseParams(env, info, context); - if (result == nullptr) { - CM_LOG_E("could not parse params"); - DeleteGetAppCertListAsyncContext(env, context); - return nullptr; - } - result = GetCallingAppCertListAsyncWork(env, context); - if (result == nullptr) { - CM_LOG_E("could not start async work"); - DeleteGetAppCertListAsyncContext(env, context); - return nullptr; - } - return result; -} } // namespace CertManagerNapi diff --git a/services/cert_manager_standard/cert_manager_engine/main/core/include/cert_manager.h b/services/cert_manager_standard/cert_manager_engine/main/core/include/cert_manager.h index 1f9cbb5..2fbd3d8 100644 --- a/services/cert_manager_standard/cert_manager_engine/main/core/include/cert_manager.h +++ b/services/cert_manager_standard/cert_manager_engine/main/core/include/cert_manager.h @@ -43,9 +43,6 @@ int32_t CmRemoveAllAppCert(const struct CmContext *context); int32_t CmServiceGetAppCertList(const struct CmContext *context, uint32_t store, struct CmBlob *fileNames, const uint32_t fileSize, uint32_t *fileCount); -int32_t CmServiceGetCallingAppCertList(const struct CmContext *context, uint32_t store, struct CmBlob *fileNames, - const uint32_t fileSize, uint32_t *fileCount); - void CmFreeFileNames(struct CmBlob *fileNames, const uint32_t fileSize); int32_t CmGetUri(const char *filePath, struct CmBlob *uriBlob); diff --git a/services/cert_manager_standard/cert_manager_engine/main/core/include/cert_manager_check.h b/services/cert_manager_standard/cert_manager_engine/main/core/include/cert_manager_check.h index 863bf81..02e8d03 100755 --- a/services/cert_manager_standard/cert_manager_engine/main/core/include/cert_manager_check.h +++ b/services/cert_manager_standard/cert_manager_engine/main/core/include/cert_manager_check.h @@ -37,8 +37,6 @@ int32_t CmServiceUninstallAppCertCheck(struct CmContext *cmContext, const uint32 int32_t CmServiceGetAppCertListCheck(const struct CmContext *cmContext, const uint32_t store); -int32_t CmServiceGetCallingAppCertListCheck(const struct CmContext *cmContext, const uint32_t store); - int32_t CmServiceGetAppCertCheck(struct CmContext *cmContext, const uint32_t store, const struct CmBlob *keyUri); int32_t CmServiceInstallUserCertCheck(struct CmContext *cmContext, const struct CmBlob *userCert, diff --git a/services/cert_manager_standard/cert_manager_engine/main/core/src/cert_manager.c b/services/cert_manager_standard/cert_manager_engine/main/core/src/cert_manager.c index c704364..c071d0d 100644 --- a/services/cert_manager_standard/cert_manager_engine/main/core/src/cert_manager.c +++ b/services/cert_manager_standard/cert_manager_engine/main/core/src/cert_manager.c @@ -286,36 +286,6 @@ static int32_t CmAppCertGetFilePath(const struct CmContext *context, const uint3 return CM_SUCCESS; } -static int32_t CmCallingAppCertGetFilePath(const struct CmContext *context, const uint32_t store, struct CmBlob *path) -{ - int32_t ret = CM_FAILURE; - - switch (store) { - case CM_CREDENTIAL_STORE : - ret = sprintf_s((char*)path->data, MAX_PATH_LEN, "%s%u/%u", - CREDNTIAL_STORE, context->userId, context->uid); - break; - case CM_PRI_CREDENTIAL_STORE : - ret = sprintf_s((char*)path->data, MAX_PATH_LEN, "%s%u/%u", - APP_CA_STORE, context->userId, context->uid); - break; - case CM_SYS_CREDENTIAL_STORE: - ret = sprintf_s((char *)path->data, MAX_PATH_LEN, "%s%u/%u", - SYS_CREDNTIAL_STORE, context->userId, context->uid); - break; - case CM_USER_TRUSTED_STORE: - ret = sprintf_s((char *)path->data, MAX_PATH_LEN, "%s%u/%u", - USER_CA_STORE, context->userId, context->uid); - break; - default: - break; - } - if (ret < 0) { - return CM_FAILURE; - } - return CM_SUCCESS; -} - void CmFreeFileNames(struct CmBlob *fileNames, const uint32_t fileSize) { if (fileNames == NULL) { @@ -484,27 +454,6 @@ int32_t CmServiceGetAppCertList(const struct CmContext *context, uint32_t store, return CM_SUCCESS; } -int32_t CmServiceGetCallingAppCertList(const struct CmContext *context, uint32_t store, struct CmBlob *fileNames, - const uint32_t fileSize, uint32_t *fileCount) -{ - char pathBuf[CERT_MAX_PATH_LEN] = {0}; - struct CmBlob path = { sizeof(pathBuf), (uint8_t*)pathBuf }; - - int32_t ret = CmCallingAppCertGetFilePath(context, store, &path); - if (ret != CM_SUCCESS) { - CM_LOG_E("Get file path for store:%u faild", store); - return CM_FAILURE; - } - - ret = CmUidLayerGetFileCountAndNames(pathBuf, fileNames, fileSize, fileCount); - if (ret != CM_SUCCESS) { - CM_LOG_E("Get file count and names from path faild ret:%d", ret); - return ret; - } - - return CM_SUCCESS; -} - static int32_t GetCertOrCredCount(const struct CmContext *context, const uint32_t store, uint32_t *certCount) { uint32_t fileCount = 0; diff --git a/services/cert_manager_standard/cert_manager_engine/main/core/src/cert_manager_check.c b/services/cert_manager_standard/cert_manager_engine/main/core/src/cert_manager_check.c index 622222c..40b804e 100644 --- a/services/cert_manager_standard/cert_manager_engine/main/core/src/cert_manager_check.c +++ b/services/cert_manager_standard/cert_manager_engine/main/core/src/cert_manager_check.c @@ -359,39 +359,6 @@ int32_t CmServiceGetAppCertListCheck(const struct CmContext *cmContext, const ui return CM_SUCCESS; } -int32_t CmServiceGetCallingAppCertListCheck(const struct CmContext *cmContext, const uint32_t store) -{ - if (CM_STORE_CHECK(store)) { - CM_LOG_E("invalid input arguments store:%u", store); - return CMR_ERROR_INVALID_ARGUMENT; - } - - if (store == CM_SYS_CREDENTIAL_STORE) { - return CmGetSysAppCertListCheck(cmContext, store); - } - - if (!CmHasCommonPermission()) { - CM_LOG_E("permission check failed"); - return CMR_ERROR_PERMISSION_DENIED; - } - - if (store == CM_PRI_CREDENTIAL_STORE) { - return CM_SUCCESS; - } - - if (!CmHasPrivilegedPermission()) { - CM_LOG_E("permission check failed"); - return CMR_ERROR_PERMISSION_DENIED; - } - - if (!CmIsSystemApp()) { - CM_LOG_E("get app cert list: caller is not system app"); - return CMR_ERROR_NOT_SYSTEMP_APP; - } - - return CM_SUCCESS; -} - int32_t CmServiceGetAppCertCheck(struct CmContext *cmContext, const uint32_t store, const struct CmBlob *keyUri) { if (CM_STORE_CHECK(store)) { diff --git a/services/cert_manager_standard/cert_manager_service/main/os_dependency/idl/cm_ipc/cm_ipc_service.c b/services/cert_manager_standard/cert_manager_service/main/os_dependency/idl/cm_ipc/cm_ipc_service.c index 2648db5..19e63bc 100644 --- a/services/cert_manager_standard/cert_manager_service/main/os_dependency/idl/cm_ipc/cm_ipc_service.c +++ b/services/cert_manager_standard/cert_manager_service/main/os_dependency/idl/cm_ipc/cm_ipc_service.c @@ -491,56 +491,6 @@ void CmIpcServiceGetAppCertList(const struct CmBlob *paramSetBlob, struct CmBlob CM_LOG_D("CmIpcServiceGetAppCertList end:%d", ret); } -void CmIpcServiceGetCallingAppCertList(const struct CmBlob *paramSetBlob, struct CmBlob *outData, - const struct CmContext *context) -{ - int32_t ret; - (void)outData; - uint32_t store; - uint32_t fileCount = 0; - struct CmContext cmContext = {0}; - struct CmBlob certificateList = { 0, NULL }; - struct CmBlob fileNamesBlob[MAX_COUNT_CERTIFICATE]; - uint32_t len = MAX_COUNT_CERTIFICATE * sizeof(struct CmBlob); - (void)memset_s(fileNamesBlob, len, 0, len); - struct CmParamSet *paramSets = NULL; - struct CmParamOut params[] = { - { .tag = CM_TAG_PARAM0_UINT32, .uint32Param = &store }, - }; - - do { - ret = GetInputParams(paramSetBlob, ¶mSets, &cmContext, params, CM_ARRAY_SIZE(params)); - if (ret != CM_SUCCESS) { - CM_LOG_E("CmIpcServiceGetCallingAppCertList get input params failed, ret = %d", ret); - break; - } - - ret = CmServiceGetCallingAppCertListCheck(&cmContext, store); - if (ret != CM_SUCCESS) { - CM_LOG_E("CmServiceGetCallingAppCertListCheck fail, ret = %d", ret); - break; - } - - ret = CmServiceGetCallingAppCertList(&cmContext, store, fileNamesBlob, MAX_COUNT_CERTIFICATE, &fileCount); - if (ret != CM_SUCCESS) { - CM_LOG_E("Get calling App cert list fail, ret = %d", ret); - break; - } - - ret = CmServiceGetAppCertListPack(&certificateList, fileNamesBlob, fileCount); - if (ret != CM_SUCCESS) { - CM_LOG_E("CmServiceGetAppCertListPack pack fail, ret = %d", ret); - } - } while (0); - - CmReport(__func__, &cmContext, NULL, ret); - CmSendResponse(context, ret, &certificateList); - CmFreeParamSet(¶mSets); - CmFreeFileNames(fileNamesBlob, fileCount); - CM_FREE_BLOB(certificateList); - CM_LOG_D("CmServiceGetCallingAppCertListCheck end:%d", ret); -} - static int32_t CopyCertificateInfoToBuffer(const struct CmBlob *certBlob, const struct CmBlob *certificateInfo, uint32_t *offset) { diff --git a/services/cert_manager_standard/cert_manager_service/main/os_dependency/idl/cm_ipc/cm_ipc_service.h b/services/cert_manager_standard/cert_manager_service/main/os_dependency/idl/cm_ipc/cm_ipc_service.h index 7f93f03..a7a4e3b 100644 --- a/services/cert_manager_standard/cert_manager_service/main/os_dependency/idl/cm_ipc/cm_ipc_service.h +++ b/services/cert_manager_standard/cert_manager_service/main/os_dependency/idl/cm_ipc/cm_ipc_service.h @@ -43,9 +43,6 @@ void CmIpcServiceUninstallAllAppCert(const struct CmBlob *paramSetBlob, struct C void CmIpcServiceGetAppCertList(const struct CmBlob *paramSetBlob, struct CmBlob *outData, const struct CmContext *context); -void CmIpcServiceGetCallingAppCertList(const struct CmBlob *paramSetBlob, struct CmBlob *outData, - const struct CmContext *context); - void CmIpcServiceGetAppCert(const struct CmBlob *paramSetBlob, struct CmBlob *outData, const struct CmContext *context); diff --git a/services/cert_manager_standard/cert_manager_service/main/os_dependency/sa/cm_sa.cpp b/services/cert_manager_standard/cert_manager_service/main/os_dependency/sa/cm_sa.cpp index 32e472b..384a612 100644 --- a/services/cert_manager_standard/cert_manager_service/main/os_dependency/sa/cm_sa.cpp +++ b/services/cert_manager_standard/cert_manager_service/main/os_dependency/sa/cm_sa.cpp @@ -63,7 +63,6 @@ static struct CmIpcPoint g_cmIpcHandler[] = { { CM_MSG_UNINSTALL_APP_CERTIFICATE, CmIpcServiceUninstallAppCert }, { CM_MSG_UNINSTALL_ALL_APP_CERTIFICATE, CmIpcServiceUninstallAllAppCert }, { CM_MSG_GET_APP_CERTIFICATE_LIST, CmIpcServiceGetAppCertList }, - { CM_MSG_GET_CALLING_APP_CERTIFICATE_LIST, CmIpcServiceGetCallingAppCertList }, { CM_MSG_GET_APP_CERTIFICATE, CmIpcServiceGetAppCert }, { CM_MSG_GRANT_APP_CERT, CmIpcServiceGrantAppCertificate }, diff --git a/test/unittest/src/cm_app_cert_test.cpp b/test/unittest/src/cm_app_cert_test.cpp index 45234d5..e601374 100644 --- a/test/unittest/src/cm_app_cert_test.cpp +++ b/test/unittest/src/cm_app_cert_test.cpp @@ -526,49 +526,6 @@ HWTEST_F(CmAppCertTest, CmGetAppCertListAbnormalTest004, TestSize.Level0) } } -/** - * @tc.name: CmGetCallingAppCertListPriCert005 - * @tc.desc: Test CertManager get app cert list interface own private - * @tc.type: FUNC - * @tc.require: AR000H0MI8 /SR000H09N9 - */ -HWTEST_F(CmAppCertTest, CmGetCallingAppCertListPriCert005, TestSize.Level0) -{ - uint8_t certAliasBuf[] = "OtherKeyA"; - struct CmBlob certAlias = { sizeof(certAliasBuf), certAliasBuf }; - - uint8_t uriBuf[MAX_LEN_URI] = {0}; - struct CmBlob keyUri = { sizeof(uriBuf), uriBuf }; - - int32_t ret = CmInstallAppCert(&g_appCert, &g_appCertPwd, &certAlias, CM_PRI_CREDENTIAL_STORE, &keyUri); - EXPECT_EQ(ret, CM_SUCCESS) << "CmGetCallingAppCertListPriCert005 install failed, retcode:" << ret; - - struct CredentialList certificateList = { 0, nullptr }; - uint32_t buffSize = MAX_COUNT_CERTIFICATE * sizeof(struct CredentialAbstract); - certificateList.credentialAbstract = static_cast(CmMalloc(buffSize)); - ASSERT_TRUE(certificateList.credentialAbstract != nullptr); - certificateList.credentialCount = MAX_COUNT_CERTIFICATE; - (void)memset_s(certificateList.credentialAbstract, buffSize, 0, buffSize); - - ret = CmCallingGetAppCertList(CM_PRI_CREDENTIAL_STORE, &certificateList); - EXPECT_EQ(ret, CM_SUCCESS) << "CmGetCallingAppCertListPriCert005 test failed, retcode:" << ret; - - struct CredentialAbstractResult expectList[] = { - { - { "ak", "OtherKeyA", "oh:t=ak;o=keyA;u=100;a=500" }, false - } - }; - uint32_t length = sizeof(expectList) / sizeof(expectList[0]); - for (uint32_t j = 0; j < length; ++j) { - bool bFind = FindCredentialAbstract(&(expectList[j].credentialAbstract), &certificateList); - EXPECT_EQ(bFind, expectList[j].bExpectResult); - } - - if (certificateList.credentialAbstract != nullptr) { - CmFree(certificateList.credentialAbstract); - } -} - /** * @tc.name: AppCertUnInstallBaseTest001 * @tc.desc: Test CertManager unInstall app cert interface base function -- Gitee