diff --git a/security/access_token/BUILD.gn b/security/access_token/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..aa81ab7862f74225bf6ac5e54d99f47977e6fbd5 --- /dev/null +++ b/security/access_token/BUILD.gn @@ -0,0 +1,28 @@ +# 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. + +import("//build/ohos.gni") + +ohos_ndk_headers("accesstoken_header") { + dest_dir = "$ndk_headers_out_dir/accesstoken" + sources = [ "./include/accesstoken_ndk_api.h" ] +} + +ohos_ndk_library("libaccesstoken_ndk") { + ndk_description_file = "./libaccesstoken.ndk.json" + min_compact_version = "11" + output_name = "accesstoken_ndk" + + system_capability = "SystemCapability.Security.AccessToken" + system_capability_headers = [ "accesstoken/accesstoken_ndk_api.h" ] +} diff --git a/security/access_token/include/accesstoken_ndk_api.h b/security/access_token/include/accesstoken_ndk_api.h new file mode 100644 index 0000000000000000000000000000000000000000..dab825a0f9c6a07e5c9da6965143164c9932087f --- /dev/null +++ b/security/access_token/include/accesstoken_ndk_api.h @@ -0,0 +1,54 @@ +/* + * 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 ACCESSTOKEN_INTERFACES_KITS_C_ACCESSTOKEN_NDK_API_H +#define ACCESSTOKEN_INTERFACES_KITS_C_ACCESSTOKEN_NDK_API_H + +#include +#include "stdint.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct RequestResult { + const char* permission; + bool isDialogShow; + int authResult; +}; + +int32_t OH_AccessToken_VerifyAccessToken(unsigned int tokenid, const char* permission); + +/** + * @brief request permission. + * + * @param env Indicates the pointer to the JavaScript Native Interface (napi) environment. + * @param abilitycontext Indicates the pointer to the JavaScript ability context. + * @param permissionList Indicates the permission list to be requested. + * @param permissionSize Indicates the permission list size. + * @param callback Indicates the permission request event callback. + * @return Returns the status code of the execution. + * @since 12 + * @version 1.0 +*/ +// int32_t OH_AccessToken_RequestPermissionFromUser( +// NativeContext* abilitycontext, char** permissionList, int permissionSize, void (*callback)(RequestResult* result); + +#ifdef __cplusplus +} +#endif + +/** @} */ +#endif /* ACCESSTOKEN_INTERFACES_KITS_C_ACCESSTOKEN_NDK_API_H */ diff --git a/security/access_token/libaccesstoken.ndk.json b/security/access_token/libaccesstoken.ndk.json new file mode 100644 index 0000000000000000000000000000000000000000..0263b5f97f3f712a1b34c551c97e487b90122e52 --- /dev/null +++ b/security/access_token/libaccesstoken.ndk.json @@ -0,0 +1,5 @@ +[ + { + "name": "OH_AccessToken_VerifyAccessToken" + } +]