diff --git a/BUILD.gn b/BUILD.gn
index 4e262743dd640165d7de1ea5031b9743cabd5a46..c26997082ee9aadebfd27f14ef8069a5bc248969 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -11,24 +11,50 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+#import("//base/security/permission/permission.gni")
import("//build/ohos.gni")
-group("accesstoken_build_module_standard") {
+group("accesstoken_build_module") {
if (is_standard_system) {
deps = [
"//base/security/access_token/interfaces/innerkits/accesstoken:libaccesstoken_sdk",
- "//base/security/access_token/services/accesstoken:accesstoken_manager_service",
- "//base/security/access_token/services/accesstoken/main/sa_profile:accesstoken_sa_profile_standard",
+ "//base/security/access_token/interfaces/innerkits/atlib:libaccesstoken_lib",
+ "//base/security/access_token/services/accesstokenmanager:accesstoken_manager_service",
+ "//base/security/access_token/services/accesstokenmanager/main/sa_profile:accesstoken_sa_profile_standard",
]
}
}
-group("accesstoken_build_module_standard_test") {
+group("tokensync_build_module") {
+ if (is_standard_system) {
+ deps = [
+ "//base/security/access_token/interfaces/innerkits/tokensync:libtokensync_sdk",
+ "//base/security/access_token/services/tokensyncmanager:tokensync_manager_service",
+ "//base/security/access_token/services/tokensyncmanager/main/sa_profile:tokensync_sa_profile_standard",
+ ]
+ }
+}
+
+group("accesstoken_build_module_test") {
testonly = true
deps = []
if (is_standard_system) {
deps += [
"//base/security/access_token/interfaces/innerkits/accesstoken/test:unittest",
+ "//base/security/access_token/interfaces/innerkits/atlib/test:unittest",
+ "//base/security/access_token/interfaces/innerkits/tokensync/test:unittest",
+ "//base/security/access_token/services/accesstokenmanager/test:unittest",
]
}
-}
\ No newline at end of file
+}
+
+#group("distributed_permission") {
+# if (is_standard_system) {
+# deps = [
+# "${distributed_permission_innerkits_distributed_path}:distributed_permission_innerkits",
+# "${distributed_permission_record_database_path}:permission_standard_infrastructure_record_database",
+# "${distributed_permission_services_path}:distributed_permission_services",
+# "${distributed_permission_services_path}/main/sa_profile:distributed_permission_sa_profile_standard",
+# ]
+# }
+#}
diff --git a/README.md b/README.md
index 9d2b06ed3c0a7d5bbad7b383686580f7721cc7c2..616187854ec4bc35be87be1272bca9061127f86c 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@
- [接口说明](#section1551164914237)
- [使用说明](#section129654513264)
-- [相关仓](#section1371113476307)
+- [相关仓](#section1371113476307)
## 简介
@@ -24,7 +24,7 @@ ATM模块主要提供如下功能:
## 目录
```
-/base/security/access_token
+/base/security/access_token
├── frameworks # 框架层,作为基础功能目录,被interfaces和services使用
│ ├── accesstoken # Accesstoken管理框架代码实现
│ ├── tokensync # Accesstoken信息同步框架代码实现
diff --git a/config/base/string.json b/config/base/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..cd352ad635d17f56e377954eaf91d337d035b4fe
--- /dev/null
+++ b/config/base/string.json
@@ -0,0 +1,436 @@
+{
+ "string": [
+ {
+ "name": "ohos_id_text_font_family_regular",
+ "value": "sans-serif"
+ },
+ {
+ "name": "ohos_id_text_font_family_medium",
+ "value": "HwChinese-medium"
+ },
+ {
+ "name": "ohos_lab_answer_call",
+ "value": "Answer phone calls"
+ },
+ {
+ "name": "ohos_desc_answer_call",
+ "value": "Allows an application to answer incoming calls."
+ },
+ {
+ "name": "ohos_lab_internet",
+ "value": "Access Internet"
+ },
+ {
+ "name": "ohos_desc_internet",
+ "value": "Allows an application to access the Internet."
+ },
+ {
+ "name": "ohos_lab_modify_audio_settings",
+ "value": "Play audio"
+ },
+ {
+ "name": "ohos_desc_modify_audio_settings",
+ "value": "Allows an application to enable or disable the audio playback channel."
+ },
+ {
+ "name": "ohos_lab_read_calendar",
+ "value": "Read calendar information"
+ },
+ {
+ "name": "ohos_desc_read_calendar",
+ "value": "Allows an application to read calendar information."
+ },
+ {
+ "name": "ohos_lab_read_call_log",
+ "value": "Read call logs"
+ },
+ {
+ "name": "ohos_desc_read_call_log",
+ "value": "Allows an application to read call logs."
+ },
+ {
+ "name": "ohos_lab_read_cell_messages",
+ "value": "Read cell broadcast messages"
+ },
+ {
+ "name": "ohos_desc_read_cell_messages",
+ "value": "Allows an application to read cell broadcast messages received by the device."
+ },
+ {
+ "name": "ohos_lab_read_contacts",
+ "value": "Read Contacts"
+ },
+ {
+ "name": "ohos_desc_read_contacts",
+ "value": "Allows an application to read Contacts."
+ },
+ {
+ "name": "ohos_lab_get_telephony_state",
+ "value": "Read telephony information"
+ },
+ {
+ "name": "ohos_desc_get_telephony_state",
+ "value": "Allows an application to access telephony information, including the phone number, device ID, voice mailbox, IMEI, and ICCID."
+ },
+ {
+ "name": "ohos_lab_read_messages",
+ "value": "Read SMS/MMS messages"
+ },
+ {
+ "name": "ohos_desc_read_messages",
+ "value": "Allows an application to read SMS/MMS messages."
+ },
+ {
+ "name": "ohos_lab_receive_mms",
+ "value": "Receive MMS messages"
+ },
+ {
+ "name": "ohos_desc_receive_mms",
+ "value": "Allows an application to receive MMS messages."
+ },
+ {
+ "name": "ohos_lab_receive_sms",
+ "value": "Receive SMS messages"
+ },
+ {
+ "name": "ohos_desc_receive_sms",
+ "value": "Allows an application to receive SMS messages."
+ },
+ {
+ "name": "ohos_lab_receive_wap_messages",
+ "value": "Receive WAP messages"
+ },
+ {
+ "name": "ohos_desc_receive_wap_messages",
+ "value": "Allows an application to receive WAP messages."
+ },
+ {
+ "name": "ohos_lab_microphone",
+ "value": "Record audio"
+ },
+ {
+ "name": "ohos_desc_microphone",
+ "value": "Allows an application to enable or disable the audio recording channel."
+ },
+ {
+ "name": "ohos_lab_send_messages",
+ "value": "Send SMS/MMS messages"
+ },
+ {
+ "name": "ohos_desc_send_messages",
+ "value": "Allows an application to send SMS/MMS messages."
+ },
+ {
+ "name": "ohos_lab_write_calendar",
+ "value": "Add/Modify/Delete calendar events"
+ },
+ {
+ "name": "ohos_desc_write_calendar",
+ "value": "Allows an application to add, modify, and delete calendar events."
+ },
+ {
+ "name": "ohos_lab_write_call_log",
+ "value": "Add/Modify/Delete call logs"
+ },
+ {
+ "name": "ohos_desc_write_call_log",
+ "value": "Allows an application to add, modify, and delete call logs."
+ },
+ {
+ "name": "ohos_lab_write_contacts",
+ "value": "Add/Modify/Delete Contacts"
+ },
+ {
+ "name": "ohos_desc_write_contacts",
+ "value": "Allows an application to add, modify, and delete Contacts."
+ },
+ {
+ "name": "ohos_lab_distributed_datasync",
+ "value": "Obtain the device location"
+ },
+ {
+ "name": "ohos_desc_distributed_datasync",
+ "value": "Allows a background application to obtain the device location."
+ },
+ {
+ "name": "ohos_lab_manage_voicemail",
+ "value": "Manage the voice mailbox"
+ },
+ {
+ "name": "ohos_desc_manage_voicemail",
+ "value": "Allows an application to manage the voice mailbox."
+ },
+ {
+ "name": "ohos_lab_location_in_background",
+ "value": "Obtain the device location"
+ },
+ {
+ "name": "ohos_desc_location_in_background",
+ "value": "Allows a background application to obtain the device location."
+ },
+ {
+ "name": "ohos_lab_location",
+ "value": "Obtain the device location"
+ },
+ {
+ "name": "ohos_desc_location",
+ "value": "Allows a foreground application to obtain the device location."
+ },
+ {
+ "name": "ohos_lab_media_location",
+ "value": "Access location information"
+ },
+ {
+ "name": "ohos_desc_media_location",
+ "value": "Allows an application to read the location where a photo is taken, such as the longitude and latitude."
+ },
+ {
+ "name": "ohos_lab_get_network_info",
+ "value": "Read network information"
+ },
+ {
+ "name": "ohos_desc_get_network_info",
+ "value": "Allows an application to obtain network information."
+ },
+ {
+ "name": "ohos_lab_place_call",
+ "value": "Make calls"
+ },
+ {
+ "name": "ohos_desc_place_call",
+ "value": "Allows an application to make calls without starting the dialer."
+ },
+ {
+ "name": "ohos_lab_camera",
+ "value": "Take photos or shoot videos"
+ },
+ {
+ "name": "ohos_desc_camera",
+ "value": "Allows an application to take photos and shoot videos."
+ },
+ {
+ "name": "ohos_lab_set_network_info",
+ "value": "Set data network"
+ },
+ {
+ "name": "ohos_desc_set_network_info",
+ "value": "Allows an application to set data network information."
+ },
+ {
+ "name": "ohos_lab_read_media",
+ "value": "Read media files"
+ },
+ {
+ "name": "ohos_desc_read_media",
+ "value": "Allows an application to read media files, such as video and audio clips and images."
+ },
+ {
+ "name": "ohos_lab_write_media",
+ "value": "Read and write media files"
+ },
+ {
+ "name": "ohos_desc_write_media",
+ "value": "Allows an application to read and write media files, such as video and audio clips and images."
+ },
+ {
+ "name": "ohos_lab_distributed_virtualdevice",
+ "value": "Discover devices for multi-device collaboration"
+ },
+ {
+ "name": "ohos_desc_distributed_virtualdevice",
+ "value": "Allows an application to discover and access other devices in multi-device collaboration."
+ },
+ {
+ "name": "ohos_lab_enroll_biometric",
+ "value": "Manage biological features"
+ },
+ {
+ "name": "ohos_desc_enroll_biometric",
+ "value": "Allows an application to manage biometrical features."
+ },
+ {
+ "name": "ohos_lab_access_biometric",
+ "value": "Biometric feature authentication"
+ },
+ {
+ "name": "ohos_desc_access_biometric",
+ "value": "Allows an application to use biometric features for authentication."
+ },
+ {
+ "name": "ohos_lab_access_biometric_internal",
+ "value": "Biometric feature authentication for system applications"
+ },
+ {
+ "name": "ohos_desc_access_biometric_internal",
+ "value": "Allows a system application to use biometric features for authentication."
+ },
+ {
+ "name": "ohos_lab_reset_biometric_lockout",
+ "value": "Reset the upper limit for biometric feature authentication failures"
+ },
+ {
+ "name": "ohos_desc_reset_biometric_lockout",
+ "value": "Allows an application to reset the maximum number of failures allowed before biometric feature authentication is locked."
+ },
+ {
+ "name": "ohos_lab_set_time",
+ "value": "Set the system time"
+ },
+ {
+ "name": "ohos_desc_set_time",
+ "value": "Allows an application to set the system time."
+ },
+ {
+ "name": "ohos_lab_set_time_zone",
+ "value": "Set the system time zone"
+ },
+ {
+ "name": "ohos_desc_set_time_zone",
+ "value": "Allows an application to set the system time zone."
+ },
+ {
+ "name": "ohos_lab_download_session_manager",
+ "value": "Manage download sessions"
+ },
+ {
+ "name": "ohos_desc_download_session_manager",
+ "value": "Allows an application to manage download sessions."
+ },
+ {
+ "name": "ohos_lab_commonevent_sticky",
+ "value": "Sticky common events"
+ },
+ {
+ "name": "ohos_desc_commonevent_sticky",
+ "value": "Allows an application to publish sticky common events."
+ },
+ {
+ "name": "ohos_lab_manage_local_accounts",
+ "value": "Manage local accounts"
+ },
+ {
+ "name": "ohos_desc_manage_local_accounts",
+ "value": "Allows an application to add, delete, modify, and query local accounts."
+ },
+ {
+ "name": "ohos_lab_interact_across_local_accounts",
+ "value": "Multi-account mutual access"
+ },
+ {
+ "name": "ohos_desc_interact_across_local_accounts",
+ "value": "Allows an application to access accounts of other applications."
+ },
+ {
+ "name": "ohos_lab_vibrate",
+ "value": "Vibrate"
+ },
+ {
+ "name": "ohos_desc_vibrate",
+ "value": "Allows an application to use the vibrator."
+ },
+ {
+ "name": "ohos_lab_activity_motion",
+ "value": "Read workout status"
+ },
+ {
+ "name": "ohos_desc_activity_motion",
+ "value": "Allows an application to read the workout status of the user."
+ },
+ {
+ "name": "ohos_lab_read_health_data",
+ "value": "Read health data"
+ },
+ {
+ "name": "ohos_desc_read_health_data",
+ "value": "Allows an application to read the health data of the user."
+ },
+ {
+ "name": "ohos_lab_connect_ime_ability",
+ "value": "Bind to the input method framework"
+ },
+ {
+ "name": "ohos_desc_connect_ime_ability",
+ "value": "Allows an application to be invoked by the input method framework."
+ },
+ {
+ "name": "ohos_lab_set_wallpaper",
+ "value": "Set static wallpapers"
+ },
+ {
+ "name": "ohos_desc_set_wallpaper",
+ "value": "Allows an application to set a static wallpaper."
+ },
+ {
+ "name": "ohos_lab_get_wallpaper",
+ "value": "Read wallpaper files"
+ },
+ {
+ "name": "ohos_desc_get_wallpaper",
+ "value": "Allows an application to read wallpaper files."
+ },
+ {
+ "name": "ohos_lab_interact_across_local_accounts_extension",
+ "value": "Multi-account access extension"
+ },
+ {
+ "name": "ohos_desc_interact_across_local_accounts_extension",
+ "value": "Allows an application to set the attributes of applications of other users."
+ },
+ {
+ "name": "ohos_lab_accelerometer",
+ "value": "Read acceleration sensor data"
+ },
+ {
+ "name": "ohos_desc_accelerometer",
+ "value": "Allows an application to read data from an acceleration sensor."
+ },
+ {
+ "name": "ohos_lab_gyroscope",
+ "value": "Read gyroscope sensor data"
+ },
+ {
+ "name": "ohos_desc_gyroscope",
+ "value": "Allows an application to read data from a gyroscope sensor."
+ },
+ {
+ "name": "ohos_lab_set_telephony_state",
+ "value": "Set telephony state"
+ },
+ {
+ "name": "ohos_desc_set_telephony_state",
+ "value": "Allows an application to set the telephony state, for example, to enable or disable the airplane mode, and change the network mode."
+ },
+ {
+ "name": "ohos_lab_bundle_active_info",
+ "value": "Query application running time"
+ },
+ {
+ "name": "ohos_desc_bundle_active_info",
+ "value": "Allows a system application or privileged application to obtain how long other applications have been running in the foreground or background."
+ },
+ {
+ "name": "ohos_lab_publish_agent_reminder",
+ "value": "Agent-powered reminder"
+ },
+ {
+ "name": "ohos_desc_publish_agent_reminder",
+ "value": "Allows an application to use agent-powered reminders."
+ },
+ {
+ "name": "ohos_lab_control_task_sync_animator",
+ "value": "Sync task animation"
+ },
+ {
+ "name": "ohos_desc_control_task_sync_animator",
+ "value": "Allows an application to use sync task animations."
+ },
+ {
+ "name": "ohos_lab_notification_controller",
+ "value": "System interfaces"
+ },
+ {
+ "name": "ohos_desc_notification_controller",
+ "value": "Allows an application to use notification management interfaces."
+ }
+ ]
+}
\ No newline at end of file
diff --git a/config/config.json b/config/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..a3737ed9168c43ca6817a54ca9ce9d4a5c8bab70
--- /dev/null
+++ b/config/config.json
@@ -0,0 +1,770 @@
+{
+ "app": {
+ "bundleName": "ohos.global.systemres",
+ "vendor": "ohos",
+ "version": {
+ "code": 1,
+ "name": "1.0.0.1"
+ },
+ "apiVersion": {
+ "compatible": 3,
+ "target": 3
+ }
+ },
+ "deviceConfig": {
+ "default": {
+ }
+ },
+ "module": {
+ "package": "ohos.global.systemres",
+ "deviceType": [
+ "default",
+ "tv",
+ "car",
+ "wearable"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "entry",
+ "moduleType": "entry"
+ },
+ "definePermissions": [
+ {
+ "name": "ohos.permission.ANSWER_CALL",
+ "grantMode": "user_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_answer_call",
+ "description": "$string:ohos_desc_answer_call"
+ },
+ {
+ "name": "ohos.permission.USE_BLUETOOTH",
+ "grantMode": "system_grant",
+ "availableScope": "normal",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ },
+ {
+ "name": "ohos.permission.DISCOVER_BLUETOOTH",
+ "grantMode": "system_grant",
+ "availableScope": "normal",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ },
+ {
+ "name": "ohos.permission.MANAGE_BLUETOOTH",
+ "grantMode": "system_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ },
+ {
+ "name": "ohos.permission.INTERNET",
+ "grantMode": "system_grant",
+ "availableScope": "normal",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_internet",
+ "description": "$string:ohos_desc_internet"
+ },
+ {
+ "name": "ohos.permission.MODIFY_AUDIO_SETTINGS",
+ "grantMode": "system_grant",
+ "availableScope": "normal",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_modify_audio_settings",
+ "description": "$string:ohos_desc_modify_audio_settings"
+ },
+ {
+ "name": "ohos.permission.READ_CALENDAR",
+ "grantMode": "user_grant",
+ "availableScope": "normal",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_read_calendar",
+ "description": "$string:ohos_desc_read_calendar"
+ },
+ {
+ "name": "ohos.permission.READ_CALL_LOG",
+ "grantMode": "user_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_read_call_log",
+ "description": "$string:ohos_desc_read_call_log"
+ },
+ {
+ "name": "ohos.permission.READ_CELL_MESSAGES",
+ "grantMode": "user_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_read_cell_messages",
+ "description": "$string:ohos_desc_read_cell_messages"
+ },
+ {
+ "name": "ohos.permission.READ_CONTACTS",
+ "grantMode": "user_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_read_contacts",
+ "description": "$string:ohos_desc_read_contacts"
+ },
+ {
+ "name": "ohos.permission.GET_TELEPHONY_STATE",
+ "grantMode": "system_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_get_telephony_state",
+ "description": "$string:ohos_desc_get_telephony_state"
+ },
+ {
+ "name": "ohos.permission.READ_MESSAGES",
+ "grantMode": "user_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_read_messages",
+ "description": "$string:ohos_desc_read_messages"
+ },
+ {
+ "name": "ohos.permission.RECEIVE_MMS",
+ "grantMode": "user_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_receive_mms",
+ "description": "$string:ohos_desc_receive_mms"
+ },
+ {
+ "name": "ohos.permission.RECEIVE_SMS",
+ "grantMode": "user_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_receive_sms",
+ "description": "$string:ohos_desc_receive_sms"
+ },
+ {
+ "name": "ohos.permission.RECEIVE_WAP_MESSAGES",
+ "grantMode": "user_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_receive_wap_messages",
+ "description": "$string:ohos_desc_receive_wap_messages"
+ },
+ {
+ "name": "ohos.permission.MICROPHONE",
+ "grantMode": "user_grant",
+ "availableScope": "normal",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_microphone",
+ "description": "$string:ohos_desc_microphone"
+ },
+ {
+ "name": "ohos.permission.SEND_MESSAGES",
+ "grantMode": "user_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_send_messages",
+ "description": "$string:ohos_desc_send_messages"
+ },
+ {
+ "name": "ohos.permission.WRITE_CALENDAR",
+ "grantMode": "user_grant",
+ "availableScope": "normal",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_write_calendar",
+ "description": "$string:ohos_desc_write_calendar"
+ },
+ {
+ "name": "ohos.permission.WRITE_CALL_LOG",
+ "grantMode": "user_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_write_call_log",
+ "description": "$string:ohos_desc_write_call_log"
+ },
+ {
+ "name": "ohos.permission.WRITE_CONTACTS",
+ "grantMode": "user_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_write_contacts",
+ "description": "$string:ohos_desc_write_contacts"
+ },
+ {
+ "name": "ohos.permission.DISTRIBUTED_DATASYNC",
+ "grantMode": "user_grant",
+ "availableScope": "normal",
+ "provisionEnable": true,
+ "distributedSceneEnable": true,
+ "label": "$string:ohos_lab_distributed_datasync",
+ "description": "$string:ohos_desc_distributed_datasync"
+ },
+ {
+ "name": "ohos.permission.MANAGE_VOICEMAIL",
+ "grantMode": "user_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_manage_voicemail",
+ "description": "$string:ohos_desc_manage_voicemail"
+ },
+ {
+ "name": "ohos.permission.REQUIRE_FORM",
+ "grantMode": "system_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ },
+ {
+ "name": "ohos.permission.LOCATION_IN_BACKGROUND",
+ "grantMode": "user_grant",
+ "availableScope": "normal",
+ "provisionEnable": false,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_location_in_background",
+ "description": "$string:ohos_desc_location_in_background"
+ },
+ {
+ "name": "ohos.permission.LOCATION",
+ "grantMode": "user_grant",
+ "availableScope": "normal",
+ "provisionEnable": true,
+ "distributedSceneEnable": true,
+ "label": "$string:ohos_lab_location",
+ "description": "$string:ohos_desc_location"
+ },
+ {
+ "name": "ohos.permission.MEDIA_LOCATION",
+ "grantMode": "user_grant",
+ "availableScope": "normal",
+ "provisionEnable": true,
+ "distributedSceneEnable": true,
+ "label": "$string:ohos_lab_media_location",
+ "description": "$string:ohos_desc_media_location"
+ },
+ {
+ "name": "ohos.permission.GET_NETWORK_INFO",
+ "grantMode": "system_grant",
+ "availableScope": "normal",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_get_network_info",
+ "description": "$string:ohos_desc_get_network_info"
+ },
+ {
+ "name": "ohos.permission.PLACE_CALL",
+ "grantMode": "system_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": true,
+ "label": "$string:ohos_lab_place_call",
+ "description": "$string:ohos_desc_place_call"
+ },
+ {
+ "name": "ohos.permission.CAMERA",
+ "grantMode": "user_grant",
+ "availableScope": "normal",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_camera",
+ "description": "$string:ohos_desc_camera"
+ },
+ {
+ "name": "ohos.permission.SET_NETWORK_INFO",
+ "grantMode": "system_grant",
+ "availableScope": "normal",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_set_network_info",
+ "description": "$string:ohos_desc_set_network_info"
+ },
+ {
+ "name": "ohos.permission.REMOVE_CACHE_FILES",
+ "grantMode": "system_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ },
+ {
+ "name": "ohos.permission.READ_MEDIA",
+ "grantMode": "user_grant",
+ "availableScope": "normal",
+ "provisionEnable": true,
+ "distributedSceneEnable": true,
+ "label": "$string:ohos_lab_read_media",
+ "description": "$string:ohos_desc_read_media"
+ },
+ {
+ "name": "ohos.permission.REBOOT",
+ "grantMode": "system_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ },
+ {
+ "name": "ohos.permission.RUNNING_LOCK",
+ "grantMode": "system_grant",
+ "availableScope": "normal",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ },
+ {
+ "name": "ohos.permission.WRITE_MEDIA",
+ "grantMode": "user_grant",
+ "availableScope": "normal",
+ "provisionEnable": true,
+ "distributedSceneEnable": true,
+ "label": "$string:ohos_lab_write_media",
+ "description": "$string:ohos_desc_write_media"
+ },
+ {
+ "name": "com.huawei.permission.DISTRIBUTED_VIRTUALDEVICE",
+ "grantMode": "user_grant",
+ "availableScope": "normal",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_distributed_virtualdevice",
+ "description": "$string:ohos_desc_distributed_virtualdevice"
+ },
+ {
+ "name": "ohos.permission.ENROLL_BIOMETRIC",
+ "grantMode": "system_grant",
+ "availableScope": "system_core",
+ "provisionEnable": false,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_enroll_biometric",
+ "description": "$string:ohos_desc_enroll_biometric"
+ },
+ {
+ "name": "ohos.permission.ACCESS_BIOMETRIC",
+ "grantMode": "system_grant",
+ "availableScope": "normal",
+ "provisionEnable": false,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_access_biometric",
+ "description": "$string:ohos_desc_access_biometric"
+ },
+ {
+ "name": "ohos.permission.ACCESS_BIOMETRIC_INTERNAL",
+ "grantMode": "system_grant",
+ "availableScope": "system_core",
+ "provisionEnable": false,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_access_biometric_internal",
+ "description": "$string:ohos_desc_access_biometric_internal"
+ },
+ {
+ "name": "ohos.permission.RESET_BIOMETRIC_LOCKOUT",
+ "grantMode": "system_grant",
+ "availableScope": "system_core",
+ "provisionEnable": false,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_reset_biometric_lockout",
+ "description": "$string:ohos_desc_reset_biometric_lockout"
+ },
+ {
+ "name": "ohos.permission.SET_TIME",
+ "grantMode": "system_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_set_time",
+ "description": "$string:ohos_desc_set_time"
+ },
+ {
+ "name": "ohos.permission.SET_TIME_ZONE",
+ "grantMode": "system_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_set_time_zone",
+ "description": "$string:ohos_desc_set_time_zone"
+ },
+ {
+ "name": "ohos.permission.DOWNLOAD_SESSION_MANAGER",
+ "grantMode": "system_grant",
+ "availableScope": "system_core",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_download_session_manager",
+ "description": "$string:ohos_desc_download_session_manager"
+ },
+ {
+ "name": "ohos.permission.COMMONEVENT_STICKY",
+ "grantMode": "system_grant",
+ "availableScope": "normal",
+ "provisionEnable": true,
+ "distributedSceneEnable": true,
+ "label": "$string:ohos_lab_commonevent_sticky",
+ "description": "$string:ohos_desc_commonevent_sticky"
+ },
+ {
+ "name": "ohos.permission.SYSTEM_FLOAT_WINDOW",
+ "grantMode": "system_grant",
+ "availableScope": "normal",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ },
+ {
+ "name": "ohos.permission.POWER_MANAGER",
+ "grantMode": "system_grant",
+ "availableScope": "system_core",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ },
+ {
+ "name": "ohos.permission.REFRESH_USER_ACTION",
+ "grantMode": "system_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ },
+ {
+ "name": "ohos.permission.POWER_OPTIMIZATION",
+ "grantMode": "system_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ },
+ {
+ "name": "ohos.permission.REBOOT_RECOVERY",
+ "grantMode": "system_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ },
+ {
+ "name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS",
+ "grantMode": "system_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_manage_local_accounts",
+ "description": "$string:ohos_desc_manage_local_accounts"
+ },
+ {
+ "name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS",
+ "grantMode": "system_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_interact_across_local_accounts",
+ "description": "$string:ohos_desc_interact_across_local_accounts"
+ },
+ {
+ "name": "ohos.permission.VIBRATE",
+ "grantMode": "system_grant",
+ "availableScope": "normal",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_vibrate",
+ "description": "$string:ohos_desc_vibrate"
+ },
+ {
+ "name": "ohos.permission.ACTIVITY_MOTION",
+ "grantMode": "user_grant",
+ "availableScope": "normal",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_activity_motion",
+ "description": "$string:ohos_desc_activity_motion"
+ },
+ {
+ "name": "ohos.permission.READ_HEALTH_DATA",
+ "grantMode": "user_grant",
+ "availableScope": "normal",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_read_health_data",
+ "description": "$string:ohos_desc_read_health_data"
+ },
+ {
+ "name": "ohos.permission.CONNECT_IME_ABILITY",
+ "grantMode": "system_grant",
+ "availableScope": "system_core",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_connect_ime_ability",
+ "description": "$string:ohos_desc_connect_ime_ability"
+ },
+ {
+ "name": "ohos.permission.CONNECT_SCREEN_SAVER_ABILITY",
+ "grantMode": "system_grant",
+ "availableScope": "system_core",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ },
+ {
+ "name": "ohos.permission.READ_SCREEN_SAVER",
+ "grantMode": "system_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ },
+ {
+ "name": "ohos.permission.WRITE_SCREEN_SAVER",
+ "grantMode": "system_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ },
+ {
+ "name": "ohos.permission.SET_WALLPAPER",
+ "grantMode": "system_grant",
+ "availableScope": "normal",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_set_wallpaper",
+ "description": "$string:ohos_desc_set_wallpaper"
+ },
+ {
+ "name": "ohos.permission.GET_WALLPAPER",
+ "grantMode": "system_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_get_wallpaper",
+ "description": "$string:ohos_desc_get_wallpaper"
+ },
+ {
+ "name": "ohos.permission.CHANGE_ABILITY_ENABLED_STATE",
+ "grantMode": "system_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ },
+ {
+ "name": "ohos.permission.ACCESS_MISSIONS",
+ "grantMode": "system_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ },
+ {
+ "name": "ohos.permission.CLEAN_BACKGROUND_PROCESSES",
+ "grantMode": "system_grant",
+ "availableScope": "normal",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ },
+ {
+ "name": "ohos.permission.KEEP_BACKGROUND_RUNNING",
+ "grantMode": "system_grant",
+ "availableScope": "normal",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ },
+ {
+ "name": "ohos.permission.UPDATE_CONFIGURATION",
+ "grantMode": "system_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ },
+ {
+ "name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",
+ "grantMode": "system_grant",
+ "availableScope": "system_core",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ },
+ {
+ "name": "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS",
+ "grantMode": "system_grant",
+ "availableScope": "system_core",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ },
+ {
+ "name": "ohos.permission.GET_SENSITIVE_PERMISSIONS",
+ "grantMode": "system_grant",
+ "availableScope": "system_core",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ },
+ {
+ "name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION",
+ "grantMode": "system_grant",
+ "availableScope": "system_core",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_interact_across_local_accounts_extension",
+ "description": "$string:ohos_desc_interact_across_local_accounts_extension"
+ },
+ {
+ "name": "ohos.permission.LISTEN_BUNDLE_CHANGE",
+ "grantMode": "system_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ },
+ {
+ "name": "ohos.permission.GET_BUNDLE_INFO",
+ "grantMode": "system_grant",
+ "availableScope": "normal",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ },
+ {
+ "name": "ohos.permission.ACCELEROMETER",
+ "grantMode": "system_grant",
+ "availableScope": "normal",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_accelerometer",
+ "description": "$string:ohos_desc_accelerometer"
+ },
+ {
+ "name": "ohos.permission.GYROSCOPE",
+ "grantMode": "system_grant",
+ "availableScope": "normal",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_gyroscope",
+ "description": "$string:ohos_desc_gyroscope"
+ },
+ {
+ "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
+ "grantMode": "system_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ },
+ {
+ "name": "ohos.permission.INSTALL_BUNDLE",
+ "grantMode": "system_grant",
+ "availableScope": "system_core",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ },
+ {
+ "name": "ohos.permission.MANAGE_SHORTCUTS",
+ "grantMode": "system_grant",
+ "availableScope": "system_core",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ },
+ {
+ "name": "ohos.permission.radio.ACCESS_FM_AM",
+ "grantMode": "system_grant",
+ "availableScope": "system_core",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ },
+ {
+ "name": "ohos.permission.SET_TELEPHONY_STATE",
+ "grantMode": "system_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_set_telephony_state",
+ "description": "$string:ohos_desc_set_telephony_state"
+ },
+ {
+ "name": "ohos.permission.START_ABILIIES_FROM_BACKGROUND",
+ "grantMode": "system_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ },
+ {
+ "name": "ohos.permission.BUNDLE_ACTIVE_INFO",
+ "grantMode": "system_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_bundle_active_info",
+ "description": "$string:ohos_desc_bundle_active_info"
+ },
+ {
+ "name": "ohos.permission.START_INVISIBLE_ABILITY",
+ "grantMode": "system_grant",
+ "availableScope": "system_core",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ },
+ {
+ "name": "ohos.permission.sec.ACCESS_UDID",
+ "grantMode": "system_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ },
+ {
+ "name": "ohos.permission.LAUNCH_DATA_PRIVACY_CENTER",
+ "grantMode": "system_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ },
+ {
+ "name": "ohos.permission.MANAGE_MEDIA_RESOURCES",
+ "grantMode": "system_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ },
+ {
+ "name": "ohos.permission.PUBLISH_AGENT_REMINDER",
+ "grantMode": "system_grant",
+ "availableScope": "normal",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_publish_agent_reminder",
+ "description": "$string:ohos_desc_publish_agent_reminder"
+ },
+ {
+ "name": "ohos.permission.CONTROL_TASK_SYNC_ANIMATOR",
+ "grantMode": "system_grant",
+ "availableScope": "system_core",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_control_task_sync_animator",
+ "description": "$string:ohos_desc_control_task_sync_animator"
+ },
+ {
+ "name": "ohos.permission.INPUT_MONITORING",
+ "grantMode": "system_grant",
+ "availableScope": "system_core",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ },
+ {
+ "name": "ohos.permission.MANAGE_MISSIONS",
+ "grantMode": "system_grant",
+ "availableScope": "system_core",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ },
+ {
+ "name": "ohos.permission.NOTIFICATION_CONTROLLER",
+ "grantMode": "system_grant",
+ "availableScope": "system_core",
+ "provisionEnable": true,
+ "distributedSceneEnable": false,
+ "label": "$string:ohos_lab_notification_controller",
+ "description": "$string:ohos_desc_notification_controller"
+ },
+ {
+ "name": "ohos.permission.CONNECTIVITY_INTERNAL",
+ "grantMode": "system_grant",
+ "availableScope": "system_basic",
+ "provisionEnable": true,
+ "distributedSceneEnable": false
+ }
+ ]
+ }
+}
diff --git a/config/zh_CN/string.json b/config/zh_CN/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..5f0134df360bf6edb2a6679a88ee04959019d6cb
--- /dev/null
+++ b/config/zh_CN/string.json
@@ -0,0 +1,428 @@
+{
+ "string": [
+ {
+ "name": "ohos_lab_answer_call",
+ "value": "绰"
+ },
+ {
+ "name": "ohos_desc_answer_call",
+ "value": "Ӧý绰"
+ },
+ {
+ "name": "ohos_lab_internet",
+ "value": ""
+ },
+ {
+ "name": "ohos_desc_internet",
+ "value": "Ӧ÷硣"
+ },
+ {
+ "name": "ohos_lab_modify_audio_settings",
+ "value": "Ƶ"
+ },
+ {
+ "name": "ohos_desc_modify_audio_settings",
+ "value": "Ӧôرղͨ·"
+ },
+ {
+ "name": "ohos_lab_read_calendar",
+ "value": "ȡ"
+ },
+ {
+ "name": "ohos_desc_read_calendar",
+ "value": "Ӧöȡ"
+ },
+ {
+ "name": "ohos_lab_read_call_log",
+ "value": "ȡͨ¼"
+ },
+ {
+ "name": "ohos_desc_read_call_log",
+ "value": "Ӧöȡ豸ϵͨ¼Ϣ"
+ },
+ {
+ "name": "ohos_lab_read_cell_messages",
+ "value": "ȡС㲥"
+ },
+ {
+ "name": "ohos_desc_read_cell_messages",
+ "value": "Ӧöȡ豸յС㲥Ϣ"
+ },
+ {
+ "name": "ohos_lab_read_contacts",
+ "value": "ȡͨѶ¼"
+ },
+ {
+ "name": "ohos_desc_read_contacts",
+ "value": "Ӧöȡ豸ϴ洢ϵϢ"
+ },
+ {
+ "name": "ohos_lab_get_telephony_state",
+ "value": "ȡ绰Ϣ"
+ },
+ {
+ "name": "ohos_desc_get_telephony_state",
+ "value": "Ӧ÷豸ı롢豸ID䡢IMEIICCIDϢ"
+ },
+ {
+ "name": "ohos_lab_read_messages",
+ "value": "ȡ̲"
+ },
+ {
+ "name": "ohos_desc_read_messages",
+ "value": "Ӧöȡ豸յĶ̲Ϣ"
+ },
+ {
+ "name": "ohos_lab_receive_mms",
+ "value": "ղ"
+ },
+ {
+ "name": "ohos_desc_receive_mms",
+ "value": "Ӧýղš"
+ },
+ {
+ "name": "ohos_lab_receive_sms",
+ "value": "ն"
+ },
+ {
+ "name": "ohos_desc_receive_sms",
+ "value": "Ӧýնš"
+ },
+ {
+ "name": "ohos_lab_receive_wap_messages",
+ "value": "WAPϢ"
+ },
+ {
+ "name": "ohos_desc_receive_wap_messages",
+ "value": "ӦýWAPϢ"
+ },
+ {
+ "name": "ohos_lab_microphone",
+ "value": "¼Ƶ"
+ },
+ {
+ "name": "ohos_desc_microphone",
+ "value": "Ӧôر¼ͨ·"
+ },
+ {
+ "name": "ohos_lab_send_messages",
+ "value": "Ͷ̲"
+ },
+ {
+ "name": "ohos_desc_send_messages",
+ "value": "Ӧ÷Ͷ̲š"
+ },
+ {
+ "name": "ohos_lab_write_calendar",
+ "value": "½//ɾ"
+ },
+ {
+ "name": "ohos_desc_write_calendar",
+ "value": "Ӧ½//ɾ"
+ },
+ {
+ "name": "ohos_lab_write_call_log",
+ "value": "½//ɾͨ¼"
+ },
+ {
+ "name": "ohos_desc_write_call_log",
+ "value": "Ӧ½//ɾ豸ϵͨ¼Ϣ"
+ },
+ {
+ "name": "ohos_lab_write_contacts",
+ "value": "½//ɾͨѶ¼"
+ },
+ {
+ "name": "ohos_desc_write_contacts",
+ "value": "Ӧ½//ɾ豸ϴ洢ϵϢ"
+ },
+ {
+ "name": "ohos_lab_distributed_datasync",
+ "value": "ͬ豸ݽ"
+ },
+ {
+ "name": "ohos_desc_distributed_datasync",
+ "value": "ӦԶ豸ûݣͼƬ֡ƵӦݵȣ"
+ },
+ {
+ "name": "ohos_lab_manage_voicemail",
+ "value": ""
+ },
+ {
+ "name": "ohos_desc_manage_voicemail",
+ "value": "Ӧù䡣"
+ },
+ {
+ "name": "ohos_lab_location_in_background",
+ "value": "λȨ"
+ },
+ {
+ "name": "ohos_desc_location_in_background",
+ "value": "Ӧں̨ʱȡλϢ"
+ },
+ {
+ "name": "ohos_lab_location",
+ "value": "λȨ"
+ },
+ {
+ "name": "ohos_desc_location",
+ "value": "Ӧǰ̨ʱȡλϢ"
+ },
+ {
+ "name": "ohos_lab_media_location",
+ "value": "Ӧ÷λ"
+ },
+ {
+ "name": "ohos_desc_media_location",
+ "value": "Ӧ÷ûýļеλϢ羭γϢҪȨޡ"
+ },
+ {
+ "name": "ohos_lab_get_network_info",
+ "value": "ȡϢ"
+ },
+ {
+ "name": "ohos_desc_get_network_info",
+ "value": "ӦûȡϢ"
+ },
+ {
+ "name": "ohos_lab_place_call",
+ "value": "绰"
+ },
+ {
+ "name": "ohos_desc_place_call",
+ "value": "ӦֱӲ绰"
+ },
+ {
+ "name": "ohos_lab_camera",
+ "value": "Ƭ¼Ƶ"
+ },
+ {
+ "name": "ohos_desc_camera",
+ "value": "ӦƬƵ"
+ },
+ {
+ "name": "ohos_lab_set_network_info",
+ "value": ""
+ },
+ {
+ "name": "ohos_desc_set_network_info",
+ "value": "Ӧ硣"
+ },
+ {
+ "name": "ohos_lab_read_media",
+ "value": "Ӧöȡýļ"
+ },
+ {
+ "name": "ohos_desc_read_media",
+ "value": "Ӧ÷ûýļƵƵͼƬȣҪȨޡ"
+ },
+ {
+ "name": "ohos_lab_write_media",
+ "value": "Ӧöдýļ"
+ },
+ {
+ "name": "ohos_desc_write_media",
+ "value": "ӦöдûýļƵƵͼƬȣҪȨޡ"
+ },
+ {
+ "name": "ohos_lab_distributed_virtualdevice",
+ "value": "ֶ֧豸Эͬ豸"
+ },
+ {
+ "name": "ohos_desc_distributed_virtualdevice",
+ "value": "Ӧ÷ֲ豸Աж豸Эͬ"
+ },
+ {
+ "name": "ohos_lab_enroll_biometric",
+ "value": ""
+ },
+ {
+ "name": "ohos_desc_enroll_biometric",
+ "value": "Ӧù"
+ },
+ {
+ "name": "ohos_lab_access_biometric",
+ "value": "ʹ֤"
+ },
+ {
+ "name": "ohos_desc_access_biometric",
+ "value": "Ӧʹ֤"
+ },
+ {
+ "name": "ohos_lab_access_biometric_internal",
+ "value": "ϵͳӦʹ֤"
+ },
+ {
+ "name": "ohos_desc_access_biometric_internal",
+ "value": "Ӧʹ֤"
+ },
+ {
+ "name": "ohos_lab_reset_biometric_lockout",
+ "value": "֤ʧܼ"
+ },
+ {
+ "name": "ohos_desc_reset_biometric_lockout",
+ "value": "Ӧ֤ʧܵļ"
+ },
+ {
+ "name": "ohos_lab_set_time",
+ "value": "ϵͳʱ"
+ },
+ {
+ "name": "ohos_desc_set_time",
+ "value": "Ӧϵͳʱ䡣"
+ },
+ {
+ "name": "ohos_lab_set_time_zone",
+ "value": "ϵͳʱ"
+ },
+ {
+ "name": "ohos_desc_set_time_zone",
+ "value": "Ӧϵͳʱ"
+ },
+ {
+ "name": "ohos_lab_download_session_manager",
+ "value": "Ự"
+ },
+ {
+ "name": "ohos_desc_download_session_manager",
+ "value": "ӦùỰ"
+ },
+ {
+ "name": "ohos_lab_commonevent_sticky",
+ "value": "ճԹ¼"
+ },
+ {
+ "name": "ohos_desc_commonevent_sticky",
+ "value": "Ӧ÷ճԹ¼"
+ },
+ {
+ "name": "ohos_lab_manage_local_accounts",
+ "value": "˻"
+ },
+ {
+ "name": "ohos_desc_manage_local_accounts",
+ "value": "ӦöԱ˻ɾIJ顣"
+ },
+ {
+ "name": "ohos_lab_interact_across_local_accounts",
+ "value": "˻"
+ },
+ {
+ "name": "ohos_desc_interact_across_local_accounts",
+ "value": "˺֮ʡ"
+ },
+ {
+ "name": "ohos_lab_vibrate",
+ "value": "ʹ"
+ },
+ {
+ "name": "ohos_desc_vibrate",
+ "value": "Ӧóʹ"
+ },
+ {
+ "name": "ohos_lab_activity_motion",
+ "value": "ȡû˶״̬"
+ },
+ {
+ "name": "ohos_desc_activity_motion",
+ "value": "Ӧóȡû˶״̬"
+ },
+ {
+ "name": "ohos_lab_read_health_data",
+ "value": "ȡûĽ"
+ },
+ {
+ "name": "ohos_desc_read_health_data",
+ "value": "ӦóȡûĽݡ"
+ },
+ {
+ "name": "ohos_lab_connect_ime_ability",
+ "value": "뷨Ӧ"
+ },
+ {
+ "name": "ohos_desc_connect_ime_ability",
+ "value": "뷨ܿôȨ档"
+ },
+ {
+ "name": "ohos_lab_set_wallpaper",
+ "value": "þֽ̬"
+ },
+ {
+ "name": "ohos_desc_set_wallpaper",
+ "value": "Ӧþֽ̬"
+ },
+ {
+ "name": "ohos_lab_get_wallpaper",
+ "value": "ȡֽļ"
+ },
+ {
+ "name": "ohos_desc_get_wallpaper",
+ "value": "Ӧöȡֽļ"
+ },
+ {
+ "name": "ohos_lab_interact_across_local_accounts_extension",
+ "value": "˻չ"
+ },
+ {
+ "name": "ohos_desc_interact_across_local_accounts_extension",
+ "value": "ӦÿźöӦõԽá"
+ },
+ {
+ "name": "ohos_lab_accelerometer",
+ "value": "ȡٶȴ"
+ },
+ {
+ "name": "ohos_desc_accelerometer",
+ "value": "Ӧóȡٶȴݡ"
+ },
+ {
+ "name": "ohos_lab_gyroscope",
+ "value": "ȡǴ"
+ },
+ {
+ "name": "ohos_desc_gyroscope",
+ "value": "ӦóȡǴݡ"
+ },
+ {
+ "name": "ohos_lab_set_telephony_state",
+ "value": "õ绰Ϣ"
+ },
+ {
+ "name": "ohos_desc_set_telephony_state",
+ "value": "Ӧtelephony״̬翪رշģʽģʽȡ"
+ },
+ {
+ "name": "ohos_lab_bundle_active_info",
+ "value": "ѯӦǰ̨̨ʱ"
+ },
+ {
+ "name": "ohos_desc_bundle_active_info",
+ "value": "ϵͳ/ȨӦòѯӦǰ̨̨ʱ䡣"
+ },
+ {
+ "name": "ohos_lab_publish_agent_reminder",
+ "value": ""
+ },
+ {
+ "name": "ohos_desc_publish_agent_reminder",
+ "value": "Ӧʹų́ѡ"
+ },
+ {
+ "name": "ohos_lab_control_task_sync_animator",
+ "value": "ͬ"
+ },
+ {
+ "name": "ohos_desc_control_task_sync_animator",
+ "value": "Ӧʹͬ"
+ },
+ {
+ "name": "ohos_lab_notification_controller",
+ "value": "ϵͳӿ"
+ },
+ {
+ "name": "ohos_desc_notification_controller",
+ "value": "Ӧʹ֪ͨӿڡ"
+ }
+ ]
+}
diff --git a/frameworks/accesstoken/BUILD.gn b/frameworks/accesstoken/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..b11ba2978b77b8614641ec42e3bad5ef30db3581
--- /dev/null
+++ b/frameworks/accesstoken/BUILD.gn
@@ -0,0 +1,52 @@
+# Copyright (c) 2021 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")
+
+################################################################
+# C++, Main source file here.
+################################################################
+config("accesstoken_communication_adapter_cxx_public_config") {
+ visibility = [ ":*" ]
+ include_dirs = [
+ "include",
+ "//base/security/access_token/interfaces/innerkits/accesstoken/main/cpp/include",
+ ]
+}
+
+ohos_shared_library("accesstoken_communication_adapter_cxx") {
+ subsystem_name = "security"
+ part_name = "access_token"
+
+ public_configs =
+ [ ":accesstoken_communication_adapter_cxx_public_config" ]
+
+ include_dirs = [
+ "include",
+ "//base/security/access_token/interfaces/innerkits/accesstoken/main/cpp/include",
+ "//utils/native/base/include",
+ ]
+
+ sources = [
+ "src/permission_def_parcel.cpp",
+ "src/permission_state_full_parcel.cpp",
+ "src/hap_policy_parcel.cpp",
+ "src/hap_token_info_parcel.cpp",
+ "src/hap_info_parcel.cpp",
+ "src/native_token_info_parcel.cpp"
+ ]
+
+ deps = [ "//utils/native/base:utils" ]
+
+ external_deps = [ "ipc:ipc_core" ]
+}
diff --git a/frameworks/accesstoken/include/hap_info_parcel.h b/frameworks/accesstoken/include/hap_info_parcel.h
new file mode 100644
index 0000000000000000000000000000000000000000..8f496175e23d78cc314654838ab443d6dc91fa3c
--- /dev/null
+++ b/frameworks/accesstoken/include/hap_info_parcel.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2021 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 HAP_INFO_PARCEL_H
+#define HAP_INFO_PARCEL_H
+
+#include "hap_token_info.h"
+
+#include "parcel.h"
+
+namespace OHOS {
+namespace Security {
+namespace AccessToken {
+struct HapInfoParcel final : public Parcelable {
+ HapInfoParcel() = default;
+
+ ~HapInfoParcel() override = default;
+
+ bool Marshalling(Parcel &out) const override;
+
+ static HapInfoParcel *Unmarshalling(Parcel &in);
+
+ HapInfoParams hapInfoParameter;
+};
+} // namespace AccessToken
+} // namespace Security
+} // namespace OHOS
+#endif // HAP_INFO_PARCEL_H
diff --git a/frameworks/accesstoken/include/hap_policy_parcel.h b/frameworks/accesstoken/include/hap_policy_parcel.h
new file mode 100644
index 0000000000000000000000000000000000000000..7886bfbeb7fff89c01ecba7eb4a6a7f712221129
--- /dev/null
+++ b/frameworks/accesstoken/include/hap_policy_parcel.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2021 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 HAP_POLICY_PARCEL_H
+#define HAP_POLICY_PARCEL_H
+
+#include "hap_token_info.h"
+#include "permission_def_parcel.h"
+#include "permission_state_full_parcel.h"
+
+
+namespace OHOS {
+namespace Security {
+namespace AccessToken {
+struct HapPolicyParcel final : public Parcelable {
+ HapPolicyParcel() = default;
+
+ ~HapPolicyParcel() override = default;
+
+ bool Marshalling(Parcel &out) const override;
+
+ static HapPolicyParcel *Unmarshalling(Parcel &in);
+
+ HapPolicyParams hapPolicyParameter;
+};
+} // namespace AccessToken
+} // namespace Security
+} // namespace OHOS
+#endif // HAP_POLICY_PARCEL_H
diff --git a/frameworks/accesstoken/include/hap_token_info_parcel.h b/frameworks/accesstoken/include/hap_token_info_parcel.h
new file mode 100644
index 0000000000000000000000000000000000000000..d13fda88a2ec7c89c5ab9be86f46f19db3d8841b
--- /dev/null
+++ b/frameworks/accesstoken/include/hap_token_info_parcel.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2021 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 HAP_TOKEN_INFO_PARCEL_H
+#define HAP_TOKEN_INFO_PARCEL_H
+
+#include "hap_token_info.h"
+
+#include "parcel.h"
+
+namespace OHOS {
+namespace Security {
+namespace AccessToken {
+struct HapTokenInfoParcel final : public Parcelable {
+ HapTokenInfoParcel() = default;
+
+ ~HapTokenInfoParcel() override = default;
+
+ bool Marshalling(Parcel &out) const override;
+
+ static HapTokenInfoParcel *Unmarshalling(Parcel &in);
+
+ HapTokenInfo hapTokenInfoParams;
+};
+} // namespace AccessToken
+} // namespace Security
+} // namespace OHOS
+#endif // HAP_TOKEN_INFO_PARCEL_H
diff --git a/frameworks/accesstoken/include/i_accesstoken_manager.h b/frameworks/accesstoken/include/i_accesstoken_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..aec6c78be4074d4045e73120b84fe278dc6df86a
--- /dev/null
+++ b/frameworks/accesstoken/include/i_accesstoken_manager.h
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2021 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 I_ACCESSTOKEN_MANAGER_H
+#define I_ACCESSTOKEN_MANAGER_H
+
+#include
+
+#include "iremote_broker.h"
+#include "errors.h"
+
+#include "access_token.h"
+#include "permission_def_parcel.h"
+#include "permission_state_full_parcel.h"
+#include "hap_policy_parcel.h"
+#include "hap_token_info_parcel.h"
+#include "hap_info_parcel.h"
+#include "native_token_info_parcel.h"
+
+namespace OHOS {
+namespace Security {
+namespace AccessToken {
+class IAccessTokenManager : public IRemoteBroker {
+public:
+ static const int SA_ID_ACCESSTOKEN_MANAGER_SERVICE = 3503;
+
+ DECLARE_INTERFACE_DESCRIPTOR(u"ohos.security.accesstoken.IAccessTokenManager");
+
+ virtual int VerifyAccessToken(AccessTokenID tokenID, const std::string& permissionName) = 0;
+ virtual int GetDefPermission(const std::string& permissionName, PermissionDefParcel& permissionDefResult) = 0;
+ virtual int GetDefPermissions(AccessTokenID tokenID, std::vector& permList) = 0;
+ virtual int GetReqPermissions(
+ AccessTokenID tokenID, std::vector& reqPermList, bool isSystemGrant) = 0;
+ virtual int GetPermissionFlag(AccessTokenID tokenID, const std::string& permissionName) = 0;
+ virtual int GrantPermission(AccessTokenID tokenID, const std::string& permissionName, int flag) = 0;
+ virtual int RevokePermission(AccessTokenID tokenID, const std::string& permissionName, int flag) = 0;
+ virtual int ClearUserGrantedPermissionState(AccessTokenID tokenID) = 0;
+ virtual AccessTokenIDEx AllocHapToken(const HapInfoParcel& hapInfo, const HapPolicyParcel& policyParcel) = 0;
+ virtual int DeleteToken(AccessTokenID tokenID) = 0;
+ virtual int GetTokenType(AccessTokenID tokenID) = 0;
+ virtual int CheckNativeDCap(AccessTokenID tokenID, const std::string& dcap) = 0;
+ virtual AccessTokenID GetHapTokenID(int userID, const std::string& bundleName, int instIndex) = 0;
+ virtual AccessTokenID AllocLocalTokenID(const std::string& remoteDeviceID, AccessTokenID remoteTokenID) = 0;
+ virtual int GetNativeTokenInfo(AccessTokenID tokenID, NativeTokenInfoParcel& nativeTokenInfoRes) = 0;
+ virtual int GetHapTokenInfo(AccessTokenID tokenID, HapTokenInfoParcel& hapTokenInfoRes) = 0;
+ virtual int UpdateHapToken(
+ AccessTokenID tokenID, const std::string& appIDDesc, const HapPolicyParcel& policyParcel) = 0;
+
+ enum class InterfaceCode {
+ VERIFY_ACCESSTOKEN = 0xff10,
+ GET_DEF_PERMISSION = 0xff11,
+ GET_DEF_PERMISSIONS = 0xff12,
+ GET_REQ_PERMISSIONS = 0xff13,
+ GET_PERMISSION_FLAG = 0xff14,
+ GRANT_PERMISSION = 0xff15,
+ REVOKE_PERMISSION = 0xff16,
+ CLEAR_USER_GRANT_PERMISSION = 0xff17,
+ ALLOC_TOKEN_HAP = 0xff18,
+ TOKEN_DELETE = 0xff19,
+ GET_TOKEN_TYPE = 0xff20,
+ CHECK_NATIVE_DCAP = 0xff21,
+ GET_HAP_TOKEN_ID = 0xff22,
+ ALLOC_LOCAL_TOKEN_ID = 0xff23,
+ GET_NATIVE_TOKENINFO = 0xff24,
+ GET_HAP_TOKENINFO = 0xff25,
+ UPDATE_HAP_TOKEN = 0xff26,
+ };
+};
+} // namespace AccessToken
+} // namespace Security
+} // namespace OHOS
+
+#endif // I_ACCESSTOKEN_MANAGER_H
diff --git a/frameworks/accesstoken/include/native_token_info_parcel.h b/frameworks/accesstoken/include/native_token_info_parcel.h
new file mode 100644
index 0000000000000000000000000000000000000000..80bf8909cba6cc20826ab2b4276572fc058f91dc
--- /dev/null
+++ b/frameworks/accesstoken/include/native_token_info_parcel.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2021 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 NATIVE_TOKEN_INFO_PARCEL_H
+#define NATIVE_TOKEN_INFO_PARCEL_H
+
+#include "native_token_info.h"
+
+#include "parcel.h"
+
+namespace OHOS {
+namespace Security {
+namespace AccessToken {
+struct NativeTokenInfoParcel final : public Parcelable {
+ NativeTokenInfoParcel() = default;
+
+ ~NativeTokenInfoParcel() override = default;
+
+ bool Marshalling(Parcel &out) const override;
+
+ static NativeTokenInfoParcel *Unmarshalling(Parcel &in);
+
+ NativeTokenInfo nativeTokenInfoParams;
+};
+} // namespace AccessToken
+} // namespace Security
+} // namespace OHOS
+#endif // NATIVE_TOKEN_INFO_PARCEL_H
diff --git a/frameworks/accesstoken/include/permission_def_parcel.h b/frameworks/accesstoken/include/permission_def_parcel.h
new file mode 100644
index 0000000000000000000000000000000000000000..52e0a80c4197ea155f98ba126a7c13df22ac02f1
--- /dev/null
+++ b/frameworks/accesstoken/include/permission_def_parcel.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2021 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_DEF_PARCEL_H
+#define PERMISSION_DEF_PARCEL_H
+
+#include "permission_def.h"
+#include "parcel.h"
+
+namespace OHOS {
+namespace Security {
+namespace AccessToken {
+struct PermissionDefParcel final : public Parcelable {
+ PermissionDefParcel() = default;
+
+ ~PermissionDefParcel() override = default;
+
+ bool Marshalling(Parcel &out) const override;
+
+ static PermissionDefParcel *Unmarshalling(Parcel &in);
+
+ PermissionDef permissionDef;
+};
+} // namespace AccessToken
+} // namespace Security
+} // namespace OHOS
+#endif // PERMISSION_DEF_PARCEL_H
diff --git a/frameworks/accesstoken/include/permission_state_full_parcel.h b/frameworks/accesstoken/include/permission_state_full_parcel.h
new file mode 100644
index 0000000000000000000000000000000000000000..f4b8714a7a832d6291adff4992eee953e60f8994
--- /dev/null
+++ b/frameworks/accesstoken/include/permission_state_full_parcel.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2021 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 INTERFACES_INNER_KITS_PERMISSION_PERMISSION_STATE_FULL_PARCEL_H
+#define INTERFACES_INNER_KITS_PERMISSION_PERMISSION_STATE_FULL_PARCEL_H
+
+#include "permission_state_full.h"
+#include "parcel.h"
+
+namespace OHOS {
+namespace Security {
+namespace AccessToken {
+struct PermissionStateFullParcel final : public Parcelable {
+ PermissionStateFullParcel() = default;
+
+ ~PermissionStateFullParcel() override = default;
+
+ bool Marshalling(Parcel &out) const override;
+
+ static PermissionStateFullParcel *Unmarshalling(Parcel &in);
+
+ PermissionStateFull permStatFull;
+};
+} // namespace AccessToken
+} // namespace Security
+} // namespace OHOS
+#endif // INTERFACES_INNER_KITS_PERMISSION_PERMISSION_STATE_FULL_PARCEL_H
diff --git a/frameworks/accesstoken/src/hap_info_parcel.cpp b/frameworks/accesstoken/src/hap_info_parcel.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c0e3d984a4e0764e108080ab227cf5a97b3088c9
--- /dev/null
+++ b/frameworks/accesstoken/src/hap_info_parcel.cpp
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2021 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 "hap_info_parcel.h"
+
+namespace OHOS {
+namespace Security {
+namespace AccessToken {
+#define RETURN_IF_FALSE(expr) \
+ if (!(expr)) { \
+ return false; \
+ }
+
+#define RELEASE_IF_FALSE(expr, obj) \
+ if (!(expr)) { \
+ delete (obj); \
+ (obj) = nullptr; \
+ return (obj); \
+ }
+
+bool HapInfoParcel::Marshalling(Parcel& out) const
+{
+ RETURN_IF_FALSE(out.WriteInt32(this->hapInfoParameter.userID));
+ RETURN_IF_FALSE(out.WriteString(this->hapInfoParameter.bundleName));
+ RETURN_IF_FALSE(out.WriteInt32(this->hapInfoParameter.instIndex));
+ RETURN_IF_FALSE(out.WriteString(this->hapInfoParameter.appIDDesc));
+ return true;
+}
+
+HapInfoParcel* HapInfoParcel::Unmarshalling(Parcel& in)
+{
+ auto* hapInfoParcel = new (std::nothrow) HapInfoParcel();
+ RELEASE_IF_FALSE(hapInfoParcel != nullptr, hapInfoParcel);
+ RELEASE_IF_FALSE(in.ReadInt32(hapInfoParcel->hapInfoParameter.userID), hapInfoParcel);
+ hapInfoParcel->hapInfoParameter.bundleName = in.ReadString();
+ RELEASE_IF_FALSE(in.ReadInt32(hapInfoParcel->hapInfoParameter.instIndex), hapInfoParcel);
+ hapInfoParcel->hapInfoParameter.appIDDesc = in.ReadString();
+
+ return hapInfoParcel;
+}
+} // namespace AccessToken
+} // namespace Security
+} // namespace OHOS
diff --git a/frameworks/accesstoken/src/hap_policy_parcel.cpp b/frameworks/accesstoken/src/hap_policy_parcel.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0c14d15a3f7e6071cec75b31892685113ea889cd
--- /dev/null
+++ b/frameworks/accesstoken/src/hap_policy_parcel.cpp
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2021 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 "hap_policy_parcel.h"
+
+namespace OHOS {
+namespace Security {
+namespace AccessToken {
+#define RETURN_IF_FALSE(expr) \
+ if (!(expr)) { \
+ return false; \
+ }
+
+#define RELEASE_IF_FALSE(expr, obj) \
+ if (!(expr)) { \
+ delete (obj); \
+ (obj) = nullptr; \
+ return (obj); \
+ }
+
+bool HapPolicyParcel::Marshalling(Parcel& out) const
+{
+ RETURN_IF_FALSE(out.WriteInt32(this->hapPolicyParameter.apl));
+ RETURN_IF_FALSE(out.WriteString(this->hapPolicyParameter.domain));
+
+ const std::vector& permList = this->hapPolicyParameter.permList;
+ int permListSize = permList.size();
+ RETURN_IF_FALSE(out.WriteInt32(permListSize));
+
+ for (int i = 0; i < permListSize; i++) {
+ PermissionDefParcel permDefParcel;
+ permDefParcel.permissionDef = permList[i];
+ out.WriteParcelable(&permDefParcel);
+ }
+
+ const std::vector& permStateList = this->hapPolicyParameter.permStateList;
+ int permStateListSize = permStateList.size();
+ RETURN_IF_FALSE(out.WriteInt32(permStateListSize));
+
+ for (int i = 0; i < permStateListSize; i++) {
+ PermissionStateFullParcel permStateParcel;
+ permStateParcel.permStatFull = permStateList[i];
+ out.WriteParcelable(&permStateParcel);
+ }
+
+ return true;
+}
+
+HapPolicyParcel* HapPolicyParcel::Unmarshalling(Parcel& in)
+{
+ auto* hapPolicyParcel = new (std::nothrow) HapPolicyParcel();
+ RELEASE_IF_FALSE(hapPolicyParcel != nullptr, hapPolicyParcel);
+
+ int32_t apl;
+ RELEASE_IF_FALSE(in.ReadInt32(apl), hapPolicyParcel);
+ hapPolicyParcel->hapPolicyParameter.apl = ATokenAplEnum(apl);
+
+ hapPolicyParcel->hapPolicyParameter.domain = in.ReadString();
+
+ int permListSize;
+ RELEASE_IF_FALSE(in.ReadInt32(permListSize), hapPolicyParcel);
+
+ for (int i = 0; i < permListSize; i++) {
+ sptr permDefParcel = in.ReadParcelable();
+ RELEASE_IF_FALSE(permDefParcel != nullptr, hapPolicyParcel);
+ hapPolicyParcel->hapPolicyParameter.permList.emplace_back(permDefParcel->permissionDef);
+ }
+
+ int permStateListSize;
+ RELEASE_IF_FALSE(in.ReadInt32(permStateListSize), hapPolicyParcel);
+ for (int i = 0; i < permStateListSize; i++) {
+ sptr permissionStateParcel = in.ReadParcelable();
+ RELEASE_IF_FALSE(permissionStateParcel != nullptr, hapPolicyParcel);
+ hapPolicyParcel->hapPolicyParameter.permStateList.emplace_back(permissionStateParcel->permStatFull);
+ }
+ return hapPolicyParcel;
+}
+} // namespace AccessToken
+} // namespace Security
+} // namespace OHOS
\ No newline at end of file
diff --git a/frameworks/accesstoken/src/hap_token_info_parcel.cpp b/frameworks/accesstoken/src/hap_token_info_parcel.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5d5c2c519b97f1a957a1b0cde687d36f9a6e6f43
--- /dev/null
+++ b/frameworks/accesstoken/src/hap_token_info_parcel.cpp
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2021 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 "hap_token_info_parcel.h"
+
+namespace OHOS {
+namespace Security {
+namespace AccessToken {
+#define RETURN_IF_FALSE(expr) \
+ if (!(expr)) { \
+ return false; \
+ }
+
+#define RELEASE_IF_FALSE(expr, obj) \
+ if (!(expr)) { \
+ delete (obj); \
+ (obj) = nullptr; \
+ return (obj); \
+ }
+
+bool HapTokenInfoParcel::Marshalling(Parcel& out) const
+{
+ RETURN_IF_FALSE(out.WriteInt32(this->hapTokenInfoParams.apl));
+ RETURN_IF_FALSE(out.WriteUint8(this->hapTokenInfoParams.ver));
+ RETURN_IF_FALSE(out.WriteInt32(this->hapTokenInfoParams.userID));
+ RETURN_IF_FALSE(out.WriteString(this->hapTokenInfoParams.bundleName));
+ RETURN_IF_FALSE(out.WriteInt32(this->hapTokenInfoParams.instIndex));
+ RETURN_IF_FALSE(out.WriteString(this->hapTokenInfoParams.appID));
+ RETURN_IF_FALSE(out.WriteString(this->hapTokenInfoParams.deviceID));
+ RETURN_IF_FALSE(out.WriteUint32(this->hapTokenInfoParams.tokenID));
+ RETURN_IF_FALSE(out.WriteUint32(this->hapTokenInfoParams.tokenAttr));
+ return true;
+}
+
+HapTokenInfoParcel* HapTokenInfoParcel::Unmarshalling(Parcel& in)
+{
+ auto* hapTokenInfoParcel = new (std::nothrow) HapTokenInfoParcel();
+ RELEASE_IF_FALSE(hapTokenInfoParcel != nullptr, hapTokenInfoParcel);
+ int apl;
+ int8_t ver;
+ RELEASE_IF_FALSE(in.ReadInt32(apl), hapTokenInfoParcel);
+ hapTokenInfoParcel->hapTokenInfoParams.apl = ATokenAplEnum(apl);
+ RELEASE_IF_FALSE(in.ReadInt8(ver), hapTokenInfoParcel);
+ hapTokenInfoParcel->hapTokenInfoParams.ver = ver;
+ RELEASE_IF_FALSE(in.ReadInt32(hapTokenInfoParcel->hapTokenInfoParams.userID), hapTokenInfoParcel);
+ hapTokenInfoParcel->hapTokenInfoParams.bundleName = in.ReadString();
+ RELEASE_IF_FALSE(in.ReadInt32(hapTokenInfoParcel->hapTokenInfoParams.instIndex), hapTokenInfoParcel);
+ hapTokenInfoParcel->hapTokenInfoParams.appID = in.ReadString();
+ hapTokenInfoParcel->hapTokenInfoParams.deviceID = in.ReadString();
+ RELEASE_IF_FALSE(in.ReadUint32(hapTokenInfoParcel->hapTokenInfoParams.tokenID), hapTokenInfoParcel);
+ RELEASE_IF_FALSE(in.ReadUint32(hapTokenInfoParcel->hapTokenInfoParams.tokenAttr), hapTokenInfoParcel);
+ return hapTokenInfoParcel;
+}
+} // namespace AccessToken
+} // namespace Security
+} // namespace OHOS
\ No newline at end of file
diff --git a/frameworks/accesstoken/src/native_token_info_parcel.cpp b/frameworks/accesstoken/src/native_token_info_parcel.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f623cfd0b5b03779800e14af87cb544952c2bdc6
--- /dev/null
+++ b/frameworks/accesstoken/src/native_token_info_parcel.cpp
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2021 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 "native_token_info_parcel.h"
+
+namespace OHOS {
+namespace Security {
+namespace AccessToken {
+#define RETURN_IF_FALSE(expr) \
+ if (!(expr)) { \
+ return false; \
+ }
+
+#define RELEASE_IF_FALSE(expr, obj) \
+ if (!(expr)) { \
+ delete (obj); \
+ (obj) = nullptr; \
+ return (obj); \
+ }
+
+bool NativeTokenInfoParcel::Marshalling(Parcel& out) const
+{
+ RETURN_IF_FALSE(out.WriteInt32(this->nativeTokenInfoParams.apl));
+ RETURN_IF_FALSE(out.WriteUint8(this->nativeTokenInfoParams.ver));
+ RETURN_IF_FALSE(out.WriteString(this->nativeTokenInfoParams.processName));
+ RETURN_IF_FALSE(out.WriteUint32(this->nativeTokenInfoParams.tokenID));
+ RETURN_IF_FALSE(out.WriteUint32(this->nativeTokenInfoParams.tokenAttr));
+
+ int dcapSize = (this->nativeTokenInfoParams.dcap).size();
+ RETURN_IF_FALSE(out.WriteInt32(dcapSize));
+
+ for (int i = 0; i < dcapSize; i++) {
+ RETURN_IF_FALSE(out.WriteString(this->nativeTokenInfoParams.dcap[i]));
+ }
+
+ return true;
+}
+
+NativeTokenInfoParcel* NativeTokenInfoParcel::Unmarshalling(Parcel& in)
+{
+ auto* nativeTokenInfoParcel = new (std::nothrow) NativeTokenInfoParcel();
+ RELEASE_IF_FALSE(nativeTokenInfoParcel != nullptr, nativeTokenInfoParcel);
+
+ int32_t apl;
+ int8_t ver;
+ RELEASE_IF_FALSE(in.ReadInt32(apl), nativeTokenInfoParcel);
+ RELEASE_IF_FALSE(in.ReadInt8(ver), nativeTokenInfoParcel);
+ nativeTokenInfoParcel->nativeTokenInfoParams.apl = ATokenAplEnum(apl);
+ nativeTokenInfoParcel->nativeTokenInfoParams.ver = ver;
+
+ nativeTokenInfoParcel->nativeTokenInfoParams.processName = in.ReadString();
+ RELEASE_IF_FALSE(in.ReadUint32(nativeTokenInfoParcel->nativeTokenInfoParams.tokenID), nativeTokenInfoParcel);
+ RELEASE_IF_FALSE(in.ReadUint32(nativeTokenInfoParcel->nativeTokenInfoParams.tokenAttr), nativeTokenInfoParcel);
+
+ int dcapSize;
+ RELEASE_IF_FALSE(in.ReadInt32(dcapSize), nativeTokenInfoParcel);
+
+ for (int i = 0; i < dcapSize; i++) {
+ nativeTokenInfoParcel->nativeTokenInfoParams.dcap[i] = in.ReadString();
+ }
+ return nativeTokenInfoParcel;
+}
+} // namespace AccessToken
+} // namespace Security
+} // namespace OHOS
\ No newline at end of file
diff --git a/frameworks/accesstoken/src/permission_def_parcel.cpp b/frameworks/accesstoken/src/permission_def_parcel.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..421731e9fc248aa3949a168432b48bfdd0b645c2
--- /dev/null
+++ b/frameworks/accesstoken/src/permission_def_parcel.cpp
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2021 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_def_parcel.h"
+
+namespace OHOS {
+namespace Security {
+namespace AccessToken {
+#define RETURN_IF_FALSE(expr) \
+ if (!(expr)) { \
+ return false; \
+ }
+
+#define RELEASE_IF_FALSE(expr, obj) \
+ if (!(expr)) { \
+ delete (obj); \
+ (obj) = nullptr; \
+ return (obj); \
+ }
+
+bool PermissionDefParcel::Marshalling(Parcel& out) const
+{
+ RETURN_IF_FALSE(out.WriteString(this->permissionDef.permissionName));
+ RETURN_IF_FALSE(out.WriteString(this->permissionDef.bundleName));
+ RETURN_IF_FALSE(out.WriteInt32(this->permissionDef.grantMode));
+ RETURN_IF_FALSE(out.WriteInt32(this->permissionDef.availableScope));
+ RETURN_IF_FALSE(out.WriteString(this->permissionDef.label));
+ RETURN_IF_FALSE(out.WriteInt32(this->permissionDef.labelId));
+ RETURN_IF_FALSE(out.WriteString(this->permissionDef.description));
+ RETURN_IF_FALSE(out.WriteInt32(this->permissionDef.descriptionId));
+ return true;
+}
+
+PermissionDefParcel* PermissionDefParcel::Unmarshalling(Parcel& in)
+{
+ auto* permissionDefParcel = new (std::nothrow) PermissionDefParcel();
+ RELEASE_IF_FALSE(permissionDefParcel != nullptr, permissionDefParcel);
+ permissionDefParcel->permissionDef.permissionName = in.ReadString();
+ permissionDefParcel->permissionDef.bundleName = in.ReadString();
+ RELEASE_IF_FALSE(in.ReadInt32(permissionDefParcel->permissionDef.grantMode), permissionDefParcel);
+ RELEASE_IF_FALSE(in.ReadInt32(permissionDefParcel->permissionDef.availableScope), permissionDefParcel);
+ permissionDefParcel->permissionDef.label = in.ReadString();
+ RELEASE_IF_FALSE(in.ReadInt32(permissionDefParcel->permissionDef.labelId), permissionDefParcel);
+ permissionDefParcel->permissionDef.description = in.ReadString();
+ RELEASE_IF_FALSE(in.ReadInt32(permissionDefParcel->permissionDef.descriptionId), permissionDefParcel);
+ return permissionDefParcel;
+}
+} // namespace AccessToken
+} // namespace Security
+} // namespace OHOS
\ No newline at end of file
diff --git a/frameworks/accesstoken/src/permission_state_full_parcel.cpp b/frameworks/accesstoken/src/permission_state_full_parcel.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..50ce4bf2b09293e45639d0dbc7082fac5359ad74
--- /dev/null
+++ b/frameworks/accesstoken/src/permission_state_full_parcel.cpp
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2021 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_state_full_parcel.h"
+
+namespace OHOS {
+namespace Security {
+namespace AccessToken {
+#define RETURN_IF_FALSE(expr) \
+ if (!(expr)) { \
+ return false; \
+ }
+
+#define RELEASE_IF_FALSE(expr, obj) \
+ if (!(expr)) { \
+ delete (obj); \
+ (obj) = nullptr; \
+ return (obj); \
+ }
+
+bool PermissionStateFullParcel::Marshalling(Parcel& out) const
+{
+ RETURN_IF_FALSE(out.WriteString(this->permStatFull.permissionName));
+ RETURN_IF_FALSE(out.WriteBool(this->permStatFull.isGeneral));
+
+ RETURN_IF_FALSE(out.WriteInt32(this->permStatFull.resDeviceID.size()));
+ for (auto devId : this->permStatFull.resDeviceID) {
+ RETURN_IF_FALSE(out.WriteString(devId));
+ }
+
+ RETURN_IF_FALSE(out.WriteInt32(this->permStatFull.grantStatus.size()));
+ for (auto grantStat : this->permStatFull.grantStatus) {
+ RETURN_IF_FALSE(out.WriteInt32(grantStat));
+ }
+
+ RETURN_IF_FALSE(out.WriteInt32(this->permStatFull.grantFlags.size()));
+ for (auto grantFlag : this->permStatFull.grantFlags) {
+ RETURN_IF_FALSE(out.WriteInt32(grantFlag));
+ }
+ return true;
+}
+
+PermissionStateFullParcel* PermissionStateFullParcel::Unmarshalling(Parcel& in)
+{
+ auto* permissionStateParcel = new (std::nothrow) PermissionStateFullParcel();
+ RELEASE_IF_FALSE(permissionStateParcel != nullptr, permissionStateParcel);
+
+ RELEASE_IF_FALSE(in.ReadString(permissionStateParcel->permStatFull.permissionName), permissionStateParcel);
+ RELEASE_IF_FALSE(in.ReadBool(permissionStateParcel->permStatFull.isGeneral), permissionStateParcel);
+
+ int resIdSize = 0;
+ RELEASE_IF_FALSE(in.ReadInt32(resIdSize), permissionStateParcel);
+ for (int i = 0; i < resIdSize; i++) {
+ std::string resId;
+ RELEASE_IF_FALSE(in.ReadString(resId), permissionStateParcel);
+ permissionStateParcel->permStatFull.resDeviceID.emplace_back(resId);
+ }
+
+ int grantStatsSize = 0;
+ RELEASE_IF_FALSE(in.ReadInt32(grantStatsSize), permissionStateParcel);
+ for (int i = 0; i < grantStatsSize; i++) {
+ int grantStat;
+ RELEASE_IF_FALSE(in.ReadInt32(grantStat), permissionStateParcel);
+ permissionStateParcel->permStatFull.grantStatus.emplace_back(grantStat);
+ }
+
+ int grantFlagSize = 0;
+ RELEASE_IF_FALSE(in.ReadInt32(grantFlagSize), permissionStateParcel);
+ for (int i = 0; i < grantFlagSize; i++) {
+ int flag;
+ RELEASE_IF_FALSE(in.ReadInt32(flag), permissionStateParcel);
+ permissionStateParcel->permStatFull.grantFlags.emplace_back(flag);
+ }
+ return permissionStateParcel;
+}
+} // namespace AccessToken
+} // namespace Security
+} // namespace OHOS
\ No newline at end of file
diff --git a/frameworks/common/BUILD.gn b/frameworks/common/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..b63c67b3c222d47a82255414167f29f5121f59f8
--- /dev/null
+++ b/frameworks/common/BUILD.gn
@@ -0,0 +1,49 @@
+# Copyright (c) 2021 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")
+
+################################################################
+# C++, Main source file here.
+################################################################
+config("accesstoken_common_cxx_public_config") {
+ visibility = [ ":*" ]
+ include_dirs = [ "main/cpp/include" ]
+}
+
+ohos_shared_library("accesstoken_common_cxx") {
+ subsystem_name = "security"
+ part_name = "access_token"
+
+ public_configs = [ ":accesstoken_common_cxx_public_config" ]
+
+ include_dirs = [
+ "include",
+ "//utils/system/safwk/native/include",
+ "//third_party/mbedtls/include",
+ "//base/security/access_token/interfaces/innerkits/accesstoken/main/cpp/include",
+ ]
+
+ sources = [
+ "src/data_validator.cpp",
+ "src/random_mbedtls.cpp"
+ ]
+
+ deps = [
+ "//utils/native/base:utils",
+ "//third_party/mbedtls:mbedtls_shared",
+ ]
+ external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
+
+ cflags_cc = [ "-DHILOG_ENABLE" ]
+}
diff --git a/frameworks/common/include/accesstoken_log.h b/frameworks/common/include/accesstoken_log.h
new file mode 100644
index 0000000000000000000000000000000000000000..3fb142587227c69a27538bb953da33d1b954b74a
--- /dev/null
+++ b/frameworks/common/include/accesstoken_log.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2021 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_LOG_H
+#define ACCESSTOKEN_LOG_H
+
+#ifdef HILOG_ENABLE
+
+#include "hilog/log.h"
+
+#ifndef __cplusplus
+
+#define ACCESSTOKEN_LOG_DEBUG(fmt, ...) HILOG_DEBUG(LOG_CORE, fmt, ##__VA_ARGS__)
+#define ACCESSTOKEN_LOG_INFO(fmt, ...) HILOG_INFO(LOG_CORE, fmt, ##__VA_ARGS__)
+#define ACCESSTOKEN_LOG_WARN(fmt, ...) HILOG_WARN(LOG_CORE, fmt, ##__VA_ARGS__)
+#define ACCESSTOKEN_LOG_ERROR(fmt, ...) HILOG_ERROR(LOG_CORE, fmt, ##__VA_ARGS__)
+#define ACCESSTOKEN_LOG_FATAL(fmt, ...) HILOG_FATAL(LOG_CORE, fmt, ##__VA_ARGS__)
+
+#else
+
+#define ACCESSTOKEN_LOG_DEBUG(label, fmt, ...) OHOS::HiviewDFX::HiLog::Debug(label, fmt, ##__VA_ARGS__)
+#define ACCESSTOKEN_LOG_INFO(label, fmt, ...) OHOS::HiviewDFX::HiLog::Info(label, fmt, ##__VA_ARGS__)
+#define ACCESSTOKEN_LOG_WARN(label, fmt, ...) OHOS::HiviewDFX::HiLog::Warn(label, fmt, ##__VA_ARGS__)
+#define ACCESSTOKEN_LOG_ERROR(label, fmt, ...) OHOS::HiviewDFX::HiLog::Error(label, fmt, ##__VA_ARGS__)
+#define ACCESSTOKEN_LOG_FATAL(label, fmt, ...) OHOS::HiviewDFX::HiLog::Fatal(label, fmt, ##__VA_ARGS__)
+
+#endif // __cplusplus
+
+/* define LOG_TAG as "security_*" at your submodule, * means your submodule name such as "security_dac" */
+#undef LOG_TAG
+#undef LOG_DOMAIN
+
+static constexpr unsigned int SECURITY_DOMAIN_ACCESSTOKEN = 0xD002F01;
+
+#else
+
+#include
+#include
+
+/* define LOG_TAG as "security_*" at your submodule, * means your submodule name such as "security_dac" */
+#undef LOG_TAG
+
+#define ACCESSTOKEN_LOG_DEBUG(fmt, ...) printf("[%s] debug: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__)
+#define ACCESSTOKEN_LOG_INFO(fmt, ...) printf("[%s] info: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__)
+#define ACCESSTOKEN_LOG_WARN(fmt, ...) printf("[%s] warn: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__)
+#define ACCESSTOKEN_LOG_ERROR(fmt, ...) printf("[%s] error: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__)
+#define ACCESSTOKEN_LOG_FATAL(fmt, ...) printf("[%s] fatal: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__)
+
+#endif // HILOG_ENABLE
+
+#endif // ACCESSTOKEN_LOG_H
diff --git a/frameworks/common/include/data_validator.h b/frameworks/common/include/data_validator.h
new file mode 100644
index 0000000000000000000000000000000000000000..dc486baa6bf0c7867926fe759d38a6e567a37d74
--- /dev/null
+++ b/frameworks/common/include/data_validator.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2021 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
+
+#ifndef DATA_VALIDATOR_H
+#define DATA_VALIDATOR_H
+namespace OHOS {
+namespace Security {
+namespace AccessToken {
+class DataValidator final {
+public:
+ static bool IsBundleNameValid(const std::string& bundleName);
+
+ static bool IsPermissionNameValid(const std::string& permissionName);
+
+ static bool IsUserIdValid(const int userId);
+
+ static bool IsAppIDDescValid(const std::string& appIDDesc);
+
+ static bool IsDomainValid(const std::string& domain);
+
+ static bool IsAplNumValid(const int apl);
+private:
+ const static int MAX_LENGTH = 256;
+};
+} // namespace AccessToken
+} // namespace Security
+} // namespace OHOS
+#endif // DATA_VALIDATOR_H
diff --git a/frameworks/common/include/random.h b/frameworks/common/include/random.h
new file mode 100644
index 0000000000000000000000000000000000000000..9362764210314841612be570b5edb67170e0b3ad
--- /dev/null
+++ b/frameworks/common/include/random.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2021 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_RANDOM_H
+#define ACCESSTOKEN_RANDOM_H
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif
+#endif
+
+unsigned int GetRandomUint32();
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+#endif /* ACCESSTOKEN_RANDOM_H */
diff --git a/frameworks/common/include/random_mbedtls.h b/frameworks/common/include/random_mbedtls.h
new file mode 100644
index 0000000000000000000000000000000000000000..ffd3ddd147ee2478af4cac6e74196d9c27f455ce
--- /dev/null
+++ b/frameworks/common/include/random_mbedtls.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2021 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 ACCESS_TOKEN_RANDOM_MBEDTLS
+#define ACCESS_TOKEN_RANDOM_MBEDTLS
+
+#include "rwlock.h"
+#include "mbedtls/ctr_drbg.h"
+#include "mbedtls/entropy.h"
+
+namespace OHOS {
+namespace Security {
+namespace AccessToken {
+class RandomMbedtls {
+public:
+ static RandomMbedtls& GetInstance();
+ int GenerateRandomArray(unsigned char *randStr, unsigned int len);
+ ~RandomMbedtls() {};
+ static unsigned int GetRandomUint32();
+
+private:
+ RandomMbedtls() : initFlag_(false) {};
+ mbedtls_entropy_context entropy_;
+ mbedtls_ctr_drbg_context ctrDrbg_;
+ OHOS::Utils::RWLock randomLock_;
+ bool initFlag_;
+};
+} // namespace AccessToken
+} // namespace Security
+} // namespace OHOS
+#endif // ACCESS_TOKEN_RANDOM_MBEDTLS
diff --git a/frameworks/common/src/data_validator.cpp b/frameworks/common/src/data_validator.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8928c3d777aa95c540d53d04230e4e5a56ed8627
--- /dev/null
+++ b/frameworks/common/src/data_validator.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2021 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 "data_validator.h"
+#include "access_token.h"
+
+namespace OHOS {
+namespace Security {
+namespace AccessToken {
+bool DataValidator::IsBundleNameValid(const std::string& bundleName)
+{
+ return !bundleName.empty() && (bundleName.length() <= MAX_LENGTH);
+}
+
+bool DataValidator::IsPermissionNameValid(const std::string& permissionName)
+{
+ return !permissionName.empty() && (permissionName.length() <= MAX_LENGTH);
+}
+
+bool DataValidator::IsUserIdValid(const int userId)
+{
+ return userId >= 0;
+}
+
+bool DataValidator::IsAppIDDescValid(const std::string& appIDDesc)
+{
+ return !appIDDesc.empty() && (appIDDesc.length() <= MAX_LENGTH);
+}
+
+bool DataValidator::IsDomainValid(const std::string& domain)
+{
+ return !domain.empty() && (domain.length() <= MAX_LENGTH);
+}
+
+bool DataValidator::IsAplNumValid(const int apl)
+{
+ return (apl == APL_NORMAL || apl == APL_SYSTEM_BASIC || apl == APL_SYSTEM_CORE);
+}
+} // namespace AccessToken
+} // namespace Security
+} // namespace OHOS
diff --git a/frameworks/common/src/random_mbedtls.cpp b/frameworks/common/src/random_mbedtls.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..20d7dfbbcaf6e4d50df90e605e5ccdbbb1fec644
--- /dev/null
+++ b/frameworks/common/src/random_mbedtls.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2021 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 "random_mbedtls.h"
+#include "access_token.h"
+
+using OHOS::Security::AccessToken::RandomMbedtls;
+using OHOS::Security::AccessToken::RET_SUCCESS;
+
+namespace OHOS {
+namespace Security {
+namespace AccessToken {
+extern "C" unsigned int GetRandomUint32()
+{
+ unsigned int rand;
+ int ret = RandomMbedtls::GetInstance().GenerateRandomArray((unsigned char *)&rand, sizeof(rand));
+ if (ret != RET_SUCCESS) {
+ return 0;
+ }
+ return rand;
+}
+
+int RandomMbedtls::GenerateRandomArray(unsigned char *randStr, unsigned int len)
+{
+ if (randStr == NULL || len == 0) {
+ return RET_FAILED;
+ }
+ int ret;
+
+ Utils::UniqueWriteGuard infoGuard(this->randomLock_);
+ if (initFlag_ == false) {
+ mbedtls_ctr_drbg_init(&ctrDrbg_);
+ mbedtls_entropy_init(&entropy_);
+ ret = mbedtls_ctr_drbg_seed(&ctrDrbg_, mbedtls_entropy_func, &entropy_, NULL, 0);
+ if (ret != 0) {
+ return RET_FAILED;
+ }
+ initFlag_ = true;
+ }
+
+ ret = mbedtls_ctr_drbg_random(&ctrDrbg_, randStr, len);
+ if (ret != 0) {
+ return RET_FAILED;
+ }
+ return RET_SUCCESS;
+}
+
+RandomMbedtls& RandomMbedtls::GetInstance()
+{
+ static RandomMbedtls instance;
+ return instance;
+}
+} // namespace AccessToken
+} // namespace Security
+} // namespace OHOS
diff --git a/frameworks/tokensync/include/i_tokensync_manager.h b/frameworks/tokensync/include/i_tokensync_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..9a2769ee3d8b13a291b23c949bfab9852ddaccea
--- /dev/null
+++ b/frameworks/tokensync/include/i_tokensync_manager.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2021 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 I_TOKENSYNC_MANAGER_H
+#define I_TOKENSYNC_MANAGER_H
+
+#include
+
+#include "iremote_broker.h"
+#include "errors.h"
+
+namespace OHOS {
+namespace Security {
+namespace TokenSync {
+class ITokenSyncManager : public IRemoteBroker {
+public:
+ static const int SA_ID_TOKENSYNC_MANAGER_SERVICE = 3504;
+
+ DECLARE_INTERFACE_DESCRIPTOR(u"ohos.security.accesstoken.ITokenSyncManager");
+
+ virtual int VerifyPermission(const std::string& bundleName, const std::string& permissionName, int userId) = 0;
+
+ enum class InterfaceCode {
+ VERIFY_PERMISSION = 0xff01,
+ };
+};
+} // namespace TokenSync
+} // namespace Security
+} // namespace OHOS
+
+#endif // I_TOKENSYNC_MANAGER_H
diff --git a/interfaces/innerkits/accesstoken/BUILD.gn b/interfaces/innerkits/accesstoken/BUILD.gn
index 2cc576843c7f6a990473d776dec065d9a24188c8..b6cc8e22c48ca5c14439b842f0368825a622ab0b 100644
--- a/interfaces/innerkits/accesstoken/BUILD.gn
+++ b/interfaces/innerkits/accesstoken/BUILD.gn
@@ -16,7 +16,7 @@ import("//build/ohos.gni")
################################################################
# C++, Main, source file here.
################################################################
-config("accesstoken_sdk_cxx_public_config_standard") {
+config("accesstoken") {
visibility = [ ":*" ]
include_dirs = [ "main/cpp/include" ]
}
@@ -27,14 +27,15 @@ ohos_shared_library("libaccesstoken_sdk") {
output_name = "libaccesstoken_sdk"
- public_configs = [ ":accesstoken_sdk_cxx_public_config_standard" ]
+ public_configs = [ ":accesstoken" ]
include_dirs = [
"//utils/native/base/include",
"main/cpp/include",
"main/cpp/src",
- "//base/security/access_token/frameworks/accesstoken",
- "//base/security/access_token/nterfaces/innerkits/accesstoken/main/cpp/include",
+ "//base/security/access_token/frameworks/accesstoken/include",
+ "//base/security/access_token/frameworks/common/include",
+ "//base/security/access_token/interfaces/innerkits/accesstoken/main/cpp/include"
]
sources = [
@@ -44,8 +45,7 @@ ohos_shared_library("libaccesstoken_sdk") {
]
deps = [
- "//base/security/permission/frameworks/permission_standard/permissioncommunicationadapter:permission_standard_communication_adapter_cxx",
- "//base/security/permission/frameworks/permission_standard/permissioninfrastructure:permission_standard_infrastructure_cxx",
+ "//base/security/access_token/frameworks/accesstoken:accesstoken_communication_adapter_cxx",
"//utils/native/base:utils",
]
diff --git a/interfaces/innerkits/accesstoken/main/cpp/include/access_token.h b/interfaces/innerkits/accesstoken/main/cpp/include/access_token.h
new file mode 100644
index 0000000000000000000000000000000000000000..5f8909948b71c2c2027b79a8efb3b951c225d64a
--- /dev/null
+++ b/interfaces/innerkits/accesstoken/main/cpp/include/access_token.h
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2021 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 ACCESS_TOKEN_DEF_H
+#define ACCESS_TOKEN_DEF_H
+
+namespace OHOS {
+namespace Security {
+namespace AccessToken {
+typedef unsigned int AccessTokenID;
+typedef unsigned int AccessTokenAttr;
+static const int DEFAULT_TOKEN_VERSION = 1;
+
+enum AccessTokenKitRet {
+ RET_FAILED = -1,
+ RET_SUCCESS = 0,
+};
+
+typedef struct {
+ unsigned int tokenUniqueID : 24;
+ unsigned int res : 3;
+ unsigned int type : 2;
+ unsigned int version : 3;
+} AccessTokenIDInner;
+
+typedef enum TypeATokenTypeEnum {
+ TOKEN_INVALID = -1,
+ TOKEN_HAP = 0,
+ TOKEN_NATIVE,
+} ATokenTypeEnum;
+
+typedef enum TypeATokenAplEnum {
+ APL_NORMAL = 1,
+ APL_SYSTEM_BASIC = 2,
+ APL_SYSTEM_CORE = 3,
+} ATokenAplEnum;
+
+typedef union {
+ unsigned long long tokenIDEx;
+ struct {
+ AccessTokenID tokenID;
+ AccessTokenAttr tokenAttr;
+ } tokenIdExStruct;
+} AccessTokenIDEx;
+
+typedef enum TypePermissionState {
+ PERMISSION_DENIED = -1,
+ PERMISSION_GRANTED = 0,
+} PermissionState;
+
+typedef enum TypeGrantMode {
+ USER_GRANT = 0,
+ SYSTEM_GRANT = 1,
+} GrantMode;
+
+typedef enum TypeAvailableScope {
+ AVAILABLE_SCOPE_ALL = 1 << 0,
+ AVAILABLE_SCOPE_SIGNATURE = 1 << 1,
+ AVAILABLE_SCOPE_RESTRICTED = 1 << 2
+} AvailableScope;
+
+typedef enum TypePermissionFlag {
+ PERMISSION_USER_SET = 1 << 0,
+ PERMISSION_USER_FIXED = 1 << 1,
+ PERMISSION_SYSTEM_FIXED = 1 << 2,
+} PermissionFlag;
+} // namespace AccessToken
+} // namespace Security
+} // namespace OHOS
+#endif // ACCESS_TOKEN_DEF_H
diff --git a/interfaces/innerkits/accesstoken/main/cpp/include/accesstoken_kit.h b/interfaces/innerkits/accesstoken/main/cpp/include/accesstoken_kit.h
index 22fedd97a90f46c80ed4b1c0e784c90b8464b5c1..c8ccb5860fb7a5907565d3a6c521b36b124c30eb 100644
--- a/interfaces/innerkits/accesstoken/main/cpp/include/accesstoken_kit.h
+++ b/interfaces/innerkits/accesstoken/main/cpp/include/accesstoken_kit.h
@@ -1,32 +1,57 @@
-/*
- * Copyright (c) 2021 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 INTERFACES_INNER_KITS_ACCESSTOKEN_KIT_H
-#define INTERFACES_INNER_KITS_ACCESSTOKEN_KIT_H
-
-#include
-#include "accesstoken.h"
-
-namespace OHOS {
-namespace Security {
-namespace AccessToken {
-class AccessTokenKit {
-public:
- static int VerifyAccesstoken(AccessTokenID tokenID, const std::string& permissionName);
-};
-} // namespace AccessToken
-} // namespace Security
-} // namespace OHOS
-#endif
+/*
+ * Copyright (c) 2021 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 INTERFACES_INNER_KITS_ACCESSTOKEN_KIT_H
+#define INTERFACES_INNER_KITS_ACCESSTOKEN_KIT_H
+
+#include
+#include
+
+#include "access_token.h"
+#include "hap_token_info.h"
+#include "native_token_info.h"
+#include "permission_def.h"
+#include "permission_state_full.h"
+
+namespace OHOS {
+namespace Security {
+namespace AccessToken {
+class AccessTokenKit {
+public:
+ static AccessTokenIDEx AllocHapToken(const HapInfoParams& info, const HapPolicyParams& policy);
+ static AccessTokenID AllocLocalTokenID(const std::string& remoteDeviceID, AccessTokenID remoteTokenID);
+ static int UpdateHapToken(AccessTokenID tokenID, const std::string& appIDDesc, const HapPolicyParams& policy);
+ static int DeleteToken(AccessTokenID tokenID);
+ static int GetTokenType(AccessTokenID tokenID);
+ static int CheckNativeDCap(AccessTokenID tokenID, const std::string& dcap);
+ static AccessTokenID GetHapTokenID(int userID, const std::string& bundleName, int instIndex);
+ static int GetHapTokenInfo(AccessTokenID tokenID, HapTokenInfo& hapTokenInfoRes);
+ static int GetNativeTokenInfo(AccessTokenID tokenID, NativeTokenInfo& nativeTokenInfoRes);
+ static int VerifyAccessToken(AccessTokenID tokenID, const std::string& permissionName);
+ static int VerifyAccessToken(
+ AccessTokenID callerTokenID, AccessTokenID firstTokenID, const std::string& permissionName);
+ static int GetDefPermission(const std::string& permissionName, PermissionDef& permissionDefResult);
+ static int GetDefPermissions(AccessTokenID tokenID, std::vector& permList);
+ static int GetReqPermissions(
+ AccessTokenID tokenID, std::vector& reqPermList, bool isSystemGrant);
+ static int GetPermissionFlag(AccessTokenID tokenID, const std::string& permissionName);
+ static int GrantPermission(AccessTokenID tokenID, const std::string& permissionName, int flag);
+ static int RevokePermission(AccessTokenID tokenID, const std::string& permissionName, int flag);
+ static int ClearUserGrantedPermissionState(AccessTokenID tokenID);
+};
+} // namespace AccessToken
+} // namespace Security
+} // namespace OHOS
+#endif
diff --git a/interfaces/innerkits/accesstoken/main/cpp/include/hap_token_info.h b/interfaces/innerkits/accesstoken/main/cpp/include/hap_token_info.h
new file mode 100644
index 0000000000000000000000000000000000000000..26477f893f39bc6c12d00651283a3af1629c0c06
--- /dev/null
+++ b/interfaces/innerkits/accesstoken/main/cpp/include/hap_token_info.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2021 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_HAP_TOKEN_INFO_H
+#define ACCESSTOKEN_HAP_TOKEN_INFO_H
+
+#include "access_token.h"
+#include "permission_def.h"
+#include "permission_state_full.h"
+#include
+#include
+
+namespace OHOS {
+namespace Security {
+namespace AccessToken {
+class HapInfoParams final {
+public:
+ int userID;
+ std::string bundleName;
+ int instIndex;
+ std::string appIDDesc;
+};
+
+class HapPolicyParams final {
+public:
+ ATokenAplEnum apl;
+ std::string domain;
+ std::vector permList;
+ std::vector permStateList;
+};
+
+class HapTokenInfo final {
+public:
+ ATokenAplEnum apl;
+ char ver;
+ int userID;
+ std::string bundleName;
+ int instIndex;
+ std::string appID;
+ std::string deviceID;
+ AccessTokenID tokenID;
+ AccessTokenAttr tokenAttr;
+};
+} // namespace AccessToken
+} // namespace Security
+} // namespace OHOS
+#endif // ACCESSTOKEN_HAP_TOKEN_INFO_H
diff --git a/interfaces/innerkits/accesstoken/main/cpp/include/native_token_info.h b/interfaces/innerkits/accesstoken/main/cpp/include/native_token_info.h
new file mode 100644
index 0000000000000000000000000000000000000000..60b427f3598d5fc059a3f4fa10ab15d185a01f0c
--- /dev/null
+++ b/interfaces/innerkits/accesstoken/main/cpp/include/native_token_info.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2021 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_NATIVE_TOKEN_INFO_H
+#define ACCESSTOKEN_NATIVE_TOKEN_INFO_H
+
+#include "access_token.h"
+#include
+#include
+
+namespace OHOS {
+namespace Security {
+namespace AccessToken {
+class NativeTokenInfo final {
+public:
+ ATokenAplEnum apl;
+ unsigned char ver;
+ std::string processName;
+ std::vector dcap;
+ AccessTokenID tokenID;
+ AccessTokenAttr tokenAttr;
+};
+} // namespace AccessToken
+} // namespace Security
+} // namespace OHOS
+#endif // ACCESSTOKEN_NATIVE_TOKEN_INFO_H
diff --git a/interfaces/innerkits/accesstoken/main/cpp/include/permission_def.h b/interfaces/innerkits/accesstoken/main/cpp/include/permission_def.h
new file mode 100644
index 0000000000000000000000000000000000000000..a08b3103c26b05333aee4690f28e53cc9f16e18e
--- /dev/null
+++ b/interfaces/innerkits/accesstoken/main/cpp/include/permission_def.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2021 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 INTERFACES_INNER_KITS_ACCESSTOKEN_PERMISSION_DEF_H
+#define INTERFACES_INNER_KITS_ACCESSTOKEN_PERMISSION_DEF_H
+
+#include
+
+namespace OHOS {
+namespace Security {
+namespace AccessToken {
+class PermissionDef final {
+public:
+ std::string permissionName;
+ std::string bundleName;
+ int grantMode;
+ int availableScope;
+ std::string label;
+ int labelId;
+ std::string description;
+ int descriptionId;
+};
+} // namespace AccessToken
+} // namespace Security
+} // namespace OHOS
+
+#endif // INTERFACES_INNER_KITS_ACCESSTOKEN_PERMISSION_DEF_H
diff --git a/interfaces/innerkits/accesstoken/main/cpp/include/permission_state_full.h b/interfaces/innerkits/accesstoken/main/cpp/include/permission_state_full.h
new file mode 100644
index 0000000000000000000000000000000000000000..17b8b0137879fa2764368d2e7ce20c00d526fb75
--- /dev/null
+++ b/interfaces/innerkits/accesstoken/main/cpp/include/permission_state_full.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2021 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 INTERFACES_INNER_KITS_PERMISSION_PERMISSION_STATE_FULL_H
+#define INTERFACES_INNER_KITS_PERMISSION_PERMISSION_STATE_FULL_H
+
+#include
+#include
+
+namespace OHOS {
+namespace Security {
+namespace AccessToken {
+class PermissionStateFull final {
+public:
+ std::string permissionName;
+ bool isGeneral;
+ std::vector resDeviceID;
+ std::vector grantStatus;
+ std::vector grantFlags;
+};
+} // namespace AccessToken
+} // namespace Security
+} // namespace OHOS
+#endif // INTERFACES_INNER_KITS_PERMISSION_PERMISSION_STATE_FULL_H
diff --git a/interfaces/innerkits/accesstoken/main/cpp/src/accesstoken_kit.cpp b/interfaces/innerkits/accesstoken/main/cpp/src/accesstoken_kit.cpp
index 1e0e8e06e7bc66a3c83dd00cbc9a4a2b9a6409a5..5d4d82bdc5573bcb83db56f2c4bddc2596930b3e 100644
--- a/interfaces/innerkits/accesstoken/main/cpp/src/accesstoken_kit.cpp
+++ b/interfaces/innerkits/accesstoken/main/cpp/src/accesstoken_kit.cpp
@@ -1,42 +1,171 @@
-/*
- * Copyright (c) 2021 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 "accesstoken_kit.h"
-
-#include
-#include
-
-#include "accesstoken_log.h"
-#include "accesstoken_manager_client.h"
-
-namespace OHOS {
-namespace Security {
-namespace AccessToken {
-using namespace std;
-
-namespace {
-static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, SECURITY_DOMAIN_ACCESSTOKEN, "AccessTokenKit"};
-} // namespace
-
-int AccessTokenKit::VerifyAccesstoken(AccessTokenID tokenID, const std::string &permissionName)
-{
- ACCESSTOKEN_LOG_INFO(LABEL, "%{public}s called", __func__);
- ACCESSTOKEN_LOG_INFO(LABEL, "tokenID=%{public}d, permissionName=%{public}s",
- tokenID, permissionName.c_str());
- return AccessTokenManagerClient::GetInstance().VerifyAccesstoken(tokenID, permissionName);
-}
-} // namespace AccessToken
-} // namespace Security
-} // namespace OHOS
\ No newline at end of file
+/*
+ * Copyright (c) 2021 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 "accesstoken_kit.h"
+
+#include
+#include
+
+#include "accesstoken_log.h"
+#include "accesstoken_manager_client.h"
+
+namespace OHOS {
+namespace Security {
+namespace AccessToken {
+namespace {
+static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, SECURITY_DOMAIN_ACCESSTOKEN, "AccessTokenKit"};
+} // namespace
+
+AccessTokenIDEx AccessTokenKit::AllocHapToken(const HapInfoParams& info, const HapPolicyParams& policy)
+{
+ ACCESSTOKEN_LOG_INFO(LABEL, "%{public}s called", __func__);
+
+ return AccessTokenManagerClient::GetInstance().AllocHapToken(info, policy);
+}
+
+AccessTokenID AccessTokenKit::AllocLocalTokenID(const std::string& remoteDeviceID, AccessTokenID remoteTokenID)
+{
+ ACCESSTOKEN_LOG_INFO(LABEL, "%{public}s called", __func__);
+ return AccessTokenManagerClient::GetInstance().AllocLocalTokenID(remoteDeviceID, remoteTokenID);
+}
+
+int AccessTokenKit::UpdateHapToken(AccessTokenID tokenID, const std::string& appIDDesc, const HapPolicyParams& policy)
+{
+ ACCESSTOKEN_LOG_INFO(LABEL, "%{public}s called", __func__);
+ return AccessTokenManagerClient::GetInstance().UpdateHapToken(tokenID, appIDDesc, policy);
+}
+
+int AccessTokenKit::DeleteToken(AccessTokenID tokenID)
+{
+ ACCESSTOKEN_LOG_INFO(LABEL, "%{public}s called", __func__);
+ ACCESSTOKEN_LOG_INFO(LABEL, "tokenID=%{public}d", tokenID);
+
+ return AccessTokenManagerClient::GetInstance().DeleteToken(tokenID);
+}
+
+int AccessTokenKit::GetTokenType(AccessTokenID tokenID)
+{
+ ACCESSTOKEN_LOG_INFO(LABEL, "%{public}s called", __func__);
+ ACCESSTOKEN_LOG_INFO(LABEL, "tokenID=%{public}d", tokenID);
+ return AccessTokenManagerClient::GetInstance().GetTokenType(tokenID);
+}
+
+int AccessTokenKit::CheckNativeDCap(AccessTokenID tokenID, const std::string& dcap)
+{
+ ACCESSTOKEN_LOG_INFO(LABEL, "%{public}s called", __func__);
+ ACCESSTOKEN_LOG_INFO(LABEL, "tokenID=%{public}d, dcap=%{public}s", tokenID, dcap.c_str());
+ return AccessTokenManagerClient::GetInstance().CheckNativeDCap(tokenID, dcap);
+}
+
+AccessTokenID AccessTokenKit::GetHapTokenID(int userID, const std::string& bundleName, int instIndex)
+{
+ ACCESSTOKEN_LOG_INFO(LABEL, "%{public}s called", __func__);
+ ACCESSTOKEN_LOG_INFO(LABEL, "int userID=%{public}d, bundleName=%{public}s, instIndex=%{public}d",
+ userID, bundleName.c_str(), instIndex);
+
+ return AccessTokenManagerClient::GetInstance().GetHapTokenID(userID, bundleName, instIndex);
+}
+
+int AccessTokenKit::GetHapTokenInfo(AccessTokenID tokenID, HapTokenInfo& hapTokenInfoRes)
+{
+ ACCESSTOKEN_LOG_INFO(LABEL, "%{public}s called", __func__);
+ ACCESSTOKEN_LOG_INFO(LABEL, "tokenID=%{public}d", tokenID);
+
+ return AccessTokenManagerClient::GetInstance().GetHapTokenInfo(tokenID, hapTokenInfoRes);
+}
+
+int AccessTokenKit::GetNativeTokenInfo(AccessTokenID tokenID, NativeTokenInfo& nativeTokenInfoRes)
+{
+ ACCESSTOKEN_LOG_INFO(LABEL, "%{public}s called", __func__);
+ ACCESSTOKEN_LOG_INFO(LABEL, "tokenID=%{public}d", tokenID);
+
+ return AccessTokenManagerClient::GetInstance().GetNativeTokenInfo(tokenID, nativeTokenInfoRes);
+}
+
+int AccessTokenKit::VerifyAccessToken(AccessTokenID tokenID, const std::string& permissionName)
+{
+ ACCESSTOKEN_LOG_INFO(LABEL, "%{public}s called", __func__);
+ ACCESSTOKEN_LOG_INFO(LABEL, "tokenID=%{public}d, permissionName=%{public}s", tokenID, permissionName.c_str());
+ return AccessTokenManagerClient::GetInstance().VerifyAccessToken(tokenID, permissionName);
+}
+
+int AccessTokenKit::VerifyAccessToken(
+ AccessTokenID callerTokenID, AccessTokenID firstTokenID, const std::string& permissionName)
+{
+ return 0;
+}
+
+int AccessTokenKit::GetDefPermission(const std::string& permissionName, PermissionDef& permissionDefResult)
+{
+ ACCESSTOKEN_LOG_INFO(LABEL, "%{public}s called", __func__);
+ ACCESSTOKEN_LOG_INFO(LABEL, "permissionName=%{public}s", permissionName.c_str());
+
+ int ret = AccessTokenManagerClient::GetInstance().GetDefPermission(permissionName, permissionDefResult);
+ ACCESSTOKEN_LOG_INFO(LABEL, "GetDefPermission bundleName = %{public}s", permissionDefResult.bundleName.c_str());
+
+ return ret;
+}
+
+int AccessTokenKit::GetDefPermissions(AccessTokenID tokenID, std::vector& permDefList)
+{
+ ACCESSTOKEN_LOG_INFO(LABEL, "%{public}s called", __func__);
+ ACCESSTOKEN_LOG_INFO(LABEL, "tokenID=%{public}d", tokenID);
+
+ ACCESSTOKEN_LOG_INFO(LABEL, "GetDefPermissions permDefList size = %{public}d", permDefList.size());
+ return AccessTokenManagerClient::GetInstance().GetDefPermissions(tokenID, permDefList);
+}
+
+int AccessTokenKit::GetReqPermissions(
+ AccessTokenID tokenID, std::vector& reqPermList, bool isSystemGrant)
+{
+ ACCESSTOKEN_LOG_INFO(LABEL, "%{public}s called", __func__);
+ ACCESSTOKEN_LOG_INFO(LABEL, "tokenID=%{public}d, isSystemGrant=%{public}d", tokenID, isSystemGrant);
+
+ ACCESSTOKEN_LOG_INFO(LABEL, "GetReqPermissions, reqPermList size=%{public}d", reqPermList.size());
+ return AccessTokenManagerClient::GetInstance().GetReqPermissions(tokenID, reqPermList, isSystemGrant);
+}
+
+int AccessTokenKit::GetPermissionFlag(AccessTokenID tokenID, const std::string& permissionName)
+{
+ ACCESSTOKEN_LOG_INFO(LABEL, "%{public}s called", __func__);
+ ACCESSTOKEN_LOG_INFO(LABEL, "tokenID=%{public}d, permissionName=%{public}s", tokenID, permissionName.c_str());
+ return AccessTokenManagerClient::GetInstance().GetPermissionFlag(tokenID, permissionName);
+}
+
+int AccessTokenKit::GrantPermission(AccessTokenID tokenID, const std::string& permissionName, int flag)
+{
+ ACCESSTOKEN_LOG_INFO(LABEL, "%{public}s called", __func__);
+ ACCESSTOKEN_LOG_INFO(LABEL, "tokenID=%{public}d, permissionName=%{public}s, flag=%{public}d",
+ tokenID, permissionName.c_str(), flag);
+ return AccessTokenManagerClient::GetInstance().GrantPermission(tokenID, permissionName, flag);
+}
+
+int AccessTokenKit::RevokePermission(AccessTokenID tokenID, const std::string& permissionName, int flag)
+{
+ ACCESSTOKEN_LOG_INFO(LABEL, "%{public}s called", __func__);
+ ACCESSTOKEN_LOG_INFO(LABEL, "tokenID=%{public}d, permissionName=%{public}s, flag=%{public}d",
+ tokenID, permissionName.c_str(), flag);
+ return AccessTokenManagerClient::GetInstance().RevokePermission(tokenID, permissionName, flag);
+}
+
+int AccessTokenKit::ClearUserGrantedPermissionState(AccessTokenID tokenID)
+{
+ ACCESSTOKEN_LOG_INFO(LABEL, "%{public}s called", __func__);
+ ACCESSTOKEN_LOG_INFO(LABEL, "tokenID=%{public}d", tokenID);
+ return AccessTokenManagerClient::GetInstance().ClearUserGrantedPermissionState(tokenID);
+}
+} // namespace AccessToken
+} // namespace Security
+} // namespace OHOS
diff --git a/interfaces/innerkits/accesstoken/main/cpp/src/accesstoken_manager_client.cpp b/interfaces/innerkits/accesstoken/main/cpp/src/accesstoken_manager_client.cpp
index a5de7d88eb882295421bdda5b6bed135a87ca48d..8f259f150ceeb3dfdf91c580a31223544fbd7b7b 100644
--- a/interfaces/innerkits/accesstoken/main/cpp/src/accesstoken_manager_client.cpp
+++ b/interfaces/innerkits/accesstoken/main/cpp/src/accesstoken_manager_client.cpp
@@ -16,8 +16,9 @@
#include "accesstoken_manager_client.h"
#include "accesstoken_log.h"
-
+#include "hap_token_info.h"
#include "iservice_registry.h"
+#include "native_token_info.h"
namespace OHOS {
namespace Security {
@@ -40,15 +41,225 @@ AccessTokenManagerClient::AccessTokenManagerClient()
AccessTokenManagerClient::~AccessTokenManagerClient()
{}
-int AccessTokenManagerClient::VerifyAccesstoken(AccessTokenID tokenID, const std::string& permissionName) const
+int AccessTokenManagerClient::VerifyAccessToken(AccessTokenID tokenID, const std::string& permissionName) const
+{
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s: called!", __func__);
+ auto proxy = GetProxy();
+ if (proxy == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: proxy is null", __func__);
+ return RET_FAILED;
+ }
+ return proxy->VerifyAccessToken(tokenID, permissionName);
+}
+
+int AccessTokenManagerClient::GetDefPermission(
+ const std::string& permissionName, PermissionDef& permissionDefResult) const
+{
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s: called!", __func__);
+ auto proxy = GetProxy();
+ if (proxy == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: proxy is null", __func__);
+ return RET_FAILED;
+ }
+ PermissionDefParcel permissionDefParcel;
+ int result = proxy->GetDefPermission(permissionName, permissionDefParcel);
+ permissionDefResult = permissionDefParcel.permissionDef;
+ return result;
+}
+
+int AccessTokenManagerClient::GetDefPermissions(AccessTokenID tokenID, std::vector& permList) const
+{
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s: called!", __func__);
+ auto proxy = GetProxy();
+ if (proxy == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: proxy is null", __func__);
+ return RET_FAILED;
+ }
+ std::vector parcelList;
+ int result = proxy->GetDefPermissions(tokenID, parcelList);
+ for (auto permParcel : parcelList) {
+ PermissionDef perm = permParcel.permissionDef;
+ permList.emplace_back(perm);
+ }
+ return result;
+}
+
+int AccessTokenManagerClient::GetReqPermissions(
+ AccessTokenID tokenID, std::vector& reqPermList, bool isSystemGrant) const
+{
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s: called!", __func__);
+ auto proxy = GetProxy();
+ if (proxy == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: proxy is null", __func__);
+ return RET_FAILED;
+ }
+ std::vector parcelList;
+ int result = proxy->GetReqPermissions(tokenID, parcelList, isSystemGrant);
+ for (auto permParcel : parcelList) {
+ PermissionStateFull perm = permParcel.permStatFull;
+ reqPermList.emplace_back(perm);
+ }
+ return result;
+}
+
+int AccessTokenManagerClient::GetPermissionFlag(AccessTokenID tokenID, const std::string& permissionName) const
+{
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s: called!", __func__);
+ auto proxy = GetProxy();
+ if (proxy == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: proxy is null", __func__);
+ return RET_FAILED;
+ }
+ return proxy->GetPermissionFlag(tokenID, permissionName);
+}
+
+int AccessTokenManagerClient::GrantPermission(AccessTokenID tokenID, const std::string& permissionName, int flag) const
+{
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s: called!", __func__);
+ auto proxy = GetProxy();
+ if (proxy == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: proxy is null", __func__);
+ return RET_FAILED;
+ }
+ return proxy->GrantPermission(tokenID, permissionName, flag);
+}
+
+int AccessTokenManagerClient::RevokePermission(AccessTokenID tokenID, const std::string& permissionName, int flag) const
+{
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s: called!", __func__);
+ auto proxy = GetProxy();
+ if (proxy == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: proxy is null", __func__);
+ return RET_FAILED;
+ }
+ return proxy->RevokePermission(tokenID, permissionName, flag);
+}
+
+int AccessTokenManagerClient::ClearUserGrantedPermissionState(AccessTokenID tokenID) const
+{
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s: called!", __func__);
+ auto proxy = GetProxy();
+ if (proxy == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: proxy is null", __func__);
+ return RET_FAILED;
+ }
+ return proxy->ClearUserGrantedPermissionState(tokenID);
+}
+
+AccessTokenIDEx AccessTokenManagerClient::AllocHapToken(const HapInfoParams& info, const HapPolicyParams& policy) const
+{
+ AccessTokenIDEx res = { 0 };
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s: called!", __func__);
+ auto proxy = GetProxy();
+ if (proxy == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: proxy is null", __func__);
+ return res;
+ }
+ HapInfoParcel hapInfoParcel;
+ HapPolicyParcel hapPolicyParcel;
+ hapInfoParcel.hapInfoParameter = info;
+ hapPolicyParcel.hapPolicyParameter = policy;
+
+ return proxy->AllocHapToken(hapInfoParcel, hapPolicyParcel);
+}
+
+int AccessTokenManagerClient::DeleteToken(AccessTokenID tokenID) const
+{
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s: called!", __func__);
+ auto proxy = GetProxy();
+ if (proxy == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: proxy is null", __func__);
+ return RET_FAILED;
+ }
+ return proxy->DeleteToken(tokenID);
+}
+
+int AccessTokenManagerClient::GetTokenType(AccessTokenID tokenID) const
+{
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s: called!", __func__);
+ auto proxy = GetProxy();
+ if (proxy == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: proxy is null", __func__);
+ return RET_FAILED;
+ }
+ return proxy->GetTokenType(tokenID);
+}
+
+int AccessTokenManagerClient::CheckNativeDCap(AccessTokenID tokenID, const std::string& dcap) const
+{
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s: called!", __func__);
+ auto proxy = GetProxy();
+ if (proxy == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: proxy is null", __func__);
+ return RET_FAILED;
+ }
+ return proxy->CheckNativeDCap(tokenID, dcap);
+}
+
+AccessTokenID AccessTokenManagerClient::GetHapTokenID(int userID, const std::string& bundleName, int instIndex) const
+{
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s: called!", __func__);
+ auto proxy = GetProxy();
+ if (proxy == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: proxy is null", __func__);
+ return RET_FAILED;
+ }
+ return proxy->GetHapTokenID(userID, bundleName, instIndex);
+}
+
+AccessTokenID AccessTokenManagerClient::AllocLocalTokenID(
+ const std::string& remoteDeviceID, AccessTokenID remoteTokenID) const
+{
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s: called!", __func__);
+ auto proxy = GetProxy();
+ if (proxy == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: proxy is null", __func__);
+ return RET_FAILED;
+ }
+ return proxy->AllocLocalTokenID(remoteDeviceID, remoteTokenID);
+}
+
+int AccessTokenManagerClient::UpdateHapToken(
+ AccessTokenID tokenID, const std::string& appIDDesc, const HapPolicyParams& policy) const
+{
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s: called!", __func__);
+ auto proxy = GetProxy();
+ if (proxy == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: proxy is null", __func__);
+ return RET_FAILED;
+ }
+ HapPolicyParcel hapPolicyParcel;
+ hapPolicyParcel.hapPolicyParameter = policy;
+ return proxy->UpdateHapToken(tokenID, appIDDesc, hapPolicyParcel);
+}
+
+int AccessTokenManagerClient::GetHapTokenInfo(AccessTokenID tokenID, HapTokenInfo& hapTokenInfoRes) const
+{
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s: called!", __func__);
+ auto proxy = GetProxy();
+ if (proxy == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: proxy is null", __func__);
+ return RET_FAILED;
+ }
+ HapTokenInfoParcel hapTokenInfoParcel;
+ int res = proxy->GetHapTokenInfo(tokenID, hapTokenInfoParcel);
+
+ hapTokenInfoRes = hapTokenInfoParcel.hapTokenInfoParams;
+ return res;
+}
+
+int AccessTokenManagerClient::GetNativeTokenInfo(AccessTokenID tokenID, NativeTokenInfo& nativeTokenInfoRes) const
{
ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s: called!", __func__);
auto proxy = GetProxy();
if (proxy == nullptr) {
ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: proxy is null", __func__);
- return PERMISSION_DENIED;
+ return RET_FAILED;
}
- return proxy->VerifyAccesstoken(tokenID, permissionName);
+ NativeTokenInfoParcel nativeTokenInfoParcel;
+ int res = proxy->GetNativeTokenInfo(tokenID, nativeTokenInfoParcel);
+ nativeTokenInfoRes = nativeTokenInfoParcel.nativeTokenInfoParams;
+ return res;
}
sptr AccessTokenManagerClient::GetProxy() const
@@ -74,4 +285,4 @@ sptr AccessTokenManagerClient::GetProxy() const
}
} // namespace AccessToken
} // namespace Security
-} // namespace OHOS
\ No newline at end of file
+} // namespace OHOS
diff --git a/interfaces/innerkits/accesstoken/main/cpp/src/accesstoken_manager_client.h b/interfaces/innerkits/accesstoken/main/cpp/src/accesstoken_manager_client.h
index 758e6f59845c8e89cb35b70631ef84390d8efa91..cedcdae1086c94fb5a8b7a6d82f435fe925184b9 100755
--- a/interfaces/innerkits/accesstoken/main/cpp/src/accesstoken_manager_client.h
+++ b/interfaces/innerkits/accesstoken/main/cpp/src/accesstoken_manager_client.h
@@ -17,9 +17,17 @@
#define ACCESSTOKEN_MANAGER_CLIENT_H
#include
+#include
+#include "access_token.h"
+#include "hap_info_parcel.h"
+#include "hap_policy_parcel.h"
+#include "hap_token_info.h"
#include "i_accesstoken_manager.h"
+#include "native_token_info.h"
#include "nocopyable.h"
+#include "permission_def.h"
+#include "permission_state_full.h"
namespace OHOS {
namespace Security {
@@ -30,7 +38,25 @@ public:
virtual ~AccessTokenManagerClient();
- int VerifyAccesstoken(AccessTokenID tokenID, const std::string& permissionName) const;
+ int VerifyAccessToken(AccessTokenID tokenID, const std::string& permissionName) const;
+ int GetDefPermission(const std::string& permissionName, PermissionDef& permissionDefResult) const;
+ int GetDefPermissions(AccessTokenID tokenID, std::vector& permList) const;
+ int GetReqPermissions(
+ AccessTokenID tokenID, std::vector& reqPermList, bool isSystemGrant) const;
+ int GetPermissionFlag(AccessTokenID tokenID, const std::string& permissionName) const;
+ int GrantPermission(AccessTokenID tokenID, const std::string& permissionName, int flag) const;
+ int RevokePermission(AccessTokenID tokenID, const std::string& permissionName, int flag) const;
+ int ClearUserGrantedPermissionState(AccessTokenID tokenID) const;
+ AccessTokenIDEx AllocHapToken(const HapInfoParams& info, const HapPolicyParams& policy) const;
+ int DeleteToken(AccessTokenID tokenID) const;
+ int GetTokenType(AccessTokenID tokenID) const;
+ int CheckNativeDCap(AccessTokenID tokenID, const std::string& dcap) const;
+ AccessTokenID GetHapTokenID(int userID, const std::string& bundleName, int instIndex) const;
+ AccessTokenID AllocLocalTokenID(const std::string& remoteDeviceID, AccessTokenID remoteTokenID) const;
+ int UpdateHapToken(AccessTokenID tokenID, const std::string& appIDDesc, const HapPolicyParams& policy) const;
+ int GetHapTokenInfo(AccessTokenID tokenID, HapTokenInfo& hapTokenInfoRes) const;
+ int GetNativeTokenInfo(AccessTokenID tokenID, NativeTokenInfo& nativeTokenInfoRes) const;
+
private:
AccessTokenManagerClient();
diff --git a/interfaces/innerkits/accesstoken/main/cpp/src/accesstoken_manager_proxy.cpp b/interfaces/innerkits/accesstoken/main/cpp/src/accesstoken_manager_proxy.cpp
index ce8d6ec7f793bf28900da3a21276e24233863a88..e031e8c025d46d67bca37119127bdd6baeb92210 100644
--- a/interfaces/innerkits/accesstoken/main/cpp/src/accesstoken_manager_proxy.cpp
+++ b/interfaces/innerkits/accesstoken/main/cpp/src/accesstoken_manager_proxy.cpp
@@ -28,13 +28,13 @@ static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, SECURITY_DOMAIN_
}
AccessTokenManagerProxy::AccessTokenManagerProxy(const sptr& impl)
- : IRemoteProxy(impl)
-{}
+ : IRemoteProxy(impl) {
+}
AccessTokenManagerProxy::~AccessTokenManagerProxy()
{}
-int AccessTokenManagerProxy::VerifyAccesstoken(AccessTokenID tokenID, const std::string& permissionName)
+int AccessTokenManagerProxy::VerifyAccessToken(AccessTokenID tokenID, const std::string& permissionName)
{
MessageParcel data;
data.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
@@ -66,6 +66,547 @@ int AccessTokenManagerProxy::VerifyAccesstoken(AccessTokenID tokenID, const std:
return result;
}
+int AccessTokenManagerProxy::GetDefPermission(
+ const std::string& permissionName, PermissionDefParcel& permissionDefResult)
+{
+ MessageParcel data;
+ data.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
+ if (!data.WriteString(permissionName)) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: Failed to write permissionName", __func__);
+ return RET_FAILED;
+ }
+
+ MessageParcel reply;
+ MessageOption option;
+ sptr remote = Remote();
+ if (remote == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: remote service null.", __func__);
+ return RET_FAILED;
+ }
+ int32_t requestResult = remote->SendRequest(
+ static_cast(IAccessTokenManager::InterfaceCode::GET_DEF_PERMISSION), data, reply, option);
+ if (requestResult != NO_ERROR) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s send request fail, result: %{public}d", __func__, requestResult);
+ return RET_FAILED;
+ }
+
+ sptr resultSptr = reply.ReadParcelable();
+ if (resultSptr == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s ReadParcelable fail", __func__);
+ return RET_FAILED;
+ }
+ permissionDefResult = *resultSptr;
+ int32_t result = reply.ReadInt32();
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s get result from server data = %{public}d", __func__, result);
+ return result;
+}
+
+int AccessTokenManagerProxy::GetDefPermissions(AccessTokenID tokenID,
+ std::vector& permList)
+{
+ MessageParcel data;
+ data.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
+ if (!data.WriteUint32(tokenID)) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: Failed to write tokenID", __func__);
+ return RET_FAILED;
+ }
+
+ MessageParcel reply;
+ MessageOption option;
+ sptr remote = Remote();
+ if (remote == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: remote service null.", __func__);
+ return RET_FAILED;
+ }
+ int32_t requestResult = remote->SendRequest(
+ static_cast(IAccessTokenManager::InterfaceCode::GET_DEF_PERMISSIONS), data, reply, option);
+ if (requestResult != NO_ERROR) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s send request fail, result: %{public}d", __func__, requestResult);
+ return RET_FAILED;
+ }
+
+ int32_t size = reply.ReadInt32();
+ for (int i = 0; i < size; i++) {
+ sptr permissionDef = reply.ReadParcelable();
+ if (permissionDef != nullptr) {
+ permList.emplace_back(*permissionDef);
+ }
+ }
+ int32_t result = reply.ReadInt32();
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s get result from server data = %{public}d", __func__, result);
+ return result;
+}
+
+int AccessTokenManagerProxy::GetReqPermissions(
+ AccessTokenID tokenID, std::vector& reqPermList, bool isSystemGrant)
+{
+ MessageParcel data;
+ data.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
+ if (!data.WriteUint32(tokenID)) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: Failed to write tokenID", __func__);
+ return RET_FAILED;
+ }
+ if (!data.WriteInt32(isSystemGrant)) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: Failed to write isSystemGrant", __func__);
+ return RET_FAILED;
+ }
+
+ MessageParcel reply;
+ MessageOption option;
+ sptr remote = Remote();
+ if (remote == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: remote service null.", __func__);
+ return RET_FAILED;
+ }
+ int32_t requestResult = remote->SendRequest(
+ static_cast(IAccessTokenManager::InterfaceCode::GET_REQ_PERMISSIONS), data, reply, option);
+ if (requestResult != NO_ERROR) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s send request fail, result: %{public}d", __func__, requestResult);
+ return RET_FAILED;
+ }
+
+ int32_t size = reply.ReadInt32();
+ for (int i = 0; i < size; i++) {
+ sptr permissionReq = reply.ReadParcelable();
+ if (permissionReq != nullptr) {
+ reqPermList.emplace_back(*permissionReq);
+ }
+ }
+ int32_t result = reply.ReadInt32();
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s get result from server data = %{public}d", __func__, result);
+ return result;
+}
+
+int AccessTokenManagerProxy::GetPermissionFlag(AccessTokenID tokenID, const std::string& permissionName)
+{
+ MessageParcel data;
+ data.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
+ if (!data.WriteUint32(tokenID)) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: Failed to write tokenID", __func__);
+ return RET_FAILED;
+ }
+ if (!data.WriteString(permissionName)) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: Failed to write permissionName", __func__);
+ return RET_FAILED;
+ }
+
+ MessageParcel reply;
+ MessageOption option;
+ sptr remote = Remote();
+ if (remote == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: remote service null.", __func__);
+ return RET_FAILED;
+ }
+ int32_t requestResult = remote->SendRequest(
+ static_cast(IAccessTokenManager::InterfaceCode::GET_PERMISSION_FLAG), data, reply, option);
+ if (requestResult != NO_ERROR) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s send request fail, result: %{public}d", __func__, requestResult);
+ return RET_FAILED;
+ }
+
+ int32_t result = reply.ReadInt32();
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s get result from server data = %{public}d", __func__, result);
+ return result;
+}
+
+int AccessTokenManagerProxy::GrantPermission(AccessTokenID tokenID, const std::string& permissionName, int flag)
+{
+ MessageParcel data;
+ data.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
+ if (!data.WriteUint32(tokenID)) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: Failed to write tokenID", __func__);
+ return RET_FAILED;
+ }
+ if (!data.WriteString(permissionName)) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: Failed to write permissionName", __func__);
+ return RET_FAILED;
+ }
+ if (!data.WriteInt32(flag)) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: Failed to write flag", __func__);
+ return RET_FAILED;
+ }
+
+ MessageParcel reply;
+ MessageOption option;
+ sptr remote = Remote();
+ if (remote == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: remote service null.", __func__);
+ return RET_FAILED;
+ }
+ int32_t requestResult = remote->SendRequest(
+ static_cast(IAccessTokenManager::InterfaceCode::GRANT_PERMISSION), data, reply, option);
+ if (requestResult != NO_ERROR) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s send request fail, result: %{public}d", __func__, requestResult);
+ return RET_FAILED;
+ }
+
+ int32_t result = reply.ReadInt32();
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s get result from server data = %{public}d", __func__, result);
+ return result;
+}
+
+int AccessTokenManagerProxy::RevokePermission(AccessTokenID tokenID, const std::string& permissionName, int flag)
+{
+ MessageParcel data;
+ data.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
+ if (!data.WriteUint32(tokenID)) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: Failed to write tokenID", __func__);
+ return RET_FAILED;
+ }
+ if (!data.WriteString(permissionName)) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: Failed to write permissionName", __func__);
+ return RET_FAILED;
+ }
+ if (!data.WriteInt32(flag)) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: Failed to write flag", __func__);
+ return RET_FAILED;
+ }
+
+ MessageParcel reply;
+ MessageOption option;
+ sptr remote = Remote();
+ if (remote == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: remote service null.", __func__);
+ return RET_FAILED;
+ }
+ int32_t requestResult = remote->SendRequest(
+ static_cast(IAccessTokenManager::InterfaceCode::REVOKE_PERMISSION), data, reply, option);
+ if (requestResult != NO_ERROR) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s send request fail, result: %{public}d", __func__, requestResult);
+ return RET_FAILED;
+ }
+
+ int32_t result = reply.ReadInt32();
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s get result from server data = %{public}d", __func__, result);
+ return result;
+}
+
+int AccessTokenManagerProxy::ClearUserGrantedPermissionState(AccessTokenID tokenID)
+{
+ MessageParcel data;
+ data.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
+ if (!data.WriteUint32(tokenID)) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: Failed to write tokenID", __func__);
+ return RET_FAILED;
+ }
+
+ MessageParcel reply;
+ MessageOption option;
+ sptr remote = Remote();
+ if (remote == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: remote service null.", __func__);
+ return RET_FAILED;
+ }
+ int32_t requestResult = remote->SendRequest(
+ static_cast(IAccessTokenManager::InterfaceCode::CLEAR_USER_GRANT_PERMISSION), data, reply, option);
+ if (requestResult != NO_ERROR) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s send request fail, result: %{public}d", __func__, requestResult);
+ return RET_FAILED;
+ }
+
+ int32_t result = reply.ReadInt32();
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s get result from server data = %{public}d", __func__, result);
+ return result;
+}
+
+AccessTokenIDEx AccessTokenManagerProxy::AllocHapToken(
+ const HapInfoParcel& hapInfo, const HapPolicyParcel& policyParcel)
+{
+ MessageParcel data;
+ AccessTokenIDEx res;
+ data.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
+
+ if (!data.WriteParcelable(&hapInfo)) {
+ res.tokenIDEx = 0;
+ return res;
+ }
+ if (!data.WriteParcelable(&policyParcel)) {
+ res.tokenIDEx = 0;
+ return res;
+ }
+
+ MessageParcel reply;
+ MessageOption option;
+ sptr remote = Remote();
+ if (remote == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: remote service null.", __func__);
+ res.tokenIDEx = 0;
+ return res;
+ }
+ int32_t requestResult = remote->SendRequest(
+ static_cast(IAccessTokenManager::InterfaceCode::ALLOC_TOKEN_HAP), data, reply, option);
+ if (requestResult != NO_ERROR) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s send request fail, result: %{public}d", __func__, requestResult);
+ res.tokenIDEx = 0;
+ return res;
+ }
+
+ uint64_t result = reply.ReadUint64();
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s get result from server data = %{public}llu", __func__, result);
+ res.tokenIDEx = result;
+ return res;
+}
+
+int AccessTokenManagerProxy::DeleteToken(AccessTokenID tokenID)
+{
+ MessageParcel data;
+ data.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
+
+ if (!data.WriteUint32(tokenID)) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: Failed to write tokenID", __func__);
+ return RET_FAILED;
+ }
+
+ MessageParcel reply;
+ MessageOption option;
+ sptr remote = Remote();
+ if (remote == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: remote service null.", __func__);
+ return RET_FAILED;
+ }
+ int32_t requestResult = remote->SendRequest(
+ static_cast(IAccessTokenManager::InterfaceCode::TOKEN_DELETE), data, reply, option);
+ if (requestResult != NO_ERROR) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s send request fail, result: %{public}d", __func__, requestResult);
+ return RET_FAILED;
+ }
+
+ int result = reply.ReadInt32();
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s get result from server data = %{public}d", __func__, result);
+ return result;
+}
+
+int AccessTokenManagerProxy::GetTokenType(AccessTokenID tokenID)
+{
+ MessageParcel data;
+ data.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
+
+ if (!data.WriteUint32(tokenID)) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: Failed to write tokenID", __func__);
+ return RET_FAILED;
+ }
+
+ MessageParcel reply;
+ MessageOption option;
+ sptr remote = Remote();
+ if (remote == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: remote service null.", __func__);
+ return RET_FAILED;
+ }
+ int32_t requestResult = remote->SendRequest(
+ static_cast(IAccessTokenManager::InterfaceCode::GET_TOKEN_TYPE), data, reply, option);
+ if (requestResult != NO_ERROR) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s send request fail, result: %{public}d", __func__, requestResult);
+ return RET_FAILED;
+ }
+
+ int result = reply.ReadInt32();
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s get result from server data = %{public}d", __func__, result);
+ return result;
+}
+
+int AccessTokenManagerProxy::CheckNativeDCap(AccessTokenID tokenID, const std::string& dcap)
+{
+ MessageParcel data;
+ data.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
+
+ if (!data.WriteUint32(tokenID)) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: Failed to write tokenID", __func__);
+ return RET_FAILED;
+ }
+ if (!data.WriteString(dcap)) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: Failed to write dcap", __func__);
+ return RET_FAILED;
+ }
+ MessageParcel reply;
+ MessageOption option;
+ sptr remote = Remote();
+ if (remote == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: remote service null.", __func__);
+ return RET_FAILED;
+ }
+ int32_t requestResult = remote->SendRequest(
+ static_cast(IAccessTokenManager::InterfaceCode::CHECK_NATIVE_DCAP), data, reply, option);
+ if (requestResult != NO_ERROR) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s send request fail, result: %{public}d", __func__, requestResult);
+ return RET_FAILED;
+ }
+
+ int result = reply.ReadInt32();
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s get result from server data = %{public}d", __func__, result);
+ return result;
+}
+
+AccessTokenID AccessTokenManagerProxy::GetHapTokenID(int userID, const std::string& bundleName, int instIndex)
+{
+ MessageParcel data;
+ data.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
+
+ if (!data.WriteInt32(userID)) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: Failed to write tokenID", __func__);
+ return 0;
+ }
+ if (!data.WriteString(bundleName)) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: Failed to write dcap", __func__);
+ return 0;
+ }
+ if (!data.WriteInt32(instIndex)) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: Failed to write dcap", __func__);
+ return 0;
+ }
+ MessageParcel reply;
+ MessageOption option;
+ sptr remote = Remote();
+ if (remote == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: remote service null.", __func__);
+ return 0;
+ }
+ int32_t requestResult = remote->SendRequest(
+ static_cast(IAccessTokenManager::InterfaceCode::GET_HAP_TOKEN_ID), data, reply, option);
+ if (requestResult != NO_ERROR) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s send request fail, result: %{public}d", __func__, requestResult);
+ return 0;
+ }
+
+ int result = reply.ReadInt32();
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s get result from server data = %{public}d", __func__, result);
+ return result;
+}
+
+AccessTokenID AccessTokenManagerProxy::AllocLocalTokenID(
+ const std::string& remoteDeviceID, AccessTokenID remoteTokenID)
+{
+ MessageParcel data;
+ data.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
+
+ if (!data.WriteString(remoteDeviceID)) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: Failed to write dcap", __func__);
+ return 0;
+ }
+ if (!data.WriteUint32(remoteTokenID)) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: Failed to write dcap", __func__);
+ return 0;
+ }
+ MessageParcel reply;
+ MessageOption option;
+ sptr remote = Remote();
+ if (remote == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: remote service null.", __func__);
+ return 0;
+ }
+ int32_t requestResult = remote->SendRequest(
+ static_cast(IAccessTokenManager::InterfaceCode::ALLOC_LOCAL_TOKEN_ID), data, reply, option);
+ if (requestResult != NO_ERROR) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s send request fail, result: %{public}d", __func__, requestResult);
+ return 0;
+ }
+
+ AccessTokenID result = reply.ReadUint32();
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s get result from server data = %{public}d", __func__, result);
+ return result;
+}
+
+int AccessTokenManagerProxy::GetNativeTokenInfo(AccessTokenID tokenID, NativeTokenInfoParcel& nativeTokenInfoRes)
+{
+ MessageParcel data;
+ data.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
+ if (!data.WriteUint32(tokenID)) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: Failed to write permissionName", __func__);
+ return RET_FAILED;
+ }
+
+ MessageParcel reply;
+ MessageOption option;
+ sptr remote = Remote();
+ if (remote == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: remote service null.", __func__);
+ return RET_FAILED;
+ }
+ int32_t requestResult = remote->SendRequest(
+ static_cast(IAccessTokenManager::InterfaceCode::GET_NATIVE_TOKENINFO), data, reply, option);
+ if (requestResult != NO_ERROR) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s send request fail, result: %{public}d", __func__, requestResult);
+ return RET_FAILED;
+ }
+
+ sptr resultSptr = reply.ReadParcelable();
+ if (resultSptr == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s ReadParcelable fail", __func__);
+ return RET_FAILED;
+ }
+ nativeTokenInfoRes = *resultSptr;
+ int32_t result = reply.ReadInt32();
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s get result from server data = %{public}d", __func__, result);
+ return result;
+}
+
+int AccessTokenManagerProxy::GetHapTokenInfo(AccessTokenID tokenID, HapTokenInfoParcel& hapTokenInfoRes)
+{
+ MessageParcel data;
+ data.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
+ if (!data.WriteUint32(tokenID)) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: Failed to write permissionName", __func__);
+ return RET_FAILED;
+ }
+
+ MessageParcel reply;
+ MessageOption option;
+ sptr remote = Remote();
+ if (remote == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: remote service null.", __func__);
+ return RET_FAILED;
+ }
+ int32_t requestResult = remote->SendRequest(
+ static_cast(IAccessTokenManager::InterfaceCode::GET_HAP_TOKENINFO), data, reply, option);
+ if (requestResult != NO_ERROR) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s send request fail, result: %{public}d", __func__, requestResult);
+ return RET_FAILED;
+ }
+
+ sptr resultSptr = reply.ReadParcelable();
+ if (resultSptr == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s ReadParcelable fail", __func__);
+ return RET_FAILED;
+ }
+ hapTokenInfoRes = *resultSptr;
+ int32_t result = reply.ReadInt32();
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s get result from server data = %{public}d", __func__, result);
+ return result;
+}
+
+int AccessTokenManagerProxy::UpdateHapToken(AccessTokenID tokenID,
+ const std::string& appIDDesc, const HapPolicyParcel& policyParcel)
+{
+ MessageParcel data;
+ data.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
+ if (!data.WriteUint32(tokenID)) {
+ return RET_FAILED;
+ }
+ if (!data.WriteString(appIDDesc)) {
+ return RET_FAILED;
+ }
+ if (!data.WriteParcelable(&policyParcel)) {
+ return RET_FAILED;
+ }
+
+ MessageParcel reply;
+ MessageOption option;
+ sptr remote = Remote();
+ if (remote == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: remote service null.", __func__);
+ return RET_FAILED;
+ }
+ int32_t requestResult = remote->SendRequest(
+ static_cast(IAccessTokenManager::InterfaceCode::UPDATE_HAP_TOKEN), data, reply, option);
+ if (requestResult != NO_ERROR) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s send request fail, result: %{public}d", __func__, requestResult);
+ return RET_FAILED;
+ }
+
+ int32_t result = reply.ReadInt32();
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s get result from server data = %{public}d", __func__, result);
+ return result;
+}
} // namespace AccessToken
} // namespace Security
-} // namespace OHOS
\ No newline at end of file
+} // namespace OHOS
diff --git a/interfaces/innerkits/accesstoken/main/cpp/src/accesstoken_manager_proxy.h b/interfaces/innerkits/accesstoken/main/cpp/src/accesstoken_manager_proxy.h
index e0c99c62dc48c7f9c5f9b51106077cb0d4e33a64..9737147025553c2de865d677247bacc2b9faed5f 100644
--- a/interfaces/innerkits/accesstoken/main/cpp/src/accesstoken_manager_proxy.h
+++ b/interfaces/innerkits/accesstoken/main/cpp/src/accesstoken_manager_proxy.h
@@ -16,9 +16,18 @@
#ifndef ACCESSTOKEN_MANAGER_PROXY_H
#define ACCESSTOKEN_MANAGER_PROXY_H
-#include "i_accesstoken_manager.h"
+#include
+#include
+#include "access_token.h"
+#include "hap_info_parcel.h"
+#include "hap_policy_parcel.h"
+#include "hap_token_info_parcel.h"
+#include "i_accesstoken_manager.h"
#include "iremote_proxy.h"
+#include "native_token_info_parcel.h"
+#include "permission_def_parcel.h"
+#include "permission_state_full_parcel.h"
namespace OHOS {
namespace Security {
@@ -28,7 +37,25 @@ public:
explicit AccessTokenManagerProxy(const sptr& impl);
virtual ~AccessTokenManagerProxy() override;
- int VerifyAccesstoken(AccessTokenID tokenID, const std::string& permissionName) override;
+ int VerifyAccessToken(AccessTokenID tokenID, const std::string& permissionName) override;
+ int GetDefPermission(const std::string& permissionName, PermissionDefParcel& permissionDefResult) override;
+ int GetDefPermissions(AccessTokenID tokenID, std::vector& permList) override;
+ int GetReqPermissions(
+ AccessTokenID tokenID, std::vector& reqPermList, bool isSystemGrant) override;
+ int GetPermissionFlag(AccessTokenID tokenID, const std::string& permissionName) override;
+ int GrantPermission(AccessTokenID tokenID, const std::string& permissionName, int flag) override;
+ int RevokePermission(AccessTokenID tokenID, const std::string& permissionName, int flag) override;
+ int ClearUserGrantedPermissionState(AccessTokenID tokenID) override;
+ int GetTokenType(AccessTokenID tokenID) override;
+ int CheckNativeDCap(AccessTokenID tokenID, const std::string& dcap) override;
+ AccessTokenID GetHapTokenID(int userID, const std::string& bundleName, int instIndex) override;
+ AccessTokenID AllocLocalTokenID(const std::string& remoteDeviceID, AccessTokenID remoteTokenID) override;
+ AccessTokenIDEx AllocHapToken(const HapInfoParcel& hapInfo, const HapPolicyParcel& policyParcel) override;
+ int DeleteToken(AccessTokenID tokenID) override;
+ int UpdateHapToken(AccessTokenID tokenID, const std::string& appIDDesc,
+ const HapPolicyParcel& policyPar) override;
+ int GetHapTokenInfo(AccessTokenID tokenID, HapTokenInfoParcel& hapTokenInfoRes) override;
+ int GetNativeTokenInfo(AccessTokenID tokenID, NativeTokenInfoParcel& nativeTokenInfoRes) override;
private:
static inline BrokerDelegator delegator_;
};
diff --git a/interfaces/innerkits/accesstoken/test/BUILD.gn b/interfaces/innerkits/accesstoken/test/BUILD.gn
index a61294493aa5b096203ec73b1f644abca06eb99a..fed32567e96d179dfebb8307f1f7d826aec8fbc9 100755
--- a/interfaces/innerkits/accesstoken/test/BUILD.gn
+++ b/interfaces/innerkits/accesstoken/test/BUILD.gn
@@ -20,7 +20,8 @@ ohos_unittest("libaccesstoken_sdk_test") {
include_dirs = [
"//utils/native/base/include",
- "//base/security/access_token/interfaces/innerkits/accesstoken/main/cpp/include/",
+ "//third_party/googletest/include",
+ "//base/security/access_token/interfaces/innerkits/accesstoken/main/cpp/include"
]
sources = [ "unittest/cpp/src/accesstoken_kit_test.cpp" ]
diff --git a/interfaces/innerkits/accesstoken/test/unittest/cpp/src/accesstoken_kit_test.cpp b/interfaces/innerkits/accesstoken/test/unittest/cpp/src/accesstoken_kit_test.cpp
index 7fbf82406a97720a7a04c6b8de520cacbc67b662..cce73330e8752b833d29957f1f146311a1459549 100755
--- a/interfaces/innerkits/accesstoken/test/unittest/cpp/src/accesstoken_kit_test.cpp
+++ b/interfaces/innerkits/accesstoken/test/unittest/cpp/src/accesstoken_kit_test.cpp
@@ -24,26 +24,285 @@ void AccessTokenKitTest::SetUpTestCase()
{}
void AccessTokenKitTest::TearDownTestCase()
-{}
+{
+}
void AccessTokenKitTest::SetUp()
-{}
+{
+ HapInfoParams info = {
+ .userID = TEST_USER_ID,
+ .bundleName = TEST_BUNDLE_NAME,
+ .instIndex = 0,
+ .appIDDesc = "appIDDesc",
+ };
+ HapPolicyParams policy = {
+ .apl = APL_NORMAL,
+ .domain = "domain"
+ };
+
+ PermissionDef permissionDefAlpha = {
+ .permissionName = TEST_PERMISSION_NAME_ALPHA,
+ .bundleName = TEST_BUNDLE_NAME,
+ .grantMode = GrantMode::USER_GRANT,
+ .availableScope = AVAILABLE_SCOPE_ALL,
+ };
+
+ PermissionDef permissionDefBeta = {
+ .permissionName = TEST_PERMISSION_NAME_BETA,
+ .bundleName = TEST_BUNDLE_NAME,
+ .grantMode = GrantMode::SYSTEM_GRANT,
+ .availableScope = AVAILABLE_SCOPE_ALL,
+ };
+ policy.permList.emplace_back(permissionDefAlpha);
+ policy.permList.emplace_back(permissionDefBeta);
+
+ PermissionStateFull permStatAlpha = {
+ .permissionName = TEST_PERMISSION_NAME_ALPHA,
+ .isGeneral = true,
+ .resDeviceID = {"device"},
+ .grantStatus = {PermissionState::PERMISSION_DENIED},
+ .grantFlags = {PermissionFlag::PERMISSION_USER_SET}
+ };
+ PermissionStateFull permStatBeta = {
+ .permissionName = TEST_PERMISSION_NAME_BETA,
+ .isGeneral = true,
+ .resDeviceID = {"device"},
+ .grantStatus = {PermissionState::PERMISSION_GRANTED},
+ .grantFlags = {PermissionFlag::PERMISSION_USER_SET}
+ };
+ policy.permStateList.emplace_back(permStatAlpha);
+ policy.permStateList.emplace_back(permStatBeta);
+
+ AccessTokenKit::AllocHapToken(info, policy);
+}
void AccessTokenKitTest::TearDown()
-{}
+{
+ AccessTokenID tokenID = GetAccessTokenID(TEST_USER_ID, TEST_BUNDLE_NAME, 0);
+ AccessTokenKit::DeleteToken(tokenID);
+}
+
+unsigned int AccessTokenKitTest::GetAccessTokenID(int userID, std::string bundleName, int instIndex)
+{
+ return AccessTokenKit::GetHapTokenID(userID, bundleName, instIndex);
+}
+/**
+ * @tc.name: AllocHapToken001
+ * @tc.desc: Get permission definition info after AllocHapToken function has been invoked.
+ * @tc.type: FUNC
+ * @tc.require:
+ */
+HWTEST_F(AccessTokenKitTest, AllocHapToken001, TestSize.Level1)
+{
+ PermissionDef permDefResultAlpha;
+ int ret = AccessTokenKit::GetDefPermission(TEST_PERMISSION_NAME_ALPHA, permDefResultAlpha);
+ ASSERT_EQ(TEST_PERMISSION_NAME_ALPHA, permDefResultAlpha.permissionName);
+ ASSERT_EQ(RET_SUCCESS, ret);
+
+ PermissionDef permDefResultBeta;
+ ret = AccessTokenKit::GetDefPermission(TEST_PERMISSION_NAME_BETA, permDefResultBeta);
+ ASSERT_EQ(TEST_PERMISSION_NAME_BETA, permDefResultBeta.permissionName);
+ ASSERT_EQ(RET_SUCCESS, ret);
+}
+
+/**
+ * @tc.name: AllocHapToken002
+ * @tc.desc: Get permission definition info that permission is not exist.
+ * @tc.type: FUNC
+ * @tc.require:
+ */
+HWTEST_F(AccessTokenKitTest, AllocHapToken002, TestSize.Level1)
+{
+ PermissionDef permDefResult;
+ int ret = AccessTokenKit::GetDefPermission(TEST_PERMISSION_NAME_GAMMA, permDefResult);
+ ASSERT_EQ(RET_FAILED, ret);
+}
/**
- * @tc.name: VerifyAccesstoken001
- * @tc.desc: Verify user granted permission
+ * @tc.name: AllocHapToken003
+ * @tc.desc: Get permission definition info list after AllocHapToken function has been invoked.
* @tc.type: FUNC
* @tc.require:
*/
-HWTEST_F(AccessTokenKitTest, VerifyAccesstoken001, TestSize.Level0)
+HWTEST_F(AccessTokenKitTest, AllocHapToken003, TestSize.Level1)
{
- AccessTokenID tokenID = 1;
- const std::string TEST_PERMISSION_NAME = "ohos.permission.TEST";
+ AccessTokenID tokenID = GetAccessTokenID(TEST_USER_ID, TEST_BUNDLE_NAME, 0);
+ std::vector permDefList;
+ int ret = AccessTokenKit::GetDefPermissions(tokenID, permDefList);
+ ASSERT_EQ(RET_SUCCESS, ret);
+ ASSERT_EQ(2, permDefList.size());
+}
- int ret = AccessTokenKit::VerifyAccesstoken(tokenID, TEST_PERMISSION_NAME);
+/**
+ * @tc.name: AllocHapToken004
+ * @tc.desc: Get permission definition info list that tokenID is invalid.
+ * @tc.type: FUNC
+ * @tc.require:
+ */
+HWTEST_F(AccessTokenKitTest, AllocHapToken004, TestSize.Level1)
+{
+ std::vector permDefList;
+ int ret = AccessTokenKit::GetDefPermissions(TEST_TOKENID_INVALID, permDefList);
+ ASSERT_EQ(RET_FAILED, ret);
+}
+
+/**
+ * @tc.name: GetReqPermissions001
+ * @tc.desc: Get user granted permission state info.
+ * @tc.type: FUNC
+ * @tc.require:
+ */
+HWTEST_F(AccessTokenKitTest, GetReqPermissions001, TestSize.Level1)
+{
+ AccessTokenID tokenID = GetAccessTokenID(TEST_USER_ID, TEST_BUNDLE_NAME, 0);
+ std::vector permStatList;
+ int ret = AccessTokenKit::GetReqPermissions(tokenID, permStatList, false);
+ ASSERT_EQ(RET_SUCCESS, ret);
+ ASSERT_EQ(1, permStatList.size());
+ ASSERT_EQ(TEST_PERMISSION_NAME_ALPHA, permStatList[0].permissionName);
+
+ ret = AccessTokenKit::VerifyAccessToken(tokenID, TEST_PERMISSION_NAME_ALPHA);
+ ASSERT_EQ(ret, permStatList[0].grantStatus[0]);
+}
+
+/**
+ * @tc.name: GetReqPermissions002
+ * @tc.desc: Get system granted permission state info.
+ * @tc.type: FUNC
+ * @tc.require:
+ */
+HWTEST_F(AccessTokenKitTest, GetReqPermissions002, TestSize.Level1)
+{
+ AccessTokenID tokenID = GetAccessTokenID(TEST_USER_ID, TEST_BUNDLE_NAME, 0);
+ std::vector permStatList;
+ int ret = AccessTokenKit::GetReqPermissions(tokenID, permStatList, true);
+ ASSERT_EQ(RET_SUCCESS, ret);
+ ASSERT_EQ(1, permStatList.size());
+ ASSERT_EQ(TEST_PERMISSION_NAME_BETA, permStatList[0].permissionName);
+
+ ret = AccessTokenKit::VerifyAccessToken(tokenID, TEST_PERMISSION_NAME_BETA);
+ ASSERT_EQ(ret, permStatList[0].grantStatus[0]);
+}
+
+/**
+ * @tc.name: GetPermissionFlag001
+ * @tc.desc: Get permission flag after grant permission.
+ * @tc.type: FUNC
+ * @tc.require:
+ */
+HWTEST_F(AccessTokenKitTest, GetPermissionFlag001, TestSize.Level1)
+{
+ AccessTokenID tokenID = GetAccessTokenID(TEST_USER_ID, TEST_BUNDLE_NAME, 0);
+ int ret = AccessTokenKit::GrantPermission(tokenID, TEST_PERMISSION_NAME_ALPHA, PERMISSION_USER_FIXED);
+ ASSERT_EQ(RET_SUCCESS, ret);
+
+ ret = AccessTokenKit::GetPermissionFlag(tokenID, TEST_PERMISSION_NAME_ALPHA);
+ ASSERT_EQ(PERMISSION_USER_FIXED, ret);
+}
+
+/**
+ * @tc.name: VerifyAccessToken001
+ * @tc.desc: Verify user granted permission.
+ * @tc.type: FUNC
+ * @tc.require:
+ */
+HWTEST_F(AccessTokenKitTest, VerifyAccessToken001, TestSize.Level0)
+{
+ AccessTokenID tokenID = GetAccessTokenID(TEST_USER_ID, TEST_BUNDLE_NAME, 0);
+ int ret = AccessTokenKit::GrantPermission(tokenID, TEST_PERMISSION_NAME_ALPHA, PERMISSION_USER_FIXED);
+ ASSERT_EQ(RET_SUCCESS, ret);
+
+ ret = AccessTokenKit::VerifyAccessToken(tokenID, TEST_PERMISSION_NAME_ALPHA);
+ ASSERT_EQ(PERMISSION_GRANTED, ret);
+
+ ret = AccessTokenKit::RevokePermission(tokenID, TEST_PERMISSION_NAME_ALPHA, PERMISSION_USER_FIXED);
+ ASSERT_EQ(RET_SUCCESS, ret);
+
+ ret = AccessTokenKit::VerifyAccessToken(tokenID, TEST_PERMISSION_NAME_ALPHA);
+ ASSERT_EQ(PERMISSION_DENIED, ret);
+}
+
+/**
+ * @tc.name: VerifyAccessToken002
+ * @tc.desc: Verify system granted permission.
+ * @tc.type: FUNC
+ * @tc.require:
+ */
+HWTEST_F(AccessTokenKitTest, VerifyAccessToken002, TestSize.Level0)
+{
+ AccessTokenID tokenID = GetAccessTokenID(TEST_USER_ID, TEST_BUNDLE_NAME, 0);
+ int ret = AccessTokenKit::GrantPermission(tokenID, TEST_PERMISSION_NAME_BETA, PERMISSION_USER_FIXED);
+ ASSERT_EQ(RET_SUCCESS, ret);
+
+ ret = AccessTokenKit::VerifyAccessToken(tokenID, TEST_PERMISSION_NAME_BETA);
ASSERT_EQ(PERMISSION_GRANTED, ret);
-}
\ No newline at end of file
+ ret = AccessTokenKit::RevokePermission(tokenID, TEST_PERMISSION_NAME_BETA, PERMISSION_USER_FIXED);
+ ASSERT_EQ(RET_SUCCESS, ret);
+
+ ret = AccessTokenKit::VerifyAccessToken(tokenID, TEST_PERMISSION_NAME_BETA);
+ ASSERT_EQ(PERMISSION_DENIED, ret);
+}
+
+/**
+ * @tc.name: VerifyAccessToken003
+ * @tc.desc: Verify permission that has not been defined.
+ * @tc.type: FUNC
+ * @tc.require:
+ */
+HWTEST_F(AccessTokenKitTest, VerifyAccessToken003, TestSize.Level0)
+{
+ AccessTokenID tokenID = GetAccessTokenID(TEST_USER_ID, TEST_BUNDLE_NAME, 0);
+ int ret = AccessTokenKit::VerifyAccessToken(tokenID, TEST_PERMISSION_NAME_GAMMA);
+ ASSERT_EQ(PERMISSION_DENIED, ret);
+}
+
+/**
+ * @tc.name: ClearUserGrantedPermissionState001
+ * @tc.desc: Clear user granted permission fater ClearUserGrantedPermissionState has been invoked.
+ * @tc.type: FUNC
+ * @tc.require:
+ */
+HWTEST_F(AccessTokenKitTest, ClearUserGrantedPermissionState001, TestSize.Level0)
+{
+ AccessTokenID tokenID = GetAccessTokenID(TEST_USER_ID, TEST_BUNDLE_NAME, 0);
+ int ret = AccessTokenKit::ClearUserGrantedPermissionState(tokenID);
+ ASSERT_EQ(RET_SUCCESS, ret);
+
+ ret = AccessTokenKit::VerifyAccessToken(tokenID, TEST_PERMISSION_NAME_ALPHA);
+ ASSERT_EQ(PERMISSION_DENIED, ret);
+}
+
+/**
+ * @tc.name: DeleteToken001
+ * @tc.desc: Cannot get permission definition info after DeleteToken function has been invoked.
+ * @tc.type: FUNC
+ * @tc.require:
+ */
+HWTEST_F(AccessTokenKitTest, DeleteToken001, TestSize.Level1)
+{
+ AccessTokenID tokenID = GetAccessTokenID(TEST_USER_ID, TEST_BUNDLE_NAME, 0);
+ PermissionDef permDefResultAlpha;
+ int ret = AccessTokenKit::GetDefPermission(TEST_PERMISSION_NAME_ALPHA, permDefResultAlpha);
+ ASSERT_EQ(TEST_PERMISSION_NAME_ALPHA, permDefResultAlpha.permissionName);
+ ASSERT_EQ(RET_SUCCESS, ret);
+
+ ret = AccessTokenKit::DeleteToken(tokenID);
+ ASSERT_EQ(RET_SUCCESS, ret);
+
+ PermissionDef defResult;
+ ret = AccessTokenKit::GetDefPermission(TEST_PERMISSION_NAME_ALPHA, defResult);
+ ASSERT_EQ(RET_FAILED, ret);
+}
+
+/**
+ * @tc.name: DeleteToken002
+ * @tc.desc: Delete invalid tokenID.
+ * @tc.type: FUNC
+ * @tc.require:
+ */
+HWTEST_F(AccessTokenKitTest, DeleteToken002, TestSize.Level1)
+{
+ int ret = AccessTokenKit::DeleteToken(TEST_USER_ID_INVALID);
+ ASSERT_EQ(RET_FAILED, ret);
+}
diff --git a/interfaces/innerkits/accesstoken/test/unittest/cpp/src/accesstoken_kit_test.h b/interfaces/innerkits/accesstoken/test/unittest/cpp/src/accesstoken_kit_test.h
index 5784ad6f4cccb0584a0794179a4b32e6de6212c6..25de97777f62a265f66b7da8e7911faa359495fd 100644
--- a/interfaces/innerkits/accesstoken/test/unittest/cpp/src/accesstoken_kit_test.h
+++ b/interfaces/innerkits/accesstoken/test/unittest/cpp/src/accesstoken_kit_test.h
@@ -21,6 +21,13 @@
namespace OHOS {
namespace Security {
namespace AccessToken {
+static const std::string TEST_BUNDLE_NAME = "ohos";
+static const std::string TEST_PERMISSION_NAME_ALPHA = "ohos.permission.ALPHA";
+static const std::string TEST_PERMISSION_NAME_BETA = "ohos.permission.BETA";
+static const std::string TEST_PERMISSION_NAME_GAMMA = "ohos.permission.GAMMA";
+static const int TEST_USER_ID = 0;
+static const int TEST_USER_ID_INVALID = -1;
+static const unsigned int TEST_TOKENID_INVALID = 0;
class AccessTokenKitTest : public testing::Test {
public:
static void SetUpTestCase();
@@ -30,6 +37,7 @@ public:
void SetUp();
void TearDown();
+ unsigned int GetAccessTokenID(int userID, std::string bundleName, int instIndex);
};
} // namespace AccessToken
} // namespace Security
diff --git a/interfaces/innerkits/atlib/BUILD.gn b/interfaces/innerkits/atlib/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..29099e670ad8d321e457f6b211fdc347261b8f57
--- /dev/null
+++ b/interfaces/innerkits/atlib/BUILD.gn
@@ -0,0 +1,55 @@
+# Copyright (C) 2021 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")
+
+################################################################
+# C, Main, source file here.
+################################################################
+config("accesstokenlib") {
+ visibility = [ ":*" ]
+ include_dirs = [ "main/include" ]
+}
+
+ohos_shared_library("libaccesstoken_lib") {
+ subsystem_name = "security"
+ part_name = "access_token"
+ output_name = "libaccesstoken_lib"
+
+ public_configs = [ ":accesstokenlib" ]
+
+ cflags = [ "-Wall" ]
+
+ include_dirs = [
+ "//utils/native/base/include",
+ "main/include",
+ "main/src",
+ "//third_party/cJSON",
+ "//third_party/bounds_checking_function/include",
+ "//base/hiviewdfx/hilog_lite/interfaces/native/kits",
+ ]
+
+ sources = [
+ "main/src/accesstoken_lib.c",
+ ]
+
+ deps = [
+ "//utils/native/base:utils",
+ "//third_party/cJSON:cjson_static",
+ "//utils/native/base:utilsecurec_shared",
+ ]
+
+ external_deps = [
+ "hiviewdfx_hilog_native:libhilog",
+ ]
+}
diff --git a/interfaces/innerkits/atlib/main/include/accesstoken_lib.h b/interfaces/innerkits/atlib/main/include/accesstoken_lib.h
new file mode 100644
index 0000000000000000000000000000000000000000..da37447118b727d4d3f5bea57060b0dc4fc9b725
--- /dev/null
+++ b/interfaces/innerkits/atlib/main/include/accesstoken_lib.h
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2021 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 ACCESSTOKENs and
+ * limitations under the License.
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "cJSON.h"
+#include "securec.h"
+#include "accesstoken_log.h"
+
+#ifndef ACCESSTOKEN_LIB_H
+#define ACCESSTOKEN_LIB_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define MAX_PROCESS_NAME_LEN 256
+#define TOKEN_ID_CFG_PATH "/data/token.json"
+#define SOCKET_FILE "/data/token_unix_socket"
+#define ERR 1
+#define SUCCESS 0
+#define TOKEN_NATIVE_TYPE 1
+#define DEFAULT_AT_VERSION 1
+#define TRANSFER_KEY_WORDS "NativeTokenInfo"
+#define MAX_JSON_FILE_LEN 102400
+
+typedef unsigned int NativeAtId;
+typedef unsigned int NativeAtAttr;
+
+typedef struct {
+ unsigned int tokenUniqueId : 24;
+ unsigned int reserved : 3;
+ unsigned int type : 2;
+ unsigned int version : 3;
+} AtInnerInfo;
+
+typedef struct {
+ NativeAtId tokenId;
+ NativeAtAttr tokenAttr;
+} NativeAtIdEx;
+
+typedef struct TokenList {
+ NativeAtId tokenId;
+ char processName[MAX_PROCESS_NAME_LEN];
+ struct TokenList *next;
+} NativeTokenList;
+
+typedef struct TokenQueue {
+ NativeAtId tokenId;
+ int apl;
+ const char *processName;
+ const char **dcaps;
+ int dcapsNum;
+ int flag;
+ struct TokenQueue *next;
+} NativeTokenQueue;
+
+#define TOKEN_QUEUE_NODE_INFO_SET(tmp, aplStr, processname, tokenId, exist, dcap, dacpNum) do { \
+ (tmp).apl = GetAplLevel((aplStr)); \
+ (tmp).processName = (processname); \
+ (tmp).tokenId = (tokenId); \
+ (tmp).flag = (exist); \
+ (tmp).dcaps = (dcap); \
+ (tmp).dcapsNum = (dacpNum); \
+} while (0)
+
+extern void *ThreadTransferFunc(const void *args);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // ACCESSTOKEN_LIB_H
diff --git a/interfaces/innerkits/atlib/main/include/accesstoken_log.h b/interfaces/innerkits/atlib/main/include/accesstoken_log.h
new file mode 100644
index 0000000000000000000000000000000000000000..cdf5fa761840922ab558017cb9a08e202e77f755
--- /dev/null
+++ b/interfaces/innerkits/atlib/main/include/accesstoken_log.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2021 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 ACCESSTOKENs and
+ * limitations under the License.
+ */
+
+#ifndef ACCESSTOKEN_LOG_H
+#define ACCESSTOKEN_LOG_H
+
+#ifdef HILOG_ENABLE
+
+#include "hilog/log.h"
+
+#define ACCESSTOKEN_LOG_DEBUG(fmt, ...) HILOG_DEBUG(LOG_CORE, fmt, ##__VA_ARGS__)
+#define ACCESSTOKEN_LOG_INFO(fmt, ...) HILOG_INFO(LOG_CORE, fmt, ##__VA_ARGS__)
+#define ACCESSTOKEN_LOG_WARN(fmt, ...) HILOG_WARN(LOG_CORE, fmt, ##__VA_ARGS__)
+#define ACCESSTOKEN_LOG_ERROR(fmt, ...) ACCESSTOKEN_LOG_ERROR(LOG_CORE, fmt, ##__VA_ARGS__)
+#define ACCESSTOKEN_LOG_FATAL(fmt, ...) HILOG_FATAL(LOG_CORE, fmt, ##__VA_ARGS__)
+
+/* define LOG_TAG as "security_*" at your submodule, * means your submodule name such as "security_dac" */
+#undef LOG_TAG
+#undef LOG_DOMAIN
+
+#else
+
+#include
+#include
+
+/* define LOG_TAG as "security_*" at your submodule, * means your submodule name such as "security_dac" */
+#define LOG_TAG "accssToken_"
+
+#define ACCESSTOKEN_LOG_DEBUG(fmt, ...) printf("[%s] debug: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__)
+#define ACCESSTOKEN_LOG_INFO(fmt, ...) printf("[%s] info: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__)
+#define ACCESSTOKEN_LOG_WARN(fmt, ...) printf("[%s] warn: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__)
+#define ACCESSTOKEN_LOG_ERROR(fmt, ...) printf("[%s] error: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__)
+#define ACCESSTOKEN_LOG_FATAL(fmt, ...) printf("[%s] fatal: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__)
+
+#endif // HILOG_ENABLE
+
+#endif // ACCESSTOKEN_LOG_H
diff --git a/interfaces/innerkits/atlib/main/include/accesstokenlib_kit.h b/interfaces/innerkits/atlib/main/include/accesstokenlib_kit.h
new file mode 100644
index 0000000000000000000000000000000000000000..d0511410ec647e910583e879c222b8af494f8732
--- /dev/null
+++ b/interfaces/innerkits/atlib/main/include/accesstokenlib_kit.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2021 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 INTERFACES_INNER_KITS_ACCESSTOKEN_LIB_H
+#define INTERFACES_INNER_KITS_ACCESSTOKEN_LIB_H
+
+#include
+#include
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int32_t AtlibInit(void);
+
+extern uint64_t GetAccessTokenId(const char *processname, const char **dcap, int32_t dacpNum, const char *aplStr);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // INTERFACES_INNER_KITS_ACCESSTOKEN_LIB_H
diff --git a/interfaces/innerkits/atlib/main/src/accesstoken_lib.c b/interfaces/innerkits/atlib/main/src/accesstoken_lib.c
new file mode 100644
index 0000000000000000000000000000000000000000..7a921900ee11fce8eb03420afeceba6ae03a30a1
--- /dev/null
+++ b/interfaces/innerkits/atlib/main/src/accesstoken_lib.c
@@ -0,0 +1,514 @@
+/*
+ * Copyright (c) 2021 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 ACCESSTOKENs and
+ * limitations under the License.
+ */
+
+#include "accesstoken_lib.h"
+#include "accesstokenlib_kit.h"
+
+NativeTokenQueue *g_tokenQueueHead;
+NativeTokenList *g_tokenListHead;
+int g_isAtmExist;
+int g_signalFd;
+static pthread_mutex_t g_tokenQueueHeadLock = PTHREAD_MUTEX_INITIALIZER;
+
+char *GetFileBuff(const char *cfg)
+{
+ char *buff = NULL;
+ FILE *cfgFd = NULL;
+ struct stat fileStat;
+ int fileSize;
+
+ if (stat(cfg, &fileStat) != 0) {
+ ACCESSTOKEN_LOG_ERROR("stat file failed.");
+ return NULL;
+ }
+ fileSize = (int)fileStat.st_size;
+ if ((fileSize < 0) || (fileSize > MAX_JSON_FILE_LEN)) {
+ ACCESSTOKEN_LOG_ERROR("stat file size is invalid.");
+ return NULL;
+ }
+
+ cfgFd = fopen(cfg, "r");
+ if (cfgFd == NULL) {
+ ACCESSTOKEN_LOG_ERROR("fopen file failed.");
+ return NULL;
+ }
+
+ buff = (char *)malloc((size_t)(fileSize + 1));
+ if (buff == NULL) {
+ ACCESSTOKEN_LOG_ERROR("memory alloc failed.");
+ fclose(cfgFd);
+ return NULL;
+ }
+
+ if (fread(buff, fileSize, 1, cfgFd) != 1) {
+ ACCESSTOKEN_LOG_ERROR("fread failed.");
+ free(buff);
+ buff = NULL;
+ } else {
+ buff[fileSize] = '\0';
+ }
+
+ fclose(cfgFd);
+ return buff;
+}
+
+int GetTokenList(const cJSON *object)
+{
+ if (object == NULL) {
+ return ERR;
+ }
+ int arraySize = cJSON_GetArraySize(object);
+
+ for (int i = 0; i < arraySize; i++) {
+ cJSON *cjsonItem = cJSON_GetArrayItem(object, i);
+ cJSON *processNameJson = cJSON_GetObjectItem(cjsonItem, "processName");
+ cJSON *tokenIdJson = cJSON_GetObjectItem(cjsonItem, "tokenId");
+ if (cJSON_IsString(processNameJson) == 0 || (strlen(processNameJson->valuestring) > MAX_PROCESS_NAME_LEN)) {
+ ACCESSTOKEN_LOG_ERROR("processNameJson is invalid.");
+ return ERR;
+ }
+ if ((cJSON_IsNumber(tokenIdJson) == 0) || (cJSON_GetNumberValue(tokenIdJson) <= 0)) {
+ ACCESSTOKEN_LOG_ERROR("tokenIdJson is invalid.");
+ return ERR;
+ }
+
+ NativeTokenList *tmp = (NativeTokenList *)malloc(sizeof(NativeTokenList));
+ if (tmp == NULL) {
+ ACCESSTOKEN_LOG_ERROR("memory alloc failed.");
+ return ERR;
+ }
+ (void)strcpy_s(tmp->processName, MAX_PROCESS_NAME_LEN, processNameJson->valuestring);
+ tmp->tokenId = tokenIdJson->valueint;
+ tmp->next = g_tokenListHead->next;
+ g_tokenListHead->next = tmp;
+ }
+ return SUCCESS;
+}
+
+int ParseTokenInfoCfg(const char *filename)
+{
+ char *fileBuff;
+ cJSON *record;
+ int ret;
+
+ if (filename == NULL || filename[0] == '\0') {
+ return ERR;
+ }
+ fileBuff = GetFileBuff(filename);
+ if (fileBuff == NULL) {
+ return ERR;
+ }
+ record = cJSON_Parse(fileBuff);
+ free(fileBuff);
+ fileBuff = NULL;
+
+ ret = GetTokenList(record);
+ cJSON_Delete(record);
+
+ return ret;
+}
+
+int AtlibInit(void)
+{
+ g_tokenListHead = (NativeTokenList *)malloc(sizeof(NativeTokenList));
+ if (g_tokenListHead == NULL) {
+ ACCESSTOKEN_LOG_ERROR("g_tokenListHead memory alloc failed.");
+ return ERR;
+ }
+ g_tokenListHead->next = NULL;
+
+ g_tokenQueueHead = (NativeTokenQueue *)malloc(sizeof(NativeTokenQueue));
+ if (g_tokenQueueHead == NULL) {
+ free(g_tokenListHead);
+ ACCESSTOKEN_LOG_ERROR("g_tokenQueueHead memory alloc failed.");
+ return ERR;
+ }
+ g_tokenQueueHead->next = NULL;
+ g_isAtmExist = 0;
+
+ return ParseTokenInfoCfg(TOKEN_ID_CFG_PATH);
+}
+
+int GetRandomTokenId(unsigned int *randNum)
+{
+ unsigned int random;
+ int len;
+ int fd = open("/dev/urandom", O_RDONLY);
+ if (fd == -1) {
+ return ERR;
+ }
+ len = read(fd, &random, sizeof(random));
+ (void)close(fd);
+ if (len != sizeof(random)) {
+ ACCESSTOKEN_LOG_ERROR("read failed.");
+ return ERR;
+ }
+ *randNum = random;
+ return SUCCESS;
+}
+
+NativeAtId CreateNativeTokenId(const char *processName)
+{
+ unsigned int rand;
+ NativeAtId tokenId;
+ AtInnerInfo *innerId = (AtInnerInfo *)(&tokenId);
+
+ if (GetRandomTokenId(&rand) == ERR) {
+ return 0;
+ }
+
+ innerId->reserved = 0;
+ innerId->tokenUniqueId = rand & (0xFFFFFF);
+ innerId->type = TOKEN_NATIVE_TYPE;
+ innerId->version = 1;
+ return tokenId;
+}
+
+int TriggerTransfer()
+{
+ int ret;
+ static const uint64_t increment = 1;
+ ret = write(g_signalFd, &increment, sizeof(increment));
+ if (ret == -1) {
+ ACCESSTOKEN_LOG_ERROR("TriggerTransfer write failed.");
+ return ERR;
+ }
+ return SUCCESS;
+}
+
+int TokenInfoSave(const NativeTokenQueue *node)
+{
+ if (node->apl == 0) {
+ return ERR;
+ }
+ NativeTokenQueue *curr;
+ curr = (NativeTokenQueue *)malloc(sizeof(NativeTokenQueue));
+ if (curr == NULL) {
+ ACCESSTOKEN_LOG_ERROR("memory alloc failed.");
+ return ERR;
+ }
+ curr->apl = node->apl;
+ curr->processName = node->processName;
+ curr->tokenId = node->tokenId;
+ curr->flag = node->flag;
+ curr->dcaps = node->dcaps;
+ curr->dcapsNum = node->dcapsNum;
+
+ pthread_mutex_lock(&g_tokenQueueHeadLock);
+ curr->next = g_tokenQueueHead->next;
+ g_tokenQueueHead->next = curr;
+ pthread_mutex_unlock(&g_tokenQueueHeadLock);
+
+ if (g_isAtmExist == 1) {
+ return TriggerTransfer();
+ }
+ return SUCCESS;
+}
+
+int GetAplLevel(const char *aplStr)
+{
+ if (strcmp(aplStr, "system_core") == 0) {
+ return 3; // system_core means apl level is 3
+ }
+ if (strcmp(aplStr, "system_basic") == 0) {
+ return 2; // system_basic means apl level is 2
+ }
+ if (strcmp(aplStr, "normal") == 0) {
+ return 1;
+ }
+ return 0;
+}
+
+uint64_t GetAccessTokenId(const char *processname, const char **dcap, int dacpNum, const char *aplStr)
+{
+ NativeAtId tokenId;
+ NativeTokenList *tokenNode = g_tokenListHead;
+ NativeTokenQueue tmp;
+
+ int exist = 0;
+ int ret;
+ uint64_t result = 0;
+ NativeAtIdEx *atPoint = (NativeAtIdEx *)(&result);
+
+ while (tokenNode != NULL) {
+ if (strcmp(tokenNode->processName, processname) == 0) {
+ exist = 1;
+ tokenId = tokenNode->tokenId;
+ break;
+ }
+ tokenNode = tokenNode->next;
+ }
+
+ if (exist == 0) {
+ tokenId = CreateNativeTokenId(processname);
+ tokenNode = (NativeTokenList *)malloc(sizeof(NativeTokenList));
+ if (tokenNode == NULL) {
+ ACCESSTOKEN_LOG_ERROR("memory alloc failed.");
+ return 0;
+ }
+ (void)strcpy_s(tokenNode->processName, MAX_PROCESS_NAME_LEN, processname);
+ tokenNode->tokenId = tokenId;
+ tokenNode->next = g_tokenListHead->next;
+ g_tokenListHead->next = tokenNode;
+ ACCESSTOKEN_LOG_INFO("tokenNode->tokenId :%d, tokenNode->processName: %s\n", tokenNode->tokenId, tokenNode->processName);
+ }
+
+ TOKEN_QUEUE_NODE_INFO_SET(tmp, aplStr, processname, tokenId, exist, dcap, dacpNum);
+ ret = TokenInfoSave(&tmp);
+ if (ret == 0) {
+ return result;
+ }
+ atPoint->tokenId = tokenId;
+ atPoint->tokenAttr = 0;
+ return result;
+}
+
+int SendString(const char *str, int fd)
+{
+ int writtenSize;
+ int len = strlen(str);
+
+ writtenSize = write(fd, str, len);
+ if (len != writtenSize) {
+ ACCESSTOKEN_LOG_ERROR("SendString write failed.");
+ return ERR;
+ }
+ return SUCCESS;
+}
+
+void WriteToFile(const cJSON *root)
+{
+ char *jsonStr;
+ jsonStr = cJSON_PrintUnformatted(root);
+ if (jsonStr == NULL) {
+ ACCESSTOKEN_LOG_ERROR("cJSON_PrintUnformatted failed.");
+ return;
+ }
+ ACCESSTOKEN_LOG_INFO("jsonStr %s.\n", jsonStr);
+
+ do {
+ int fd = open(TOKEN_ID_CFG_PATH, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
+ if (fd < 0) {
+ break;
+ }
+ int strLen = strlen(jsonStr);
+ int writtenLen = write(fd, (void *)jsonStr, strLen);
+ close(fd);
+ if (writtenLen != strLen) {
+ ACCESSTOKEN_LOG_ERROR("write failed.");
+ break;
+ }
+ } while (0);
+
+ cJSON_free(jsonStr);
+ return;
+}
+
+int ExistNewTokenInfo(const NativeTokenQueue *head)
+{
+ const NativeTokenQueue *iter = head;
+ while (iter != NULL) {
+ if (iter->flag == 0) {
+ return 1;
+ }
+ iter = iter->next;
+ }
+ return 0;
+}
+void SaveTokenIdToCfg(const NativeTokenQueue *head)
+{
+ const NativeTokenQueue *iter = head;
+ char *fileBuff;
+ cJSON *record;
+ int ret;
+
+ ret = ExistNewTokenInfo(head);
+ if (ret == 0) {
+ ACCESSTOKEN_LOG_INFO("there is no new info.\n");
+ return;
+ }
+ fileBuff = GetFileBuff(TOKEN_ID_CFG_PATH);
+ if (fileBuff == NULL) {
+ return;
+ }
+
+ record = cJSON_Parse(fileBuff);
+ free(fileBuff);
+ fileBuff = NULL;
+
+ if (record == NULL) {
+ ACCESSTOKEN_LOG_ERROR("cJSON_Parse failed.");
+ return;
+ }
+
+ while (iter != NULL) {
+ if (iter->flag == 1) {
+ continue;
+ }
+ cJSON *node = cJSON_CreateObject();
+ if (node == NULL) {
+ ACCESSTOKEN_LOG_ERROR("cJSON_CreateObject failed.");
+ cJSON_Delete(record);
+ return;
+ }
+ cJSON_AddItemToObject(node, "processName", cJSON_CreateString(iter->processName));
+ cJSON_AddItemToObject(node, "tokenId", cJSON_CreateNumber(iter->tokenId));
+ cJSON_AddItemToArray(record, node);
+ iter = iter->next;
+ }
+ WriteToFile(record);
+ cJSON_Delete(record);
+ return;
+}
+
+char * GetStringToBeSync(NativeTokenQueue *head)
+{
+ if (head == NULL) {
+ return NULL;
+ }
+
+ cJSON *array = cJSON_CreateArray();
+ if (array == NULL) {
+ return NULL;
+ }
+
+ NativeTokenQueue *curr = head;
+ while (curr != 0) {
+ cJSON *object = cJSON_CreateObject();
+ if (object == NULL) {
+ cJSON_Delete(array);
+ return NULL;
+ }
+ cJSON_AddItemToObject(object, "processName", cJSON_CreateString(curr->processName));
+ cJSON_AddItemToObject(object, "APL", cJSON_CreateNumber(curr->apl));
+ cJSON_AddItemToObject(object, "version", cJSON_CreateNumber(DEFAULT_AT_VERSION));
+ cJSON_AddItemToObject(object, "tokenId", cJSON_CreateNumber(curr->tokenId));
+ cJSON_AddItemToObject(object, "tokenAttr", cJSON_CreateNumber(0));
+
+ cJSON *dcapsArr = cJSON_CreateArray();
+ if (dcapsArr == NULL) {
+ cJSON_Delete(array);
+ return NULL;
+ }
+ for (int i = 0; i < curr->dcapsNum; i++) {
+ cJSON_AddItemToArray(dcapsArr, cJSON_CreateString(curr->dcaps[i]));
+ }
+ cJSON_AddItemToObject(object, "dcaps", dcapsArr);
+ cJSON_AddItemToArray(array, object);
+
+ NativeTokenQueue *node;
+ node = curr;
+ curr = curr->next;
+ free(node);
+ node = NULL;
+ }
+
+ cJSON *root = cJSON_CreateObject();
+ if (root == NULL) {
+ cJSON_Delete(array);
+ return NULL;
+ }
+
+ cJSON_AddItemToObject(root, TRANSFER_KEY_WORDS, array);
+
+ char *jsonStr = cJSON_PrintUnformatted(root);
+ if (jsonStr == NULL) {
+ cJSON_Delete(root);
+ return NULL;
+ }
+
+ char *str = (char *)malloc(sizeof(char) * (strlen(jsonStr) + 1));
+ if (str == NULL) {
+ cJSON_free(jsonStr);
+ cJSON_Delete(root);
+ return NULL;
+ }
+
+ (void)strcpy_s(str, strlen(jsonStr) + 1, jsonStr);
+ cJSON_free(jsonStr);
+ cJSON_Delete(root);
+ return str;
+}
+
+int SyncToAtm(void)
+{
+ int result;
+ struct sockaddr_un addr;
+ int fd;
+ char *str;
+
+ /* get data to be processed */
+ pthread_mutex_lock(&g_tokenQueueHeadLock);
+ NativeTokenQueue *begin = g_tokenQueueHead->next;
+ g_tokenQueueHead->next = NULL;
+ pthread_mutex_unlock(&g_tokenQueueHeadLock);
+
+ /* update the token file */
+ SaveTokenIdToCfg(begin);
+
+ str = GetStringToBeSync(begin);
+ if (str == NULL) {
+ return SUCCESS;
+ }
+
+ /* set socket */
+ fd = socket(AF_UNIX, SOCK_STREAM, 0);
+ (void)memset_s(&addr, sizeof(struct sockaddr_un), 0, sizeof(struct sockaddr_un));
+ addr.sun_family = AF_UNIX;
+ if (memcpy_s(addr.sun_path, sizeof(addr.sun_path), SOCKET_FILE, sizeof(addr.sun_path) - 1) != EOK) {
+ ACCESSTOKEN_LOG_ERROR("memcpy_s failed.");
+ return ERR;
+ }
+ result = connect(fd, (struct sockaddr *)&addr, sizeof(addr)); // 建立socket后默认connect()函数为阻塞连接状态
+ if (result != 0) {
+ ACCESSTOKEN_LOG_ERROR("connect failed %d.", result);
+ return ERR;
+ }
+
+ result = SendString(str, fd);
+ free(str);
+ close(fd);
+ return result;
+}
+
+void *ThreadTransferFunc(const void *args)
+{
+ uint64_t result;
+
+ /*
+ getpram
+ */
+
+ g_signalFd = eventfd(0, 0);
+ if (g_signalFd == -1) {
+ ACCESSTOKEN_LOG_ERROR("eventfd failed.");
+ return NULL;
+ }
+
+ g_isAtmExist = 1;
+ while (1) {
+ int ret;
+ ret = read(g_signalFd, &result, sizeof(uint64_t));
+ if (ret == -1) {
+ ACCESSTOKEN_LOG_ERROR("read failed.");
+ continue;
+ }
+ ret = SyncToAtm();
+ if (ret == -1) {
+ ACCESSTOKEN_LOG_ERROR("SyncToAtm failed.");
+ }
+ }
+ return NULL;
+}
diff --git a/interfaces/innerkits/atlib/test/BUILD.gn b/interfaces/innerkits/atlib/test/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..913506e798fe9602c0ad44eb394c9f0aba84f5f3
--- /dev/null
+++ b/interfaces/innerkits/atlib/test/BUILD.gn
@@ -0,0 +1,44 @@
+# Copyright (C) 2021 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/test.gni")
+
+ohos_unittest("libaccesstoken_lib_test") {
+ subsystem_name = "security"
+ part_name = "access_token"
+ module_out_path = part_name + "/" + part_name
+
+ include_dirs = [
+ "//utils/native/base/include",
+ "//third_party/cJSON",
+ "//third_party/bounds_checking_function/include",
+ "//base/security/access_token/interfaces/innerkits/atlib/main/include"
+ ]
+
+ sources = [ "unittest/cpp/src/accesstokenlib_kit_test.cpp" ]
+ cflags_cc = ["-fexceptions" ]
+ ldflags = ["-lpthread",]
+ deps = [
+ "//third_party/cJSON:cjson_static",
+ "//utils/native/base:utils",
+ "//third_party/googletest:gmock",
+ "//third_party/googletest:gtest",
+ "//third_party/libuv:uv_static",
+ "//third_party/bounds_checking_function:libsec_static",
+ ]
+}
+
+group("unittest") {
+ testonly = true
+ deps = [ ":libaccesstoken_lib_test" ]
+}
diff --git a/interfaces/innerkits/atlib/test/unittest/cpp/src/accesstokenlib_kit_test.cpp b/interfaces/innerkits/atlib/test/unittest/cpp/src/accesstokenlib_kit_test.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..04a1e5ffb90622d6c0452f0590e5c4810b45e816
--- /dev/null
+++ b/interfaces/innerkits/atlib/test/unittest/cpp/src/accesstokenlib_kit_test.cpp
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2021 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 "accesstokenlib_kit_test.h"
+
+#include "accesstokenlib_kit.h"
+#include "accesstoken_lib.h"
+
+using namespace testing::ext;
+using namespace OHOS::Security;
+
+void TokenLibKitTest::SetUpTestCase()
+{}
+
+void TokenLibKitTest::TearDownTestCase()
+{}
+
+void TokenLibKitTest::SetUp()
+{}
+
+void TokenLibKitTest::TearDown()
+{}
+
+extern char *GetFileBuff(const char *cfg);
+
+void * ThreadATMFuncBackUp(void *args)
+{
+ socklen_t len = sizeof(struct sockaddr_un);
+ struct sockaddr_un addr;
+ struct sockaddr_un clientAddr;
+ int listenFd, ret;
+ int readLen;
+
+ /* set socket */
+ (void)memset_s(&addr, sizeof(addr), 0, sizeof(addr));
+ addr.sun_family = AF_UNIX;
+ if (memcpy_s(addr.sun_path, sizeof(addr.sun_path), SOCKET_FILE, sizeof(addr.sun_path) - 1) != EOK) {
+ return NULL;
+ }
+ unlink(SOCKET_FILE);
+ listenFd = socket(AF_UNIX, SOCK_STREAM, 0);
+ if (listenFd < 0) {
+ ACCESSTOKEN_LOG_INFO("socket failed %d\n", listenFd);
+ return NULL;
+ }
+
+ ::bind(listenFd, (struct sockaddr *)(&addr), (unsigned int)len);
+
+ ret = listen(listenFd, 1);
+ if (ret < 0) {
+ ACCESSTOKEN_LOG_INFO("listenFd failed %d\n", errno);
+ remove(SOCKET_FILE);
+ close(listenFd);
+ return NULL;
+ }
+ while (1) {
+ int sockFd = accept(listenFd, (struct sockaddr *)(&clientAddr), &len);
+ ACCESSTOKEN_LOG_INFO("accept sockFd %d\n", sockFd);
+ do {
+ readLen = read(sockFd, OHOS::Security::TokenLibKitTest::buffer, 102400);
+ OHOS::Security::TokenLibKitTest::buffer[readLen] = '\0';
+ ACCESSTOKEN_LOG_INFO("read :%s\n", OHOS::Security::TokenLibKitTest::buffer);
+ } while (readLen > 0);
+
+ close(sockFd);
+ if (readLen < 0) {
+ break;
+ }
+ }
+ close(listenFd);
+ return NULL;
+}
+
+int Start(const char *processName)
+{
+ const char *processname = processName;
+ const char **dcaps = (const char **)malloc(sizeof(char *) * 2);
+ dcaps[0] = "AT_CAP";
+ dcaps[1] = "ST_CAP";
+ int dcapNum = 2;
+ pthread_t tid[2];
+ (void)GetAccessTokenId(processname, dcaps, dcapNum, "system_core");
+
+ if (strcmp("foundation", processname) == 0) {
+ (void)pthread_create(&tid[0], 0, ThreadTransferFunc, NULL);
+ }
+ return 0;
+}
+
+HWTEST_F(TokenLibKitTest, TestAtlib, TestSize.Level1)
+{
+ pthread_t tid[2];
+
+ AtlibInit();
+ (void)pthread_create(&tid[1], 0, ThreadATMFuncBackUp, NULL);
+ sleep(5);
+ Start("process1");
+ Start("process2");
+ Start("process3");
+ Start("process4");
+ sleep(5);
+ Start("foundation");
+ Start("process5");
+ Start("process6");
+ sleep(20);
+ Start("process7");
+ Start("process8");
+ Start("process9");
+ sleep(50);
+
+}
diff --git a/interfaces/innerkits/atlib/test/unittest/cpp/src/accesstokenlib_kit_test.h b/interfaces/innerkits/atlib/test/unittest/cpp/src/accesstokenlib_kit_test.h
new file mode 100644
index 0000000000000000000000000000000000000000..f03660d8ce29bf1a927c1da060fdfedbb9bdd99b
--- /dev/null
+++ b/interfaces/innerkits/atlib/test/unittest/cpp/src/accesstokenlib_kit_test.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2021 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 TOKENSYNC_KIT_TEST_H
+#define TOKENSYNC_KIT_TEST_H
+
+#include
+
+namespace OHOS {
+namespace Security {
+class TokenLibKitTest : public testing::Test {
+public:
+ static char buffer[102400];
+ static void SetUpTestCase();
+
+ static void TearDownTestCase();
+
+ void SetUp();
+
+ void TearDown();
+};
+} // namespace Security
+} // namespace OHOS
+#endif // TOKENSYNC_KIT_TEST_H
diff --git a/interfaces/innerkits/tokensync/BUILD.gn b/interfaces/innerkits/tokensync/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..0fe7a79073e3f5b663afec7443584d4398f8846a
--- /dev/null
+++ b/interfaces/innerkits/tokensync/BUILD.gn
@@ -0,0 +1,64 @@
+# Copyright (C) 2021 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")
+
+################################################################
+# C++, Main, source file here.
+################################################################
+config("tokensync") {
+ visibility = [ ":*" ]
+ include_dirs = [ "main/cpp/include" ]
+}
+
+ohos_shared_library("libtokensync_sdk") {
+ subsystem_name = "security"
+ part_name = "access_token"
+
+ output_name = "libtokensync_sdk"
+
+ public_configs = [ ":tokensync" ]
+
+ include_dirs = [
+ "//utils/native/base/include",
+ "main/cpp/include",
+ "main/cpp/src",
+ "//base/security/access_token/frameworks/tokensync/include",
+ "//base/security/access_token/frameworks/common/include",
+ "//base/security/access_token/interfaces/innerkits/tokensync/main/cpp/include"
+ #"//base/security/permission/interfaces/innerkits/permission_standard/permissionsdk/main/cpp/include/permission",
+ ]
+
+ sources = [
+ #"main/cpp/src/permission/permission_kit.cpp",
+ #"main/cpp/src/permission/permission_manager_client.cpp",
+ #"main/cpp/src/permission/permission_manager_proxy.cpp",
+ "main/cpp/src/tokensync_kit.cpp",
+ "main/cpp/src/tokensync_manager_client.cpp",
+ "main/cpp/src/tokensync_manager_proxy.cpp",
+ ]
+
+ deps = [
+ #"//base/security/permission/frameworks/permission_standard/permissioncommunicationadapter:permission_standard_communication_adapter_cxx",
+ #"//base/security/permission/frameworks/permission_standard/permissioninfrastructure:permission_standard_infrastructure_cxx",
+ "//utils/native/base:utils",
+ ]
+
+ external_deps = [
+ "hiviewdfx_hilog_native:libhilog",
+ "ipc:ipc_core",
+ "samgr_standard:samgr_proxy",
+ ]
+
+ cflags_cc = [ "-DHILOG_ENABLE" ]
+}
diff --git a/interfaces/innerkits/tokensync/main/cpp/include/tokensync_kit.h b/interfaces/innerkits/tokensync/main/cpp/include/tokensync_kit.h
new file mode 100644
index 0000000000000000000000000000000000000000..c39e1a64a3c851b8ecb1578d6370f09d38a6e2ee
--- /dev/null
+++ b/interfaces/innerkits/tokensync/main/cpp/include/tokensync_kit.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2021 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 INTERFACES_INNER_KITS_TOKENSYNC_KIT_H
+#define INTERFACES_INNER_KITS_TOKENSYNC_KIT_H
+
+#include
+#include
+
+namespace OHOS {
+namespace Security {
+namespace TokenSync {
+class TokenSyncKit {
+public:
+ static int VerifyPermission(const std::string& bundleName, const std::string& permissionName, int userId);
+};
+} // namespace TokenSync
+} // namespace Security
+} // namespace OHOS
+
+#endif
diff --git a/interfaces/innerkits/tokensync/main/cpp/src/tokensync_kit.cpp b/interfaces/innerkits/tokensync/main/cpp/src/tokensync_kit.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..02a462ffbde3596de9630ae05290d0121afc39fc
--- /dev/null
+++ b/interfaces/innerkits/tokensync/main/cpp/src/tokensync_kit.cpp
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2021 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 "tokensync_kit.h"
+
+#include
+#include
+
+#include "accesstoken_log.h"
+#include "tokensync_manager_client.h"
+
+namespace OHOS {
+namespace Security {
+namespace TokenSync {
+using namespace std;
+
+namespace {
+static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, SECURITY_DOMAIN_ACCESSTOKEN, "TokenSyncKit"};
+} // namespace
+
+int TokenSyncKit::VerifyPermission(const string& bundleName, const string& permissionName, int userId)
+{
+ ACCESSTOKEN_LOG_INFO(LABEL, "%{public}s called", __func__);
+ ACCESSTOKEN_LOG_INFO(LABEL, "bundleName=%{public}s, permissionName=%{public}s, userId=%{public}d",
+ bundleName.c_str(), permissionName.c_str(), userId);
+ return TokenSyncManagerClient::GetInstance().VerifyPermission(bundleName, permissionName, userId);
+}
+} // namespace TokenSync
+} // namespace Security
+} // namespace OHOS
diff --git a/interfaces/innerkits/tokensync/main/cpp/src/tokensync_manager_client.cpp b/interfaces/innerkits/tokensync/main/cpp/src/tokensync_manager_client.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..98f658bc65ba87727d2295767cd187b9fcf6a18f
--- /dev/null
+++ b/interfaces/innerkits/tokensync/main/cpp/src/tokensync_manager_client.cpp
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2021 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 "tokensync_manager_client.h"
+
+#include "accesstoken_log.h"
+
+#include "iservice_registry.h"
+
+namespace OHOS {
+namespace Security {
+namespace TokenSync {
+namespace {
+static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, SECURITY_DOMAIN_ACCESSTOKEN, "TokenSyncManagerClient"};
+} // namespace
+
+TokenSyncManagerClient& TokenSyncManagerClient::GetInstance()
+{
+ static TokenSyncManagerClient instance;
+ return instance;
+}
+
+TokenSyncManagerClient::TokenSyncManagerClient()
+{}
+
+TokenSyncManagerClient::~TokenSyncManagerClient()
+{}
+
+int TokenSyncManagerClient::VerifyPermission(
+ const std::string& bundleName, const std::string& permissionName, int userId) const
+{
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s: called!", __func__);
+ auto proxy = GetProxy();
+ if (proxy == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: proxy is null", __func__);
+ return -1;
+ }
+ return proxy->VerifyPermission(bundleName, permissionName, userId);
+}
+
+sptr TokenSyncManagerClient::GetProxy() const
+{
+ auto sam = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
+ if (sam == nullptr) {
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s: GetSystemAbilityManager is null", __func__);
+ return nullptr;
+ }
+ auto tokensyncSa = sam->GetSystemAbility(ITokenSyncManager::SA_ID_TOKENSYNC_MANAGER_SERVICE);
+ if (tokensyncSa == nullptr) {
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s: GetSystemAbility %{public}d is null", __func__,
+ ITokenSyncManager::SA_ID_TOKENSYNC_MANAGER_SERVICE);
+ return nullptr;
+ }
+
+ auto proxy = iface_cast(tokensyncSa);
+ if (proxy == nullptr) {
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s: iface_cast get null", __func__);
+ return nullptr;
+ }
+ return proxy;
+}
+} // namespace TokenSync
+} // namespace Security
+} // namespace OHOS
diff --git a/interfaces/innerkits/tokensync/main/cpp/src/tokensync_manager_client.h b/interfaces/innerkits/tokensync/main/cpp/src/tokensync_manager_client.h
new file mode 100644
index 0000000000000000000000000000000000000000..06445abc50dc4f61445662636a85869843cf7526
--- /dev/null
+++ b/interfaces/innerkits/tokensync/main/cpp/src/tokensync_manager_client.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2021 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_MANAGER_CLIENT_H
+#define ACCESSTOKEN_MANAGER_CLIENT_H
+
+#include
+
+#include "i_tokensync_manager.h"
+
+#include "nocopyable.h"
+
+namespace OHOS {
+namespace Security {
+namespace TokenSync {
+class TokenSyncManagerClient final {
+public:
+ static TokenSyncManagerClient& GetInstance();
+
+ virtual ~TokenSyncManagerClient();
+
+ int VerifyPermission(const std::string& bundleName, const std::string& permissionName, int userId) const;
+
+private:
+ TokenSyncManagerClient();
+
+ DISALLOW_COPY_AND_MOVE(TokenSyncManagerClient);
+
+ sptr GetProxy() const;
+};
+} // namespace TokenSync
+} // namespace Security
+} // namespace OHOS
+#endif // ACCESSTOKEN_MANAGER_CLIENT_H
diff --git a/interfaces/innerkits/tokensync/main/cpp/src/tokensync_manager_proxy.cpp b/interfaces/innerkits/tokensync/main/cpp/src/tokensync_manager_proxy.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4a0e9f8300a65ce071b368392d6dafd11ccee321
--- /dev/null
+++ b/interfaces/innerkits/tokensync/main/cpp/src/tokensync_manager_proxy.cpp
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2021 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 "tokensync_manager_proxy.h"
+
+#include "accesstoken_log.h"
+
+#include "parcel.h"
+#include "string_ex.h"
+
+namespace OHOS {
+namespace Security {
+namespace TokenSync {
+namespace {
+static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, SECURITY_DOMAIN_ACCESSTOKEN, "TokenSyncManagerProxy"};
+}
+
+TokenSyncManagerProxy::TokenSyncManagerProxy(const sptr& impl) : IRemoteProxy(impl)
+{}
+
+TokenSyncManagerProxy::~TokenSyncManagerProxy()
+{}
+
+int TokenSyncManagerProxy::VerifyPermission(
+ const std::string& bundleName, const std::string& permissionName, int userId)
+{
+ MessageParcel data;
+ data.WriteInterfaceToken(ITokenSyncManager::GetDescriptor());
+ if (!data.WriteString(bundleName)) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: Failed to write bundleName", __func__);
+ return -1;
+ }
+ if (!data.WriteString(permissionName)) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: Failed to write permissionName", __func__);
+ return -1;
+ }
+ if (!data.WriteInt32(userId)) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: Failed to write userId", __func__);
+ return -1;
+ }
+
+ MessageParcel reply;
+ MessageOption option;
+ sptr remote = Remote();
+ if (remote == nullptr) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s: remote service null.", __func__);
+ return -1;
+ }
+ int32_t requestResult = remote->SendRequest(
+ static_cast(ITokenSyncManager::InterfaceCode::VERIFY_PERMISSION), data, reply, option);
+ if (requestResult != NO_ERROR) {
+ ACCESSTOKEN_LOG_ERROR(LABEL, "%{public}s send request fail, result: %{public}d", __func__, requestResult);
+ return -1;
+ }
+
+ int32_t result = reply.ReadInt32();
+ ACCESSTOKEN_LOG_DEBUG(LABEL, "%{public}s get result from server data = %{public}d", __func__, result);
+ return result;
+}
+} // namespace TokenSync
+} // namespace Security
+} // namespace OHOS
diff --git a/interfaces/innerkits/tokensync/main/cpp/src/tokensync_manager_proxy.h b/interfaces/innerkits/tokensync/main/cpp/src/tokensync_manager_proxy.h
new file mode 100644
index 0000000000000000000000000000000000000000..fc0dbc10d1b18c5fe31336bfac4d8916f06c88f1
--- /dev/null
+++ b/interfaces/innerkits/tokensync/main/cpp/src/tokensync_manager_proxy.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2021 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 TOKENSYNC_MANAGER_PROXY_H
+#define TOKENSYNC_MANAGER_PROXY_H
+
+#include
+
+#include "i_tokensync_manager.h"
+#include "iremote_broker.h"
+#include "iremote_proxy.h"
+
+namespace OHOS {
+namespace Security {
+namespace TokenSync {
+class TokenSyncManagerProxy : public IRemoteProxy {
+public:
+ explicit TokenSyncManagerProxy(const sptr& impl);
+ virtual ~TokenSyncManagerProxy() override;
+
+ int VerifyPermission(const std::string& packageName, const std::string& permissionName, int userId) override;
+
+private:
+ static inline BrokerDelegator delegator_;
+};
+} // namespace TokenSync
+} // namespace Security
+} // namespace OHOS
+#endif // TOKENSYNC_MANAGER_PROXY_H
diff --git a/interfaces/innerkits/tokensync/test/BUILD.gn b/interfaces/innerkits/tokensync/test/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..afbd3655fe10526155461090e03a6562d935f9f8
--- /dev/null
+++ b/interfaces/innerkits/tokensync/test/BUILD.gn
@@ -0,0 +1,42 @@
+# Copyright (C) 2021 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/test.gni")
+
+ohos_unittest("libtokensync_sdk_test") {
+ subsystem_name = "security"
+ part_name = "access_token"
+ module_out_path = part_name + "/" + part_name
+
+ include_dirs = [
+ "//utils/native/base/include",
+ "//third_party/googletest/include",
+ #"//base/security/permission/interfaces/innerkits/permission_standard/permissionsdk/main/cpp/include/permission/",
+ "//base/security/access_token/interfaces/innerkits/tokensync/main/cpp/include"
+ ]
+
+ sources = [ "unittest/cpp/src/tokensync_kit_test.cpp" ]
+
+ cflags_cc = [ "-DHILOG_ENABLE" ]
+
+ deps = [
+#"//base/security/permission/frameworks/permission_standard/permissioninfrastructure:permission_standard_infrastructure_cxx",
+ "//base/security/access_token/interfaces/innerkits/tokensync:libtokensync_sdk",
+ "//utils/native/base:utils",
+ ]
+}
+
+group("unittest") {
+ testonly = true
+ deps = [ ":libtokensync_sdk_test" ]
+}
diff --git a/interfaces/innerkits/tokensync/test/unittest/cpp/src/tokensync_kit_test.cpp b/interfaces/innerkits/tokensync/test/unittest/cpp/src/tokensync_kit_test.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b4ae1174ee9f70c5f8be33585ce4c767d025674a
--- /dev/null
+++ b/interfaces/innerkits/tokensync/test/unittest/cpp/src/tokensync_kit_test.cpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2021 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 "tokensync_kit_test.h"
+
+#include "tokensync_kit.h"
+
+using namespace testing::ext;
+using namespace OHOS::Security::TokenSync;
+
+void TokenSyncKitTest::SetUpTestCase()
+{}
+
+void TokenSyncKitTest::TearDownTestCase()
+{
+}
+
+void TokenSyncKitTest::SetUp()
+{
+}
+
+void TokenSyncKitTest::TearDown()
+{}
+
+/**
+ * @tc.name: VerifyPermission001
+ * @tc.desc: Verify user granted permission
+ * @tc.type: FUNC
+ * @tc.require:
+ */
+HWTEST_F(TokenSyncKitTest, VerifyPermission001, TestSize.Level1)
+{
+ const std::string TEST_BUNDLE_NAME = "ohos";
+ const std::string TEST_PERMISSION_NAME_ALPHA = "ohos.permission.ALPHA";
+ const int TEST_USER_ID = 0;
+ int ret = TokenSyncKit::VerifyPermission(TEST_BUNDLE_NAME, TEST_PERMISSION_NAME_ALPHA, TEST_USER_ID);
+
+ ASSERT_EQ(0, ret);
+}
+
diff --git a/interfaces/innerkits/tokensync/test/unittest/cpp/src/tokensync_kit_test.h b/interfaces/innerkits/tokensync/test/unittest/cpp/src/tokensync_kit_test.h
new file mode 100644
index 0000000000000000000000000000000000000000..4202bcd9bc86741fa1629371ec1fe59a6e6a1455
--- /dev/null
+++ b/interfaces/innerkits/tokensync/test/unittest/cpp/src/tokensync_kit_test.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2021 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 TOKENSYNC_KIT_TEST_H
+#define TOKENSYNC_KIT_TEST_H
+
+#include
+
+namespace OHOS {
+namespace Security {
+namespace TokenSync {
+class TokenSyncKitTest : public testing::Test {
+public:
+ static void SetUpTestCase();
+
+ static void TearDownTestCase();
+
+ void SetUp();
+
+ void TearDown();
+};
+} // namespace TokenSync
+} // namespace Security
+} // namespace OHOS
+#endif // TOKENSYNC_KIT_TEST_H
diff --git a/ohos.build b/ohos.build
index f8bc9d11fc3b32f44714844cd5f9e93365e2372e..f87ae64db91df4d037205238260e02cdf985e38d 100644
--- a/ohos.build
+++ b/ohos.build
@@ -11,7 +11,6 @@
"name": "//base/security/access_token/interfaces/innerkits/accesstoken:libaccesstoken_sdk",
"header": {
"header_files": [
- "accesstoken.h",
"accesstoken_kit.h"
],
"header_base": "//base/security/access_token/interfaces/innerkits/accesstoken/main/cpp/include"
@@ -19,10 +18,12 @@
}
],
"module_list": [
- "//base/security/access_token:accesstoken_build_module_standard"
+ "//base/security/access_token:accesstoken_build_module",
+ "//base/security/access_token:tokensync_build_module"
],
"test_list": [
- "//base/security/access_token:accesstoken_build_module_standard_test"
+ "//base/security/access_token:accesstoken_build_module_test",
+ "//base/security/access_token/interfaces/innerkits/accesstoken/test:unittest"
]
}
}
diff --git a/services/accesstokenmanager/BUILD.gn b/services/accesstokenmanager/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..4622a3086d424227e49d9ced179cd855fbd27fae
--- /dev/null
+++ b/services/accesstokenmanager/BUILD.gn
@@ -0,0 +1,78 @@
+# Copyright (c) 2021 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_prebuilt_etc("access_token.rc") {
+ source = "access_token.cfg"
+ relative_install_dir = "init"
+ subsystem_name = "security"
+ part_name = "access_token"
+}
+
+ohos_shared_library("accesstoken_manager_service") {
+ subsystem_name = "security"
+ part_name = "access_token"
+
+ include_dirs = [
+ "main/cpp/include/service",
+ "main/cpp/include/token",
+ "main/cpp/include/permission",
+ "main/cpp/include/database",
+ "//utils/system/safwk/native/include",
+ "//base/security/access_token/frameworks/common/include",
+ "//base/security/access_token/frameworks/accesstoken/include",
+ "//base/security/access_token/interfaces/innerkits/accesstoken/main/cpp/include",
+ "//third_party/json/include",
+ ]
+
+ sources = [
+ "main/cpp/src/service/accesstoken_manager_service.cpp",
+ "main/cpp/src/service/accesstoken_manager_stub.cpp",
+ "main/cpp/src/token/accesstoken_id_manager.cpp",
+ "main/cpp/src/token/accesstoken_info_manager.cpp",
+ "main/cpp/src/token/hap_token_info_inner.cpp",
+ "main/cpp/src/token/native_token_info_inner.cpp",
+ "main/cpp/src/permission/permission_manager.cpp",
+ "main/cpp/src/permission/permission_definition_cache.cpp",
+ "main/cpp/src/permission/permission_policy_set.cpp",
+ "main/cpp/src/permission/permission_validator.cpp",
+ "main/cpp/src/database/data_storage.cpp",
+ "main/cpp/src/database/data_translator.cpp",
+ "main/cpp/src/database/generic_values.cpp",
+ "main/cpp/src/database/sqlite_helper.cpp",
+ "main/cpp/src/database/sqlite_storage.cpp",
+ "main/cpp/src/database/statement.cpp",
+ "main/cpp/src/database/variant_value.cpp",
+ ]
+
+ cflags_cc = [ "-DHILOG_ENABLE" ]
+
+ deps = [
+ #"//base/security/accesstoken/frameworks/accesstooken/permissioncommunicationadapter:permission_standard_communication_adapter_cxx",
+ #"//base/security/accesstoken/frameworks/accesstooken/common:permission_standard_infrastructure_cxx",
+ "//third_party/sqlite:sqlite",
+ "//base/security/access_token/frameworks/common:accesstoken_common_cxx",
+ "//base/security/access_token/frameworks/accesstoken:accesstoken_communication_adapter_cxx",
+ "//base/security/access_token/services/accesstokenmanager:access_token.rc",
+ "//utils/native/base:utils",
+ ]
+
+ external_deps = [
+ "hiviewdfx_hilog_native:libhilog",
+ "ipc:ipc_core",
+ "safwk:system_ability_fwk",
+ "samgr_standard:samgr_proxy",
+ ]
+}
diff --git a/services/accesstokenmanager/access_token.cfg b/services/accesstokenmanager/access_token.cfg
new file mode 100644
index 0000000000000000000000000000000000000000..e06136d1c671f2e6d420ae1107314fc0e29938cf
--- /dev/null
+++ b/services/accesstokenmanager/access_token.cfg
@@ -0,0 +1,17 @@
+{
+ "jobs" : [{
+ "name" : "late-fs",
+ "cmds" : [
+ "start accesstoken_service"
+ ]
+ }
+ ],
+ "services" : [{
+ "name" : "accesstoken_service",
+ "path" : ["/system/bin/sa_main", "/system/profile/accesstoken_service.xml"],
+ "importance" : -20,
+ "uid" : "system",
+ "gid" : ["system"]
+ }
+ ]
+}
diff --git a/services/accesstokenmanager/access_token.rc b/services/accesstokenmanager/access_token.rc
new file mode 100644
index 0000000000000000000000000000000000000000..68b9f548b6f5f31b3fc30abc1da6be5c14c380d4
--- /dev/null
+++ b/services/accesstokenmanager/access_token.rc
@@ -0,0 +1,22 @@
+# Copyright (C) 2021 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.
+
+on late-fs
+ start accesstoken_service
+
+service accesstoken_service /system/bin/sa_main /system/profile/accesstoken_service.xml
+ class accesstoken_service
+ priority -20
+ user system
+ group system
+ seclabel u:r:accesstoken_service:s0
diff --git a/services/accesstokenmanager/main/cpp/include/database/data_storage.h b/services/accesstokenmanager/main/cpp/include/database/data_storage.h
new file mode 100644
index 0000000000000000000000000000000000000000..9233596bbb9931ea52eb3fb95d6d6a7f5a9bf01a
--- /dev/null
+++ b/services/accesstokenmanager/main/cpp/include/database/data_storage.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2021 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 DATA_STORAGE_H
+#define DATA_STORAGE_H
+
+#include
+#include