From 529a2935d29b511ae9c48861d682566f82fd2677 Mon Sep 17 00:00:00 2001 From: heyinshen Date: Wed, 16 Mar 2022 11:16:06 +0800 Subject: [PATCH] modify copyright and fix permission check Signed-off-by: heyinshen --- BUILD.gn | 2 +- common_lib/impl/src/hc_string_vector.c | 2 +- common_lib/interfaces/hc_string_vector.h | 2 +- .../os_adapter/impl/src/linux/hc_file.c | 2 +- .../os_adapter/impl/src/liteos/mini/hc_file.c | 2 +- .../os_adapter/interfaces/linux/hc_file.h | 2 +- .../os_adapter/interfaces/liteos/hc_file.h | 2 +- frameworks/deviceauth_lite/BUILD.gn | 2 +- .../source/huks_adapter/huks_adapter.c | 2 +- .../deviceauth_lite/source/json/commonutil.c | 2 +- .../source/schedule/distribution.c | 2 +- frameworks/inc/ipc_sdk.h | 2 +- frameworks/inc/standard/ipc_iface.h | 6 +-- frameworks/src/ipc_sdk.c | 2 +- frameworks/src/ipc_service.c | 2 +- .../src/standard/ipc_callback_proxy.cpp | 2 +- frameworks/src/standard/ipc_callback_stub.cpp | 4 +- .../src/standard/ipc_dev_auth_proxy.cpp | 11 ++++- frameworks/src/standard/ipc_dev_auth_stub.cpp | 10 +++- interfaces/innerkits/device_auth.h | 2 +- services/BUILD.gn | 8 +++- services/data_manager/inc/data_manager.h | 2 +- services/data_manager/src/data_manager.c | 2 +- services/device_auth.c | 2 +- services/deviceauth.gni | 5 +- .../inc/module/dev_auth_module_manager.h | 2 +- .../permission_adapter/permission_adapter.h | 31 ++++++++++++ .../src/module/dev_auth_module_manager.c | 2 +- .../permission_adapter/permission_adapter.cpp | 48 +++++++++++++++++++ .../account_related_group_auth.h | 2 +- services/group_auth/inc/base_group_auth.h | 2 +- .../auth_session/auth_session_common.h | 2 +- .../session/auth_session/auth_session_util.h | 2 +- .../account_unrelated_group_auth.c | 2 +- .../auth_session/auth_session_client.c | 2 +- .../auth_session/auth_session_common.c | 2 +- .../auth_session/auth_session_server.c | 2 +- .../session/auth_session/auth_session_util.c | 2 +- services/group_manager/inc/base_group.h | 2 +- .../inc/base_group_manager_task.h | 2 +- .../inc/broadcast_manager/broadcast_manager.h | 2 +- services/group_manager/inc/group_manager.h | 2 +- .../group_manager/inc/group_manager_common.h | 2 +- services/group_manager/inc/group_operation.h | 2 +- .../inc/group_operation_common.h | 2 +- .../group_manager/inc/peer_to_peer_group.h | 2 +- .../bind_session/bind_session_common.h | 2 +- .../inc/session/bind_session_common_defines.h | 2 +- .../src/broadcast_manager/broadcast_manager.c | 2 +- services/group_manager/src/group_manager.c | 2 +- .../group_manager/src/group_manager_common.c | 2 +- .../src/group_operation/group_operation.c | 2 +- .../group_operation/group_operation_common.c | 2 +- .../peer_to_peer_group/peer_to_peer_group.c | 2 +- .../peer_to_peer_group_mock.c | 2 +- .../bind_session/bind_session_client.c | 2 +- .../bind_session/bind_session_common.c | 2 +- .../bind_session/bind_session_server.c | 2 +- .../src/session/bind_session_common_util.c | 2 +- test/unittest/deviceauth/BUILD.gn | 2 +- .../include/deviceauth_standard_test.h | 2 +- 61 files changed, 167 insertions(+), 62 deletions(-) create mode 100644 services/frameworks/inc/permission_adapter/permission_adapter.h create mode 100644 services/frameworks/src/permission_adapter/permission_adapter.cpp diff --git a/BUILD.gn b/BUILD.gn index 1a6b6d4..c556e7d 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (C) 2021-2022 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 diff --git a/common_lib/impl/src/hc_string_vector.c b/common_lib/impl/src/hc_string_vector.c index d0de80b..03bd623 100644 --- a/common_lib/impl/src/hc_string_vector.c +++ b/common_lib/impl/src/hc_string_vector.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2022 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 diff --git a/common_lib/interfaces/hc_string_vector.h b/common_lib/interfaces/hc_string_vector.h index 0eb1347..29ef5dc 100644 --- a/common_lib/interfaces/hc_string_vector.h +++ b/common_lib/interfaces/hc_string_vector.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2022 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 diff --git a/deps_adapter/os_adapter/impl/src/linux/hc_file.c b/deps_adapter/os_adapter/impl/src/linux/hc_file.c index 4c0791a..553fbd8 100644 --- a/deps_adapter/os_adapter/impl/src/linux/hc_file.c +++ b/deps_adapter/os_adapter/impl/src/linux/hc_file.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/deps_adapter/os_adapter/impl/src/liteos/mini/hc_file.c b/deps_adapter/os_adapter/impl/src/liteos/mini/hc_file.c index eced8f8..0bdc81d 100644 --- a/deps_adapter/os_adapter/impl/src/liteos/mini/hc_file.c +++ b/deps_adapter/os_adapter/impl/src/liteos/mini/hc_file.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/deps_adapter/os_adapter/interfaces/linux/hc_file.h b/deps_adapter/os_adapter/interfaces/linux/hc_file.h index 8818644..29ec77c 100644 --- a/deps_adapter/os_adapter/interfaces/linux/hc_file.h +++ b/deps_adapter/os_adapter/interfaces/linux/hc_file.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/deps_adapter/os_adapter/interfaces/liteos/hc_file.h b/deps_adapter/os_adapter/interfaces/liteos/hc_file.h index b0e4c08..2cd8735 100644 --- a/deps_adapter/os_adapter/interfaces/liteos/hc_file.h +++ b/deps_adapter/os_adapter/interfaces/liteos/hc_file.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/frameworks/deviceauth_lite/BUILD.gn b/frameworks/deviceauth_lite/BUILD.gn index c6f34d4..532254c 100644 --- a/frameworks/deviceauth_lite/BUILD.gn +++ b/frameworks/deviceauth_lite/BUILD.gn @@ -1,5 +1,5 @@ # -# Copyright (c) 2020-2021 Huawei Device Co., Ltd. +# Copyright (c) 2020-2022 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 diff --git a/frameworks/deviceauth_lite/source/huks_adapter/huks_adapter.c b/frameworks/deviceauth_lite/source/huks_adapter/huks_adapter.c index cda6efa..22eaeab 100644 --- a/frameworks/deviceauth_lite/source/huks_adapter/huks_adapter.c +++ b/frameworks/deviceauth_lite/source/huks_adapter/huks_adapter.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021 Huawei Device Co., Ltd. + * Copyright (c) 2020-2022 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 diff --git a/frameworks/deviceauth_lite/source/json/commonutil.c b/frameworks/deviceauth_lite/source/json/commonutil.c index 6d04558..6a4f935 100755 --- a/frameworks/deviceauth_lite/source/json/commonutil.c +++ b/frameworks/deviceauth_lite/source/json/commonutil.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Huawei Device Co., Ltd. + * Copyright (c) 2020-2022 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 diff --git a/frameworks/deviceauth_lite/source/schedule/distribution.c b/frameworks/deviceauth_lite/source/schedule/distribution.c index 5ab7f95..0727680 100644 --- a/frameworks/deviceauth_lite/source/schedule/distribution.c +++ b/frameworks/deviceauth_lite/source/schedule/distribution.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Huawei Device Co., Ltd. + * Copyright (c) 2020-2022 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 diff --git a/frameworks/inc/ipc_sdk.h b/frameworks/inc/ipc_sdk.h index 6416e04..b6d5449 100755 --- a/frameworks/inc/ipc_sdk.h +++ b/frameworks/inc/ipc_sdk.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/frameworks/inc/standard/ipc_iface.h b/frameworks/inc/standard/ipc_iface.h index b801f8d..4fa8f21 100755 --- a/frameworks/inc/standard/ipc_iface.h +++ b/frameworks/inc/standard/ipc_iface.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 @@ -26,7 +26,7 @@ public: enum { DEV_AUTH_CALL_REQUEST = 1, }; - DECLARE_INTERFACE_DESCRIPTOR(u"MethodsIpcCall"); + DECLARE_INTERFACE_DESCRIPTOR(u"deviceauth.IMethodsIpcCall"); }; class ICommIpcCallback : public IRemoteBroker { @@ -34,7 +34,7 @@ public: enum { DEV_AUTH_CALLBACK_REQUEST = 1, }; - DECLARE_INTERFACE_DESCRIPTOR(u"CommIpcCallback"); + DECLARE_INTERFACE_DESCRIPTOR(u"deviceauth.ICommIpcCallback"); virtual void DoCallBack(int32_t callbackId, uintptr_t cbHook, MessageParcel &dataParcel, MessageParcel &reply, MessageOption &option) = 0; }; diff --git a/frameworks/src/ipc_sdk.c b/frameworks/src/ipc_sdk.c index 185c320..3c0b21f 100644 --- a/frameworks/src/ipc_sdk.c +++ b/frameworks/src/ipc_sdk.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/frameworks/src/ipc_service.c b/frameworks/src/ipc_service.c index 87e004f..1480275 100644 --- a/frameworks/src/ipc_service.c +++ b/frameworks/src/ipc_service.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/frameworks/src/standard/ipc_callback_proxy.cpp b/frameworks/src/standard/ipc_callback_proxy.cpp index b8d644f..0c44906 100644 --- a/frameworks/src/standard/ipc_callback_proxy.cpp +++ b/frameworks/src/standard/ipc_callback_proxy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/frameworks/src/standard/ipc_callback_stub.cpp b/frameworks/src/standard/ipc_callback_stub.cpp index 4fd3563..c2fd70e 100644 --- a/frameworks/src/standard/ipc_callback_stub.cpp +++ b/frameworks/src/standard/ipc_callback_stub.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 @@ -72,4 +72,4 @@ int32_t StubDevAuthCb::OnRemoteRequest(uint32_t code, LOGI("Invoke callback done"); return 0; } -} \ No newline at end of file +} diff --git a/frameworks/src/standard/ipc_dev_auth_proxy.cpp b/frameworks/src/standard/ipc_dev_auth_proxy.cpp index 0b61897..bc3abeb 100644 --- a/frameworks/src/standard/ipc_dev_auth_proxy.cpp +++ b/frameworks/src/standard/ipc_dev_auth_proxy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 @@ -86,6 +86,15 @@ int32_t ProxyDevAuthData::FinalCallRequest(int32_t methodId) LOGE("data invalid"); return HC_ERROR; } + auto proxy = GetProxy(); + if (proxy == nullptr) { + LOGE("get proxy failed"); + return HC_ERR_IPC_GET_PROXY; + } + if (!dataParcel.WriteInterfaceToken(proxy->GetDescriptor())) { + LOGE("Failed to write interface token!"); + return HC_ERROR; + } LOGI("method id %d, param num %d, data length %d", methodId, paramCnt, dataLen); /* request data length = number of params + params information */ if (!dataParcel.WriteInt32(methodId) || !dataParcel.WriteInt32(dataLen + sizeof(int32_t)) || diff --git a/frameworks/src/standard/ipc_dev_auth_stub.cpp b/frameworks/src/standard/ipc_dev_auth_stub.cpp index 67072d2..e33b770 100644 --- a/frameworks/src/standard/ipc_dev_auth_stub.cpp +++ b/frameworks/src/standard/ipc_dev_auth_stub.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 @@ -20,6 +20,7 @@ #include "ipc_adapt.h" #include "ipc_callback_stub.h" #include "ipc_sdk.h" +#include "permission_adapter.h" #include "securec.h" #include "system_ability_definition.h" @@ -146,6 +147,13 @@ static void InitCbStubTable() int32_t ServiceDevAuth::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { + if (data.ReadInterfaceToken() != GetDescriptor()) { + LOGE("The client interface token is invalid!"); + return -1; + } + if (CheckPermission() != HC_SUCCESS) { + return -1; + } int32_t ret = HC_ERR_IPC_UNKNOW_OPCODE; int32_t dataLen; int32_t methodId = 0; diff --git a/interfaces/innerkits/device_auth.h b/interfaces/innerkits/device_auth.h index fd6e166..dbe73ba 100644 --- a/interfaces/innerkits/device_auth.h +++ b/interfaces/innerkits/device_auth.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/services/BUILD.gn b/services/BUILD.gn index 975f3de..06d716f 100644 --- a/services/BUILD.gn +++ b/services/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (C) 2021-2022 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 @@ -193,10 +193,12 @@ if (os_level == "mini" || os_level == "small") { "//third_party/cJSON", "//utils/native/base/include", "${frameworks_path}/inc/standard", + "${dev_frameworks_path}/inc/permission_adapter", "//utils/system/safwk/native/include", ] sources = deviceauth_ipc_files + sources += permission_adapter_files sources += [ "${frameworks_path}/src/ipc_service.c" ] cflags = [ "-DHILOG_ENABLE" ] @@ -213,6 +215,7 @@ if (os_level == "mini" || os_level == "small") { ] external_deps = [ + "access_token:libaccesstoken_sdk", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "safwk:system_ability_fwk", @@ -229,12 +232,14 @@ if (os_level == "mini" || os_level == "small") { "//third_party/cJSON", "//utils/native/base/include", "${frameworks_path}/inc/standard", + "${dev_frameworks_path}/inc/permission_adapter", "//utils/system/safwk/native/include", "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include", "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy/include", ] sources = deviceauth_ipc_files + sources += permission_adapter_files sources += [ "${frameworks_path}/src/ipc_sdk.c" ] defines = [ @@ -254,6 +259,7 @@ if (os_level == "mini" || os_level == "small") { ] external_deps = [ + "access_token:libaccesstoken_sdk", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "samgr_standard:samgr_proxy", diff --git a/services/data_manager/inc/data_manager.h b/services/data_manager/inc/data_manager.h index 5190007..2d28c23 100644 --- a/services/data_manager/inc/data_manager.h +++ b/services/data_manager/inc/data_manager.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2022 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 diff --git a/services/data_manager/src/data_manager.c b/services/data_manager/src/data_manager.c index 6c15b3f..3b62a38 100644 --- a/services/data_manager/src/data_manager.c +++ b/services/data_manager/src/data_manager.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2022 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 diff --git a/services/device_auth.c b/services/device_auth.c index f54ab30..2fe1af1 100644 --- a/services/device_auth.c +++ b/services/device_auth.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/services/deviceauth.gni b/services/deviceauth.gni index 4c83ae0..1546926 100644 --- a/services/deviceauth.gni +++ b/services/deviceauth.gni @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (C) 2021-2022 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 @@ -97,6 +97,9 @@ os_account_adapter_files = os_account_adapter_lite_files = [ "${dev_frameworks_path}/src/os_account_adapter_mock/os_account_adapter_mock.cpp" ] +permission_adapter_files = + [ "${dev_frameworks_path}/src/permission_adapter/permission_adapter.cpp" ] + group_auth_files = [ "${group_auth_path}/src/group_auth_manager/group_auth_data_operation.c", "${group_auth_path}/src/group_auth_manager/group_auth_manager.c", diff --git a/services/frameworks/inc/module/dev_auth_module_manager.h b/services/frameworks/inc/module/dev_auth_module_manager.h index 9eb1ce6..c890ee1 100644 --- a/services/frameworks/inc/module/dev_auth_module_manager.h +++ b/services/frameworks/inc/module/dev_auth_module_manager.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/services/frameworks/inc/permission_adapter/permission_adapter.h b/services/frameworks/inc/permission_adapter/permission_adapter.h new file mode 100644 index 0000000..b5cd0bf --- /dev/null +++ b/services/frameworks/inc/permission_adapter/permission_adapter.h @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2022 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 PERMISSION_ADAPTER_H +#define PERMISSION_ADAPTER_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int32_t CheckPermission(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/services/frameworks/src/module/dev_auth_module_manager.c b/services/frameworks/src/module/dev_auth_module_manager.c index 9b63b02..6f26bf1 100644 --- a/services/frameworks/src/module/dev_auth_module_manager.c +++ b/services/frameworks/src/module/dev_auth_module_manager.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/services/frameworks/src/permission_adapter/permission_adapter.cpp b/services/frameworks/src/permission_adapter/permission_adapter.cpp new file mode 100644 index 0000000..dcdb912 --- /dev/null +++ b/services/frameworks/src/permission_adapter/permission_adapter.cpp @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2022 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 "permission_adapter.h" + +#include "accesstoken_kit.h" +#include "ipc_skeleton.h" + +#include "device_auth_defines.h" +#include "hc_log.h" + +using namespace OHOS; +using namespace OHOS::Security::AccessToken; + +int32_t CheckPermission(void) +{ + AccessTokenID tokenId = IPCSkeleton::GetCallingTokenID(); + ATokenTypeEnum tokenType = AccessTokenKit::GetTokenType(tokenId); + if (tokenType == TOKEN_NATIVE) { + NativeTokenInfo findInfo; + if (AccessTokenKit::GetNativeTokenInfo(tokenId, findInfo) != 0) { + LOGE("GetNativeTokenInfo failed!"); + return HC_ERROR; + } + if (findInfo.apl == APL_SYSTEM_CORE) { + LOGI("Check permission(APL3=SYSTEM_CORE) success!"); + return HC_SUCCESS; + } else { + LOGE("Check permission(APL3=SYSTEM_CORE) failed! APL: %d", findInfo.apl); + return HC_ERROR; + } + } else { + LOGE("Invalid token type: %d", tokenType); + return HC_ERROR; + } +} \ No newline at end of file diff --git a/services/group_auth/inc/account_related_group_auth/account_related_group_auth.h b/services/group_auth/inc/account_related_group_auth/account_related_group_auth.h index 076094b..1ee1e64 100644 --- a/services/group_auth/inc/account_related_group_auth/account_related_group_auth.h +++ b/services/group_auth/inc/account_related_group_auth/account_related_group_auth.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/services/group_auth/inc/base_group_auth.h b/services/group_auth/inc/base_group_auth.h index 5f750cb..020945b 100644 --- a/services/group_auth/inc/base_group_auth.h +++ b/services/group_auth/inc/base_group_auth.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/services/group_auth/inc/session/auth_session/auth_session_common.h b/services/group_auth/inc/session/auth_session/auth_session_common.h index 9996240..ec6b595 100644 --- a/services/group_auth/inc/session/auth_session/auth_session_common.h +++ b/services/group_auth/inc/session/auth_session/auth_session_common.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/services/group_auth/inc/session/auth_session/auth_session_util.h b/services/group_auth/inc/session/auth_session/auth_session_util.h index 0a88168..152151a 100644 --- a/services/group_auth/inc/session/auth_session/auth_session_util.h +++ b/services/group_auth/inc/session/auth_session/auth_session_util.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/services/group_auth/src/group_auth_manager/account_unrelated_group_auth/account_unrelated_group_auth.c b/services/group_auth/src/group_auth_manager/account_unrelated_group_auth/account_unrelated_group_auth.c index 230e754..da8c716 100644 --- a/services/group_auth/src/group_auth_manager/account_unrelated_group_auth/account_unrelated_group_auth.c +++ b/services/group_auth/src/group_auth_manager/account_unrelated_group_auth/account_unrelated_group_auth.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/services/group_auth/src/session/auth_session/auth_session_client.c b/services/group_auth/src/session/auth_session/auth_session_client.c index 2d1865f..4a1fd06 100644 --- a/services/group_auth/src/session/auth_session/auth_session_client.c +++ b/services/group_auth/src/session/auth_session/auth_session_client.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/services/group_auth/src/session/auth_session/auth_session_common.c b/services/group_auth/src/session/auth_session/auth_session_common.c index 188c042..8ddf8ea 100644 --- a/services/group_auth/src/session/auth_session/auth_session_common.c +++ b/services/group_auth/src/session/auth_session/auth_session_common.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/services/group_auth/src/session/auth_session/auth_session_server.c b/services/group_auth/src/session/auth_session/auth_session_server.c index 1ba4adc..f370a72 100644 --- a/services/group_auth/src/session/auth_session/auth_session_server.c +++ b/services/group_auth/src/session/auth_session/auth_session_server.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/services/group_auth/src/session/auth_session/auth_session_util.c b/services/group_auth/src/session/auth_session/auth_session_util.c index b4a1c97..30584b5 100644 --- a/services/group_auth/src/session/auth_session/auth_session_util.c +++ b/services/group_auth/src/session/auth_session/auth_session_util.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/services/group_manager/inc/base_group.h b/services/group_manager/inc/base_group.h index a76ef1c..acc2145 100644 --- a/services/group_manager/inc/base_group.h +++ b/services/group_manager/inc/base_group.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/services/group_manager/inc/base_group_manager_task.h b/services/group_manager/inc/base_group_manager_task.h index 5edbb7c..cf0f633 100644 --- a/services/group_manager/inc/base_group_manager_task.h +++ b/services/group_manager/inc/base_group_manager_task.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/services/group_manager/inc/broadcast_manager/broadcast_manager.h b/services/group_manager/inc/broadcast_manager/broadcast_manager.h index cf47887..4247f88 100644 --- a/services/group_manager/inc/broadcast_manager/broadcast_manager.h +++ b/services/group_manager/inc/broadcast_manager/broadcast_manager.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/services/group_manager/inc/group_manager.h b/services/group_manager/inc/group_manager.h index 94ba799..cd21b64 100644 --- a/services/group_manager/inc/group_manager.h +++ b/services/group_manager/inc/group_manager.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/services/group_manager/inc/group_manager_common.h b/services/group_manager/inc/group_manager_common.h index 3e7a10d..e30e30e 100644 --- a/services/group_manager/inc/group_manager_common.h +++ b/services/group_manager/inc/group_manager_common.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/services/group_manager/inc/group_operation.h b/services/group_manager/inc/group_operation.h index 500ab29..bc56027 100644 --- a/services/group_manager/inc/group_operation.h +++ b/services/group_manager/inc/group_operation.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/services/group_manager/inc/group_operation_common.h b/services/group_manager/inc/group_operation_common.h index 392f3c0..dc60b75 100644 --- a/services/group_manager/inc/group_operation_common.h +++ b/services/group_manager/inc/group_operation_common.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/services/group_manager/inc/peer_to_peer_group.h b/services/group_manager/inc/peer_to_peer_group.h index 33a93cb..01ad6d1 100644 --- a/services/group_manager/inc/peer_to_peer_group.h +++ b/services/group_manager/inc/peer_to_peer_group.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/services/group_manager/inc/session/bind_session/bind_session_common.h b/services/group_manager/inc/session/bind_session/bind_session_common.h index 2ace16f..39e9a97 100644 --- a/services/group_manager/inc/session/bind_session/bind_session_common.h +++ b/services/group_manager/inc/session/bind_session/bind_session_common.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/services/group_manager/inc/session/bind_session_common_defines.h b/services/group_manager/inc/session/bind_session_common_defines.h index a90ddc6..08afef7 100644 --- a/services/group_manager/inc/session/bind_session_common_defines.h +++ b/services/group_manager/inc/session/bind_session_common_defines.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/services/group_manager/src/broadcast_manager/broadcast_manager.c b/services/group_manager/src/broadcast_manager/broadcast_manager.c index 365f8b0..45db4b8 100644 --- a/services/group_manager/src/broadcast_manager/broadcast_manager.c +++ b/services/group_manager/src/broadcast_manager/broadcast_manager.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/services/group_manager/src/group_manager.c b/services/group_manager/src/group_manager.c index 50aed27..cba43c3 100644 --- a/services/group_manager/src/group_manager.c +++ b/services/group_manager/src/group_manager.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/services/group_manager/src/group_manager_common.c b/services/group_manager/src/group_manager_common.c index 5571fb9..5a1e696 100644 --- a/services/group_manager/src/group_manager_common.c +++ b/services/group_manager/src/group_manager_common.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/services/group_manager/src/group_operation/group_operation.c b/services/group_manager/src/group_operation/group_operation.c index 789b072..ae63472 100644 --- a/services/group_manager/src/group_operation/group_operation.c +++ b/services/group_manager/src/group_operation/group_operation.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/services/group_manager/src/group_operation/group_operation_common.c b/services/group_manager/src/group_operation/group_operation_common.c index 491c843..8a621c0 100644 --- a/services/group_manager/src/group_operation/group_operation_common.c +++ b/services/group_manager/src/group_operation/group_operation_common.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/services/group_manager/src/group_operation/peer_to_peer_group/peer_to_peer_group.c b/services/group_manager/src/group_operation/peer_to_peer_group/peer_to_peer_group.c index faf5686..7bd3045 100644 --- a/services/group_manager/src/group_operation/peer_to_peer_group/peer_to_peer_group.c +++ b/services/group_manager/src/group_operation/peer_to_peer_group/peer_to_peer_group.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/services/group_manager/src/group_operation/peer_to_peer_group_mock/peer_to_peer_group_mock.c b/services/group_manager/src/group_operation/peer_to_peer_group_mock/peer_to_peer_group_mock.c index 4715025..c203048 100644 --- a/services/group_manager/src/group_operation/peer_to_peer_group_mock/peer_to_peer_group_mock.c +++ b/services/group_manager/src/group_operation/peer_to_peer_group_mock/peer_to_peer_group_mock.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/services/group_manager/src/session/bind_session/bind_session_client.c b/services/group_manager/src/session/bind_session/bind_session_client.c index 256ad3e..6da974b 100644 --- a/services/group_manager/src/session/bind_session/bind_session_client.c +++ b/services/group_manager/src/session/bind_session/bind_session_client.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/services/group_manager/src/session/bind_session/bind_session_common.c b/services/group_manager/src/session/bind_session/bind_session_common.c index 2e52a03..6babdb8 100644 --- a/services/group_manager/src/session/bind_session/bind_session_common.c +++ b/services/group_manager/src/session/bind_session/bind_session_common.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/services/group_manager/src/session/bind_session/bind_session_server.c b/services/group_manager/src/session/bind_session/bind_session_server.c index 828dced..b630fef 100644 --- a/services/group_manager/src/session/bind_session/bind_session_server.c +++ b/services/group_manager/src/session/bind_session/bind_session_server.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/services/group_manager/src/session/bind_session_common_util.c b/services/group_manager/src/session/bind_session_common_util.c index 9132d97..42d8972 100644 --- a/services/group_manager/src/session/bind_session_common_util.c +++ b/services/group_manager/src/session/bind_session_common_util.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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 diff --git a/test/unittest/deviceauth/BUILD.gn b/test/unittest/deviceauth/BUILD.gn index a24d719..ddcadc1 100644 --- a/test/unittest/deviceauth/BUILD.gn +++ b/test/unittest/deviceauth/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (C) 2021-2022 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 diff --git a/test/unittest/deviceauth/include/deviceauth_standard_test.h b/test/unittest/deviceauth/include/deviceauth_standard_test.h index d068644..efca2c2 100644 --- a/test/unittest/deviceauth/include/deviceauth_standard_test.h +++ b/test/unittest/deviceauth/include/deviceauth_standard_test.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 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