diff --git a/Security/DeviceCertificateKit/CertificateManagement/.gitignore b/Security/DeviceCertificateKit/CertificateManagement/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/Security/DeviceCertificateKit/CertificateManagement/AppScope/app.json5 b/Security/DeviceCertificateKit/CertificateManagement/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..8395cc27234909907a0d245bd7f6b7e11f005844 --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.certificatemanager_sample", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/Security/DeviceCertificateKit/CertificateManagement/AppScope/resources/base/element/string.json b/Security/DeviceCertificateKit/CertificateManagement/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..a25b8dabe83794ddc0d68ec8a8cec7fc079e94f1 --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "certificatemanager_sample" + } + ] +} diff --git a/Security/DeviceCertificateKit/CertificateManagement/AppScope/resources/base/media/background.png b/Security/DeviceCertificateKit/CertificateManagement/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/Security/DeviceCertificateKit/CertificateManagement/AppScope/resources/base/media/background.png differ diff --git a/Security/DeviceCertificateKit/CertificateManagement/AppScope/resources/base/media/foreground.png b/Security/DeviceCertificateKit/CertificateManagement/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..eb9427585b36d14b12477435b6419d1f07b3e0bb Binary files /dev/null and b/Security/DeviceCertificateKit/CertificateManagement/AppScope/resources/base/media/foreground.png differ diff --git a/Security/DeviceCertificateKit/CertificateManagement/AppScope/resources/base/media/layered_image.json b/Security/DeviceCertificateKit/CertificateManagement/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/Security/DeviceCertificateKit/CertificateManagement/README.md b/Security/DeviceCertificateKit/CertificateManagement/README.md new file mode 100644 index 0000000000000000000000000000000000000000..33eb0cc35131b2fd355e79f69e45514d631625a2 --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/README.md @@ -0,0 +1,72 @@ +# 证书管理 + +### 介绍 + +证书管理主要提供系统级的证书管理能力,实现证书全生命周期(安装、存储、使用和销毁)的管理和安全使用。 + +本示例主要展示了证书管理中证书管理与证书管理对话框的使用场景。该工程中展示的代码详细描述可查如下链接中介绍。 + +- [证书管理开发指导](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/DeviceCertificateKit/certManager-guidelines.md) +- [证书管理对话框开发指导](https://gitee.com/openharmony/docs/blob/OpenHarmony-5.0.1-Release/zh-cn/application-dev/security/DeviceCertificateKit/certManagerDialog-guidelines.md) + +### 效果预览 + +| 首页效果图 | 执行结果图 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| | | + +### 使用说明 + +1. 运行Index主界面。 +2. 页面呈现上述执行结果图效果,点击不同按钮可以跳转到不同功能页面,点击跳转页面中按钮可以执行对应操作,并更新文本内容。 +3. 运行测试用例CertificateManagement.test.ets文件对页面代码进行测试可以全部通过。 + +### 工程目录 + +``` +entry/src/ + ├── main + │ ├── ets + │ │ ├── entryability + │ │ ├── entrybackupability + │ │ ├── pages + │ │ ├── Index.ets // 证书管理示例代码 + │ │ ├── CertManagerGuidelines.ets + │ │ ├── CertManagerDialogGuidelines.ets + │ ├── module.json5 + │ └── resources + ├── ohosTest + │ ├── ets + │ │ └── test + │ │ ├── Ability.test.ets + │ │ ├── CertificateManagement.test.ets // 自动化测试代码 + │ │ └── List.test.ets +``` + +### 相关权限 + +[ohos.permission.ACCESS_CERT_MANAGER](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionaccesscertmanager) + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 + +3.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/Security/DeviceCertificateKit/CertificateManagement > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull origin master +```` \ No newline at end of file diff --git a/Security/DeviceCertificateKit/CertificateManagement/build-profile.json5 b/Security/DeviceCertificateKit/CertificateManagement/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c602ead655ae113d7946b283e0cec4b8d2f35cc2 --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/build-profile.json5 @@ -0,0 +1,56 @@ +{ + "app": { + "signingConfigs": [ + { + "name": "default", + "type": "HarmonyOS", + "material": { + "certpath": "C:\\Users\\wanghaixiang\\.ohos\\config\\default_certificatemanager_sample_in33Tinbev40rA9RgCQXEi0ENj_GFqIdq6XkZNlJFPc=.cer", + "keyAlias": "debugKey", + "keyPassword": "0000001BB58B66CA64FA956BFE978140DB0C4F2FAFBA3561429991779D14C9FEDECE4E17451F2678BE2FC3", + "profile": "C:\\Users\\wanghaixiang\\.ohos\\config\\default_certificatemanager_sample_in33Tinbev40rA9RgCQXEi0ENj_GFqIdq6XkZNlJFPc=.p7b", + "signAlg": "SHA256withECDSA", + "storeFile": "C:\\Users\\wanghaixiang\\.ohos\\config\\default_certificatemanager_sample_in33Tinbev40rA9RgCQXEi0ENj_GFqIdq6XkZNlJFPc=.p12", + "storePassword": "0000001B639CEC37444563017C58886D36401E76BD029EA43B2F3C8EBF77ACE0B7670624537F397C1A4BAE" + } + } + ], + "products": [ + { + "name": "default", + "signingConfig": "default", + "targetSdkVersion": "6.0.0(20)", + "compatibleSdkVersion": "6.0.0(20)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/Security/DeviceCertificateKit/CertificateManagement/code-linter.json5 b/Security/DeviceCertificateKit/CertificateManagement/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..073990fa45394e1f8e85d85418ee60a8953f9b99 --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/code-linter.json5 @@ -0,0 +1,32 @@ +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/Security/DeviceCertificateKit/CertificateManagement/entry/.gitignore b/Security/DeviceCertificateKit/CertificateManagement/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/Security/DeviceCertificateKit/CertificateManagement/entry/build-profile.json5 b/Security/DeviceCertificateKit/CertificateManagement/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..6bd6457a2fed846cc10698666fa1268219f1bee1 --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/entry/build-profile.json5 @@ -0,0 +1,33 @@ +{ + "apiType": "stageMode", + "buildOption": { + "resOptions": { + "copyCodeResource": { + "enable": false + } + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/Security/DeviceCertificateKit/CertificateManagement/entry/hvigorfile.ts b/Security/DeviceCertificateKit/CertificateManagement/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..b0e3a1ab98a91bc918d6404b2413111a5011f14a --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins: [] /* Custom plugin to extend the functionality of Hvigor. */ +} \ No newline at end of file diff --git a/Security/DeviceCertificateKit/CertificateManagement/entry/obfuscation-rules.txt b/Security/DeviceCertificateKit/CertificateManagement/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/Security/DeviceCertificateKit/CertificateManagement/entry/oh-package.json5 b/Security/DeviceCertificateKit/CertificateManagement/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..248c3b7541a589682a250f86a6d3ecf7414d2d6a --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/entry/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/entryability/EntryAbility.ets b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..edc2839f203ba057c186e19b0cbbbf80c8faa8b3 --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 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 { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..b1e212947256c5533c7b06285a597c94f840a6e3 --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 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 { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(0x0000, 'testTag', 'onBackup ok'); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + } +} \ No newline at end of file diff --git a/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/pages/CertManagerCACertsGuidelines.ets b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/pages/CertManagerCACertsGuidelines.ets new file mode 100644 index 0000000000000000000000000000000000000000..6485493af6c5453a1ce23d49202caea94650afbd --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/pages/CertManagerCACertsGuidelines.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 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 { userCASample } from '../samples/CertManagerUserCASample'; +import { getUserCaPathSample } from '../samples/CertManagerGetCAPathSample'; + +@Entry +@Component +struct Index { + @State message: string = 'CertManagerDialogGuidelines'; + + build() { + Column({ space: 5 }) { + Text(this.message) + .fontWeight(FontWeight.Bold) + .fontSize(25) + Button($r('app.string.call_userCASample')) + .width('70%') + .onClick(() => { + userCASample(); + this.message = 'userCASample Success'; + }) + Button($r('app.string.call_getUserCAPathSample')) + .width('70%') + .onClick(() => { + getUserCaPathSample(); + this.message = 'getUserCaPathSample Success'; + }) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/pages/CertManagerDialogGuidelines.ets b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/pages/CertManagerDialogGuidelines.ets new file mode 100644 index 0000000000000000000000000000000000000000..c686881a41c1af71477089ef6473f8b694b41a04 --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/pages/CertManagerDialogGuidelines.ets @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2025 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 { + installUserCADialogSample, + uninstallUserCADialogSample, + certDetailDialogSample +} from '../samples/CertManagerCaDialogSample'; +import { certificateManagerDialogSample } from '../samples/CertManagerDialogSample'; + +@Entry +@Component +struct Index { + @State message: string = 'CertManagerDialogGuidelines'; + + build() { + Column({ space: 5 }) { + Text(this.message) + .fontWeight(FontWeight.Bold) + .fontSize(25) + Button($r('app.string.call_certManagerDialogGuidelines')) + .width('70%') + .onClick(() => { + certificateManagerDialogSample(); + this.message = 'CertManagerDialogGuidelines Success'; + }) + Button($r('app.string.call_installUserCADialog')) + .width('70%') + .onClick(() => { + installUserCADialogSample(); + this.message = 'installUserCADialogSample Success'; + }) + Button($r('app.string.call_uninstallUserCADialog')) + .width('70%') + .onClick(() => { + uninstallUserCADialogSample(); + this.message = 'uninstallUserCADialogSample Success'; + }) + Button($r('app.string.call_certDetailDialog')) + .width('70%') + .onClick(() => { + certDetailDialogSample(); + this.message = 'certDetailDialogSample Success'; + }) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/pages/CertManagerGuidelines.ets b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/pages/CertManagerGuidelines.ets new file mode 100644 index 0000000000000000000000000000000000000000..e78bfb6963ba2e4c4dad65f06ff194337cff40a4 --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/pages/CertManagerGuidelines.ets @@ -0,0 +1,183 @@ +/* + * Copyright (c) 2025 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. + */ +// [Start certificate_management_development_guidance] + +import { certificateManager } from '@kit.DeviceCertificateKit'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { util } from '@kit.ArkTS'; + +async function privateCredSample() { + /* 安装的凭据数据需要业务赋值,本例数据非凭据数据。 */ + let keystoreBase64Str = 'MIIMJgIBAzCCC+AGCSqGSIb3DQEHAaCCC9EEggvNMIILyTCCBW4G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fjLExS/0Jn9GMD0wITAJBgUrDgMCGgUABBQze1zR' + + 'G615kxCjeS6uixCHuij3pgQUhHiChcSeohRPrVkVPSPmYr9tjAYCAgQA'; + /* 凭据数据转换为Uint8Array,凭据数据为der格式 */ + let keystore: Uint8Array = new util.Base64Helper().decodeSync(keystoreBase64Str); + + /* 安装凭据对应的密码,业务赋值。 */ + let keystorePwd: string = 'huawei'; + let appKeyUri: string = ''; + try { + /* 安装应用证书凭据。 */ + const res: certificateManager.CMResult = await certificateManager.installPrivateCertificate(keystore, keystorePwd, 'testPriCredential'); + appKeyUri = (res.uri != undefined) ? res.uri : ''; + console.error(`installPrivateCertificate appKeyUri: ${appKeyUri}`); + } catch (err) { + let e: BusinessError = err as BusinessError; + console.error(`Failed to install private certificate. Code: ${e.code}, message: ${e.message}`); + } + + try { + /* 获取应用证书凭据。 */ + let res: certificateManager.CMResult = await certificateManager.getPrivateCertificate(appKeyUri); + if (res === undefined || res.credential == undefined) { + console.error('The result of getting private certificate is undefined.'); + } else { + let credential = res.credential; + console.info('Succeeded in getting private certificate.'); + } + } catch (err) { + console.error(`Failed to get private certificate. Code: ${err.code}, message: ${err.message}`); + } + + try { + /* srcData为待签名、验签的数据,业务自行赋值。 */ + let srcData: Uint8Array = new Uint8Array([ + 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x01, + ]); + + /* 构造签名的属性参数。 */ + const signSpec: certificateManager.CMSignatureSpec = { + purpose: certificateManager.CmKeyPurpose.CM_KEY_PURPOSE_SIGN, + padding: certificateManager.CmKeyPadding.CM_PADDING_PSS, + digest: certificateManager.CmKeyDigest.CM_DIGEST_SHA256 + }; + + /* 签名。 */ + const signHandle: certificateManager.CMHandle = await certificateManager.init(appKeyUri, signSpec); + await certificateManager.update(signHandle.handle, srcData); + const signResult: certificateManager.CMResult = await certificateManager.finish(signHandle.handle); + + /* 构造验签的属性参数。 */ + const verifySpec: certificateManager.CMSignatureSpec = { + purpose: certificateManager.CmKeyPurpose.CM_KEY_PURPOSE_VERIFY, + padding: certificateManager.CmKeyPadding.CM_PADDING_PSS, + digest: certificateManager.CmKeyDigest.CM_DIGEST_SHA256 + }; + + /* 验签。 */ + const verifyHandle: certificateManager.CMHandle = await certificateManager.init(appKeyUri, verifySpec); + await certificateManager.update(verifyHandle.handle, srcData); + const verifyResult = await certificateManager.finish(verifyHandle.handle, signResult.outData); + console.info('Succeeded in signing and verifying.'); + } catch (err) { + let e: BusinessError = err as BusinessError; + console.error(`Failed to sign or verify. Code: ${e.code}, message: ${e.message}`); + } + + try { + /* 删除应用证书凭据。 */ + await certificateManager.uninstallPrivateCertificate(appKeyUri); + } catch (err) { + let e: BusinessError = err as BusinessError; + console.error(`Failed to uninstall private certificate. Code: ${e.code}, message: ${e.message}`); + } +} + +// [End certificate_management_development_guidance] + +@Entry +@Component +struct Index { + @State message: string = 'CertManagerGuidelines'; + + build() { + Column({space: 5}) { + Text(this.message) + .fontSize(25) + .fontWeight(FontWeight.Bold) + Button($r('app.string.call_certManagerGuidelines')) + .width('70%') + .onClick(()=>{ + privateCredSample(); + this.message = 'CertManagerGuidelines Success'; + }) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/pages/Index.ets b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..b7d0cb1731276c6e53b888c6f6822f00cbcfdf9a --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 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 { router } from '@kit.ArkUI'; + +@Entry +@Component +struct Index { + @State message: string = 'CertificateManagement'; + goToSample(url: string): void { + router.pushUrl({ + url: url, + }, router.RouterMode.Single, (err) => { + if (err) { + console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`); + return; + } + console.info('pushUrl success'); + }) + } + + build() { + Column({ space: 5 }) { + Text(this.message) + .fontSize(25) + .fontWeight(FontWeight.Bold) + Button($r('app.string.certManagerGuidelines')) + .width('70%') + .onClick(() => { + this.goToSample('pages/CertManagerGuidelines') + }) + Button($r('app.string.certManagerDialogGuidelines')) + .width('70%') + .onClick(() => { + this.goToSample('pages/CertManagerDialogGuidelines') + }) + Button($r('app.string.certManagerCACertsGuidelines')) + .width('70%') + .onClick(() => { + this.goToSample('pages/CertManagerCACertsGuidelines') + }) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/samples/CertManagerCaDialogSample.ets b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/samples/CertManagerCaDialogSample.ets new file mode 100644 index 0000000000000000000000000000000000000000..19e45340ee3400bbce0aa30f7f8cbd0d424f3676 --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/samples/CertManagerCaDialogSample.ets @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2025 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. + */ +// [Start certificate_management_ca_dialog_development_guide] +import { certificateManagerDialog } from '@kit.DeviceCertificateKit'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { common } from '@kit.AbilityKit'; +import { UIContext } from '@kit.ArkUI'; +import { util } from '@kit.ArkTS'; + +let certType = certificateManagerDialog.CertificateType.CA_CERT; +let certUri: string = ''; +/* 用户CA证书数据需要业务赋值。 */ +let cert: Uint8Array = new util.TextEncoder().encodeInto(`-----BEGIN CERTIFICATE----- +MIIDSTCCAjECFFRZKkiBuiZ+zqfjJOg05yeTePM9MA0GCSqGSIb3DQEBCwUAMGEx +CzAJBgNVBAYTAmNuMQ0wCwYDVQQIDARvaG9zMQswCQYDVQQHDAJjbTEhMB8GA1UE +CgwYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMRMwEQYDVQQDDApUZXN0Um9vdENB +MB4XDTI1MTAxNTA3MzE0MloXDTI2MTAxNTA3MzE0MlowYTELMAkGA1UEBhMCY24x +DTALBgNVBAgMBG9ob3MxCzAJBgNVBAcMAmNtMSEwHwYDVQQKDBhJbnRlcm5ldCBX +aWRnaXRzIFB0eSBMdGQxEzARBgNVBAMMClRlc3RSb290Q0EwggEiMA0GCSqGSIb3 +DQEBAQUAA4IBDwAwggEKAoIBAQC5p4eoQJyTBvn01M8SwEi8dguTIPGmD3a8SGIj +KXaB6ltv742H5EBjgk+zC8+Gis0ehEqwk3pVnnmByeYvrERxsUqDt69/FndlfTxI +C2/2MxWVk97g/6TpJ5Lt2mTrH+rSOgUDyU27aPn12ZnDF1mLsT+U+CBmfj4+J4tW +yzdFNj7kcKMQQok+L1dtFlDNMNpMA1UqADzoC3XgFl49CpDtoFId9DVsgUPkPfX1 +89cCunomgJe1b17FzxfNu2yhbl5cnUEjeHGbmBgBIB7uG8tjGstnDPx7fl3Xrj+Q +fRrwCpVKD9RxoyUBFbHttixxY5bHFUdvHRB251sxD+JfxxxLAgMBAAEwDQYJKoZI +hvcNAQELBQADggEBAEGbNqcMU7C/lrIytI/OTtzYbkWDsfnRSPxlCUoZ2Xh3S83A +SNQ9Ze5tDwWdW9Hlde9May6hzvuQSYeMLLnyM8WGResXCs7UbnSQe7fGfUu+xDGb +h4tamnRFtZydxCCgDT9lIdHeutlPwOuxlR4HXpeowGeGJX0iFrdo6D0iXAY34hic +yLQzuBqE/1s3PLA83Fi4EOOOV7P/ahmOLtBFlHbySHV68i9PNeNr9SDykH9/RgI9 +5G8ZTZj8oSmbTGGtfNuVXybMyJMRlz6BkxG++kYcg7STRBqHGX7RrWHiupguNreO +4sJBdSpWBq172ZEyOvTqC4xX9lLYqwwBQ++TFoo= +-----END CERTIFICATE-----`); + +async function installUserCADialogSample() { + /* context为应用的上下文信息,由调用方自行获取,此处仅为示例。 */ + let context: common.Context = new UIContext().getHostContext() as common.Context; + let certScope = certificateManagerDialog.CertificateScope.CURRENT_USER; /* 安装在当前用户下。 */ + try { + /* 安装证书。 */ + certificateManagerDialog.openInstallCertificateDialog(context, certType, certScope, cert).then((result) => { + console.info('Succeeded in opening install ca dialog.'); + certUri = result; + }).catch((err: BusinessError) => { + console.error(`Failed to open install ca dialog. Code: ${err.code}, message: ${err.message}`); + }) + } catch (error) { + console.error(`Failed to open install ca dialog. Code: ${error.code}, message: ${error.message}`); + } +} + +async function uninstallUserCADialogSample() { + /* context为应用的上下文信息,由调用方自行获取,此处仅为示例。 */ + let context: common.Context = new UIContext().getHostContext() as common.Context; + try { + /* 删除证书。 */ + certificateManagerDialog.openUninstallCertificateDialog(context, certType, certUri).then(() => { + console.info('Succeeded in opening uninstall ca dialog.'); + }).catch((err: BusinessError) => { + console.error(`Failed to open uninstall ca dialog. Code: ${err.code}, message: ${err.message}`); + }) + } catch (error) { + console.error(`Failed to open uninstall ca dialog. Code: ${error.code}, message: ${error.message}`); + } +} + +async function certDetailDialogSample() { + /* context为应用的上下文信息,由调用方自行获取,此处仅为示例。 */ + let context: common.Context = new UIContext().getHostContext() as common.Context; + try { + let property: certificateManagerDialog.CertificateDialogProperty = { + showInstallButton: false /* 不显示安装按钮。 */ + }; + /* 显示证书详情。 */ + certificateManagerDialog.openCertificateDetailDialog(context, cert, property).then(() => { + console.info('Succeeded in opening show ca detail dialog.'); + }).catch((err: BusinessError) => { + console.error(`Failed to open show ca detail dialog. Code: ${err.code}, message: ${err.message}`); + }) + } catch (error) { + console.error(`Failed to open show ca detail dialog. Code: ${error.code}, message: ${error.message}`); + } +} +// [End certificate_management_ca_dialog_development_guide] + +export { installUserCADialogSample, uninstallUserCADialogSample, certDetailDialogSample }; \ No newline at end of file diff --git a/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/samples/CertManagerDialogSample.ets b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/samples/CertManagerDialogSample.ets new file mode 100644 index 0000000000000000000000000000000000000000..65738bfd7a8e661fa736119745a2af6459e91bb1 --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/samples/CertManagerDialogSample.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 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. + */ +// [Start certificate_management_dialog_box_development_guide] +import { certificateManagerDialog } from '@kit.DeviceCertificateKit'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { common } from '@kit.AbilityKit'; + +async function certificateManagerDialogSample() { + /* context为应用的上下文信息,由调用方自行获取,此处仅为示例 */ + let context: common.Context = getContext(); + /* pageType为页面类型,此处赋值PAGE_MAIN,即拉起证书管理主界面 */ + let pageType: certificateManagerDialog.CertificateDialogPageType = + certificateManagerDialog.CertificateDialogPageType.PAGE_MAIN; + try { + certificateManagerDialog.openCertificateManagerDialog(context, pageType).then(() => { + console.info('Succeeded in opening certificate manager dialog.'); + }).catch((err: BusinessError) => { + console.error(`Failed to open certificate manager dialog. Code: ${err.code}, message: ${err.message}`); + }) + } catch (error) { + console.error(`Failed to open certificate manager dialog. Code: ${error.code}, message: ${error.message}`); + } +} +// [End certificate_management_dialog_box_development_guide] + +export { certificateManagerDialogSample }; \ No newline at end of file diff --git a/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/samples/CertManagerGetCAPathSample.ets b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/samples/CertManagerGetCAPathSample.ets new file mode 100644 index 0000000000000000000000000000000000000000..271e06038113bba34e398da81a2b03ebe2149507 --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/samples/CertManagerGetCAPathSample.ets @@ -0,0 +1,49 @@ + +/* + * Copyright (c) 2025 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. + */ +// [Start certificate_management_get_ca_path] +import { certificateManager } from '@kit.DeviceCertificateKit'; + +function getUserCaPathSample() { + try { + /* 获取系统CA的存储位置。 */ + let property1: certificateManager.CertStoreProperty = { + certType: certificateManager.CertType.CA_CERT_SYSTEM, + } + let systemCAPath = certificateManager.getCertificateStorePath(property1); + console.info(`Success to get system ca path: ${systemCAPath}`); + + /* 获取当前用户的用户CA存储位置。 */ + let property2: certificateManager.CertStoreProperty = { + certType: certificateManager.CertType.CA_CERT_USER, + certScope: certificateManager.CertScope.CURRENT_USER, + } + let userCACurrentPath = certificateManager.getCertificateStorePath(property2); + console.info(`Success to get current user's user ca path: ${userCACurrentPath}`); + + /* 获取设备公共的用户CA存储位置。 */ + let property3: certificateManager.CertStoreProperty = { + certType: certificateManager.CertType.CA_CERT_USER, + certScope: certificateManager.CertScope.GLOBAL_USER, + } + let globalCACurrentPath = certificateManager.getCertificateStorePath(property3); + console.info(`Success to get global user's user ca path: ${globalCACurrentPath}`); + } catch (error) { + console.error(`Failed to get store path. Code: ${error.code}, message: ${error.message}`); + } +} +// [End certificate_management_get_ca_path] + +export { getUserCaPathSample }; \ No newline at end of file diff --git a/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/samples/CertManagerUserCASample.ets b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/samples/CertManagerUserCASample.ets new file mode 100644 index 0000000000000000000000000000000000000000..8dce1b5d0a05ec3179edf519df5619738cfbfcbb --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/samples/CertManagerUserCASample.ets @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2025 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. + */ +// [Start certificate_management_user_ca] +import { certificateManager } from '@kit.DeviceCertificateKit'; +import { util } from '@kit.ArkTS'; + +async function userCASample() { + /* 安装的用户CA证书数据需要业务赋值。 */ + let userCAData: Uint8Array = new util.TextEncoder().encodeInto('-----BEGIN CERTIFICATE-----\n' + + 'MIIDSTCCAjECFFRZKkiBuiZ+zqfjJOg05yeTePM9MA0GCSqGSIb3DQEBCwUAMGEx\n' + + 'CzAJBgNVBAYTAmNuMQ0wCwYDVQQIDARvaG9zMQswCQYDVQQHDAJjbTEhMB8GA1UE\n' + + 'CgwYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMRMwEQYDVQQDDApUZXN0Um9vdENB\n' + + 'MB4XDTI1MTAxNTA3MzE0MloXDTI2MTAxNTA3MzE0MlowYTELMAkGA1UEBhMCY24x\n' + + 'DTALBgNVBAgMBG9ob3MxCzAJBgNVBAcMAmNtMSEwHwYDVQQKDBhJbnRlcm5ldCBX\n' + + 'aWRnaXRzIFB0eSBMdGQxEzARBgNVBAMMClRlc3RSb290Q0EwggEiMA0GCSqGSIb3\n' + + 'DQEBAQUAA4IBDwAwggEKAoIBAQC5p4eoQJyTBvn01M8SwEi8dguTIPGmD3a8SGIj\n' + + 'KXaB6ltv742H5EBjgk+zC8+Gis0ehEqwk3pVnnmByeYvrERxsUqDt69/FndlfTxI\n' + + 'C2/2MxWVk97g/6TpJ5Lt2mTrH+rSOgUDyU27aPn12ZnDF1mLsT+U+CBmfj4+J4tW\n' + + 'yzdFNj7kcKMQQok+L1dtFlDNMNpMA1UqADzoC3XgFl49CpDtoFId9DVsgUPkPfX1\n' + + '89cCunomgJe1b17FzxfNu2yhbl5cnUEjeHGbmBgBIB7uG8tjGstnDPx7fl3Xrj+Q\n' + + 'fRrwCpVKD9RxoyUBFbHttixxY5bHFUdvHRB251sxD+JfxxxLAgMBAAEwDQYJKoZI\n' + + 'hvcNAQELBQADggEBAEGbNqcMU7C/lrIytI/OTtzYbkWDsfnRSPxlCUoZ2Xh3S83A\n' + + 'SNQ9Ze5tDwWdW9Hlde9May6hzvuQSYeMLLnyM8WGResXCs7UbnSQe7fGfUu+xDGb\n' + + 'h4tamnRFtZydxCCgDT9lIdHeutlPwOuxlR4HXpeowGeGJX0iFrdo6D0iXAY34hic\n' + + 'yLQzuBqE/1s3PLA83Fi4EOOOV7P/ahmOLtBFlHbySHV68i9PNeNr9SDykH9/RgI9\n' + + '5G8ZTZj8oSmbTGGtfNuVXybMyJMRlz6BkxG++kYcg7STRBqHGX7RrWHiupguNreO\n' + + '4sJBdSpWBq172ZEyOvTqC4xX9lLYqwwBQ++TFoo=\n' + + '-----END CERTIFICATE-----'); + + let certUri: string = ''; + let certScope = certificateManager.CertScope.CURRENT_USER; + try { + /* 在当前用户下,安装用户CA证书。 */ + let result = certificateManager.installUserTrustedCertificateSync(userCAData, certScope); + certUri = (result.uri != undefined) ? result.uri : ''; + console.info(`Succeeded in install user ca cert, certUri is ${certUri}`); + } catch (err) { + console.error(`Failed to install user ca cert. Code: ${err.code}, message: ${err.message}`); + } + + try { + /* 获取用户CA证书详情。 */ + let result = await certificateManager.getUserTrustedCertificate(certUri); + if (result === undefined || result.certInfo == undefined) { + console.error('The result of getting user ca cert is undefined.'); + } else { + let certInfo = result.certInfo; + console.info('Succeeded in getting user ca cert.'); + } + } catch (err) { + console.error(`Failed to get user ca certificate. Code: ${err.code}, message: ${err.message}`); + } + + try { + /* 获取当前用户下的用户CA证书列表。 */ + let result = await certificateManager.getAllUserTrustedCertificates(certScope); + if (result == undefined) { /* 用户根CA证书个数为0时,返回result为undefined。 */ + console.info('the count of the user trusted certificates is 0'); + } else if (result.certList == undefined) { + console.error('The result of getting current user trusted certificates is undefined.'); + } else { + let list = result.certList; + console.info('Succeeded in getting user ca cert list.'); + } + } catch (err) { + console.error(`Failed to get user ca certificate. Code: ${err.code}, message: ${err.message}`); + } + + try { + /* 删除安装的用户CA证书。 */ + certificateManager.uninstallUserTrustedCertificateSync(certUri); + } catch (err) { + console.error(`Failed to uninstall user ca certificate. Code: ${err.code}, message: ${err.message}`); + } +} +// [End certificate_management_user_ca] + +export { userCASample }; \ No newline at end of file diff --git a/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/module.json5 b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..690c81622d33b00d0e97bfe2422a0ec3051b8bde --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/module.json5 @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2025 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. + */ + +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "default" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ] + } + ], + "requestPermissions": [ + // To use the installUserTrustedCertificateSync or uninstallUserTrustedCertificateSync interface, + // you need to apply for the following permission: ohos.permission.ACCESS_ENTERPRISE_USER_TRUSTED_CERT. + { + "name": "ohos.permission.ACCESS_CERT_MANAGER", + "reason": "$string:reason", + "usedScene": { + "abilities": [ + "FormAbility" + ], + "when": "always" + } + } + ] + } +} \ No newline at end of file diff --git a/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/element/color.json b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/element/string.json b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..6b11d65104559b193532f31fbaabfd6ea9232e12 --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/element/string.json @@ -0,0 +1,64 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "CertificateManagement" + }, + { + "name": "reason", + "value": "CertificateManagement" + }, + { + "name": "dialog", + "value": "证书与凭据" + }, + { + "name": "certManagerGuidelines", + "value": "CertManagerGuidelines" + }, + { + "name": "certManagerDialogGuidelines", + "value": "CertManagerDialogGuidelines" + }, + { + "name": "certManagerCACertsGuidelines", + "value": "CertManagerCACertsGuidelines" + }, + { + "name": "call_certManagerGuidelines", + "value": "Call CertManagerGuidelines" + }, + { + "name": "call_certManagerDialogGuidelines", + "value": "Call CertManagerDialogGuidelines" + }, + { + "name": "call_installUserCADialog", + "value": "Call InstallUserCADialog" + }, + { + "name": "call_uninstallUserCADialog", + "value": "Call UninstallUserCADialog" + }, + { + "name": "call_certDetailDialog", + "value": "Call CertDetailDialog" + }, + { + "name": "call_userCASample", + "value": "Call UserCaSample" + }, + { + "name": "call_getUserCAPathSample", + "value": "Call GetUserCaPathSample" + } + ] +} \ No newline at end of file diff --git a/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/media/background.png b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/media/background.png differ diff --git a/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/media/foreground.png b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/media/foreground.png differ diff --git a/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/media/layered_image.json b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/media/startIcon.png b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/media/startIcon.png differ diff --git a/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/profile/backup_config.json b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/profile/main_pages.json b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..7ff1eaaa2d64b84ace3dec928a373448e52e5e9b --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,8 @@ +{ + "src": [ + "pages/Index", + "pages/CertManagerDialogGuidelines", + "pages/CertManagerGuidelines", + "pages/CertManagerCACertsGuidelines" + ] +} diff --git a/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/dark/element/color.json b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/Security/DeviceCertificateKit/CertificateManagement/entry/src/mock/mock-config.json5 b/Security/DeviceCertificateKit/CertificateManagement/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7a73a41bfdf76d6f793007240d80983a52f15f97 --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/entry/src/mock/mock-config.json5 @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/Security/DeviceCertificateKit/CertificateManagement/entry/src/ohosTest/ets/test/Ability.test.ets b/Security/DeviceCertificateKit/CertificateManagement/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..85c78f67579d6e31b5f5aeea463e216b9b141048 --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/Security/DeviceCertificateKit/CertificateManagement/entry/src/ohosTest/ets/test/List.test.ets b/Security/DeviceCertificateKit/CertificateManagement/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..794c7dc4ed66bd98fa3865e07922906e2fcef545 --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/Security/DeviceCertificateKit/CertificateManagement/entry/src/ohosTest/module.json5 b/Security/DeviceCertificateKit/CertificateManagement/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..55725a929993a8a18b3808d41ef037759440488b --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/entry/src/ohosTest/module.json5 @@ -0,0 +1,13 @@ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/Security/DeviceCertificateKit/CertificateManagement/entry/src/test/List.test.ets b/Security/DeviceCertificateKit/CertificateManagement/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bb5b5c3731e283dd507c847560ee59bde477bbc7 --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/entry/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/Security/DeviceCertificateKit/CertificateManagement/entry/src/test/LocalUnit.test.ets b/Security/DeviceCertificateKit/CertificateManagement/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..165fc1615ee8618b4cb6a622f144a9a707eee99f --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/Security/DeviceCertificateKit/CertificateManagement/hvigor/hvigor-config.json5 b/Security/DeviceCertificateKit/CertificateManagement/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7a7ab8914d8db6ab89758e185df5855dffe88d04 --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/hvigor/hvigor-config.json5 @@ -0,0 +1,23 @@ +{ + "modelVersion": "6.0.0", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | "ultrafine" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + // "optimizationStrategy": "memory" /* Define the optimization strategy. Value: [ "memory" | "performance" ]. Default: "memory" */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/Security/DeviceCertificateKit/CertificateManagement/hvigorfile.ts b/Security/DeviceCertificateKit/CertificateManagement/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..47113e2e36ecefde41c136272a0bd6ff745cffe4 --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins: [] /* Custom plugin to extend the functionality of Hvigor. */ +} \ No newline at end of file diff --git a/Security/DeviceCertificateKit/CertificateManagement/oh-package.json5 b/Security/DeviceCertificateKit/CertificateManagement/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c72aa05d549507e5ea6ce0bc0a8080c450508c7d --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "modelVersion": "6.0.0", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.24", + "@ohos/hamock": "1.0.0" + } +} diff --git a/Security/DeviceCertificateKit/CertificateManagement/ohosTest.md b/Security/DeviceCertificateKit/CertificateManagement/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..6301852ad71ebe1413bf61d336122af484a2e4c0 --- /dev/null +++ b/Security/DeviceCertificateKit/CertificateManagement/ohosTest.md @@ -0,0 +1,9 @@ +# **证书管理**测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ---------------------------------------------------- | ------------ | ---- | ---------------------- | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 点击按钮安装,获取,应用私有凭据进行签名、验签,删除 | 成功拉起应用 | | 成功并输出日志 | 是 | Pass | +| 点击按钮拉起证书管理界面 | 成功拉起应用 | | 成功拉起弹窗并输出日志 | 是 | Pass | \ No newline at end of file diff --git a/Security/DeviceCertificateKit/CertificateManagement/screenshots/CertificateManagement1.png b/Security/DeviceCertificateKit/CertificateManagement/screenshots/CertificateManagement1.png new file mode 100644 index 0000000000000000000000000000000000000000..2b44666b90a7f4cb6b308e49080d9461b434cbb1 Binary files /dev/null and b/Security/DeviceCertificateKit/CertificateManagement/screenshots/CertificateManagement1.png differ diff --git a/Security/DeviceCertificateKit/CertificateManagement/screenshots/CertificateManagement2.png b/Security/DeviceCertificateKit/CertificateManagement/screenshots/CertificateManagement2.png new file mode 100644 index 0000000000000000000000000000000000000000..48c54cfa91b9837069b7aaf035d24e5e0d983ea6 Binary files /dev/null and b/Security/DeviceCertificateKit/CertificateManagement/screenshots/CertificateManagement2.png differ