diff --git a/cer_manager/AppScope/app.json5 b/cer_manager/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..837e5f7dfa242e0c591f5dae923d56085b397c22 --- /dev/null +++ b/cer_manager/AppScope/app.json5 @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "app": { + "bundleName": "com.example.applications_certmanager", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "distributedNotificationEnabled": true + } +} diff --git a/cer_manager/AppScope/resources/base/element/string.json b/cer_manager/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..5d9f6bd1121cdf755b21a2a9dac631e8bc900efd --- /dev/null +++ b/cer_manager/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "applications_certmanager" + } + ] +} diff --git a/cer_manager/AppScope/resources/base/media/app_icon.png b/cer_manager/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/cer_manager/AppScope/resources/base/media/app_icon.png differ diff --git a/cer_manager/README.md b/cer_manager/README.md new file mode 100644 index 0000000000000000000000000000000000000000..619589e02a326ca29e85c124ed924019fe485d02 --- /dev/null +++ b/cer_manager/README.md @@ -0,0 +1,67 @@ +# 证书管理FA应用 + +## 简介 + +### 内容介绍 + +证书管理Fa应用是OpenHarmony中预置的系统应用,主要的功能包含系统根CA证书查看与启用禁用,用户根CA证书的安装、查看、启用禁用与卸载,公共业务证书的安装、查看、授权管理与卸载,私有业务证书的查看等功能。 + +### 架构图 + +![](doc/image/image-20220727141455437.png) + +该应用架构主要结合MVP和领域驱动设计思路。 + +### 目录 + +``` +/CertManagerFa/ +├── AppScope # 应用配置 +├── common # 公共工具类 +└── product + └── phone + └── src + └── main + ├── ets # 代码目录 + │   ├── Application # AbilityStage类实现 + │   ├── MainAbility # Ability类实现 + │   ├── model # model层功能类实现 + │   ├── pages # 页面展示实现 + │   ├── presenter # 页面presenter层功能类实现 + │   └── stub # certManager打桩代码 + └── resources # 资源文件目录 +``` + +### 使用方法 + +其他应用拉起证书管理FA并执行证书安装,使用方法如下: + +``` +globalThis.context.startAbility( +{ + bundleName: "com.example.applications_certmanager", + abilityName: "MainAbility", + uri: "certInstall", +}) +``` + +其他应用拉起证书管理FA并执行申请应用授权,使用方法如下: + +``` +//拉起应用申请应用授权 +globalThis.context.startAbilityForResult( +{ + bundleName: "com.example.applications_certmanager", + abilityName: "MainAbility", + uri: "requestAuthorize", + parameters: { + appUid: appUid, //传入申请应用的appUid + } +}) +.then((data) => { + if (!data.resultCode) { + this.authUri = data.want.parameters.authUri; //授权成功后获取返回的authUri + } +}) +``` + diff --git a/cer_manager/build-profile.json5 b/cer_manager/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..31544c186517b07a22bd8f58d2516fcca6f99749 --- /dev/null +++ b/cer_manager/build-profile.json5 @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "app": { + "signingConfigs": [ + { + "name": "default", + "material": { + "certpath": "C:\\Users\\zhang.zht\\.ohos\\config\\openharmony\\auto_ohos.cer", + "storePassword": "000000182D49AC81C66300693B659CDA6E750AE965D969F3BCBA2B534C3221927E2BF07CBA032464", + "keyAlias": "debugKey", + "keyPassword": "000000183DAF88DEE9072451FAAF3CBCCEB00EDF068D880A64BD52681A17B65407DAD43C45D74203", + "profile": "C:\\Users\\zhang.zht\\.ohos\\config\\openharmony\\auto_ohos_default_com.example.applications_certmanager.p7b", + "signAlg": "SHA256withECDSA", + "storeFile": "C:\\Users\\zhang.zht\\.ohos\\config\\openharmony\\auto_ohos.p12" + } + } + ], + "compileSdkVersion": 9, + "compatibleSdkVersion": 9, + "products": [ + { + "name": "default", + "signingConfig": "default", + } + ] + }, + "modules": [ + { + "name": "phone", + "srcPath": "./product/phone", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/cer_manager/common/component/ComponentConfig.ets b/cer_manager/common/component/ComponentConfig.ets new file mode 100644 index 0000000000000000000000000000000000000000..0507a27ad122f6fcc57917452209136719ade46f --- /dev/null +++ b/cer_manager/common/component/ComponentConfig.ets @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class ComponentConfig { + WH_100_100 = '100%'; + WH_30_100 = '30%'; + WH_33_100 = '33%'; + WH_35_100 = '35%'; + WH_40_100 = '40%'; + WH_45_100 = '45%'; + WH_50_100 = '50%'; + WH_55_100 = '55%'; + WH_83_100 = '83%'; + WH_90_100 = '90%'; + value_20 = 20; + font_20 = 20; + MAX_LINES_1 = 1; + MAX_LINES_2 = 2; + MAX_LINES_3 = 3; + DURATION_TIME = 200; +} + +let componentConfig = new ComponentConfig(); + +export default componentConfig as ComponentConfig; \ No newline at end of file diff --git a/cer_manager/common/component/entryComponent.ets b/cer_manager/common/component/entryComponent.ets new file mode 100644 index 0000000000000000000000000000000000000000..9ce16775abb417e52fe206a0f895c7de41b25799 --- /dev/null +++ b/cer_manager/common/component/entryComponent.ets @@ -0,0 +1,143 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import ComponentConfig from './componentconfig'; + +/** + * item custom component + */ +@Component +export default struct EntryComponent { + @State isShow: Boolean = true; + @Prop settingIcon: string; + @State endTextIsShow: Boolean= true; + private settingTitle: string | Resource; + @State settingSummary: string | Resource = ''; + private settingValue: string; + @State settingArrow: string | PixelMap | Resource = ''; + @Prop settingArrowStyle: string; + private settingUri: string; + @State titleFontColor: Color | number | string | Resource = $r('sys.color.ohos_id_color_text_primary'); + private enabled: boolean = true; + private onArrowClick?: () => void; + @State isTouched: boolean = false; + private height ?= $r('app.float.wh_value_70'); + private image_wh ?= $r('app.float.wh_value_50'); + private fontSize ?= $r('sys.float.ohos_id_text_size_body1'); + private valueFontSize ?= $r('sys.float.ohos_id_text_size_body2'); + + build() { + Row() { + Row() { + Image(this.settingIcon) + .width(this.image_wh) + .height(this.image_wh) + .margin({ right: $r('app.float.wh_10') }) + .visibility('' === this.settingIcon ? Visibility.None : Visibility.Visible) + .objectFit(ImageFit.Contain) + .fillColor($r("sys.color.ohos_id_color_primary")) + Column() { + Text(this.settingTitle) + .fontColor(this.enabled ? this.titleFontColor : $r("sys.color.ohos_id_color_primary")) + .fontSize(this.fontSize) + .textAlign(TextAlign.Start) + .maxLines(ComponentConfig.MAX_LINES_3) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .fontWeight(500) + Row() { + Text($r('app.string.version')) + .fontColor($r('sys.color.ohos_id_color_text_secondary')) + .fontSize($r('sys.float.ohos_id_text_size_body2')) + .textAlign(TextAlign.Start) + .maxLines(ComponentConfig.MAX_LINES_1) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .visibility('pages/applicationInfo' === this.settingUri ? Visibility.Visible : Visibility.None) + .margin({ top: $r('sys.float.ohos_id_text_margin_vertical') }); + + Text(this.settingSummary) + .fontColor($r('sys.color.ohos_id_color_text_secondary')) + .fontSize($r('sys.float.ohos_id_text_size_body2')) + .fontWeight('sans-serif') + .textAlign(TextAlign.Start) + .maxLines(ComponentConfig.MAX_LINES_1) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .visibility('' === this.settingSummary || undefined === this.settingSummary ? Visibility.None : Visibility.Visible) + .margin({ top: $r('sys.float.ohos_id_text_margin_vertical') }); + } + } + .alignItems(HorizontalAlign.Start); + } + .flexShrink(0) + .alignItems(VerticalAlign.Center) + .align(Alignment.Start) + .layoutWeight(1) + + Row() { + Text(this.settingValue) + .fontSize(this.valueFontSize) + .fontColor($r("sys.color.ohos_id_color_primary")) + .opacity($r('sys.float.ohos_id_alpha_content_secondary')) + .fontWeight('HwChinese-medium') + .height($r('app.float.wh_value_40')) + .margin({ left: $r('sys.float.ohos_id_elements_margin_horizontal_l'), right: $r('app.float.wh_value_4') }) + .align(Alignment.End); + + if (!this.settingArrowStyle && this.settingArrow) { + Image(this.settingArrow) + .visibility('' === this.settingArrow ? Visibility.None : Visibility.Visible) + .width($r("app.float.wh_value_12")) + .height($r("app.float.wh_value_24")) + .margin({ right: $r('app.float.wh_24') }) + .fillColor($r("sys.color.ohos_id_color_primary")) + .opacity($r("app.float.opacity_0_2")) + } else if (this.settingArrow) { + Image(this.settingArrow) + .visibility('' === this.settingArrow ? Visibility.None : Visibility.Visible) + .fillColor($r("sys.color.ohos_id_color_primary")) + .width($r('app.float.wh_value_24')) + .height($r('app.float.wh_value_24')) + .margin({ right: $r('app.float.wh_24') }) + .borderRadius($r("sys.float.ohos_id_corner_radius_default_l")) + .onClick(this.onArrowClick) + + } + } + .alignItems(VerticalAlign.Center) + .align(Alignment.End); + } + .opacity(this.enabled?1:$r('sys.float.ohos_id_alpha_disabled')) + .height(this.height) + .width(ComponentConfig.WH_100_100) + .padding({ left: $r('sys.float.ohos_id_default_padding_start') }) + .borderRadius($r("sys.float.ohos_id_corner_radius_default_l")) + .linearGradient((this.enabled && this.isTouched) ? { + angle: 90, + direction: GradientDirection.Right, + colors: [[$r("app.color.DCEAF9"), 0.0], [$r("app.color.FAFAFA"), 1.0]] + } : { + angle: 90, + direction: GradientDirection.Right, + colors: [[$r("sys.color.ohos_id_color_foreground_contrary"), 1], [$r("sys.color.ohos_id_color_foreground_contrary"), 1]] + }) + .alignItems(VerticalAlign.Center) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.isTouched = true; + } + if (event.type === TouchType.Up) { + this.isTouched = false; + } + }) + } +} \ No newline at end of file diff --git a/cer_manager/common/component/headComponent.ets b/cer_manager/common/component/headComponent.ets new file mode 100644 index 0000000000000000000000000000000000000000..138a323294c1c69bf58839fcbdf099596955c392 --- /dev/null +++ b/cer_manager/common/component/headComponent.ets @@ -0,0 +1,67 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import ComponentConfig from './componentconfig'; +import Router from '@system.router'; + +/** + * head custom component + */ +@Component +export default struct HeadComponent { + private icBackIsVisibility: boolean= true; + private headName: string | Resource = ''; + @State isTouch: boolean= false; + + build() { + Row() { + Stack({ alignContent: Alignment.Center }) { + Image($r('app.media.ic_back')) + .width($r('app.float.wh_value_24')) + .height($r('app.float.wh_value_24')) + .fillColor($r("sys.color.ohos_id_color_primary")) + } + .margin({ right: $r('app.float.wh_value_16') }) + .backgroundColor(this.isTouch ? $r('app.color.color_E3E3E3_grey') : $r('app.color.color_00000000_transparent')) + .visibility(this.icBackIsVisibility ? Visibility.Visible : Visibility.None) + .onClick(() => { + Router.back(); + }) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.isTouch = true; + } + if (event.type === TouchType.Up) { + this.isTouch = false; + } + }); + + Text(this.headName) + .fontSize($r('app.float.head_font_20')) + .lineHeight($r('app.float.wh_value_33')) + .fontFamily('HarmonyHeiTi-Bold') + .fontWeight(FontWeight.Regular) + .fontColor($r('app.color.font_color_182431')) + .maxLines(ComponentConfig.MAX_LINES_1) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .textAlign(TextAlign.Start) + .margin({ top: $r('app.float.wh_value_13'), bottom: $r('app.float.wh_value_15') }); + } + .width(ComponentConfig.WH_100_100) + .padding({ left: $r('app.float.wh_value_24') }) + .height($r('app.float.wh_value_56')) + .alignItems(VerticalAlign.Center) + .align(Alignment.Start) + } +} \ No newline at end of file diff --git a/cer_manager/common/component/subEntryComponent.ets b/cer_manager/common/component/subEntryComponent.ets new file mode 100644 index 0000000000000000000000000000000000000000..76ab7b2c9d68cd9ff89aeabcdb4817b354b9b620 --- /dev/null +++ b/cer_manager/common/component/subEntryComponent.ets @@ -0,0 +1,140 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import ComponentConfig from './componentconfig'; + +/** + * Sub-Page Entry Component + */ +@Component +export struct SubEntryComponent { + private targetPage: string; + private title: string | Resource; + @State isTouched: boolean = false; + + build() { + Navigator({ target: this.targetPage }) { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Row() { + Text(this.title) + .fontSize($r('app.float.font_16')) + .lineHeight($r('app.float.wh_value_22')) + .fontColor($r('app.color.font_color_182431')) + .fontWeight(FontWeight.Medium) + .margin({ left: $r('app.float.distance_8') }) + .textAlign(TextAlign.Start); + } + + Image('/res/image/ic_settings_arrow.svg') + .width($r('app.float.wh_value_12')) + .height($r('app.float.wh_value_24')) + .margin({ right: $r('app.float.distance_8') }) + .fillColor($r("sys.color.ohos_id_color_primary")) + .opacity($r("app.float.opacity_0_2")) + } + .height(ComponentConfig.WH_100_100) + .width(ComponentConfig.WH_100_100) + .borderRadius($r('app.float.radius_20')) + .linearGradient(this.isTouched ? { + angle: 90, + direction: GradientDirection.Right, + colors: [[$r("app.color.DCEAF9"), 0.0], [$r("app.color.FAFAFA"), 1.0]] + } : { + angle: 90, + direction: GradientDirection.Right, + colors: [[$r("sys.color.ohos_id_color_foreground_contrary"), 1], [$r("sys.color.ohos_id_color_foreground_contrary"), 1]] + }) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.isTouched = true; + } + if (event.type === TouchType.Up) { + this.isTouched = false; + } + }) + } + .padding($r('app.float.distance_4')) + .height($r('app.float.wh_value_56')) + .borderRadius($r('app.float.radius_24')) + .backgroundColor($r("sys.color.ohos_id_color_foreground_contrary")); + } +} + + +/** + * Sub-Page Entry Component with EndText + */ +@Component +export struct SubEntryComponentWithEndText { + @State isTouched: boolean = false; + @Prop endText: string; + private targetPage: string; + private title: string | Resource; + + build() { + Navigator({ target: this.targetPage }) { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Row() { + Text(this.title) + .fontSize($r('app.float.font_16')) + .lineHeight($r('app.float.wh_value_22')) + .fontWeight(FontWeight.Medium) + .fontColor($r('app.color.font_color_182431')) + .margin({ left: $r('app.float.distance_8') }) + .textAlign(TextAlign.Start); + } + + Row() { + Text(this.endText) + .fontSize($r('app.float.font_14')) + .lineHeight($r('app.float.wh_value_19')) + .fontWeight(FontWeight.Regular) + .fontColor($r('sys.color.ohos_id_color_text_secondary')) + .margin({ right: $r('app.float.distance_4') }) + .textAlign(TextAlign.End); + Image('/res/image/ic_settings_arrow.svg') + .width($r('app.float.wh_value_12')) + .height($r('app.float.wh_value_24')) + .margin({ right: $r('app.float.distance_8') }) + .fillColor($r("sys.color.ohos_id_color_primary")) + .opacity($r("app.float.opacity_0_2")) + } + } + .height(ComponentConfig.WH_100_100) + .width(ComponentConfig.WH_100_100) + .borderRadius($r('app.float.radius_20')) + .linearGradient(this.isTouched ? { + angle: 90, + direction: GradientDirection.Right, + colors: [[$r("app.color.DCEAF9"), 0.0], [$r("app.color.FAFAFA"), 1.0]] + } : { + angle: 90, + direction: GradientDirection.Right, + colors: [[$r("sys.color.ohos_id_color_foreground_contrary"), 1], [$r("sys.color.ohos_id_color_foreground_contrary"), 1]] + }) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.isTouched = true; + } + if (event.type === TouchType.Up) { + this.isTouched = false; + } + }); + } + .padding($r('app.float.distance_4')) + .height($r('app.float.wh_value_56')) + .borderRadius($r('app.float.radius_24')) + .backgroundColor($r("sys.color.ohos_id_color_foreground_contrary")); + } +} \ No newline at end of file diff --git a/cer_manager/common/util/ConfigData.ts b/cer_manager/common/util/ConfigData.ts new file mode 100644 index 0000000000000000000000000000000000000000..569d9d89d5e3d6385cc7f2890955ae966bfa8136 --- /dev/null +++ b/cer_manager/common/util/ConfigData.ts @@ -0,0 +1,65 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class ConfigData { + + WH_100_100 = '100%'; + WH_3_100 = '3%'; + WH_4_100 = '4%'; + WH_20_100 = '20%'; + WH_25_100 = '25%'; + WH_30_100 = '30%'; + WH_33_100 = '33%'; + WH_35_100 = '35%'; + WH_40_100 = '40%'; + WH_43_100 = '43%'; + WH_45_100 = '45%'; + WH_50_100 = '50%'; + WH_53_100 = '53%'; + WH_55_100 = '55%'; + WH_60_100 = '60%'; + WH_65_100 = '65%'; + WH_70_100 = '70%'; + WH_75_100 = '75%'; + WH_80_100 = '80%'; + WH_85_100 = '85%'; + WH_88_100 = '88%'; + WH_90_100 = '90%'; + WH_92_100 = '92%'; + WH_93_100 = '93%'; + WH_94_100 = '94%'; + + value_20 = 20; + font_20 = 20; + + TAG = 'CertManager Fa ' + SWITCH_BUTTON_X_OFFSET = '-4vp' + DIALOG_DY_OFFSET = '-16vp' + + PWD_MAX_LENGTH = 64; + ALIAS_MAX_LENGTH = 64; + MAX_LINES_1 = 1; + MAX_LINES_2 = 2; + MAX_LINES_3 = 3; + DURATION_TIME = 200; + FUNCTION_TYPE_HDC = 4; + APP_AUTH_MAX_LENGTH = 4; + REQUEST_AUTH_MAX_LENGTH = 5; + VERTICAL_DIVIDER_WIDTH = 1; + +} + +let configData = new ConfigData(); +export default configData as ConfigData; \ No newline at end of file diff --git a/cer_manager/common/util/LogDecorator.ts b/cer_manager/common/util/LogDecorator.ts new file mode 100644 index 0000000000000000000000000000000000000000..027ade5700f0546cba8655eb43bd880ef016dc9d --- /dev/null +++ b/cer_manager/common/util/LogDecorator.ts @@ -0,0 +1,63 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import LogUtil from './logutil'; +import ConfigData from './configdata'; + +/** + * Method log decorator + */ +const LogMethod = (target: Object, methodName: string, propertyDescriptor: PropertyDescriptor): PropertyDescriptor => { + const method = propertyDescriptor.value; + + propertyDescriptor.value = function (...args: any[]) { + const params = args.map(a => JSON.stringify(a)).join(); + LogUtil.info(ConfigData.TAG + `${target.constructor.name}#${methodName}(${params}) in `); + + const result = method.apply(this, args); + const r = JSON.stringify(result); + + LogUtil.info(ConfigData.TAG + `${target.constructor.name}#${methodName}(${params}) out => ${r}`); + return result; + } + + return propertyDescriptor; +}; + +/** + * Class decorator to log all methods + */ +export const LogAll = (target: any) => { + Reflect.ownKeys(target.prototype).forEach(propertyKey => { + let propertyDescriptor: PropertyDescriptor = Object.getOwnPropertyDescriptor(target.prototype, propertyKey); + const method = propertyDescriptor.value; + + if (method) { + propertyDescriptor.value = function (...args: any[]) { + const params = args.map(a => JSON.stringify(a)).join(); + LogUtil.info(ConfigData.TAG + `${target.name}#${propertyKey.toString()}(${params}) in `); + + const result = method.apply(this, args); + const r = JSON.stringify(result); + + LogUtil.info(ConfigData.TAG + `${target.name}#${propertyKey.toString()}(${params}) out => ${r}`); + return result; + } + + Object.defineProperty(target.prototype, propertyKey, propertyDescriptor); + } + }); +} + +export default LogMethod; diff --git a/cer_manager/common/util/LogUtil.ts b/cer_manager/common/util/LogUtil.ts new file mode 100644 index 0000000000000000000000000000000000000000..dcdfe6e43c3f96f3d3f8724f619aac1f9ec1f261 --- /dev/null +++ b/cer_manager/common/util/LogUtil.ts @@ -0,0 +1,85 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Log level + */ +let LogLevel = { + /** + * debug + */ + DEBUG: 3, + + /** + * info + */ + INFO: 4, + + /** + * warn + */ + WARN: 5, + + /** + * error + */ + ERROR: 6, + + /** + * fatal + */ + FATAL: 7, +}; + +const LOG_LEVEL = LogLevel.INFO + +/** + * log package tool class + */ +export class LogUtil { + debug(msg): void { + if (LogLevel.DEBUG >= LOG_LEVEL) { + console.info(msg); + } + } + + log(msg): void { + if (LogLevel.INFO >= LOG_LEVEL) { + console.log(msg); + } + } + + info(msg): void { + if (LogLevel.INFO >= LOG_LEVEL) { + console.info(msg); + } + } + + warn(msg): void { + if (LogLevel.WARN >= LOG_LEVEL) { + console.warn(msg); + } + } + + error(msg): void { + if (LogLevel.ERROR >= LOG_LEVEL) { + console.error(msg); + } + } +} + +let mLogUtil = new LogUtil(); +export default mLogUtil as LogUtil +; diff --git a/cer_manager/common/util/ResourceUtil.ts b/cer_manager/common/util/ResourceUtil.ts new file mode 100644 index 0000000000000000000000000000000000000000..f16c4e2575aeaa8332fecec9c275a2a85af8793f --- /dev/null +++ b/cer_manager/common/util/ResourceUtil.ts @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import Log from './logdecorator'; + +/** + * Resource util + */ +export class ResourceUtil { + private resMgr: any; + + /** + * Initialize ResourceManager + */ + @Log + async initResourceManager(): Promise { + if (!this.resMgr) { + this.resMgr = await globalThis.certManagerAbilityContext.resourceManager; + } + } + + /** + * Get string value from NormalResource instance + * + * @param resource - NormalResource instance + */ + @Log + async getString(resource): Promise { + await this.initResourceManager(); + return await this.resMgr.getString(resource.id); + } + +} + +let resourceUtil = new ResourceUtil(); +export default resourceUtil as ResourceUtil; diff --git a/cer_manager/doc/image/image-20220727141455437.png b/cer_manager/doc/image/image-20220727141455437.png new file mode 100644 index 0000000000000000000000000000000000000000..b4102ad263aee8c2c955765341923f4629d2dea2 Binary files /dev/null and b/cer_manager/doc/image/image-20220727141455437.png differ diff --git a/cer_manager/hvigorfile.js b/cer_manager/hvigorfile.js new file mode 100644 index 0000000000000000000000000000000000000000..5f2735e3deeaf655828407544bbed9365c258278 --- /dev/null +++ b/cer_manager/hvigorfile.js @@ -0,0 +1,2 @@ +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +module.exports = require('@ohos/hvigor-ohos-plugin').appTasks \ No newline at end of file diff --git a/cer_manager/package-lock.json b/cer_manager/package-lock.json new file mode 100644 index 0000000000000000000000000000000000000000..ddf37182c53685cc3ef8c7c8605050364f0361eb --- /dev/null +++ b/cer_manager/package-lock.json @@ -0,0 +1,1652 @@ +{ + "name": "applications_certmanager", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@ohos/hvigor": { + "version": "1.0.6", + "resolved": "https://repo.harmonyos.com/npm/@ohos/hvigor/-/@ohos/hvigor-1.0.6.tgz", + "integrity": "sha512-jjp7vpvUOMW1Nf7TdyhOtonwWHoSyBJLUiZTQqIx/GJV4UJyIqsiURUOqFwncQ4L7PDdeHuWly4uEelknYeWhg==", + "requires": { + "@ohos/hvigor-base": "1.0.6", + "interpret": "1.4.0", + "liftoff": "4.0.0", + "mute-stdout": "1.0.0", + "pretty-hrtime": "1.0.0", + "v8flags": "3.2.0", + "yargs": "7.1.0" + } + }, + "@ohos/hvigor-base": { + "version": "1.0.6", + "resolved": "https://repo.harmonyos.com/npm/@ohos/hvigor-base/-/@ohos/hvigor-base-1.0.6.tgz", + "integrity": "sha512-cRDnWICTxmpNiFb9clIioqP5Oik1seLCICztXVhZqultrHuxwTheCRUZrHwlpyWdkSB2Al+FFBqmSwzIgZX4IQ==", + "requires": { + "json5": "2.2.0", + "log4js": "6.4.1", + "undertaker": "1.2.1" + } + }, + "@ohos/hvigor-ohos-plugin": { + "version": "1.0.6", + "resolved": "https://repo.harmonyos.com/npm/@ohos/hvigor-ohos-plugin/-/@ohos/hvigor-ohos-plugin-1.0.6.tgz", + "integrity": "sha512-MAAi8uJxMzODUoSSNfBr+fU4HQ20dfQtkje9I+X4asc7qY2kAplW/q9f5XS8IOvv8zhC8OcSgsAXOAJuLMstOQ==", + "requires": { + "@ohos/hvigor-base": "1.0.6", + "@ohos/sdkmanager-common": "1.1.3", + "ajv": "8.10.0", + "archiver": "5.3.0", + "execa": "5.1.1", + "fs-extra": "10.0.0", + "glob": "7.2.0", + "iconv-lite": "0.6.3", + "json5": "2.2.0", + "lodash": "4.17.21", + "pretty-hrtime": "1.0.3", + "resolve-package-path": "4.0.3" + }, + "dependencies": { + "fs-extra": { + "version": "10.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/fs-extra/-/fs-extra-10.0.0.tgz", + "integrity": "sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ==", + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + } + }, + "pretty-hrtime": { + "version": "1.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz", + "integrity": "sha512-66hKPCr+72mlfiSjlEB1+45IjXSqvVAIy6mocupoww4tBFE9R9IhwwUGoI4G++Tc9Aq+2rxOt0RFU6gPcrte0A==" + } + } + }, + "@ohos/sdkmanager-common": { + "version": "1.1.3", + "resolved": "https://repo.harmonyos.com/npm/@ohos/sdkmanager-common/-/@ohos/sdkmanager-common-1.1.3.tgz", + "integrity": "sha512-d2uhVauDDJZIUvyyaWWoavG4N/jLyfF5IH5kEXKV6R8HNf3606H1zDQzA+UZtOfwwJFXhD9djRjnVFNB8xc7aw==" + }, + "ajv": { + "version": "8.10.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/ajv/-/ajv-8.10.0.tgz", + "integrity": "sha512-bzqAEZOjkrUMl2afH8dknrq5KEk2SrwdBROR+vH1EKVQTqaUbJVPdc/gEdggTMM0Se+s+Ja4ju4TlNcStKl2Hw==", + "requires": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + } + }, + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==" + }, + "archiver": { + "version": "5.3.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/archiver/-/archiver-5.3.0.tgz", + "integrity": "sha512-iUw+oDwK0fgNpvveEsdQ0Ase6IIKztBJU2U0E9MzszMfmVVUyv1QJhS2ITW9ZCqx8dktAxVAjWWkKehuZE8OPg==", + "requires": { + "archiver-utils": "^2.1.0", + "async": "^3.2.0", + "buffer-crc32": "^0.2.1", + "readable-stream": "^3.6.0", + "readdir-glob": "^1.0.0", + "tar-stream": "^2.2.0", + "zip-stream": "^4.1.0" + } + }, + "archiver-utils": { + "version": "2.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/archiver-utils/-/archiver-utils-2.1.0.tgz", + "integrity": "sha512-bEL/yUb/fNNiNTuUz979Z0Yg5L+LzLxGJz8x79lYmR54fmTIb6ob/hNQgkQnIUDWIFjZVQwl9Xs356I6BAMHfw==", + "requires": { + "glob": "^7.1.4", + "graceful-fs": "^4.2.0", + "lazystream": "^1.0.0", + "lodash.defaults": "^4.2.0", + "lodash.difference": "^4.5.0", + "lodash.flatten": "^4.4.0", + "lodash.isplainobject": "^4.0.6", + "lodash.union": "^4.6.0", + "normalize-path": "^3.0.0", + "readable-stream": "^2.0.0" + }, + "dependencies": { + "readable-stream": { + "version": "2.3.7", + "resolved": "https://repo.huaweicloud.com/repository/npm/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + } + } + }, + "arr-filter": { + "version": "1.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/arr-filter/-/arr-filter-1.1.2.tgz", + "integrity": "sha512-A2BETWCqhsecSvCkWAeVBFLH6sXEUGASuzkpjL3GR1SlL/PWL6M3J8EAAld2Uubmh39tvkJTqC9LeLHCUKmFXA==", + "requires": { + "make-iterator": "^1.0.0" + } + }, + "arr-flatten": { + "version": "1.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/arr-flatten/-/arr-flatten-1.1.0.tgz", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==" + }, + "arr-map": { + "version": "2.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/arr-map/-/arr-map-2.0.2.tgz", + "integrity": "sha512-tVqVTHt+Q5Xb09qRkbu+DidW1yYzz5izWS2Xm2yFm7qJnmUfz4HPzNxbHkdRJbz2lrqI7S+z17xNYdFcBBO8Hw==", + "requires": { + "make-iterator": "^1.0.0" + } + }, + "array-each": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/array-each/-/array-each-1.0.1.tgz", + "integrity": "sha512-zHjL5SZa68hkKHBFBK6DJCTtr9sfTCPCaph/L7tMSLcTFgy+zX7E+6q5UArbtOtMBCtxdICpfTCspRse+ywyXA==" + }, + "array-initial": { + "version": "1.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/array-initial/-/array-initial-1.1.0.tgz", + "integrity": "sha512-BC4Yl89vneCYfpLrs5JU2aAu9/a+xWbeKhvISg9PT7eWFB9UlRvI+rKEtk6mgxWr3dSkk9gQ8hCrdqt06NXPdw==", + "requires": { + "array-slice": "^1.0.0", + "is-number": "^4.0.0" + } + }, + "array-last": { + "version": "1.3.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/array-last/-/array-last-1.3.0.tgz", + "integrity": "sha512-eOCut5rXlI6aCOS7Z7kCplKRKyiFQ6dHFBem4PwlwKeNFk2/XxTrhRh5T9PyaEWGy/NHTZWbY+nsZlNFJu9rYg==", + "requires": { + "is-number": "^4.0.0" + } + }, + "array-slice": { + "version": "1.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/array-slice/-/array-slice-1.1.0.tgz", + "integrity": "sha512-B1qMD3RBP7O8o0H2KbrXDyB0IccejMF15+87Lvlor12ONPRHP6gTjXMNkt/d3ZuOGbAe66hFmaCfECI24Ufp6w==" + }, + "async": { + "version": "3.2.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/async/-/async-3.2.4.tgz", + "integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ==" + }, + "async-done": { + "version": "1.3.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/async-done/-/async-done-1.3.2.tgz", + "integrity": "sha512-uYkTP8dw2og1tu1nmza1n1CMW0qb8gWWlwqMmLb7MhBVs4BXrFziT6HXUd+/RlRA/i4H9AkofYloUbs1fwMqlw==", + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.2", + "process-nextick-args": "^2.0.0", + "stream-exhaust": "^1.0.1" + } + }, + "async-settle": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/async-settle/-/async-settle-1.0.0.tgz", + "integrity": "sha512-VPXfB4Vk49z1LHHodrEQ6Xf7W4gg1w0dAPROHngx7qgDjqmIQ+fXmwgGXTW/ITLai0YLSvWepJOP9EVpMnEAcw==", + "requires": { + "async-done": "^1.2.2" + } + }, + "bach": { + "version": "1.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/bach/-/bach-1.2.0.tgz", + "integrity": "sha512-bZOOfCb3gXBXbTFXq3OZtGR88LwGeJvzu6szttaIzymOTS4ZttBNOWSv7aLZja2EMycKtRYV0Oa8SNKH/zkxvg==", + "requires": { + "arr-filter": "^1.1.1", + "arr-flatten": "^1.0.1", + "arr-map": "^2.0.0", + "array-each": "^1.0.0", + "array-initial": "^1.0.0", + "array-last": "^1.1.1", + "async-done": "^1.2.2", + "async-settle": "^1.0.0", + "now-and-later": "^2.0.0" + } + }, + "balanced-match": { + "version": "1.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + }, + "base64-js": { + "version": "1.5.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==" + }, + "bl": { + "version": "4.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/bl/-/bl-4.1.0.tgz", + "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", + "requires": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + } + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://repo.huaweicloud.com/repository/npm/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "braces": { + "version": "3.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "requires": { + "fill-range": "^7.0.1" + } + }, + "buffer": { + "version": "5.7.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "requires": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "buffer-crc32": { + "version": "0.2.13", + "resolved": "https://repo.huaweicloud.com/repository/npm/buffer-crc32/-/buffer-crc32-0.2.13.tgz", + "integrity": "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==" + }, + "call-bind": { + "version": "1.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/call-bind/-/call-bind-1.0.2.tgz", + "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", + "requires": { + "function-bind": "^1.1.1", + "get-intrinsic": "^1.0.2" + } + }, + "camelcase": { + "version": "3.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/camelcase/-/camelcase-3.0.0.tgz", + "integrity": "sha512-4nhGqUkc4BqbBBB4Q6zLuD7lzzrHYrjKGeYaEji/3tFR5VdJu9v+LilhGIVe8wxEJPPOeWo7eg8dwY13TZ1BNg==" + }, + "cliui": { + "version": "3.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/cliui/-/cliui-3.2.0.tgz", + "integrity": "sha512-0yayqDxWQbqk3ojkYqUKqaAQ6AfNKeKWRNA8kR0WXzAsdHpP4BIaOmMAG87JGuO6qcobyW4GjxHd9PmhEd+T9w==", + "requires": { + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wrap-ansi": "^2.0.0" + } + }, + "code-point-at": { + "version": "1.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha512-RpAVKQA5T63xEj6/giIbUEtZwJ4UFIc3ZtvEkiaUERylqe8xb5IvqcgOurZLahv93CLKfxcw5YI+DZcUBRyLXA==" + }, + "collection-map": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/collection-map/-/collection-map-1.0.0.tgz", + "integrity": "sha512-5D2XXSpkOnleOI21TG7p3T0bGAsZ/XknZpKBmGYyluO8pw4zA3K8ZlrBIbC4FXg3m6z/RNFiUFfT2sQK01+UHA==", + "requires": { + "arr-map": "^2.0.2", + "for-own": "^1.0.0", + "make-iterator": "^1.0.0" + } + }, + "compress-commons": { + "version": "4.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/compress-commons/-/compress-commons-4.1.1.tgz", + "integrity": "sha512-QLdDLCKNV2dtoTorqgxngQCMA+gWXkM/Nwu7FpeBhk/RdkzimqC3jueb/FDmaZeXh+uby1jkBqE3xArsLBE5wQ==", + "requires": { + "buffer-crc32": "^0.2.13", + "crc32-stream": "^4.0.2", + "normalize-path": "^3.0.0", + "readable-stream": "^3.6.0" + } + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" + }, + "core-util-is": { + "version": "1.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" + }, + "crc-32": { + "version": "1.2.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/crc-32/-/crc-32-1.2.2.tgz", + "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==" + }, + "crc32-stream": { + "version": "4.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/crc32-stream/-/crc32-stream-4.0.2.tgz", + "integrity": "sha512-DxFZ/Hk473b/muq1VJ///PMNLj0ZMnzye9thBpmjpJKCc5eMgB95aK8zCGrGfQ90cWo561Te6HK9D+j4KPdM6w==", + "requires": { + "crc-32": "^1.2.0", + "readable-stream": "^3.4.0" + } + }, + "cross-spawn": { + "version": "7.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "requires": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "dependencies": { + "which": { + "version": "2.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "requires": { + "isexe": "^2.0.0" + } + } + } + }, + "d": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/d/-/d-1.0.1.tgz", + "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==", + "requires": { + "es5-ext": "^0.10.50", + "type": "^1.0.1" + } + }, + "date-format": { + "version": "4.0.11", + "resolved": "https://repo.huaweicloud.com/repository/npm/date-format/-/date-format-4.0.11.tgz", + "integrity": "sha512-VS20KRyorrbMCQmpdl2hg5KaOUsda1RbnsJg461FfrcyCUg+pkd0b40BSW4niQyTheww4DBXQnS7HwSrKkipLw==" + }, + "debug": { + "version": "4.3.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "requires": { + "ms": "2.1.2" + } + }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==" + }, + "default-resolution": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/default-resolution/-/default-resolution-2.0.0.tgz", + "integrity": "sha512-2xaP6GiwVwOEbXCGoJ4ufgC76m8cj805jrghScewJC2ZDsb9U0b4BIrba+xt/Uytyd0HvQ6+WymSRTfnYj59GQ==" + }, + "define-properties": { + "version": "1.1.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/define-properties/-/define-properties-1.1.4.tgz", + "integrity": "sha512-uckOqKcfaVvtBdsVkdPv3XjveQJsNQqmhXgRi8uhvWWuPYZCNlzT8qAyblUgNoXdHdjMTzAqeGjAoli8f+bzPA==", + "requires": { + "has-property-descriptors": "^1.0.0", + "object-keys": "^1.1.1" + } + }, + "detect-file": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/detect-file/-/detect-file-1.0.0.tgz", + "integrity": "sha512-DtCOLG98P007x7wiiOmfI0fi3eIKyWiLTGJ2MDnVi/E04lWGbf+JzrRHMm0rgIIZJGtHpKpbVgLWHrv8xXpc3Q==" + }, + "end-of-stream": { + "version": "1.4.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "requires": { + "once": "^1.4.0" + } + }, + "error-ex": { + "version": "1.3.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "requires": { + "is-arrayish": "^0.2.1" + } + }, + "es5-ext": { + "version": "0.10.61", + "resolved": "https://repo.huaweicloud.com/repository/npm/es5-ext/-/es5-ext-0.10.61.tgz", + "integrity": "sha512-yFhIqQAzu2Ca2I4SE2Au3rxVfmohU9Y7wqGR+s7+H7krk26NXhIRAZDgqd6xqjCEFUomDEA3/Bo/7fKmIkW1kA==", + "requires": { + "es6-iterator": "^2.0.3", + "es6-symbol": "^3.1.3", + "next-tick": "^1.1.0" + } + }, + "es6-iterator": { + "version": "2.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/es6-iterator/-/es6-iterator-2.0.3.tgz", + "integrity": "sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==", + "requires": { + "d": "1", + "es5-ext": "^0.10.35", + "es6-symbol": "^3.1.1" + } + }, + "es6-symbol": { + "version": "3.1.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/es6-symbol/-/es6-symbol-3.1.3.tgz", + "integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==", + "requires": { + "d": "^1.0.1", + "ext": "^1.1.2" + } + }, + "es6-weak-map": { + "version": "2.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/es6-weak-map/-/es6-weak-map-2.0.3.tgz", + "integrity": "sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA==", + "requires": { + "d": "1", + "es5-ext": "^0.10.46", + "es6-iterator": "^2.0.3", + "es6-symbol": "^3.1.1" + } + }, + "execa": { + "version": "5.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/execa/-/execa-5.1.1.tgz", + "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", + "requires": { + "cross-spawn": "^7.0.3", + "get-stream": "^6.0.0", + "human-signals": "^2.1.0", + "is-stream": "^2.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^4.0.1", + "onetime": "^5.1.2", + "signal-exit": "^3.0.3", + "strip-final-newline": "^2.0.0" + } + }, + "expand-tilde": { + "version": "2.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/expand-tilde/-/expand-tilde-2.0.2.tgz", + "integrity": "sha512-A5EmesHW6rfnZ9ysHQjPdJRni0SRar0tjtG5MNtm9n5TUvsYU8oozprtRD4AqHxcZWWlVuAmQo2nWKfN9oyjTw==", + "requires": { + "homedir-polyfill": "^1.0.1" + } + }, + "ext": { + "version": "1.6.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/ext/-/ext-1.6.0.tgz", + "integrity": "sha512-sdBImtzkq2HpkdRLtlLWDa6w4DX22ijZLKx8BMPUuKe1c5lbN6xwQDQCxSfxBQnHZ13ls/FH0MQZx/q/gr6FQg==", + "requires": { + "type": "^2.5.0" + }, + "dependencies": { + "type": { + "version": "2.6.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/type/-/type-2.6.0.tgz", + "integrity": "sha512-eiDBDOmkih5pMbo9OqsqPRGMljLodLcwd5XD5JbtNB0o89xZAwynY9EdCDsJU7LtcVCClu9DvM7/0Ep1hYX3EQ==" + } + } + }, + "extend": { + "version": "3.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" + }, + "fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "find-up": { + "version": "1.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/find-up/-/find-up-1.1.2.tgz", + "integrity": "sha512-jvElSjyuo4EMQGoTwo1uJU5pQMwTW5lS1x05zzfJuTIyLR3zwO27LYrxNg+dlvKpGOuGy/MzBdXh80g0ve5+HA==", + "requires": { + "path-exists": "^2.0.0", + "pinkie-promise": "^2.0.0" + } + }, + "findup-sync": { + "version": "5.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/findup-sync/-/findup-sync-5.0.0.tgz", + "integrity": "sha512-MzwXju70AuyflbgeOhzvQWAvvQdo1XL0A9bVvlXsYcFEBM87WR4OakL4OfZq+QRmr+duJubio+UtNQCPsVESzQ==", + "requires": { + "detect-file": "^1.0.0", + "is-glob": "^4.0.3", + "micromatch": "^4.0.4", + "resolve-dir": "^1.0.1" + } + }, + "fined": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/fined/-/fined-2.0.0.tgz", + "integrity": "sha512-OFRzsL6ZMHz5s0JrsEr+TpdGNCtrVtnuG3x1yzGNiQHT0yaDnXAj8V/lWcpJVrnoDpcwXcASxAZYbuXda2Y82A==", + "requires": { + "expand-tilde": "^2.0.2", + "is-plain-object": "^5.0.0", + "object.defaults": "^1.1.0", + "object.pick": "^1.3.0", + "parse-filepath": "^1.0.2" + } + }, + "flagged-respawn": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/flagged-respawn/-/flagged-respawn-2.0.0.tgz", + "integrity": "sha512-Gq/a6YCi8zexmGHMuJwahTGzXlAZAOsbCVKduWXC6TlLCjjFRlExMJc4GC2NYPYZ0r/brw9P7CpRgQmlPVeOoA==" + }, + "flatted": { + "version": "3.2.5", + "resolved": "https://repo.huaweicloud.com/repository/npm/flatted/-/flatted-3.2.5.tgz", + "integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==" + }, + "for-in": { + "version": "1.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/for-in/-/for-in-1.0.2.tgz", + "integrity": "sha512-7EwmXrOjyL+ChxMhmG5lnW9MPt1aIeZEwKhQzoBUdTV0N3zuwWDZYVJatDvZ2OyzPUvdIAZDsCetk3coyMfcnQ==" + }, + "for-own": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/for-own/-/for-own-1.0.0.tgz", + "integrity": "sha512-0OABksIGrxKK8K4kynWkQ7y1zounQxP+CWnyclVwj81KW3vlLlGUx57DKGcP/LH216GzqnstnPocF16Nxs0Ycg==", + "requires": { + "for-in": "^1.0.1" + } + }, + "fs-constants": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" + }, + "fs-extra": { + "version": "10.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" + }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" + }, + "get-caller-file": { + "version": "1.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/get-caller-file/-/get-caller-file-1.0.3.tgz", + "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==" + }, + "get-intrinsic": { + "version": "1.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/get-intrinsic/-/get-intrinsic-1.1.2.tgz", + "integrity": "sha512-Jfm3OyCxHh9DJyc28qGk+JmfkpO41A4XkneDSujN9MDXrm4oDKdHvndhZ2dN94+ERNfkYJWDclW6k2L/ZGHjXA==", + "requires": { + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.3" + } + }, + "get-stream": { + "version": "6.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/get-stream/-/get-stream-6.0.1.tgz", + "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==" + }, + "glob": { + "version": "7.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "global-modules": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/global-modules/-/global-modules-1.0.0.tgz", + "integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==", + "requires": { + "global-prefix": "^1.0.1", + "is-windows": "^1.0.1", + "resolve-dir": "^1.0.0" + } + }, + "global-prefix": { + "version": "1.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/global-prefix/-/global-prefix-1.0.2.tgz", + "integrity": "sha512-5lsx1NUDHtSjfg0eHlmYvZKv8/nVqX4ckFbM+FrGcQ+04KWcWFo9P5MxPZYSzUvyzmdTbI7Eix8Q4IbELDqzKg==", + "requires": { + "expand-tilde": "^2.0.2", + "homedir-polyfill": "^1.0.1", + "ini": "^1.3.4", + "is-windows": "^1.0.1", + "which": "^1.2.14" + } + }, + "graceful-fs": { + "version": "4.2.10", + "resolved": "https://repo.huaweicloud.com/repository/npm/graceful-fs/-/graceful-fs-4.2.10.tgz", + "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==" + }, + "has": { + "version": "1.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "requires": { + "function-bind": "^1.1.1" + } + }, + "has-property-descriptors": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz", + "integrity": "sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ==", + "requires": { + "get-intrinsic": "^1.1.1" + } + }, + "has-symbols": { + "version": "1.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/has-symbols/-/has-symbols-1.0.3.tgz", + "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==" + }, + "homedir-polyfill": { + "version": "1.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz", + "integrity": "sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA==", + "requires": { + "parse-passwd": "^1.0.0" + } + }, + "hosted-git-info": { + "version": "2.8.9", + "resolved": "https://repo.huaweicloud.com/repository/npm/hosted-git-info/-/hosted-git-info-2.8.9.tgz", + "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==" + }, + "human-signals": { + "version": "2.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/human-signals/-/human-signals-2.1.0.tgz", + "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==" + }, + "hypium": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/hypium/-/hypium-1.0.0.tgz", + "integrity": "sha512-nl+RQVv2AU/5FvFRhsXyWO5wh+2huhdqRZ3bszBWZzW+kpNI3AT4ydvVRYIfaQbYwV4UlX/rSc7BtFjLAezhow==" + }, + "iconv-lite": { + "version": "0.6.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + } + }, + "ieee754": { + "version": "1.2.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==" + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "ini": { + "version": "1.3.8", + "resolved": "https://repo.huaweicloud.com/repository/npm/ini/-/ini-1.3.8.tgz", + "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==" + }, + "interpret": { + "version": "1.4.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/interpret/-/interpret-1.4.0.tgz", + "integrity": "sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==" + }, + "invert-kv": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/invert-kv/-/invert-kv-1.0.0.tgz", + "integrity": "sha512-xgs2NH9AE66ucSq4cNG1nhSFghr5l6tdL15Pk+jl46bmmBapgoaY/AacXyaDznAqmGL99TiLSQgO/XazFSKYeQ==" + }, + "is-absolute": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-absolute/-/is-absolute-1.0.0.tgz", + "integrity": "sha512-dOWoqflvcydARa360Gvv18DZ/gRuHKi2NU/wU5X1ZFzdYfH29nkiNZsF3mp4OJ3H4yo9Mx8A/uAGNzpzPN3yBA==", + "requires": { + "is-relative": "^1.0.0", + "is-windows": "^1.0.1" + } + }, + "is-arrayish": { + "version": "0.2.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==" + }, + "is-core-module": { + "version": "2.9.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-core-module/-/is-core-module-2.9.0.tgz", + "integrity": "sha512-+5FPy5PnwmO3lvfMb0AsoPaBG+5KHUI0wYFXOtYPnVVVspTFUuMZNfNaNVRt3FZadstu2c8x23vykRW/NBoU6A==", + "requires": { + "has": "^1.0.3" + } + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==" + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha512-1pqUqRjkhPJ9miNq9SwMfdvi6lBJcd6eFxvfaivQhaH3SgisfiuudvFntdKOmxuee/77l+FPjKrQjWvmPjWrRw==", + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "is-glob": { + "version": "4.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-number": { + "version": "4.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-number/-/is-number-4.0.0.tgz", + "integrity": "sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==" + }, + "is-plain-object": { + "version": "5.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-plain-object/-/is-plain-object-5.0.0.tgz", + "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==" + }, + "is-relative": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-relative/-/is-relative-1.0.0.tgz", + "integrity": "sha512-Kw/ReK0iqwKeu0MITLFuj0jbPAmEiOsIwyIXvvbfa6QfmN9pkD1M+8pdk7Rl/dTKbH34/XBFMbgD4iMJhLQbGA==", + "requires": { + "is-unc-path": "^1.0.0" + } + }, + "is-stream": { + "version": "2.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==" + }, + "is-unc-path": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-unc-path/-/is-unc-path-1.0.0.tgz", + "integrity": "sha512-mrGpVd0fs7WWLfVsStvgF6iEJnbjDFZh9/emhRDcGWTduTfNHd9CHeUwH3gYIjdbwo4On6hunkztwOaAw0yllQ==", + "requires": { + "unc-path-regex": "^0.1.2" + } + }, + "is-utf8": { + "version": "0.2.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-utf8/-/is-utf8-0.2.1.tgz", + "integrity": "sha512-rMYPYvCzsXywIsldgLaSoPlw5PfoB/ssr7hY4pLfcodrA5M/eArza1a9VmTiNIBNMjOGr1Ow9mTyU2o69U6U9Q==" + }, + "is-windows": { + "version": "1.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-windows/-/is-windows-1.0.2.tgz", + "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==" + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" + }, + "isobject": { + "version": "3.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==" + }, + "json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" + }, + "json5": { + "version": "2.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/json5/-/json5-2.2.0.tgz", + "integrity": "sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==", + "requires": { + "minimist": "^1.2.5" + } + }, + "jsonfile": { + "version": "6.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "requires": { + "graceful-fs": "^4.1.6", + "universalify": "^2.0.0" + } + }, + "kind-of": { + "version": "6.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==" + }, + "last-run": { + "version": "1.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/last-run/-/last-run-1.1.1.tgz", + "integrity": "sha512-U/VxvpX4N/rFvPzr3qG5EtLKEnNI0emvIQB3/ecEwv+8GHaUKbIB8vxv1Oai5FAF0d0r7LXHhLLe5K/yChm5GQ==", + "requires": { + "default-resolution": "^2.0.0", + "es6-weak-map": "^2.0.1" + } + }, + "lazystream": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/lazystream/-/lazystream-1.0.1.tgz", + "integrity": "sha512-b94GiNHQNy6JNTrt5w6zNyffMrNkXZb3KTkCZJb2V1xaEGCk093vkZ2jk3tpaeP33/OiXC+WvK9AxUebnf5nbw==", + "requires": { + "readable-stream": "^2.0.5" + }, + "dependencies": { + "readable-stream": { + "version": "2.3.7", + "resolved": "https://repo.huaweicloud.com/repository/npm/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + } + } + }, + "lcid": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/lcid/-/lcid-1.0.0.tgz", + "integrity": "sha512-YiGkH6EnGrDGqLMITnGjXtGmNtjoXw9SVUzcaos8RBi7Ps0VBylkq+vOcY9QE5poLasPCR849ucFUkl0UzUyOw==", + "requires": { + "invert-kv": "^1.0.0" + } + }, + "liftoff": { + "version": "4.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/liftoff/-/liftoff-4.0.0.tgz", + "integrity": "sha512-rMGwYF8q7g2XhG2ulBmmJgWv25qBsqRbDn5gH0+wnuyeFt7QBJlHJmtg5qEdn4pN6WVAUMgXnIxytMFRX9c1aA==", + "requires": { + "extend": "^3.0.2", + "findup-sync": "^5.0.0", + "fined": "^2.0.0", + "flagged-respawn": "^2.0.0", + "is-plain-object": "^5.0.0", + "object.map": "^1.0.1", + "rechoir": "^0.8.0", + "resolve": "^1.20.0" + } + }, + "load-json-file": { + "version": "1.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/load-json-file/-/load-json-file-1.1.0.tgz", + "integrity": "sha512-cy7ZdNRXdablkXYNI049pthVeXFurRyb9+hA/dZzerZ0pGTx42z+y+ssxBaVV2l70t1muq5IdKhn4UtcoGUY9A==", + "requires": { + "graceful-fs": "^4.1.2", + "parse-json": "^2.2.0", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0", + "strip-bom": "^2.0.0" + } + }, + "lodash": { + "version": "4.17.21", + "resolved": "https://repo.huaweicloud.com/repository/npm/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, + "lodash.defaults": { + "version": "4.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/lodash.defaults/-/lodash.defaults-4.2.0.tgz", + "integrity": "sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ==" + }, + "lodash.difference": { + "version": "4.5.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/lodash.difference/-/lodash.difference-4.5.0.tgz", + "integrity": "sha512-dS2j+W26TQ7taQBGN8Lbbq04ssV3emRw4NY58WErlTO29pIqS0HmoT5aJ9+TUQ1N3G+JOZSji4eugsWwGp9yPA==" + }, + "lodash.flatten": { + "version": "4.4.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/lodash.flatten/-/lodash.flatten-4.4.0.tgz", + "integrity": "sha512-C5N2Z3DgnnKr0LOpv/hKCgKdb7ZZwafIrsesve6lmzvZIRZRGaZ/l6Q8+2W7NaT+ZwO3fFlSCzCzrDCFdJfZ4g==" + }, + "lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==" + }, + "lodash.union": { + "version": "4.6.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/lodash.union/-/lodash.union-4.6.0.tgz", + "integrity": "sha512-c4pB2CdGrGdjMKYLA+XiRDO7Y0PRQbm/Gzg8qMj+QH+pFVAoTp5sBpO0odL3FjoPCGjK96p6qsP+yQoiLoOBcw==" + }, + "log4js": { + "version": "6.4.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/log4js/-/log4js-6.4.1.tgz", + "integrity": "sha512-iUiYnXqAmNKiIZ1XSAitQ4TmNs8CdZYTAWINARF3LjnsLN8tY5m0vRwd6uuWj/yNY0YHxeZodnbmxKFUOM2rMg==", + "requires": { + "date-format": "^4.0.3", + "debug": "^4.3.3", + "flatted": "^3.2.4", + "rfdc": "^1.3.0", + "streamroller": "^3.0.2" + } + }, + "make-iterator": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/make-iterator/-/make-iterator-1.0.1.tgz", + "integrity": "sha512-pxiuXh0iVEq7VM7KMIhs5gxsfxCux2URptUQaXo4iZZJxBAzTPOLE2BumO5dbfVYq/hBJFBR/a1mFDmOx5AGmw==", + "requires": { + "kind-of": "^6.0.2" + } + }, + "map-cache": { + "version": "0.2.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/map-cache/-/map-cache-0.2.2.tgz", + "integrity": "sha512-8y/eV9QQZCiyn1SprXSrCmqJN0yNRATe+PO8ztwqrvrbdRLA3eYJF0yaR0YayLWkMbsQSKWS9N2gPcGEc4UsZg==" + }, + "merge-stream": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==" + }, + "micromatch": { + "version": "4.0.5", + "resolved": "https://repo.huaweicloud.com/repository/npm/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "requires": { + "braces": "^3.0.2", + "picomatch": "^2.3.1" + } + }, + "mimic-fn": { + "version": "2.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==" + }, + "minimatch": { + "version": "3.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "1.2.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/minimist/-/minimist-1.2.6.tgz", + "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==" + }, + "ms": { + "version": "2.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "mute-stdout": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/mute-stdout/-/mute-stdout-1.0.0.tgz", + "integrity": "sha512-MaSQenn0f9oxIjtCufclpV00MuYTiHaXPbdcfPIM+quMqoa8cXywjHHx4LhhIAZlXqPWMdcUpYviajfmHtHRJw==" + }, + "next-tick": { + "version": "1.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/next-tick/-/next-tick-1.1.0.tgz", + "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==" + }, + "normalize-package-data": { + "version": "2.5.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "requires": { + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + } + }, + "normalize-path": { + "version": "3.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==" + }, + "now-and-later": { + "version": "2.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/now-and-later/-/now-and-later-2.0.1.tgz", + "integrity": "sha512-KGvQ0cB70AQfg107Xvs/Fbu+dGmZoTRJp2TaPwcwQm3/7PteUyN2BCgk8KBMPGBUXZdVwyWS8fDCGFygBm19UQ==", + "requires": { + "once": "^1.3.2" + } + }, + "npm-run-path": { + "version": "4.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/npm-run-path/-/npm-run-path-4.0.1.tgz", + "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", + "requires": { + "path-key": "^3.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha512-4jbtZXNAsfZbAHiiqjLPBiCl16dES1zI4Hpzzxw61Tk+loF+sBDBKx1ICKKKwIqQ7M0mFn1TmkN7euSncWgHiQ==" + }, + "object-keys": { + "version": "1.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==" + }, + "object.assign": { + "version": "4.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/object.assign/-/object.assign-4.1.2.tgz", + "integrity": "sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ==", + "requires": { + "call-bind": "^1.0.0", + "define-properties": "^1.1.3", + "has-symbols": "^1.0.1", + "object-keys": "^1.1.1" + } + }, + "object.defaults": { + "version": "1.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/object.defaults/-/object.defaults-1.1.0.tgz", + "integrity": "sha512-c/K0mw/F11k4dEUBMW8naXUuBuhxRCfG7W+yFy8EcijU/rSmazOUd1XAEEe6bC0OuXY4HUKjTJv7xbxIMqdxrA==", + "requires": { + "array-each": "^1.0.1", + "array-slice": "^1.0.0", + "for-own": "^1.0.0", + "isobject": "^3.0.0" + } + }, + "object.map": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/object.map/-/object.map-1.0.1.tgz", + "integrity": "sha512-3+mAJu2PLfnSVGHwIWubpOFLscJANBKuB/6A4CxBstc4aqwQY0FWcsppuy4jU5GSB95yES5JHSI+33AWuS4k6w==", + "requires": { + "for-own": "^1.0.0", + "make-iterator": "^1.0.0" + } + }, + "object.pick": { + "version": "1.3.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/object.pick/-/object.pick-1.3.0.tgz", + "integrity": "sha512-tqa/UMy/CCoYmj+H5qc07qvSL9dqcs/WZENZ1JbtWBlATP+iVOe778gE6MSijnyCnORzDuX6hU+LA4SZ09YjFQ==", + "requires": { + "isobject": "^3.0.1" + } + }, + "object.reduce": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/object.reduce/-/object.reduce-1.0.1.tgz", + "integrity": "sha512-naLhxxpUESbNkRqc35oQ2scZSJueHGQNUfMW/0U37IgN6tE2dgDWg3whf+NEliy3F/QysrO48XKUz/nGPe+AQw==", + "requires": { + "for-own": "^1.0.0", + "make-iterator": "^1.0.0" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "requires": { + "wrappy": "1" + } + }, + "onetime": { + "version": "5.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "requires": { + "mimic-fn": "^2.1.0" + } + }, + "os-locale": { + "version": "1.4.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/os-locale/-/os-locale-1.4.0.tgz", + "integrity": "sha512-PRT7ZORmwu2MEFt4/fv3Q+mEfN4zetKxufQrkShY2oGvUms9r8otu5HfdyIFHkYXjO7laNsoVGmM2MANfuTA8g==", + "requires": { + "lcid": "^1.0.0" + } + }, + "parse-filepath": { + "version": "1.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/parse-filepath/-/parse-filepath-1.0.2.tgz", + "integrity": "sha512-FwdRXKCohSVeXqwtYonZTXtbGJKrn+HNyWDYVcp5yuJlesTwNH4rsmRZ+GrKAPJ5bLpRxESMeS+Rl0VCHRvB2Q==", + "requires": { + "is-absolute": "^1.0.0", + "map-cache": "^0.2.0", + "path-root": "^0.1.1" + } + }, + "parse-json": { + "version": "2.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/parse-json/-/parse-json-2.2.0.tgz", + "integrity": "sha512-QR/GGaKCkhwk1ePQNYDRKYZ3mwU9ypsKhB0XyFnLQdomyEqk3e8wpW3V5Jp88zbxK4n5ST1nqo+g9juTpownhQ==", + "requires": { + "error-ex": "^1.2.0" + } + }, + "parse-passwd": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/parse-passwd/-/parse-passwd-1.0.0.tgz", + "integrity": "sha512-1Y1A//QUXEZK7YKz+rD9WydcE1+EuPr6ZBgKecAB8tmoW6UFv0NREVJe1p+jRxtThkcbbKkfwIbWJe/IeE6m2Q==" + }, + "path-exists": { + "version": "2.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/path-exists/-/path-exists-2.1.0.tgz", + "integrity": "sha512-yTltuKuhtNeFJKa1PiRzfLAU5182q1y4Eb4XCJ3PBqyzEDkAZRzBrKKBct682ls9reBVHf9udYLN5Nd+K1B9BQ==", + "requires": { + "pinkie-promise": "^2.0.0" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==" + }, + "path-key": { + "version": "3.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==" + }, + "path-parse": { + "version": "1.0.7", + "resolved": "https://repo.huaweicloud.com/repository/npm/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==" + }, + "path-root": { + "version": "0.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/path-root/-/path-root-0.1.1.tgz", + "integrity": "sha512-QLcPegTHF11axjfojBIoDygmS2E3Lf+8+jI6wOVmNVenrKSo3mFdSGiIgdSHenczw3wPtlVMQaFVwGmM7BJdtg==", + "requires": { + "path-root-regex": "^0.1.0" + } + }, + "path-root-regex": { + "version": "0.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/path-root-regex/-/path-root-regex-0.1.2.tgz", + "integrity": "sha512-4GlJ6rZDhQZFE0DPVKh0e9jmZ5egZfxTkp7bcRDuPlJXbAwhxcl2dINPUAsjLdejqaLsCeg8axcLjIbvBjN4pQ==" + }, + "path-type": { + "version": "1.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/path-type/-/path-type-1.1.0.tgz", + "integrity": "sha512-S4eENJz1pkiQn9Znv33Q+deTOKmbl+jj1Fl+qiP/vYezj+S8x+J3Uo0ISrx/QoEvIlOaDWJhPaRd1flJ9HXZqg==", + "requires": { + "graceful-fs": "^4.1.2", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0" + } + }, + "picomatch": { + "version": "2.3.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==" + }, + "pify": { + "version": "2.3.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/pify/-/pify-2.3.0.tgz", + "integrity": "sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==" + }, + "pinkie": { + "version": "2.0.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/pinkie/-/pinkie-2.0.4.tgz", + "integrity": "sha512-MnUuEycAemtSaeFSjXKW/aroV7akBbY+Sv+RkyqFjgAe73F+MR0TBWKBRDkmfWq/HiFmdavfZ1G7h4SPZXaCSg==" + }, + "pinkie-promise": { + "version": "2.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "integrity": "sha512-0Gni6D4UcLTbv9c57DfxDGdr41XfgUjqWZu492f0cIGr16zDU06BWP/RAEvOuo7CQ0CNjHaLlM59YJJFm3NWlw==", + "requires": { + "pinkie": "^2.0.0" + } + }, + "pretty-hrtime": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/pretty-hrtime/-/pretty-hrtime-1.0.0.tgz", + "integrity": "sha512-CU2l5CYUAptUYq/671ajexQfXuxJFwwg0n243Kdkx8bTjeenedsWgu8TGHPm03vLfNtk3aTXgySKPp3Usykudw==" + }, + "process-nextick-args": { + "version": "2.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" + }, + "punycode": { + "version": "2.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" + }, + "read-pkg": { + "version": "1.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/read-pkg/-/read-pkg-1.1.0.tgz", + "integrity": "sha512-7BGwRHqt4s/uVbuyoeejRn4YmFnYZiFl4AuaeXHlgZf3sONF0SOGlxs2Pw8g6hCKupo08RafIO5YXFNOKTfwsQ==", + "requires": { + "load-json-file": "^1.0.0", + "normalize-package-data": "^2.3.2", + "path-type": "^1.0.0" + } + }, + "read-pkg-up": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/read-pkg-up/-/read-pkg-up-1.0.1.tgz", + "integrity": "sha512-WD9MTlNtI55IwYUS27iHh9tK3YoIVhxis8yKhLpTqWtml739uXc9NWTpxoHkfZf3+DkCCsXox94/VWZniuZm6A==", + "requires": { + "find-up": "^1.0.0", + "read-pkg": "^1.0.0" + } + }, + "readable-stream": { + "version": "3.6.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + }, + "readdir-glob": { + "version": "1.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/readdir-glob/-/readdir-glob-1.1.1.tgz", + "integrity": "sha512-91/k1EzZwDx6HbERR+zucygRFfiPl2zkIYZtv3Jjr6Mn7SkKcVct8aVO+sSRiGMc6fLf72du3d92/uY63YPdEA==", + "requires": { + "minimatch": "^3.0.4" + } + }, + "rechoir": { + "version": "0.8.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/rechoir/-/rechoir-0.8.0.tgz", + "integrity": "sha512-/vxpCXddiX8NGfGO/mTafwjq4aFa/71pvamip0++IQk3zG8cbCj0fifNPrjjF1XMXUne91jL9OoxmdykoEtifQ==", + "requires": { + "resolve": "^1.20.0" + } + }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==" + }, + "require-from-string": { + "version": "2.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==" + }, + "require-main-filename": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/require-main-filename/-/require-main-filename-1.0.1.tgz", + "integrity": "sha512-IqSUtOVP4ksd1C/ej5zeEh/BIP2ajqpn8c5x+q99gvcIG/Qf0cud5raVnE/Dwd0ua9TXYDoDc0RE5hBSdz22Ug==" + }, + "resolve": { + "version": "1.22.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/resolve/-/resolve-1.22.1.tgz", + "integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==", + "requires": { + "is-core-module": "^2.9.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + } + }, + "resolve-dir": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/resolve-dir/-/resolve-dir-1.0.1.tgz", + "integrity": "sha512-R7uiTjECzvOsWSfdM0QKFNBVFcK27aHOUwdvK53BcW8zqnGdYp0Fbj82cy54+2A4P2tFM22J5kRfe1R+lM/1yg==", + "requires": { + "expand-tilde": "^2.0.0", + "global-modules": "^1.0.0" + } + }, + "resolve-package-path": { + "version": "4.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/resolve-package-path/-/resolve-package-path-4.0.3.tgz", + "integrity": "sha512-SRpNAPW4kewOaNUt8VPqhJ0UMxawMwzJD8V7m1cJfdSTK9ieZwS6K7Dabsm4bmLFM96Z5Y/UznrpG5kt1im8yA==", + "requires": { + "path-root": "^0.1.1" + } + }, + "rfdc": { + "version": "1.3.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/rfdc/-/rfdc-1.3.0.tgz", + "integrity": "sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA==" + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "semver": { + "version": "5.7.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==" + }, + "shebang-command": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "requires": { + "shebang-regex": "^3.0.0" + } + }, + "shebang-regex": { + "version": "3.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==" + }, + "signal-exit": { + "version": "3.0.7", + "resolved": "https://repo.huaweicloud.com/repository/npm/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" + }, + "spdx-correct": { + "version": "3.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/spdx-correct/-/spdx-correct-3.1.1.tgz", + "integrity": "sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w==", + "requires": { + "spdx-expression-parse": "^3.0.0", + "spdx-license-ids": "^3.0.0" + } + }, + "spdx-exceptions": { + "version": "2.3.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz", + "integrity": "sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A==" + }, + "spdx-expression-parse": { + "version": "3.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz", + "integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==", + "requires": { + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" + } + }, + "spdx-license-ids": { + "version": "3.0.11", + "resolved": "https://repo.huaweicloud.com/repository/npm/spdx-license-ids/-/spdx-license-ids-3.0.11.tgz", + "integrity": "sha512-Ctl2BrFiM0X3MANYgj3CkygxhRmr9mi6xhejbdO960nF6EDJApTYpn0BQnDKlnNBULKiCN1n3w9EBkHK8ZWg+g==" + }, + "stream-exhaust": { + "version": "1.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/stream-exhaust/-/stream-exhaust-1.0.2.tgz", + "integrity": "sha512-b/qaq/GlBK5xaq1yrK9/zFcyRSTNxmcZwFLGSTG0mXgZl/4Z6GgiyYOXOvY7N3eEvFRAG1bkDRz5EPGSvPYQlw==" + }, + "streamroller": { + "version": "3.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/streamroller/-/streamroller-3.1.1.tgz", + "integrity": "sha512-iPhtd9unZ6zKdWgMeYGfSBuqCngyJy1B/GPi/lTpwGpa3bajuX30GjUVd0/Tn/Xhg0mr4DOSENozz9Y06qyonQ==", + "requires": { + "date-format": "^4.0.10", + "debug": "^4.3.4", + "fs-extra": "^10.1.0" + } + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha512-0XsVpQLnVCXHJfyEs8tC0zpTVIr5PKKsQtkT29IwupnPTjtPmQ3xT/4yCREF9hYkV/3M3kzcUTSAZT6a6h81tw==", + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg==", + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "strip-bom": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/strip-bom/-/strip-bom-2.0.0.tgz", + "integrity": "sha512-kwrX1y7czp1E69n2ajbG65mIo9dqvJ+8aBQXOGVxqwvNbsXdFM6Lq37dLAY3mknUwru8CfcCbfOLL/gMo+fi3g==", + "requires": { + "is-utf8": "^0.2.0" + } + }, + "strip-final-newline": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/strip-final-newline/-/strip-final-newline-2.0.0.tgz", + "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==" + }, + "supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==" + }, + "tar-stream": { + "version": "2.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/tar-stream/-/tar-stream-2.2.0.tgz", + "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", + "requires": { + "bl": "^4.0.3", + "end-of-stream": "^1.4.1", + "fs-constants": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1" + } + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "requires": { + "is-number": "^7.0.0" + }, + "dependencies": { + "is-number": { + "version": "7.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==" + } + } + }, + "type": { + "version": "1.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/type/-/type-1.2.0.tgz", + "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==" + }, + "unc-path-regex": { + "version": "0.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/unc-path-regex/-/unc-path-regex-0.1.2.tgz", + "integrity": "sha512-eXL4nmJT7oCpkZsHZUOJo8hcX3GbsiDOa0Qu9F646fi8dT3XuSVopVqAcEiVzSKKH7UoDti23wNX3qGFxcW5Qg==" + }, + "undertaker": { + "version": "1.2.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/undertaker/-/undertaker-1.2.1.tgz", + "integrity": "sha512-71WxIzDkgYk9ZS+spIB8iZXchFhAdEo2YU8xYqBYJ39DIUIqziK78ftm26eecoIY49X0J2MLhG4hr18Yp6/CMA==", + "requires": { + "arr-flatten": "^1.0.1", + "arr-map": "^2.0.0", + "bach": "^1.0.0", + "collection-map": "^1.0.0", + "es6-weak-map": "^2.0.1", + "last-run": "^1.1.0", + "object.defaults": "^1.0.0", + "object.reduce": "^1.0.0", + "undertaker-registry": "^1.0.0" + } + }, + "undertaker-registry": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/undertaker-registry/-/undertaker-registry-1.0.1.tgz", + "integrity": "sha512-UR1khWeAjugW3548EfQmL9Z7pGMlBgXteQpr1IZeZBtnkCJQJIJ1Scj0mb9wQaPvUZ9Q17XqW6TIaPchJkyfqw==" + }, + "universalify": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/universalify/-/universalify-2.0.0.tgz", + "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==" + }, + "uri-js": { + "version": "4.4.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "requires": { + "punycode": "^2.1.0" + } + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" + }, + "v8flags": { + "version": "3.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/v8flags/-/v8flags-3.2.0.tgz", + "integrity": "sha512-mH8etigqMfiGWdeXpaaqGfs6BndypxusHHcv2qSHyZkGEznCd/qAXCWWRzeowtL54147cktFOC4P5y+kl8d8Jg==", + "requires": { + "homedir-polyfill": "^1.0.1" + } + }, + "validate-npm-package-license": { + "version": "3.0.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", + "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", + "requires": { + "spdx-correct": "^3.0.0", + "spdx-expression-parse": "^3.0.0" + } + }, + "which": { + "version": "1.3.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "requires": { + "isexe": "^2.0.0" + } + }, + "which-module": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/which-module/-/which-module-1.0.0.tgz", + "integrity": "sha512-F6+WgncZi/mJDrammbTuHe1q0R5hOXv/mBaiNA2TCNT/LTHusX0V+CJnj9XT8ki5ln2UZyyddDgHfCzyrOH7MQ==" + }, + "wrap-ansi": { + "version": "2.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "integrity": "sha512-vAaEaDM946gbNpH5pLVNR+vX2ht6n0Bt3GXwVB1AuAqZosOvHNF3P7wDnh8KLkSqgUh0uh77le7Owgoz+Z9XBw==", + "requires": { + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1" + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + }, + "y18n": { + "version": "3.2.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/y18n/-/y18n-3.2.2.tgz", + "integrity": "sha512-uGZHXkHnhF0XeeAPgnKfPv1bgKAYyVvmNL1xlKsPYZPaIHxGti2hHqvOCQv71XMsLxu1QjergkqogUnms5D3YQ==" + }, + "yargs": { + "version": "7.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/yargs/-/yargs-7.1.0.tgz", + "integrity": "sha512-JHLTJJ5uqdt0peYp5mHzmSNV4uHXWphgSlKk5jg3sY5XYPTBw0hzw0SDNnYISn7pAXeAv5pKT4CNY+EcCTptBg==", + "requires": { + "camelcase": "^3.0.0", + "cliui": "^3.2.0", + "decamelize": "^1.1.1", + "get-caller-file": "^1.0.1", + "os-locale": "^1.4.0", + "read-pkg-up": "^1.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^1.0.1", + "set-blocking": "^2.0.0", + "string-width": "^1.0.2", + "which-module": "^1.0.0", + "y18n": "^3.2.1", + "yargs-parser": "^5.0.0" + } + }, + "yargs-parser": { + "version": "5.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/yargs-parser/-/yargs-parser-5.0.1.tgz", + "integrity": "sha512-wpav5XYiddjXxirPoCTUPbqM0PXvJ9hiBMvuJgInvo4/lAOTZzUprArw17q2O1P2+GHhbBr18/iQwjL5Z9BqfA==", + "requires": { + "camelcase": "^3.0.0", + "object.assign": "^4.1.0" + } + }, + "zip-stream": { + "version": "4.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/zip-stream/-/zip-stream-4.1.0.tgz", + "integrity": "sha512-zshzwQW7gG7hjpBlgeQP9RuyPGNxvJdzR8SUM3QhxCnLjWN2E7j3dOvpeDcQoETfHx0urRS7EtmVToql7YpU4A==", + "requires": { + "archiver-utils": "^2.1.0", + "compress-commons": "^4.1.0", + "readable-stream": "^3.6.0" + } + } + } +} diff --git a/cer_manager/package.json b/cer_manager/package.json new file mode 100644 index 0000000000000000000000000000000000000000..13a565ee8c017d3f503b29710547a505a7f159f7 --- /dev/null +++ b/cer_manager/package.json @@ -0,0 +1,18 @@ +{ + "license":"ISC", + "devDependencies":{}, + "name":"applications_certmanager", + "ohos":{ + "org":"huawei", + "directoryLevel":"project", + "buildTool":"hvigor" + }, + "description":"example description", + "repository":{}, + "version":"1.0.0", + "dependencies":{ + "@ohos/hvigor-ohos-plugin":"1.0.6", + "hypium":"^1.0.0", + "@ohos/hvigor":"1.0.6" + } +} \ No newline at end of file diff --git a/cer_manager/product/phone/build-profile.json5 b/cer_manager/product/phone/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c2a5ba2d3141263933374ce65c65870b5232b229 --- /dev/null +++ b/cer_manager/product/phone/build-profile.json5 @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "apiType": 'stageMode', + "buildOption": { + }, + "targets": [ + { + "name": "default", + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/cer_manager/product/phone/hvigorfile.js b/cer_manager/product/phone/hvigorfile.js new file mode 100644 index 0000000000000000000000000000000000000000..d7720ee6a7aad5c617d1fd2f6fc8c87067bfa32c --- /dev/null +++ b/cer_manager/product/phone/hvigorfile.js @@ -0,0 +1,2 @@ +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +module.exports = require('@ohos/hvigor-ohos-plugin').hapTasks diff --git a/cer_manager/product/phone/package-lock.json b/cer_manager/product/phone/package-lock.json new file mode 100644 index 0000000000000000000000000000000000000000..abd853cb784cb093cda45303cecb6009864bf573 --- /dev/null +++ b/cer_manager/product/phone/package-lock.json @@ -0,0 +1,5 @@ +{ + "name": "phone", + "version": "1.0.0", + "lockfileVersion": 1 +} diff --git a/cer_manager/product/phone/package.json b/cer_manager/product/phone/package.json new file mode 100644 index 0000000000000000000000000000000000000000..e9f46efb7fa9ce9d1ee3b0874ae1c23f9e2e901c --- /dev/null +++ b/cer_manager/product/phone/package.json @@ -0,0 +1,14 @@ +{ + "license": "ISC", + "devDependencies": {}, + "name": "phone", + "ohos": { + "org": "huawei", + "directoryLevel": "module", + "buildTool": "hvigor" + }, + "description": "example description", + "repository": {}, + "version": "1.0.0", + "dependencies": {} +} diff --git a/cer_manager/product/phone/src/main/ets/Application/AbilityStage.ts b/cer_manager/product/phone/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..b3f3c306081d07be09d4367c3aa27b13cf57f046 --- /dev/null +++ b/cer_manager/product/phone/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/cer_manager/product/phone/src/main/ets/MainAbility/MainAbility.ts b/cer_manager/product/phone/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..4f8197077d647503e49f930997515f85266c6789 --- /dev/null +++ b/cer_manager/product/phone/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,71 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Ability from '@ohos.application.Ability'; +import certManager from '../stub/certStubPromise' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.certManagerAbilityContext = this.context + globalThis.abilityWant = want; + globalThis.certStub = certManager; + globalThis.certStub.restoreAllMaps(); + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + globalThis.certStub.saveAllMaps(); + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + this.requestPermissions(() => windowStage.setUIContent(this.context, "pages/certManagerFa", null)) + + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } + + onNewWant(want) { + console.log("[Demo] MainAbility onNewWant") + globalThis.abilityWant = want; + } + + private requestPermissions(callback) { + let permissionList: Array = [ + "ohos.permission.READ_MEDIA" + ] + globalThis.certManagerAbilityContext.requestPermissionsFromUser(permissionList).then(function (data) { + console.log("[Demo] MainAbility requestPermissions success") + callback() + }, (error) => { + console.log("[Demo] MainAbility requestPermissions fail to request permission error code = " + error.code) + }) + } +}; diff --git a/cer_manager/product/phone/src/main/ets/model/BundleModel.ets b/cer_manager/product/phone/src/main/ets/model/BundleModel.ets new file mode 100644 index 0000000000000000000000000000000000000000..17670467297c36dc08265b98fb41be379d882f85 --- /dev/null +++ b/cer_manager/product/phone/src/main/ets/model/BundleModel.ets @@ -0,0 +1,48 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import bundle from '@ohos.bundle' +import { CMModelErrorCode } from '../model/CertMangerModel' + +export class BundleNameModel { + async getAppInfoList(AppUid, callback) { + try { + let AppInfo = { + AppImage: "", + AppName: "", + } + let AppBundleName = await bundle.getNameForUid(AppUid) + var bundleContext = await globalThis.certManagerAbilityContext.createBundleContext(AppBundleName) + + let labelId = Number(bundleContext.applicationInfo.labelId) + let iconId = Number(bundleContext.applicationInfo.iconId) + + AppInfo.AppImage = await bundleContext.resourceManager.getMediaBase64(iconId) + + AppInfo.AppName = await bundleContext.resourceManager.getString(labelId) + + console.log("AppName1111111111", JSON.stringify(AppInfo)); + + callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS, AppInfo) + } catch (err) { + console.log("getAppNameListErr", JSON.stringify(err.code)); + callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION, null); + } + } +} + +let bundleNameModel = new BundleNameModel(); + +export default bundleNameModel as BundleNameModel; diff --git a/cer_manager/product/phone/src/main/ets/model/CertManagerVo/AppAuthorVo.ets b/cer_manager/product/phone/src/main/ets/model/CertManagerVo/AppAuthorVo.ets new file mode 100644 index 0000000000000000000000000000000000000000..c7b64447de9a5832abcb0fe3ae44f1e957fea7bf --- /dev/null +++ b/cer_manager/product/phone/src/main/ets/model/CertManagerVo/AppAuthorVo.ets @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class AppAuthorVo { + appImage: string; + uid: string; + appName: string; + status: boolean; + + constructor( + appImage: string, + uid: string, + appName: string, + status: boolean) { + this.appImage = appImage; + this.uid = uid; + this.appName = appName; + this.status = status; + } + +} \ No newline at end of file diff --git a/cer_manager/product/phone/src/main/ets/model/CertManagerVo/CertAbstractVo.ets b/cer_manager/product/phone/src/main/ets/model/CertManagerVo/CertAbstractVo.ets new file mode 100644 index 0000000000000000000000000000000000000000..020043812c2369c01d51d04ed30ed6fd3f0b9969 --- /dev/null +++ b/cer_manager/product/phone/src/main/ets/model/CertManagerVo/CertAbstractVo.ets @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class CertAbstractVo { + uri: string; + certAlias: string; + status: boolean; + subjectName: string; + SubjectNameCN : string; + + constructor(uri: string, + certAlias: string, + status: boolean, + subjectName: string, + SubjectNameCN : string) { + this.uri = uri; + this.certAlias = certAlias; + this.status = status; + this.subjectName = subjectName; + this.SubjectNameCN = SubjectNameCN; + } + +} \ No newline at end of file diff --git a/cer_manager/product/phone/src/main/ets/model/CertManagerVo/CertInfoVo.ets b/cer_manager/product/phone/src/main/ets/model/CertManagerVo/CertInfoVo.ets new file mode 100644 index 0000000000000000000000000000000000000000..a4a3eb226a71739e4dbeeef79b6e628339661534 --- /dev/null +++ b/cer_manager/product/phone/src/main/ets/model/CertManagerVo/CertInfoVo.ets @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class CertInfoVo { + uri: string; + certAlias: string; + status: boolean; + issuerName: string; + subjectName: string; + serial: string; + notBefore: string; + notAfter: string; + fingerprintSha256: string; + cert: Uint8Array; + subjectNameMap :Map; + issuerNameMap :Map; + dateMap :Map; + + constructor(uri: string, + certAlias: string, + status: boolean, + issuerName: string, + subjectName: string, + serial: string, + notBefore: string, + notAfter: string, + fingerprintSha256: string, + cert: Uint8Array, + subjectNameMap: Map, + issuerNameMap :Map, + dateMap :Map) { + this.uri = uri; + this.certAlias = certAlias; + this.status = status; + this.issuerName = issuerName; + this.subjectName = subjectName; + this.serial = serial; + this.notBefore = notBefore; + this.notAfter = notAfter; + this.fingerprintSha256 = fingerprintSha256; + this.cert = cert; + this.subjectNameMap = subjectNameMap + this.issuerNameMap = issuerNameMap + this.dateMap = dateMap + } + +} \ No newline at end of file diff --git a/cer_manager/product/phone/src/main/ets/model/CertManagerVo/CredentialAbstractVo.ets b/cer_manager/product/phone/src/main/ets/model/CertManagerVo/CredentialAbstractVo.ets new file mode 100644 index 0000000000000000000000000000000000000000..70a599b1610d8df4715032ca9268be6e073d0047 --- /dev/null +++ b/cer_manager/product/phone/src/main/ets/model/CertManagerVo/CredentialAbstractVo.ets @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class CredentialAbstractVo { + credType: string; + alias: string; + keyUri: string; + + constructor(credType: string, + alias: string, + keyUri: string) { + this.credType = credType; + this.alias = alias; + this.keyUri = keyUri; + } + +} \ No newline at end of file diff --git a/cer_manager/product/phone/src/main/ets/model/CertManagerVo/CredentialVo.ets b/cer_manager/product/phone/src/main/ets/model/CertManagerVo/CredentialVo.ets new file mode 100644 index 0000000000000000000000000000000000000000..eef674c7e896d67d7fa7ae5c47ecec24cfe8d1d2 --- /dev/null +++ b/cer_manager/product/phone/src/main/ets/model/CertManagerVo/CredentialVo.ets @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class CredentialVo { + credType: string; + alias: string; + keyUri: string; + certNum: number; + keyNum: number; + credData: Uint8Array; + + constructor(credType: string, + alias: string, + keyUri: string, + certNum: number, + keyNum: number, + credData: Uint8Array) { + this.credType = credType; + this.alias = alias; + this.keyUri = keyUri; + this.certNum = certNum; + this.keyNum = keyNum; + this.credData = credData; + } + +} \ No newline at end of file diff --git a/cer_manager/product/phone/src/main/ets/model/CertMangerModel.ets b/cer_manager/product/phone/src/main/ets/model/CertMangerModel.ets new file mode 100644 index 0000000000000000000000000000000000000000..fb9d583203f5daaefe7a5a2047e24d985d791205 --- /dev/null +++ b/cer_manager/product/phone/src/main/ets/model/CertMangerModel.ets @@ -0,0 +1,579 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { CertManagerStore } from '../stub/certStubStruct' +import { CertAbstractVo } from './CertManagerVo/CertAbstractVo' +import { CertInfoVo } from './CertManagerVo/CertInfoVo' +import { CredentialAbstractVo } from './CertManagerVo/CredentialAbstractVo' +import { CredentialVo } from './CertManagerVo/CredentialVo' + +const TAG = "CertManager Model: "; +var certManager = globalThis.certStub; + +export enum CMModelErrorCode { + CM_MODEL_ERROR_SUCCESS = 0, + CM_MODEL_ERROR_FAILED = -1, + CM_MODEL_ERROR_EXCEPTION = -2, + CM_MODEL_ERROR_UNKNOWN_OPT = -3, + CM_MODEL_ERROR_NOT_SUPPORT = -4, +} + +export enum CMModelOptType { + CM_MODEL_OPT_UNKNOWN = 0, + CM_MODEL_OPT_SYSTEM_CA = 1, + CM_MODEL_OPT_USER_CA = 2, + CM_MODEL_OPT_APP_CRED = 3, + CM_MODEL_OPT_PRIVATE_CRED = 4, +} + +export class CertMangerModel { + getCertOrCredList(optType, callback) { + console.log(TAG + "getCertOrCredList start"); + + switch (optType) { + case CMModelOptType.CM_MODEL_OPT_SYSTEM_CA: + this.getSystemTrustedCertificateList((errCode, certList) => { + callback(errCode, certList) + }); + break; + case CMModelOptType.CM_MODEL_OPT_USER_CA: + this.getUserTrustedCertificateList((errCode, certList) => { + callback(errCode, certList) + }); + break; + case CMModelOptType.CM_MODEL_OPT_APP_CRED: + this.getAppCredList((errCode, credList) => { + callback(errCode, credList) + }); + break; + case CMModelOptType.CM_MODEL_OPT_PRIVATE_CRED: + this.getPrivateCredList((errCode, credList) => { + callback(errCode, credList) + }); + break; + default: + callback(CMModelErrorCode.CM_MODEL_ERROR_UNKNOWN_OPT, null) + break; + } + } + + getCertOrCred(optType, uri, callback) { + console.log(TAG + "getCertOrCredList start"); + + switch (optType) { + case CMModelOptType.CM_MODEL_OPT_SYSTEM_CA: + this.getSystemTrustedCertificate(uri, (errCode, certInfo) => { + console.info('getSystemTrustedCertificate certInfo is' + JSON.stringify(certInfo)) + callback(errCode, certInfo) + }); + break; + case CMModelOptType.CM_MODEL_OPT_USER_CA: + this.getUserTrustedCertificate(uri, (errCode, certInfo) => { + callback(errCode, certInfo) + }); + break; + case CMModelOptType.CM_MODEL_OPT_APP_CRED: + this.getAppCredential(uri, (errCode, credInfo) => { + callback(errCode, credInfo) + }); + break; + case CMModelOptType.CM_MODEL_OPT_PRIVATE_CRED: + this.getPrivateCred(uri, (errCode, credInfo) => { + callback(errCode, credInfo) + }); + break; + default: + callback(CMModelErrorCode.CM_MODEL_ERROR_UNKNOWN_OPT, null) + break; + } + } + + deleteCertOrCred(optType, uri, callback) { + console.log(TAG + "deleteCertOrCred start"); + + switch (optType) { + case CMModelOptType.CM_MODEL_OPT_USER_CA: + this.deleteUserTrustedCertificate(uri, (errCode) => { + callback(errCode) + }); + break; + case CMModelOptType.CM_MODEL_OPT_APP_CRED: + this.deleteAppCredential(uri, (errCode) => { + callback(errCode) + }); + break; + case CMModelOptType.CM_MODEL_OPT_SYSTEM_CA: + case CMModelOptType.CM_MODEL_OPT_PRIVATE_CRED: + callback(CMModelErrorCode.CM_MODEL_ERROR_NOT_SUPPORT) + break; + default: + callback(CMModelErrorCode.CM_MODEL_ERROR_UNKNOWN_OPT) + break; + } + } + + setCertStatus(optType, uri, status, callback) { + console.log(TAG + "setCertStatus start"); + + switch (optType) { + case CMModelOptType.CM_MODEL_OPT_USER_CA: + this.setCertificateStatus(uri, CertManagerStore.CERT_MANAGER_USER_TRUSTED_STORE, status, (errCode) => { + callback(errCode) + }); + break; + case CMModelOptType.CM_MODEL_OPT_SYSTEM_CA: + this.setCertificateStatus(uri, CertManagerStore.CERT_MANAGER_SYSTEM_TRUSTED_STORE, status, (errCode) => { + callback(errCode) + }); + break; + case CMModelOptType.CM_MODEL_OPT_APP_CRED: + case CMModelOptType.CM_MODEL_OPT_PRIVATE_CRED: + callback(CMModelErrorCode.CM_MODEL_ERROR_NOT_SUPPORT) + break; + default: + callback(CMModelErrorCode.CM_MODEL_ERROR_UNKNOWN_OPT) + break; + } + } + + delAllCertOrCred(optType, callback) { + console.log(TAG + "delAllCertOrCred start"); + + switch (optType) { + case CMModelOptType.CM_MODEL_OPT_USER_CA: + this.delAllUserCertificate((errCode) => { + callback(errCode) + }); + break; + case CMModelOptType.CM_MODEL_OPT_APP_CRED: + this.delAllAppCredential((errCode) => { + callback(errCode) + }); + break; + case CMModelOptType.CM_MODEL_OPT_SYSTEM_CA: + case CMModelOptType.CM_MODEL_OPT_PRIVATE_CRED: + callback(CMModelErrorCode.CM_MODEL_ERROR_NOT_SUPPORT) + break; + default: + callback(CMModelErrorCode.CM_MODEL_ERROR_UNKNOWN_OPT) + break; + } + } + + getAuthAppList(optType, uri, callback) { + console.log(TAG + "setCertStatus start"); + + switch (optType) { + case CMModelOptType.CM_MODEL_OPT_APP_CRED: + this.getAuthorizedAppList(uri, (errCode, appUidList) => { + callback(errCode, appUidList) + }); + break; + case CMModelOptType.CM_MODEL_OPT_USER_CA: + case CMModelOptType.CM_MODEL_OPT_SYSTEM_CA: + case CMModelOptType.CM_MODEL_OPT_PRIVATE_CRED: + callback(CMModelErrorCode.CM_MODEL_ERROR_NOT_SUPPORT) + break; + default: + callback(CMModelErrorCode.CM_MODEL_ERROR_UNKNOWN_OPT) + break; + } + } + + setAppAuth(optType, uri, appUid, status, callback) { + console.log(TAG + "setCertStatus start"); + + switch (optType) { + case CMModelOptType.CM_MODEL_OPT_APP_CRED: + this.setAuthorizedAppStatus(uri, appUid, status, (errCode, data) => { + callback(errCode, data) + }); + break; + case CMModelOptType.CM_MODEL_OPT_USER_CA: + case CMModelOptType.CM_MODEL_OPT_SYSTEM_CA: + case CMModelOptType.CM_MODEL_OPT_PRIVATE_CRED: + callback(CMModelErrorCode.CM_MODEL_ERROR_NOT_SUPPORT) + break; + default: + callback(CMModelErrorCode.CM_MODEL_ERROR_UNKNOWN_OPT) + break; + } + } + + installCertOrCred(optType, alias, data, pwd, callback) { + console.log(TAG + "setCertStatus start"); + console.info(TAG + 'installCert optType: ' + optType + 'alias: ' + alias + ' pwd: ' + pwd) + switch (optType) { + case CMModelOptType.CM_MODEL_OPT_USER_CA: + this.installUserCertificate(data, alias, (errCode) => { + callback(errCode) + }); + break; + case CMModelOptType.CM_MODEL_OPT_APP_CRED: + this.installAppCertificate(data, alias, pwd, (errCode) => { + callback(errCode) + }); + break; + case CMModelOptType.CM_MODEL_OPT_PRIVATE_CRED: + case CMModelOptType.CM_MODEL_OPT_SYSTEM_CA: + callback(CMModelErrorCode.CM_MODEL_ERROR_NOT_SUPPORT) + break; + default: + callback(CMModelErrorCode.CM_MODEL_ERROR_UNKNOWN_OPT) + break; + } + } + + private async getSystemTrustedCertificateList(callback) { + console.log(TAG + "getSystemTrustedCertificateList start"); + try { + let SubjectNameCN; + let result = await certManager.getSystemTrustedCertificateList(); + let certList = new Array(); + console.log(TAG + "certManager::getSystemTrustedCertificateList result: " + JSON.stringify(result)); + for (let i = 0; i < result.certList.length; i++) { + if (result.certList[i].subjectName.length != 0) { + SubjectNameCN = result.certList[i].subjectName.match(/(?<=CN=).*?(?=,)/g).toString() + console.info('SubjectNameCN is:' + SubjectNameCN) + } + certList.push(new CertAbstractVo(result.certList[i].uri, result.certList[i].certAlias, + result.certList[i].status, result.certList[i].subjectName, SubjectNameCN)) + } + console.log(TAG + "getSystemTrustedCertificateList end"); + callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS, certList) + + } catch (err) { + console.log(TAG + "getSystemTrustedCertificateList err: " + JSON.stringify(err)); + callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION, null) + } + } + + private async getSystemTrustedCertificate(certUri, callback) { + console.log(TAG + "getSystemTrustedCertificate start"); + try { + let result = await certManager.getSystemTrustedCertificate(certUri); + let subjectNameMap: Map = new Map() + let issuerNameMap: Map = new Map() + let dateMap: Map = new Map() + if (result.certInfo.subjectName.length != 0) { + let SubjectNameCN = result.certInfo.subjectName.match(/(?<=CN=).*?(?=,)/g) + console.info('SubjectNameCN is:' + SubjectNameCN) + let SubjectNameOU = result.certInfo.subjectName.match(/(?<=OU=).*?(?=,)/g) + console.info('SubjectNameOU is:' + SubjectNameOU) + let SubjectNameO = result.certInfo.subjectName.match(/(?<=O=).*/g) + console.info('SubjectNameO is:' + SubjectNameO) + subjectNameMap.set('常用名称:', String(SubjectNameCN)) + subjectNameMap.set('组织:', String(SubjectNameO)) + subjectNameMap.set('组织单位:', String(SubjectNameOU)) + subjectNameMap.set('序列号:', result.certInfo.serial) + } + if (result.certInfo.issuerName.length != 0) { + let IssuerNameCN = result.certInfo.subjectName.match(/(?<=CN=).*?(?=,)/g) + console.info('SubjectNameCN is:' + IssuerNameCN) + let IssuerNameOU = result.certInfo.subjectName.match(/(?<=OU=).*?(?=,)/g) + console.info('SubjectNameOU is:' + IssuerNameOU) + let IssuerNameO = result.certInfo.subjectName.match(/(?<=O=).*/g) + console.info('SubjectNameO is:' + IssuerNameO) + issuerNameMap.set('常用名称:', String(IssuerNameCN)) + issuerNameMap.set('组织:', String(IssuerNameO)) + issuerNameMap.set('组织单位:', String(IssuerNameOU)) + } + dateMap.set('颁发时间:', result.certInfo.notBefore) + dateMap.set('有效期至:', result.certInfo.notAfter) + + let certInfo = new CertInfoVo(result.certInfo.uri, result.certInfo.certAlias, + result.certInfo.status, result.certInfo.issuerName, result.certInfo.subjectName, + result.certInfo.serial, result.certInfo.notBefore, + result.certInfo.notAfter, result.certInfo.fingerprintSha256, result.certInfo.cert, + subjectNameMap, issuerNameMap, dateMap); + + console.log(TAG + "getSystemTrustedCertificate end"); + callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS, certInfo) + + } catch (err) { + console.log(TAG + "getSystemTrustedCertificate err: " + JSON.stringify(err)); + callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION, null) + } + } + + private async setSystemCertificateStatus(certUri: string, status: boolean, callback) { + console.log(TAG + "setSystemCertificateStatus start"); + try { + await certManager.setCertificateStatus(certUri, CertManagerStore.CERT_MANAGER_SYSTEM_TRUSTED_STORE, + status); + console.log(TAG + "setSystemCertificateStatus end"); + callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) + } catch (err) { + console.log(TAG + "setSystemCertificateStatus err: " + JSON.stringify(err)); + callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION) + } + } + + private async getUserTrustedCertificateList(callback) { + console.log(TAG + "getUserTrustedCertificateList start"); + try { + let SubjectNameCN + let result = await certManager.getUserTrustedCertificateList(); + let certList = new Array(); + console.log(TAG + "getUserTrustedCertificateList result: " + JSON.stringify(result)); + for (let i = 0; i < result.certList.length; i++) { + if(result.certList[i].subjectName.length != 0){ + SubjectNameCN = result.certList[i].subjectName.match(/(?<=CN=).*?(?=,)/g).toString() + console.info('SubjectNameCN is:' + SubjectNameCN) + } + certList.push(new CertAbstractVo(result.certList[i].uri, result.certList[i].certAlias, + result.certList[i].status, result.certList[i].subjectName, SubjectNameCN)) + } + console.log(TAG + "getUserTrustedCertificateList end"); + callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS, certList) + } catch (err) { + console.log(TAG + "getUserTrustedCertificateList err: " + JSON.stringify(err)); + callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION) + } + } + + private async getUserTrustedCertificate(certUri, callback) { + console.log(TAG + "getUserTrustedCertificate start"); + try { + let result = await certManager.getUserTrustedCertificate(certUri); + let subjectNameMap: Map = new Map() + let issuerNameMap: Map = new Map() + let dateMap: Map = new Map() + + if (result.certInfo.subjectName.length != 0) { + let SubjectNameCN = result.certInfo.subjectName.match(/(?<=CN=).*?(?=,)/g) + console.info('SubjectNameCN is:' + SubjectNameCN) + let SubjectNameOU = result.certInfo.subjectName.match(/(?<=OU=).*?(?=,)/g) + console.info('SubjectNameOU is:' + SubjectNameOU) + let SubjectNameO = result.certInfo.subjectName.match(/(?<=O=).*/g) + console.info('SubjectNameO is:' + SubjectNameO) + subjectNameMap.set('常用名称:', String(SubjectNameCN)) + subjectNameMap.set('组织:', String(SubjectNameO)) + subjectNameMap.set('组织单位:', String(SubjectNameOU)) + subjectNameMap.set('序列号:', result.certInfo.serial) + } + if (result.certInfo.issuerName.length != 0) { + let IssuerNameCN = result.certInfo.subjectName.match(/(?<=CN=).*?(?=,)/g) + console.info('SubjectNameCN is:' + IssuerNameCN) + let IssuerNameOU = result.certInfo.subjectName.match(/(?<=OU=).*?(?=,)/g) + console.info('SubjectNameOU is:' + IssuerNameOU) + let IssuerNameO = result.certInfo.subjectName.match(/(?<=O=).*/g) + console.info('SubjectNameO is:' + IssuerNameO) + issuerNameMap.set('常用名称:', String(IssuerNameCN)) + issuerNameMap.set('组织:', String(IssuerNameO)) + issuerNameMap.set('组织单位:', String(IssuerNameOU)) + } + dateMap.set('颁发时间:', result.certInfo.notBefore) + dateMap.set('有效期至:', result.certInfo.notAfter) + let certInfo = new CertInfoVo(result.certInfo.uri, result.certInfo.certAlias, + result.certInfo.status, result.certInfo.issuerName, result.certInfo.subjectName, + result.certInfo.serial, result.certInfo.notBefore, + result.certInfo.notAfter, result.certInfo.fingerprintSha256, result.certInfo.cert, + subjectNameMap, issuerNameMap, dateMap); + console.log(TAG + "getUserTrustedCertificate end"); + callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS, certInfo) + } catch (err) { + console.log(TAG + "getUserTrustedCertificate err: " + JSON.stringify(err)); + callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION, null) + } + } + + private async deleteUserTrustedCertificate(certUri, callback) { + console.log(TAG + "deleteUserTrustedCertificate start"); + try { + await certManager.uninstallUserTrustedCertificate(certUri); + console.log(TAG + "deleteUserTrustedCertificate end"); + callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) + } catch (err) { + console.log(TAG + "deleteUserTrustedCertificate err: " + JSON.stringify(err)); + callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION) + } + } + + private async setCertificateStatus(certUri, store, status, callback) { + console.log(TAG + "setCertificateStatus start"); + try { + await certManager.setCertificateStatus(certUri, store, status); + console.log(TAG + "setCertificateStatus end"); + callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) + } catch (err) { + console.info(TAG + 'setCertificateStatus fail, err is' + err) + callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION) + } + } + + private async getAppCredList(callback) { + console.log(TAG + "getAppCredList start"); + + try { + let result = await certManager.getAppCertificateList(); + let credList = new Array(); + for (let i = 0; i < result.credentialList.length; i++) { + credList.push(new CredentialAbstractVo(result.credentialList[i].type, result.credentialList[i].alias, + result.credentialList[i].keyUri)) + } + console.log(TAG + "getAppCredList end credList: " + JSON.stringify(credList)); + callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS, credList) + } catch (err) { + console.info(TAG + 'getAppCredList fail, err is' + err) + callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION) + } + } + + private async getAppCredential(certUri, callback) { + console.log(TAG + "getAppCredential start"); + try { + let result = await certManager.getAppCertificate(certUri); + let credInfo = new CredentialVo(result.credential.type, result.credential.alias, + result.credential.keyUri, result.credential.certNum, result.credential.keyNum, result.credential.credData); + console.log(TAG + "getAppCredential end"); + callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS, credInfo) + } catch (err) { + console.info(TAG + 'getAppCredential fail, err is' + err) + callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION, null) + } + } + + private async deleteAppCredential(certUri, callback) { + console.log(TAG + "deleteAppCredential start"); + try { + await certManager.uninstallAppCertificate(certUri); + console.log(TAG + "deleteAppCredential end"); + callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) + } catch (err) { + console.info(TAG + 'deleteAppCredential fail, err is' + err) + callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION) + } + } + + private async getPrivateCredList(callback) { + console.log(TAG + "getPrivateCredList start"); + + try { + let result = await certManager.getPrivateCertificateList(); + let credList = new Array(); + for (let i = 0; i < result.credentialList.length; i++) { + credList.push(new CredentialAbstractVo(result.credentialList[i].type, result.credentialList[i].alias, + result.credentialList[i].keyUri)) + } + console.log(TAG + "getPrivateCredList end"); + callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS, credList) + } catch (err) { + console.info(TAG + 'getPrivateCredList fail, err is' + err) + callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION) + } + } + + private async getPrivateCred(certUri, callback) { + console.log(TAG + "getPrivateCred start"); + try { + let result = await certManager.getPrivateCertificate(certUri); + let credInfo = new CredentialVo(result.credential.type, result.credential.alias, + result.credential.keyUri, result.credential.certNum, result.credential.keyNum, result.credential.credData); + console.log(TAG + "getPrivateCred end"); + callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS, credInfo) + } catch (err) { + console.info(TAG + 'getPrivateCred fail, err is' + err) + callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION, null) + } + } + + private async delAllUserCertificate(callback) { + console.log(TAG + "delAllUserCertificate start"); + try { + await certManager.uninstallAllUserTrustedCertificate(); + console.log(TAG + "delAllUserCertificate end"); + callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) + } catch (err) { + console.info(TAG + 'delAllUserCertificate fail, err is' + err) + callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION) + } + } + + private async delAllAppCredential(callback) { + console.log(TAG + "delAllAppCredential start"); + try { + await certManager.uninstallAllAppCertificate(); + console.log(TAG + "delAllAppCredential end"); + callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) + } catch (err) { + console.info(TAG + 'delAllAppCredential fail, err is' + err) + callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION) + } + } + + private async getAuthorizedAppList(uri, callback) { + console.log(TAG + "getAuthorizedAppList start"); + try { + let result = await certManager.getAuthorizedAppList(uri); + console.log(TAG + "getAuthorizedAppList end"); + callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS, result.appUidList) + } catch (err) { + console.info(TAG + 'getAuthorizedAppList fail, err is' + err) + callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION, null) + } + } + + private async setAuthorizedAppStatus(uri, appUid, status, callback) { + console.log(TAG + "setAuthorizedAppStatus start"); + try { + if (status) { + let result = await certManager.grantAppCertificate(uri, appUid); + console.log(TAG + "setAuthorizedAppStatus true end"); + callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS, result.authUri) + } else { + await certManager.removeGrantedAppCertificate(uri, appUid); + console.log(TAG + "setAuthorizedAppStatus false end"); + callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) + } + } catch (err) { + console.info(TAG + 'setAuthorizedAppStatus fail, err is' + err) + callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION) + } + } + + private async installUserCertificate(data, alias, callback) { + console.info(TAG + 'installUserCertificate start alias: ' + alias + 'data' + JSON.stringify(data)) + try { + await certManager.installUserTrustedCertificate({ + inData: data, + alias: alias + }); + + console.info(TAG + 'installUserCertificate end') + callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) + } catch (err) { + console.info(TAG + 'installUserCertificate fail, err is' + err) + callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION) + } + } + + private async installAppCertificate(data, alias, pwd, callback) { + console.info(TAG + 'installAppCertificate start') + try { + await certManager.installAppCertificate(data, pwd, alias); + console.info(TAG + 'installAppCertificate end') + callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) + } catch (err) { + console.info(TAG + 'installAppCertificate fail, err is' + err) + callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION) + } + } + +} + +let certMangerModel = new CertMangerModel(); + +export default certMangerModel as CertMangerModel; \ No newline at end of file diff --git a/cer_manager/product/phone/src/main/ets/model/FileIoModel.ets b/cer_manager/product/phone/src/main/ets/model/FileIoModel.ets new file mode 100644 index 0000000000000000000000000000000000000000..7c4a287323b1763b13ea10179095f5de159c268a --- /dev/null +++ b/cer_manager/product/phone/src/main/ets/model/FileIoModel.ets @@ -0,0 +1,102 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import fileio from '@ohos.fileio'; +import mediaLibrary from '@ohos.multimedia.mediaLibrary'; + +export class FileIoModel { + media; + constructor() { + this.media = mediaLibrary.getMediaLibrary(globalThis.certManagerAbilityContext); + } + + getFileIdFromMediaUri(mediaUri) { + console.log("getMediaFileSuffix getFileIdFromMediaUri uri: " + mediaUri); + + let elemList = mediaUri.split("/"); + let fileIdString = elemList[elemList.length - 1]; + let fileIdNum = fileIdString.match(/\d+/g); + + return fileIdNum; + } + + getMediaFileSuffix(mediaUri, callback) { + console.log("getMediaFileSuffix start uri: " + mediaUri); + let fileKeyObj = mediaLibrary.FileKey + let fileId = this.getFileIdFromMediaUri(mediaUri); + console.log("getMediaFileSuffix start fileId: " + fileId); + let imagesFetchOp = { + selections: fileKeyObj.ID + '= ?', + selectionArgs: [fileId.toString()], + }; + let suffix; + + this.media.getFileAssets(imagesFetchOp, (error, fetchFileResult) => { + console.log("getMediaFile getFileAssets callback in fetchFileResult: "); + if (fetchFileResult != undefined) { + fetchFileResult.getFirstObject(async (error, fileAsset) => { + console.log("getMediaFile getFileAssets callback getFirstObject: "); + if (fileAsset) { + console.log("getMediaFile getFileAssets fileAsset: " + fileAsset.displayName); + suffix = fileAsset.displayName.substring(fileAsset.displayName.lastIndexOf(".") + 1); + callback(suffix); + } else { + console.log("getMediaFile getFileAssets callback getFirstObject else"); + } + }) + } else { + console.log("getMediaFile getFileAssets callback in else: "); + callback(undefined); + } + }) + } + + getMediaFileData(mediaUri, callback) { + console.log("getMediaFile start"); + + let fileKeyObj = mediaLibrary.FileKey; + let fileId = this.getFileIdFromMediaUri(mediaUri); + let imagesFetchOp = { + selections: fileKeyObj.ID + '= ?', + selectionArgs: [fileId.toString()], + }; + let fd; + + this.media.getFileAssets(imagesFetchOp, (error, fetchFileResult) => { + if (fetchFileResult != undefined) { + fetchFileResult.getFirstObject(async (error, fileAsset) => { + console.log("getMediaFile getFileAssets fileAsset: " + fileAsset.displayName); + + if (fileAsset) { + let buf = new ArrayBuffer(fileAsset.size); + fd = await fileAsset.open("r"); + fileio.read(fd, buf, (err, data) => { + if (data) { + console.info("getMediaFile read file data exist "); + callback(new Uint8Array(data.buffer)); + } else { + console.info("getMediaFile read file data: null"); + } + }); + } + }) + } + }) + } +} + +let fileIoModel = new FileIoModel(); + +export default fileIoModel as FileIoModel; diff --git a/cer_manager/product/phone/src/main/ets/pages/cerEvidenceFa.ets b/cer_manager/product/phone/src/main/ets/pages/cerEvidenceFa.ets new file mode 100644 index 0000000000000000000000000000000000000000..b93d109fef98ef12533cdd7efae96b7636201026 --- /dev/null +++ b/cer_manager/product/phone/src/main/ets/pages/cerEvidenceFa.ets @@ -0,0 +1,747 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import LogUtil from '../../../../../../common/util/logutil'; +import ConfigData from '../../../../../../common/util/configdata'; +import HeadComponent from '../../../../../../common/component/headcomponent'; +import CMShowAppCredPresenter from '../presenter/CMShowAppCredPresenter'; +import CMShowPrivateCredPresenter from '../presenter/CMShowPrivateCredPresenter'; +import CMFaPresenter from '../presenter/CMFaPresenter'; + +@Component +export struct DialogComponent { + @Link uidItem: CMShowAppCredPresenter; + private AppName: string | Resource; + private AppImage: string; + private Index: number; + + build() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Row() { + Image(this.AppImage) + .width($r("app.float.credentials_app_image_wh")) + .height($r("app.float.credentials_app_image_hg")) + + Text(this.AppName) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Medium) + .margin({ left: $r("app.float.credentials_app_name_margin") }) + } + .alignItems(VerticalAlign.Center) + + Toggle({ type: ToggleType.Switch, isOn: true }) + .width($r("app.float.credentials_app_Toggle_wh")) + .height($r("app.float.credentials_app_Toggle_hg")) + .selectedColor($r("app.color.credentials_app_Toggle_selectColor")) + .onChange((isOn: boolean) => { + this.uidItem.appInfoList[this.Index].status = isOn + }) + .offset({ x: 7, y:0 }) + + }.height($r("app.float.wh_value_72")) + } +} + +@CustomDialog +@Component +struct CustomDialogExampleAuthor { + controller: CustomDialogController; + @Link isShowAuthDialog: boolean; + @Link AuthorInfo: CMShowAppCredPresenter; + @State updateStatusList: boolean[] = []; + + build() { + Column() { + Text($r("app.string.managerAuthApp")) + .height($r("app.float.wh_value_56")) + .fontSize($r("sys.float.ohos_id_text_size_dialog_tittle")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Medium) + .margin({ + left: $r('app.float.wh_value_24'), + right: $r('app.float.wh_value_24') + }) + .alignSelf(ItemAlign.Start); + if (this.AuthorInfo.appInfoList.length > ConfigData.APP_AUTH_MAX_LENGTH) { + List() { + ForEach(this.AuthorInfo.appInfoList, (item, index) => { + ListItem() { + DialogComponent({ AppImage: item.appImage, AppName: item.appName, Index: index, uidItem: $AuthorInfo }) + } + }) + } + .margin({ + left: $r('app.float.wh_value_24'), + right: $r('app.float.wh_value_24') + }) + .height(ConfigData.WH_50_100) + .divider({ + strokeWidth: $r("app.float.Evidence_strokeWidth"), + color: $r("app.color.Evidence_color")}) + .borderRadius($r("app.float.Evidence_borderRadius")) + .backgroundColor($r("app.color.credentials_app_finish_backgroundColor")) + .visibility(this.AuthorInfo.appInfoList.length > 0 ? Visibility.Visible : Visibility.None) + } else { + List() { + ForEach(this.AuthorInfo.appInfoList, (item, index) => { + ListItem() { + DialogComponent({ AppImage: item.appImage, AppName: item.appName, Index: index, uidItem: $AuthorInfo }) + } + }) + } + .margin({ + left: $r('app.float.wh_value_24'), + right: $r('app.float.wh_value_24') + }) + .divider({ + strokeWidth: $r("app.float.Evidence_strokeWidth"), + color: $r("app.color.Evidence_color")}) + .borderRadius($r("app.float.Evidence_borderRadius")) + .backgroundColor($r("app.color.credentials_app_finish_backgroundColor")) + .visibility(this.AuthorInfo.appInfoList.length > 0 ? Visibility.Visible : Visibility.None) + } + + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceAround }) { + Button($r("app.string.cancelAuthApp")) + .onClick(() => { + this.isShowAuthDialog = false; + this.controller.close() + }) + .backgroundColor($r("app.color.credentials_app_finish_backgroundColor")) + .fontSize($r("sys.float.ohos_id_text_size_button1")) + .fontColor($r("sys.color.ohos_id_color_text_hyperlink")) + .width($r('app.float.wh_value_152')) + .height($r('app.float.wh_value_40')) + Divider() + .strokeWidth(ConfigData.VERTICAL_DIVIDER_WIDTH) + .color($r("sys.color.ohos_id_color_list_separator")) + .vertical(true) + .opacity($r("app.float.opacity_0_2")) + .height($r('app.float.wh_value_40')) + Button($r("app.string.finishAuthApp")) + .onClick(() => { + this.AuthorInfo.removeGrantedAppList(this.AuthorInfo.credInfo.keyUri) + this.isShowAuthDialog = false; + this.controller.close() + }) + .backgroundColor($r("app.color.credentials_app_finish_backgroundColor")) + .fontSize($r("sys.float.ohos_id_text_size_button1")) + .fontColor($r("sys.color.ohos_id_color_text_hyperlink")) + .width($r('app.float.wh_value_152')) + .height($r('app.float.wh_value_40')) + } + .height($r('app.float.wh_value_64')) + .padding({ + bottom: $r('app.float.wh_value_16') + }) + .margin({ + top: $r('app.float.wh_value_6'), + left: $r('app.float.wh_value_24'), + right: $r('app.float.wh_value_24') + }) + } + } +} + +@CustomDialog +@Component +struct CustomDialogExamplePrivate { + controller: CustomDialogController; + @State PriCerInfoPresenter: CMShowPrivateCredPresenter = CMShowPrivateCredPresenter.getInstance(); + + build() { + Column() { + Text($r("app.string.evidenceDetails")) + .height($r("app.float.wh_value_56")) + .fontSize($r("sys.float.ohos_id_text_size_dialog_tittle")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Medium) + .margin({ + left: $r('app.float.wh_value_24'), + right: $r('app.float.wh_value_24') + }) + .alignSelf(ItemAlign.Start) + + Text(this.PriCerInfoPresenter.credInfo.alias) + .fontSize($r("sys.float.ohos_id_text_size_body1")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Medium) + .margin({ + left: $r('app.float.wh_value_24'), + right: $r('app.float.wh_value_24') + }) + .alignSelf(ItemAlign.Start) + + Text($r("app.string.entryContains")) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + .margin({ + top: $r('app.float.wh_value_24'), + left: $r('app.float.wh_value_24'), + right: $r('app.float.wh_value_24') + }) + .alignSelf(ItemAlign.Start) + + Text($r("app.string.keyNum", String(this.PriCerInfoPresenter.credInfo.keyNum))) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + .margin({ + left: $r('app.float.wh_value_24'), + right: $r('app.float.wh_value_24') + }) + .opacity($r('app.float.opacity_100_60')) + .alignSelf(ItemAlign.Start) + + Text($r("app.string.userCerNum", String(this.PriCerInfoPresenter.credInfo.certNum))) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + .margin({ + left: $r('app.float.wh_value_24'), + right: $r('app.float.wh_value_24') + }) + .opacity($r('app.float.opacity_100_60')) + .alignSelf(ItemAlign.Start) + + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceAround }) { + Button($r("app.string.privateDetailsClose")) + .onClick(() => { + this.controller.close() + }) + .backgroundColor($r("app.color.credentials_app_finish_backgroundColor")) + .fontSize($r("sys.float.ohos_id_text_size_button1")) + .fontColor($r("sys.color.ohos_id_color_text_hyperlink")) + .width($r('app.float.wh_value_152')) + .height($r('app.float.wh_value_40')) + } + .height($r('app.float.wh_value_64')) + .padding({ + bottom: $r('app.float.wh_value_16') + }) + .margin({ + top: $r('app.float.wh_value_16'), + left: $r('app.float.wh_value_24'), + right: $r('app.float.wh_value_24') + }) + } + } +} + +@CustomDialog +@Component +struct CustomDialogDeleteWarning { + controller: CustomDialogController; + @Link deleteWarn: CMShowAppCredPresenter; + @Link isShowWarnDialog: boolean; + + build() { + Column() { + Text($r("app.string.warning_title")) + .height($r("app.float.wh_value_56")) + .fontSize($r("sys.float.ohos_id_text_size_dialog_tittle")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Medium) + .margin({ + left: $r('app.float.wh_value_24'), + right: $r('app.float.wh_value_24') + }) + .alignSelf(ItemAlign.Start) + Text($r("app.string.warning_message")) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontWeight(FontWeight.Regular) + .fontColor($r("sys.color.ohos_id_color_primary")) + .margin({ + top: $r("app.float.wh_value_16"), + left: $r('app.float.wh_value_24'), + right: $r('app.float.wh_value_24') + }) + .alignSelf(ItemAlign.Start) + + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceAround }) { + Button($r("app.string.deleteAllCredCancel")) + .onClick(() => { + this.isShowWarnDialog = false; + this.controller.close() + }) + .backgroundColor($r("app.color.credentials_app_finish_backgroundColor")) + .fontSize($r("sys.float.ohos_id_text_size_button1")) + .fontColor($r("sys.color.ohos_id_color_text_hyperlink")) + .width($r('app.float.wh_value_152')) + .height($r('app.float.wh_value_40')) + Divider() + .strokeWidth(ConfigData.VERTICAL_DIVIDER_WIDTH) + .color($r("sys.color.ohos_id_color_list_separator")) + .vertical(true) + .height($r('app.float.wh_value_40')) + .opacity($r("app.float.opacity_0_2")) + Button($r("app.string.deleteAllCredDelete")) + .onClick(() => { + this.deleteWarn.deleteAppCred(this.deleteWarn.credInfo.keyUri); + this.isShowWarnDialog = false; + this.controller.close() + }) + .backgroundColor($r("app.color.credentials_app_finish_backgroundColor")) + .fontSize($r("sys.float.ohos_id_text_size_button1")) + .fontColor($r("sys.color.ohos_id_color_warning")) + .width($r('app.float.wh_value_152')) + .height($r('app.float.wh_value_40')) + } + .height($r('app.float.wh_value_64')) + .padding({ + bottom: $r('app.float.wh_value_16') + }) + .margin({ + top: $r('app.float.wh_value_16'), + left: $r('app.float.wh_value_24'), + right: $r('app.float.wh_value_24') + }) + } + } +} + +@CustomDialog +@Component +struct CustomDialogExampleApp { + controller: CustomDialogController; + @Link mShowAppCaPresenter: CMShowAppCredPresenter; + @Link isShowAuthDialog: boolean; + @Link isShowWarnDialog: boolean; + + aboutToAppear() { + this.mShowAppCaPresenter.getAuthorizedAppList(this.mShowAppCaPresenter.credInfo.keyUri) + } + + build() { + Column() { + Text($r("app.string.evidenceDetails")) + .height($r("app.float.wh_value_56")) + .fontSize($r("sys.float.ohos_id_text_size_dialog_tittle")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Medium) + .margin({ + left: $r('app.float.wh_value_24'), + right: $r('app.float.wh_value_24') + }) + .alignSelf(ItemAlign.Start) + + Text(this.mShowAppCaPresenter.credInfo.alias) + .fontSize($r("sys.float.ohos_id_text_size_body1")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Medium) + .margin({ + left: $r('app.float.wh_value_24'), + right: $r('app.float.wh_value_24') + }) + .alignSelf(ItemAlign.Start) + + Text($r("app.string.entryContains")) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + .margin({ + top: $r('app.float.wh_value_24'), + left: $r('app.float.wh_value_24'), + right: $r('app.float.wh_value_24') + }) + .alignSelf(ItemAlign.Start) + + Text($r("app.string.keyNum", String(this.mShowAppCaPresenter.credInfo.keyNum))) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + .margin({ + left: $r('app.float.wh_value_24'), + right: $r('app.float.wh_value_24') + }) + .opacity($r('app.float.opacity_100_60')) + .alignSelf(ItemAlign.Start) + + Text($r("app.string.userCerNum", String(this.mShowAppCaPresenter.credInfo.certNum))) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + .margin({ + left: $r('app.float.wh_value_24'), + right: $r('app.float.wh_value_24') + }) + .opacity($r('app.float.opacity_100_60')) + .alignSelf(ItemAlign.Start) + + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Column() { + Text($r("app.string.managerAuthApp")) + .fontSize($r("sys.float.ohos_id_text_size_body1")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Medium) + } + + Row() { + Image($r('app.media.ic_settings_arrow')) + .width($r("app.float.managerAuthApp_image_wh")) + .height($r("app.float.managerAuthApp_image_hg")) + .fillColor($r("sys.color.ohos_id_color_primary")) + .opacity($r("app.float.managerAuthApp_image_opacity")) + } + } + .onClick(() => { + this.isShowAuthDialog = true; + }) + .margin({ + top: $r('app.float.wh_value_12'), + left: $r('app.float.wh_value_24'), + right: $r('app.float.wh_value_24') + }) + .height('48vp') + + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceAround }) { + Button($r("app.string.publicDetailsCancel")) + .onClick(() => { + this.isShowAuthDialog = false; + this.isShowWarnDialog = false; + this.controller.close(); + }) + .backgroundColor($r("app.color.credentials_app_finish_backgroundColor")) + .fontSize($r("sys.float.ohos_id_text_size_button1")) + .fontColor($r("sys.color.ohos_id_color_text_hyperlink")) + .width($r('app.float.wh_value_152')) + .height($r('app.float.wh_value_40')) + Divider() + .strokeWidth(ConfigData.VERTICAL_DIVIDER_WIDTH) + .color($r("sys.color.ohos_id_color_list_separator")) + .vertical(true) + .height($r('app.float.wh_value_40')) + .opacity($r("app.float.opacity_0_2")) + Button($r("app.string.publicDetailsDelete")) + .onClick(() => { + this.isShowWarnDialog = true; + this.isShowAuthDialog = false; + this.controller.close() + }) + .backgroundColor($r("app.color.credentials_app_finish_backgroundColor")) + .fontSize($r("sys.float.ohos_id_text_size_button1")) + .fontColor($r("sys.color.ohos_id_color_warning")) + .width($r('app.float.wh_value_152')) + .height($r('app.float.wh_value_40')) + } + .height($r('app.float.wh_value_64')) + .padding({ + bottom: $r('app.float.wh_value_16') + }) + .margin({ + top: $r('app.float.wh_value_16'), + left: $r('app.float.wh_value_24'), + right: $r('app.float.wh_value_24') + }) + } + } +} + +@Component +export struct componentPublic { + private Alias: string | Resource; + private KeyUri: string | Resource; + @Link mShowAppCaPresenter: CMShowAppCredPresenter; + @State @Watch("onShowAuthMngChange") isShowAuthMng: boolean = false; + @State @Watch("onShowDeleteWarnDialog") isShowWarning: boolean = false; + detailsDialogController: CustomDialogController = new CustomDialogController({ + builder: CustomDialogExampleApp({ + isShowAuthDialog: $isShowAuthMng, + isShowWarnDialog: $isShowWarning, + mShowAppCaPresenter: $mShowAppCaPresenter + }), + autoCancel: true, + alignment: DialogAlignment.Bottom, + offset: { dx: 0, dy: ConfigData.DIALOG_DY_OFFSET } + }) + appDialogController: CustomDialogController = new CustomDialogController({ + builder: CustomDialogExampleAuthor({ isShowAuthDialog: $isShowAuthMng, AuthorInfo: $mShowAppCaPresenter }), + autoCancel: false, + alignment: DialogAlignment.Bottom, + offset: { dx: 0, dy: ConfigData.DIALOG_DY_OFFSET } + }) + deleteWarnDialog: CustomDialogController = new CustomDialogController({ + builder: CustomDialogDeleteWarning({ isShowWarnDialog: $isShowWarning, deleteWarn: $mShowAppCaPresenter }), + autoCancel: false, + alignment: DialogAlignment.Bottom, + offset: { dx: 0, dy: ConfigData.DIALOG_DY_OFFSET } + }) + + onShowAuthMngChange() { + if (this.isShowAuthMng == true) { + this.appDialogController.open(); + } else { + this.detailsDialogController.close(); + this.detailsDialogController.open(); + this.appDialogController.close(); + } + } + + onShowDeleteWarnDialog() { + if (this.isShowWarning == true) { + this.deleteWarnDialog.open(); + } else { + this.detailsDialogController.close(); + this.deleteWarnDialog.close(); + } + } + + build() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Column() { + Text(this.Alias) + .fontSize($r("sys.float.ohos_id_text_size_body1")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Medium) + } + .margin({ + left: $r("app.float.publicList_margin") + }) + + Row() { + Image($r('app.media.ic_settings_arrow')) + .width($r("app.float.publicList_image_wh")) + .height($r("app.float.publicList_image_hg")) + } + .margin({ + left: $r("app.float.publicList_margin"), + right: $r("app.float.publicList_image_margin") + }) + } + .height($r("app.float.wh_value_48")) + .borderRadius($r("app.float.publicList_borderRadius")) + .onClick(() => { + this.mShowAppCaPresenter.getAppCred(this.KeyUri) + this.detailsDialogController.open() + }) + } +} + +@Component +export struct componentPrivate { + private Alias: string | Resource; + private KeyUri: string | Resource; + @State PrivateCerPresenter: CMShowPrivateCredPresenter = CMShowPrivateCredPresenter.getInstance(); + privateDetailDialog: CustomDialogController = new CustomDialogController({ + builder: CustomDialogExamplePrivate(), + autoCancel: true, + alignment: DialogAlignment.Bottom, + offset: { dx: 0, dy: ConfigData.DIALOG_DY_OFFSET } + }) + + build() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Column() { + Text(this.Alias) + .fontSize($r("sys.float.ohos_id_text_size_body1")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Medium) + } + .margin({ + left: $r("app.float.publicList_margin") + }) + + Row() { + Image($r('app.media.ic_settings_arrow')) + .width($r("app.float.publicList_image_wh")) + .height($r("app.float.publicList_image_hg")) + } + .margin({ + left: $r("app.float.publicList_margin"), + right: $r("app.float.publicList_image_margin") + }) + } + .height($r("app.float.wh_value_48")) + .borderRadius($r("app.float.publicList_borderRadius")) + .onClick(() => { + this.PrivateCerPresenter.getPrivateCred(this.KeyUri) + this.privateDetailDialog.open() + }) + } +} + +@Entry +@Component +struct evidenceList { + @State mShowAppCaPresenter: CMShowAppCredPresenter = CMShowAppCredPresenter.getInstance(); + @State mShowPrivateCaPresenter: CMShowPrivateCredPresenter = CMShowPrivateCredPresenter.getInstance(); + @State mFaPresenter: CMFaPresenter = CMFaPresenter.getInstance(); + @State isTouched: boolean = false; + @State currentIndex: number = 0 + @State fontColor: string | Resource = $r("app.color.evidenceList_TabBuilder_fontColor_182431") + private controller: TabsController = new TabsController(); + + @Builder TabBuilder(index: number) { + Column() { + Text(index == 0 ? $r('app.string.tabName_public') : $r('app.string.tabName_private')) + .fontColor(this.currentIndex === index ? $r("sys.color.ohos_id_color_bottom_tab_icon") : this.fontColor) + .fontSize($r('app.float.font_16')) + .fontWeight(this.currentIndex === index ? FontWeight.Medium : FontWeight.Regular) + .alignSelf(ItemAlign.Center) + .margin({ + top: $r('app.float.TrustedEvidence_TabBuilder_Text_padding_top_value') }) + if (this.currentIndex === index) { + Divider() + .width($r('app.float.TrustedEvidence_TabBuilder_Divider_width_value')) + .margin({ top: $r('app.float.TrustedEvidence_TabBuilder_Divider_padding_top_value') }) + .strokeWidth(2) + .color($r("sys.color.ohos_id_color_bottom_tab_icon")) + .alignSelf(ItemAlign.Center) + } + } + .width(ConfigData.WH_100_100) + } + + aboutToAppear() { + LogUtil.info('in aboutToAppear'); + this.mShowAppCaPresenter.updateAppCredList(); + this.mShowPrivateCaPresenter.updatePrivateCredList(); + } + + onPageShow() { + let uri = globalThis.abilityWant.uri; + globalThis.abilityWant.uri = ""; + + if (uri === "certInstall") { + this.mFaPresenter.startInstall(); + } else if (uri === "requestAuthorize") { + this.mFaPresenter.startRequestAuth(globalThis.abilityWant.parameters.appUid); + } + } + + build() { + Column() { + GridContainer({ + columns: 12, + sizeType: SizeType.Auto, + gutter: vp2px(1) === 2 ? '12vp' : '0vp', + margin: vp2px(1) === 2 ? '24vp' : '0vp' + }) { + Row() { + Column() { + HeadComponent({ headName: $r('app.string.userEvidence') }) + Column() { + Tabs({ barPosition: BarPosition.Start, index: 0, controller: this.controller }) { + TabContent() { + List() { + ForEach(this.mShowAppCaPresenter.credList, (item) => { + ListItem() { + componentPublic({ + Alias: item.alias, + KeyUri: item.keyUri, + mShowAppCaPresenter: $mShowAppCaPresenter + }) + } + }, item => JSON.stringify(item)) + } + .width(ConfigData.WH_92_100) + .margin({ + left: ConfigData.WH_4_100 + }) + .divider({ + strokeWidth: $r("app.float.Evidence_strokeWidth"), + color: $r("app.color.Evidence_color"), + startMargin: $r("app.float.Evidence_startMargin"), + endMargin: $r("app.float.Evidence_endMargin") + }) + .borderRadius($r("app.float.Evidence_borderRadius")) + .backgroundColor($r("app.color.credentials_app_finish_backgroundColor")) + .visibility(this.mShowAppCaPresenter.credList.length > 0 ? Visibility.Visible : Visibility.None) + } + .tabBar(this.TabBuilder(0)) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.isTouched = true; + } + if (event.type === TouchType.Up) { + this.isTouched = false; + } + }) + + TabContent() { + List() { + ForEach(this.mShowPrivateCaPresenter.credList, (item) => { + ListItem() { + componentPrivate({ Alias: item.alias, KeyUri: item.keyUri }) + } + }, item => JSON.stringify(item)) + } + .width(ConfigData.WH_92_100) + .margin({ + left: ConfigData.WH_4_100 + }) + .divider({ + strokeWidth: $r("app.float.Evidence_strokeWidth"), + color: $r("app.color.Evidence_color"), + startMargin: $r("app.float.Evidence_startMargin"), + endMargin: $r("app.float.Evidence_endMargin") }) + .borderRadius($r("app.float.Evidence_borderRadius")) + .backgroundColor($r("app.color.credentials_app_finish_backgroundColor")) + .visibility(this.mShowPrivateCaPresenter.credList.length > 0 ? Visibility.Visible : Visibility.None) + } + .tabBar(this.TabBuilder(1)) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.isTouched = true; + } + if (event.type === TouchType.Up) { + this.isTouched = false; + } + }); + } + .vertical(false) + .scrollable(true) + .barMode(BarMode.Fixed) + .barWidth('192vp') + .barHeight($r("app.float.Evidence_barHeight")) + .animationDuration(400) + .width(ConfigData.WH_100_100) + .backgroundColor($r("app.color.TrustedEvidence_tabs_backgroundColor_F1F3F5")) + .onChange((index: number) => { + this.currentIndex = index + }); + } + .height(ConfigData.WH_94_100) + .width(ConfigData.WH_100_100) + } + .backgroundColor($r("sys.color.ohos_id_color_sub_background")) + .width(ConfigData.WH_100_100) + .height(ConfigData.WH_100_100) + .useSizeType({ + xs: { span: 12, offset: 0 }, sm: { span: 12, offset: 0 }, + md: { span: 12, offset: 0 }, lg: { span: 8, offset: 2 } + }); + + Column() { + } + .width(ConfigData.WH_100_100) + .height(ConfigData.WH_100_100) + .useSizeType({ + xs: { span: 0, offset: 12 }, sm: { span: 0, offset: 12 }, + md: { span: 0, offset: 12 }, lg: { span: 2, offset: 10 } + }) + } + .width(ConfigData.WH_100_100) + .height(ConfigData.WH_100_100); + } + .width(ConfigData.WH_100_100) + .height(ConfigData.WH_100_100); + } + .backgroundColor($r("sys.color.ohos_id_color_sub_background")) + .width(ConfigData.WH_100_100) + .height(ConfigData.WH_100_100); + } +} diff --git a/cer_manager/product/phone/src/main/ets/pages/certInstallAliasInput.ets b/cer_manager/product/phone/src/main/ets/pages/certInstallAliasInput.ets new file mode 100644 index 0000000000000000000000000000000000000000..5a9b17938552f8996259080ec2bb0bf88c27d102 --- /dev/null +++ b/cer_manager/product/phone/src/main/ets/pages/certInstallAliasInput.ets @@ -0,0 +1,160 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import HeadComponent from '../../../../../../common/component/headcomponent'; +import LogUtil from '../../../../../../common/util/logutil'; +import ConfigData from '../../../../../../common/util/configdata'; +import router from '@system.router'; +import CMInstallPresenter from '../presenter/CMInstallPresenter'; +import CMFaPresenter from '../presenter/CMFaPresenter'; + +@Entry +@Component +struct CertInstallAliasInput { + @State mAppCredAuthPresenter: CMInstallPresenter = CMInstallPresenter.getInstance(); + @State mFaPresenter: CMFaPresenter = CMFaPresenter.getInstance(); + @State certAlias: string = ""; + + onPageShow() { + let uri = globalThis.abilityWant.uri; + globalThis.abilityWant.uri = ""; + + if (uri === "certInstall") { + this.mFaPresenter.startInstall(); + } else if (uri === "requestAuthorize") { + this.mFaPresenter.startRequestAuth(globalThis.abilityWant.parameters.appUid); + } + } + + build() { + Column() { + Column() { + HeadComponent({ headName: $r('app.string.certificateAliasTab') }); + Text($r('app.string.certificateAliasInfo')) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontSize($r("sys.float.ohos_id_text_size_body1")) + .fontWeight(FontWeight.Medium) + .margin({ + top: $r('app.float.distance_24'), + left: $r('app.float.distance_24') + }) + .alignSelf(ItemAlign.Start) + + TextInput() + .type(InputType.Normal) + .backgroundColor($r("sys.color.ohos_id_color_sub_background")) + .enterKeyType(EnterKeyType.Done) + .fontSize($r("sys.float.ohos_id_text_size_body1")) + .fontWeight(FontWeight.Medium) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .onChange((value: string) => { + this.certAlias = value; + }) + .maxLength(ConfigData.ALIAS_MAX_LENGTH) + .margin({ + left: $r('app.float.distance_24'), + right: $r('app.float.distance_24') + }) + .height($r('app.float.distance_48')) + + Row() { + Divider().color($r('app.color.CertManager_Divider_Color_182431')) + } + .margin({ + left: $r('app.float.distance_24'), + right: $r('app.float.distance_24'), + }) + + Text($r('app.string.installAliasInputInfo')) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .margin({ + left: $r('app.float.distance_24'), + top: $r('app.float.distance_16') + }) + .alignSelf(ItemAlign.Start) + .opacity($r('app.float.opacity_100_60')) + } + .width(ConfigData.WH_100_100) + .height(ConfigData.WH_75_100); + + Column() { + Row() { + Button() { + Text($r('app.string.installAliasInputCancel')) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontWeight(FontWeight.Medium) + .fontColor($r('sys.color.ohos_id_color_text_hyperlink')) + } + .type(ButtonType.Capsule) + .backgroundColor($r('app.color.install_cancel_bt_bg_color')) + .width($r('app.float.component_button_width_phone')) + .height($r('app.float.application_button_height')) + .margin({ + left: $r('app.float.distance_24'), + }) + .onClick(() => { + router.back(); + }) + + if ((this.certAlias.length > 0) && (this.certAlias[0] != ' ')) { + Button() { + Text($r('app.string.installAliasInputConfirm')) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontWeight(FontWeight.Medium) + .fontColor($r('app.color.install_confirm_bt_font_color')) + } + .type(ButtonType.Capsule) + .backgroundColor($r('app.color.install_confirm_bt_bg_color')) + .width($r('app.float.component_button_width_phone')) + .height($r('app.float.application_button_height')) + .margin({ + left: $r('app.float.distance_16'), + right: $r('app.float.distance_24'), + }) + .onClick(() => { + this.mAppCredAuthPresenter.installCert(router.getParams().uri, + this.certAlias, + router.getParams().certPwd, + router.getParams().suffix); + }) + } else { + Button() { + Text($r('app.string.installAliasInputConfirm')) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontWeight(FontWeight.Medium) + .fontColor($r('app.color.install_confirm_bt_font_color')) + } + .type(ButtonType.Capsule) + .backgroundColor($r('app.color.install_confirm_bt_bg_disable_color')) + .width($r('app.float.component_button_width_phone')) + .height($r('app.float.application_button_height')) + .margin({ + left: $r('app.float.distance_16'), + right: $r('app.float.distance_24'), + }) + } + } + .margin({ bottom: $r('app.float.wh_value_24') }) + } + .justifyContent(FlexAlign.End) + .height(ConfigData.WH_25_100); + } + .backgroundColor($r("sys.color.ohos_id_color_sub_background")) + .width(ConfigData.WH_100_100) + .height(ConfigData.WH_100_100); + } +} diff --git a/cer_manager/product/phone/src/main/ets/pages/certManagerFa.ets b/cer_manager/product/phone/src/main/ets/pages/certManagerFa.ets new file mode 100644 index 0000000000000000000000000000000000000000..5319a7196a545bea39a461e6dac46d272333498d --- /dev/null +++ b/cer_manager/product/phone/src/main/ets/pages/certManagerFa.ets @@ -0,0 +1,277 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import ConfigData from '../../../../../../common/util/configdata'; +import HeadComponent from '../../../../../../common/component/headcomponent'; +import { SubEntryComponent } from '../../../../../../common/component/subEntryComponent'; +import CMFaPresenter from '../presenter/CMFaPresenter'; + +@Entry +@Component +struct CertificateComponent { + @State touchedItem: boolean = false; + @State columnMargin: string = '12vp'; + @State mFaPresenter: CMFaPresenter = CMFaPresenter.getInstance(); + + build() { + Column() { + + GridContainer({ + columns: 12, + sizeType: SizeType.Auto, + gutter: vp2px(1) === 2 ? '12vp' : '0vp', + margin: vp2px(1) === 2 ? '24vp' : '0vp' + }) { + Row({}) { + Column() { + } + .width(ConfigData.WH_100_100) + .height(ConfigData.WH_100_100) + .useSizeType({ + xs: { span: 0, offset: 0 }, sm: { span: 0, offset: 0 }, + md: { span: 0, offset: 0 }, lg: { span: 2, offset: 0 } + }); + + Column() { + HeadComponent({ headName: $r('app.string.certificateTab') }) + Column({ space: this.columnMargin }) { + + SubEntryComponent({ targetPage: "pages/trustedCa", title: $r("app.string.trustedEvidence") }) + + SubEntryComponent({ targetPage: 'pages/cerEvidenceFa', title: $r("app.string.userEvidence") }) + + CertInstallComponent({ mFaPresenter: $mFaPresenter }) + + DeleteAll({ mFaPresenter: $mFaPresenter }) + } + .margin({ top: $r("app.float.distance_8") }) + .width(ConfigData.WH_100_100) + } + .backgroundColor($r("sys.color.ohos_id_color_sub_background")) + .padding({ left: $r('app.float.wh_24'), right: $r('app.float.wh_24') }) + .width(ConfigData.WH_100_100) + .height(ConfigData.WH_100_100) + .useSizeType({ + xs: { span: 12, offset: 0 }, sm: { span: 12, offset: 0 }, + md: { span: 12, offset: 0 }, lg: { span: 8, offset: 2 } + }); + + Column() { + } + .width(ConfigData.WH_100_100) + .height(ConfigData.WH_100_100) + .useSizeType({ + xs: { span: 0, offset: 12 }, sm: { span: 0, offset: 12 }, + md: { span: 0, offset: 12 }, lg: { span: 2, offset: 10 } + }) + } + .width(ConfigData.WH_100_100) + .height(ConfigData.WH_100_100); + } + .width(ConfigData.WH_100_100) + .height(ConfigData.WH_100_100); + } + .backgroundColor($r("sys.color.ohos_id_color_sub_background")) + .width(ConfigData.WH_100_100) + .height(ConfigData.WH_100_100); + } + + onPageShow() { + let uri = globalThis.abilityWant.uri; + globalThis.abilityWant.uri = ""; + + if (uri === "certInstall") { + this.mFaPresenter.startInstall(); + } else if (uri === "requestAuthorize") { + this.mFaPresenter.startRequestAuth(globalThis.abilityWant.parameters.appUid); + } + } +} + +@CustomDialog +@Component +struct CustomDialogExampleDeleteAll { + controller: CustomDialogController; + @Link deleteAll: CMFaPresenter; + + build() { + Column() { + Text($r("app.string.deleteAllCredDialogTitle")) + .height($r("app.float.wh_value_56")) + .fontSize($r("sys.float.ohos_id_text_size_dialog_tittle")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Medium) + .margin({ + left: $r('app.float.wh_value_24'), + right: $r('app.float.wh_value_24') + }) + .alignSelf(ItemAlign.Start) + Text($r("app.string.deleteAllCredDialogMessage")) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontWeight(FontWeight.Regular) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .margin({ + top: $r("app.float.wh_value_16"), + left: $r('app.float.wh_value_24'), + right: $r('app.float.wh_value_24') + }) + .alignSelf(ItemAlign.Start) + + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceAround }) { + Button($r("app.string.deleteAllCredCancel")) + .onClick(() => { + this.controller.close() + }) + .backgroundColor($r("app.color.credentials_app_finish_backgroundColor")) + .fontSize($r("sys.float.ohos_id_text_size_button1")) + .fontColor($r("sys.color.ohos_id_color_text_hyperlink")) + .width($r('app.float.wh_value_152')) + .height($r('app.float.wh_value_40')) + Divider() + .strokeWidth(ConfigData.VERTICAL_DIVIDER_WIDTH) + .color($r("sys.color.ohos_id_color_list_separator")) + .vertical(true) + .height($r('app.float.wh_value_40')) + .opacity($r("app.float.opacity_0_2")) + Button($r("app.string.deleteAllCredDelete")) + .onClick(() => { + this.deleteAll.uninstallAllCert(); + this.controller.close() + }) + .backgroundColor($r("app.color.credentials_app_finish_backgroundColor")) + .fontSize($r("sys.float.ohos_id_text_size_button1")) + .fontColor($r("sys.color.ohos_id_color_warning")) + .width($r('app.float.wh_value_152')) + .height($r('app.float.wh_value_40')) + } + .height($r('app.float.wh_value_64')) + .padding({ + bottom: $r('app.float.wh_value_16') + }) + .margin({ + top: $r('app.float.wh_value_16'), + left: $r('app.float.wh_value_24'), + right: $r('app.float.wh_value_24') + }) + } + } +} + +@Component +struct DeleteAll { + @State isTouched: boolean = false; + @Link mFaPresenter: CMFaPresenter; + + deleteWarnDialog: CustomDialogController = new CustomDialogController({ + builder: CustomDialogExampleDeleteAll({ deleteAll: $mFaPresenter }), + autoCancel: true, + alignment:DialogAlignment.Bottom, + offset :{ dx:0, dy:ConfigData.DIALOG_DY_OFFSET } + }) + + build() { + Row() { + Text($r("app.string.deleteAllCred")) + .fontSize($r('app.float.font_16')) + .lineHeight($r('app.float.wh_value_22')) + .fontWeight(FontWeight.Medium) + .fontColor($r('app.color.cm_del_all_font_color')) + .margin({ left: $r('app.float.distance_8') }) + .textAlign(TextAlign.Start); + } + .padding($r('app.float.distance_4')) + .height($r('app.float.wh_value_56')) + .width(ConfigData.WH_100_100) + .borderRadius($r('app.float.radius_24')) + .linearGradient(this.isTouched ? { + angle: 90, + direction: GradientDirection.Right, + colors: [[$r("app.color.DCEAF9"), 0.0], [$r("app.color.FAFAFA"), 1.0]] + } : { + angle: 90, + direction: GradientDirection.Right, + colors: [[$r("sys.color.ohos_id_color_foreground_contrary"), 1], + [$r("sys.color.ohos_id_color_foreground_contrary"), 1]] + }) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.isTouched = true; + } + if (event.type === TouchType.Up) { + this.isTouched = false; + } + }) + .onClick(() => { + this.deleteWarnDialog.open(); + }) + } +} + +@Component +export struct CertInstallComponent { + @State isTouched: boolean = false; + @Link mFaPresenter: CMFaPresenter; + + build() { + Column() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Row() { + Text($r('app.string.installInStorageDevice')) + .fontSize($r('app.float.font_16')) + .lineHeight($r('app.float.wh_value_22')) + .fontColor($r('app.color.font_color_182431')) + .fontWeight(FontWeight.Medium) + .margin({ left: $r('app.float.distance_8') }) + .textAlign(TextAlign.Start); + } + + Image('/res/image/ic_settings_arrow.svg') + .width($r('app.float.wh_value_12')) + .height($r('app.float.wh_value_24')) + .margin({ right: $r('app.float.distance_8') }) + .fillColor($r("sys.color.ohos_id_color_primary")) + .opacity($r("app.float.opacity_0_2")) + } + .height(ConfigData.WH_100_100) + .width(ConfigData.WH_100_100) + .borderRadius($r('app.float.radius_20')) + .linearGradient(this.isTouched ? { + angle: 90, + direction: GradientDirection.Right, + colors: [[$r("app.color.DCEAF9"), 0.0], [$r("app.color.FAFAFA"), 1.0]] + } : { + angle: 90, + direction: GradientDirection.Right, + colors: [[$r("sys.color.ohos_id_color_foreground_contrary"), 1], + [$r("sys.color.ohos_id_color_foreground_contrary"), 1]] + }) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.isTouched = true; + } + if (event.type === TouchType.Up) { + this.isTouched = false; + } + }) + } + .padding($r('app.float.distance_4')) + .backgroundColor($r('app.color.white_bg_color')) + .height($r('app.float.wh_value_56')) + .borderRadius($r('app.float.radius_24')) + .onClick(() => { + this.mFaPresenter.startInstall() + }); + } +} diff --git a/cer_manager/product/phone/src/main/ets/pages/certPwdInput.ets b/cer_manager/product/phone/src/main/ets/pages/certPwdInput.ets new file mode 100644 index 0000000000000000000000000000000000000000..1f98409d272601948bc78881614bd0b9a16c1c45 --- /dev/null +++ b/cer_manager/product/phone/src/main/ets/pages/certPwdInput.ets @@ -0,0 +1,121 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import HeadComponent from '../../../../../../common/component/headcomponent'; +import ConfigData from '../../../../../../common/util/configdata'; +import router from '@system.router'; +import CMFaPresenter from '../presenter/CMFaPresenter'; + +@Entry +@Component +struct CertPwdInput { + certPwd: string = ""; + @State mFaPresenter: CMFaPresenter = CMFaPresenter.getInstance(); + + onPageShow() { + let uri = globalThis.abilityWant.uri; + globalThis.abilityWant.uri = ""; + + if (uri === "certInstall") { + this.mFaPresenter.startInstall(); + } else if (uri === "requestAuthorize") { + this.mFaPresenter.startRequestAuth(globalThis.abilityWant.parameters.appUid); + } + } + + build() { + Column() { + Column() { + HeadComponent({ headName: $r('app.string.certificatePwdTab') }); + Text($r('app.string.certificatePwdInfo')) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontSize($r("sys.float.ohos_id_text_size_body1")) + .fontWeight(FontWeight.Medium) + .margin({ + top: $r('app.float.distance_24'), + left: $r('app.float.distance_24') + }) + .alignSelf(ItemAlign.Start); + + TextInput() + .type(InputType.Password) + .onChange((value: string) => { + this.certPwd = value; + }) + .maxLength(ConfigData.PWD_MAX_LENGTH) + .margin({ + top: $r('app.float.distance_16'), + left: $r('app.float.distance_24'), + right: $r('app.float.distance_24') + }) + .height('40vp') + } + .width(ConfigData.WH_100_100) + .height(ConfigData.WH_75_100); + + Column() { + Row() { + Button() { + Text($r('app.string.installPwdInputCancel')) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontWeight(FontWeight.Medium) + .fontColor($r('sys.color.ohos_id_color_text_hyperlink')) + } + .type(ButtonType.Capsule) + .backgroundColor($r('app.color.install_cancel_bt_bg_color')) + .width($r('app.float.component_button_width_phone')) + .height($r('app.float.application_button_height')) + .margin({ + left: $r('app.float.distance_24'), + }) + .onClick(() => { + router.back(); + }) + + Button() { + Text($r('app.string.installPwdInputConfirm')) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontWeight(FontWeight.Medium) + .fontColor($r('app.color.install_confirm_bt_font_color')) + } + .type(ButtonType.Capsule) + .backgroundColor($r('app.color.install_confirm_bt_bg_color')) + .width($r('app.float.component_button_width_phone')) + .height($r('app.float.application_button_height')) + .margin({ + left: $r('app.float.distance_16'), + right: $r('app.float.distance_24'), + }) + .onClick(() => { + router.push({ + uri: 'pages/certInstallAliasInput', + params: { + certPwd: this.certPwd, + uri: router.getParams().uri, + suffix: router.getParams().suffix + } + }) + }) + } + .margin({ bottom: $r('app.float.wh_value_24') }) + } + .justifyContent(FlexAlign.End) + .height(ConfigData.WH_25_100); + } + .backgroundColor($r("sys.color.ohos_id_color_sub_background")) + .width(ConfigData.WH_100_100) + .height(ConfigData.WH_100_100); + } +} diff --git a/cer_manager/product/phone/src/main/ets/pages/requestAuth.ets b/cer_manager/product/phone/src/main/ets/pages/requestAuth.ets new file mode 100644 index 0000000000000000000000000000000000000000..9cc03adae3faa252fe00382fd64f88ef26a8e1a2 --- /dev/null +++ b/cer_manager/product/phone/src/main/ets/pages/requestAuth.ets @@ -0,0 +1,218 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import LogUtil from '../../../../../../common/util/logutil'; +import CMAppCredAuthPresenter from '../presenter/CMAppCredAuthPresenter'; +import router from '@system.router'; +import ConfigData from '../../../../../../common/util/configdata'; + +@CustomDialog +@Component +struct CustomDialogAuthForApp { + controller: CustomDialogController + @State mAppCredAuthPresenter: CMAppCredAuthPresenter = CMAppCredAuthPresenter.getInstance(); + selectUri: string = ""; + + aboutToAppear(): void { + LogUtil.info('certPwdInput about to appear'); + this.mAppCredAuthPresenter.UpdateAppNameFromUid(router.getParams().appUid); + this.mAppCredAuthPresenter.updateAppCredList(); + } + + build() { + Column() { + Text($r('app.string.pickCredToAuth')) + .fontSize($r('sys.float.ohos_id_text_size_dialog_tittle')) + .height($r("app.float.wh_value_56")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Medium) + .margin({ + left: $r('app.float.wh_value_24'), + right: $r('app.float.wh_value_24') + }) + .alignSelf(ItemAlign.Start) + + Text($r('app.string.requestAuthMsg', this.mAppCredAuthPresenter.appName)) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + .margin({ + top: $r('app.float.wh_value_8'), + left: $r('app.float.wh_value_24'), + right: $r('app.float.wh_value_24') + }) + .alignSelf(ItemAlign.Start) + + if (this.mAppCredAuthPresenter.credList.length > ConfigData.REQUEST_AUTH_MAX_LENGTH) { + List() { + ForEach(this.mAppCredAuthPresenter.credList, (item) => { + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + + Column() { + Text(item.alias) + .fontSize($r('app.float.font_18')) + .fontColor($r('app.color.request_auth_font_color')) + .fontWeight(FontWeight.Medium) + .textAlign(TextAlign.Start); + } + .alignItems(HorizontalAlign.Start) + + Column() { + Radio({ value: item.alias, group: 'appCredGroup' }) + .checked(false) + .onChange((value: boolean) => { + console.log(item.alias + ' status is ' + value) + if (value) { + this.selectUri = item.keyUri; + console.log('selectUri is ' + this.selectUri) + } + }) + } + .alignItems(HorizontalAlign.End) + } + .width(ConfigData.WH_100_100) + } + .height($r('app.float.wh_value_64')) + }, item => JSON.stringify(item)) + } + .height(ConfigData.WH_50_100) + .margin({ + left: $r('app.float.wh_value_24'), + right: $r('app.float.wh_value_24') + }) + .divider({ + strokeWidth: $r("app.float.request_auth_strokeWidth"), + color: $r("app.color.request_auth_color"), + endMargin: $r("app.float.request_auth_divider_endMargin")}) + .borderRadius($r("app.float.request_auth_borderRadius")) + .backgroundColor($r("app.color.request_auth_background_color")) + .visibility(this.mAppCredAuthPresenter.credList.length > 0 ? Visibility.Visible : Visibility.None) + } else { + List() { + ForEach(this.mAppCredAuthPresenter.credList, (item) => { + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Column() { + Text(item.alias) + .fontSize($r('app.float.font_18')) + .fontColor($r('app.color.request_auth_font_color')) + .fontWeight(FontWeight.Medium) + .textAlign(TextAlign.Start); + } + .alignItems(HorizontalAlign.Start) + + Column() { + Radio({ value: item.alias, group: 'appCredGroup' }) + .checked(false) + .onChange((value: boolean) => { + console.log(item.alias + ' status is ' + value) + if (value) { + this.selectUri = item.keyUri; + console.log('selectUri is ' + this.selectUri) + } + }) + } + .alignItems(HorizontalAlign.End) + } + .width(ConfigData.WH_100_100) + } + .height($r('app.float.wh_value_64')) + }, item => JSON.stringify(item)) + } + .margin({ + left: $r('app.float.wh_value_24'), + right: $r('app.float.wh_value_24') + }) + .divider({ + strokeWidth: $r("app.float.request_auth_strokeWidth"), + color: $r("app.color.request_auth_color"), + endMargin: $r("app.float.request_auth_divider_endMargin") }) + .borderRadius($r("app.float.request_auth_borderRadius")) + .backgroundColor($r("app.color.request_auth_background_color")) + .visibility(this.mAppCredAuthPresenter.credList.length > 0 ? Visibility.Visible : Visibility.None) + } + + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceAround }) { + Button($r('app.string.requestAuthCancel')) + .onClick(() => { + this.mAppCredAuthPresenter.cancelProcess(); + this.controller.close(); + }) + .backgroundColor($r('app.color.request_auth_background_color')) + .fontColor($r('sys.color.ohos_id_color_text_hyperlink')) + .fontSize($r('sys.float.ohos_id_text_size_button1')) + .width($r('app.float.wh_value_152')) + .height($r('app.float.wh_value_40')) + + Divider() + .strokeWidth(ConfigData.VERTICAL_DIVIDER_WIDTH) + .color($r("sys.color.ohos_id_color_list_separator")) + .vertical(true) + .height($r('app.float.wh_value_40')) + .opacity($r("app.float.opacity_0_2")) + + Button($r('app.string.requestAuthFinish')) + .onClick(() => { + LogUtil.info('requestAuthorize uri: ' + this.selectUri); + if (router.getParams() && router.getParams().appUid) { + LogUtil.info('requestAuthorize appUid: ' + router.getParams().appUid); + this.mAppCredAuthPresenter.requestAuthorize(this.selectUri, router.getParams().appUid); + this.controller.close(); + } else { + LogUtil.info('requestAuthorize fail'); + } + }) + .backgroundColor($r('app.color.request_auth_background_color')) + .fontColor($r('sys.color.ohos_id_color_text_hyperlink')) + .fontSize($r('sys.float.ohos_id_text_size_button1')) + .width($r('app.float.wh_value_152')) + .height($r('app.float.wh_value_40')) + } + .height($r('app.float.wh_value_64')) + .padding({ + bottom: $r('app.float.wh_value_16') + }) + .margin({ + left: $r('app.float.wh_value_24'), + right: $r('app.float.wh_value_24') + }) + } + } +} + +@Entry +@Component +struct RadioAuth { + dialogController: CustomDialogController = new CustomDialogController({ + builder: CustomDialogAuthForApp(), + autoCancel: false, + alignment: DialogAlignment.Bottom, + offset: { dx: 0, dy: ConfigData.DIALOG_DY_OFFSET } + }) + + aboutToAppear() { + LogUtil.info('RadioAuth aboutToAppear'); + + if (router.getParams() && router.getParams().appUid) { + this.dialogController.open(); + } else { + router.replace({ uri: "pages/certManagerFa" }); + } + } + + build() { + } +} diff --git a/cer_manager/product/phone/src/main/ets/pages/trustedCa.ets b/cer_manager/product/phone/src/main/ets/pages/trustedCa.ets new file mode 100644 index 0000000000000000000000000000000000000000..f4a60f35fd1c7a9f8d867a4f4c482619c35fb620 --- /dev/null +++ b/cer_manager/product/phone/src/main/ets/pages/trustedCa.ets @@ -0,0 +1,900 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import LogUtil from '../../../../../../common/util/logutil'; +import ConfigData from '../../../../../../common/util/configdata'; +import HeadComponent from '../../../../../../common/component/headcomponent'; +import CMShowSysCaPresenter from '../presenter/CMShowSysCaPresenter'; +import CMShowUserCaPresenter from '../presenter/CMShowUserCaPresenter'; +import CMFaPresenter from '../presenter/CMFaPresenter'; + +@Component +struct DialogSubjectComponent { + private map: Map; + build() { + Column() { + Text($r("app.string.DialogSubjectComponent_firText")) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + .margin({ + top: $r("app.float.DialogSubjectComponent_Text_margin_top_value") + }) + Text(this.map.get('常用名称:')) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + Text($r("app.string.DialogSubjectComponent_secText")) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + .margin({ + top: $r("app.float.CustomDialogExample_Button_margin_top_value") + }) + Text(this.map.get('组织:')) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + Text($r("app.string.DialogSubjectComponent_thdText")) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + .margin({ + top: $r("app.float.CustomDialogExample_Button_margin_top_value") + }) + Text(this.map.get('组织单位:')) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + Text($r("app.string.DialogSubjectComponent_fouText")) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + .margin({ + top: $r("app.float.CustomDialogExample_Button_margin_top_value") + }) + Text(this.map.get('序列号:')) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + }.alignItems(HorizontalAlign.Start); + } +} + +@Component +struct DialogIssuerComponent { + private map: Map; + + build() { + Column() { + Text($r("app.string.DialogSubjectComponent_firText")) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + .margin({ + top: $r("app.float.wh_value_10") + }) + Text(this.map.get('常用名称:')) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + Text($r("app.string.DialogSubjectComponent_secText")) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + .margin({ + top: $r("app.float.CustomDialogExample_Button_margin_top_value") + }) + Text(this.map.get('组织:')) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + Text($r("app.string.DialogSubjectComponent_thdText")) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + .margin({ + top: $r("app.float.CustomDialogExample_Button_margin_top_value") + }) + Text(this.map.get('组织单位:')) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + }.alignItems(HorizontalAlign.Start); + } +} + +@Component +struct DialogDateComponent { + private map: Map; + + build() { + Column() { + Text($r("app.string.DialogSubjectComponent_fifText")) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + .margin({ + top: $r("app.float.wh_value_10") + }) + Text(this.map.get('颁发时间:')) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + Text($r("app.string.DialogSubjectComponent_sixText")) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + .margin({ + top: $r("app.float.CustomDialogExample_Button_margin_top_value") + }) + Text(this.map.get('有效期至:')) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + }.alignItems(HorizontalAlign.Start); + } +} + +@Component +struct DialogFingerPrintComponent { + private fingerprintSha256: string; + + build() { + Column() { + Text($r("app.string.CustomDialogExample_FingerPrint_text")) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + .margin({ + top: $r("app.float.wh_value_10") + }) + Text(this.fingerprintSha256) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + .margin({ + right: $r("app.float.wh_value_24") + }) + }.alignItems(HorizontalAlign.Start); + } +} + +@CustomDialog +@Component +struct CustomDialogDeleteWarning { + controller: CustomDialogController; + @Link deleteWarn: CMShowUserCaPresenter; + @Link mShowUserListPresenter: CMShowUserCaPresenter; + @Link isShowWarnDialog: boolean; + + build() { + Column() { + Text($r("app.string.CustomDialogExampleUser_warning_Button_title_text")) + .height($r("app.float.wh_value_56")) + .fontSize($r("sys.float.ohos_id_text_size_dialog_tittle")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Medium) + .margin({ + left: $r('app.float.wh_value_24'), + right: $r('app.float.wh_value_24') + }) + .alignSelf(ItemAlign.Start) + Text($r("app.string.CustomDialogExampleUser_warning_Button_message_text")) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + .fontWeight(FontWeight.Regular) + .fontColor($r("sys.color.ohos_id_color_primary")) + .margin({ + top: $r("app.float.wh_value_16"), + left: $r('app.float.wh_value_24'), + right: $r('app.float.wh_value_24') + }) + .alignSelf(ItemAlign.Start) + + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceAround }) { + Button($r("app.string.deleteAllCredCancel")) + .onClick(() => { + this.isShowWarnDialog = false; + this.controller.close() + }) + .backgroundColor($r("app.color.CustomDialogExample_Button_backgroundColor_FFFFFF")) + .fontSize($r("sys.float.ohos_id_text_size_button1")) + .width($r('app.float.wh_value_152')) + .height($r('app.float.wh_value_40')) + .fontColor($r("sys.color.ohos_id_color_text_hyperlink")) + Divider() + .strokeWidth(1) + .color($r("sys.color.ohos_id_color_list_separator")) + .vertical(true) + .height($r('app.float.wh_value_40')) + .opacity($r("app.float.opacity_0_2")) + Button($r("app.string.deleteAllCredDelete")) + .onClick(() => { + this.deleteWarn.deleteUserCertificate(this.deleteWarn.certInfo.uri); + this.mShowUserListPresenter.updateUserTrustedCertificateList(); + this.isShowWarnDialog = false; + this.controller.close() + }) + .backgroundColor($r("app.color.CustomDialogExample_Button_backgroundColor_FFFFFF")) + .fontSize($r("sys.float.ohos_id_text_size_button1")) + .width($r('app.float.wh_value_152')) + .height($r('app.float.wh_value_40')) + .fontColor($r("sys.color.ohos_id_color_warning")) + } + .height($r('app.float.wh_value_64')) + .padding({ + bottom: $r('app.float.wh_value_16') + }) + .margin({ + top: $r('app.float.wh_value_16'), + left: $r('app.float.wh_value_24'), + right: $r('app.float.wh_value_24') + }) + } + } +} + +@CustomDialog +@Component +struct CustomDialogExampleUser { + controller: CustomDialogController; + @Link userInfoPresenter: CMShowUserCaPresenter; + @Link userInfoPresenterForAbstractList: CMShowUserCaPresenter; + @Link isShowWarnDialog: boolean; + @State IsOn: boolean = false; + + aboutToAppear(){ + this.IsOn = this.userInfoPresenter.certInfo.status; + } + + build() { + Column() { + Text($r("app.string.CustomDialogExample_firText")) + .fontSize($r("sys.float.ohos_id_text_size_dialog_tittle")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Medium) + .margin({ + left: $r("app.float.CustomDialogExample_firText_margin_left_value"), + top: $r("app.float.CustomDialogExample_firText_margin_top_value") + }) + .alignSelf(ItemAlign.Start) + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Column() { + Text(this.userInfoPresenter.certInfo.certAlias) + .fontSize($r("sys.float.ohos_id_text_size_body1")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Medium) + .margin({ + left: $r("app.float.wh_value_26") + }) + if (this.IsOn) { + Text($r("app.string.CustomDialogExampleUser_Status_true")) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_secondary")) + .margin({ + left: $r("app.float.wh_value_26") + }) + } else { + Text($r("app.string.CustomDialogExampleUser_Status_false")) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_secondary")) + .margin({ + left: $r("app.float.wh_value_26") + }) + } + }.alignItems(HorizontalAlign.Start); + Toggle({ type: ToggleType.Switch, isOn: this.IsOn }) + .margin({ + right: $r("app.float.CustomDialogExampleUser_Flex_Toggle_margin_right_value") + }) + .width($r("app.float.CustomDialogExampleUser_Flex_Toggle_width_value")) + .height($r("app.float.CustomDialogExampleUser_Flex_Toggle_height_value")) + .selectedColor($r("app.color.CustomDialogExampleUser_Flex_Toggle_selectedColor_007DFF")) + .onChange((isOn: boolean) => { + if (isOn) { + this.IsOn = true; + this.userInfoPresenter.setUserCertificateStatus(this.userInfoPresenter.certInfo.uri, true); + } else { + this.IsOn = false; + this.userInfoPresenter.setUserCertificateStatus(this.userInfoPresenter.certInfo.uri, false); + } + }); + } + .height($r("app.float.CustomDialogExampleUser_Flex_height_value")) + .margin({}); + List() { + ListItem() { + Text($r("app.string.CustomDialogExample_firListItem_text")) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + .margin({ + top: $r("app.float.wh_value_12") + }) + } + + ListItem() { + DialogSubjectComponent({ map: this.userInfoPresenter.certInfo.subjectNameMap }); + } + + ListItem() { + Text($r("app.string.CustomDialogExample_secListItem_text")) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + .margin({ + top: $r("app.float.wh_value_12") + }) + } + + ListItem() { + DialogIssuerComponent({ map: this.userInfoPresenter.certInfo.issuerNameMap }); + } + + ListItem() { + Text($r("app.string.CustomDialogExample_thdListItem_text")) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + .margin({ + top: $r("app.float.wh_value_12") + }) + } + + ListItem() { + DialogDateComponent({ map: this.userInfoPresenter.certInfo.dateMap }); + } + + ListItem() { + Text($r("app.string.CustomDialogExample_fouListItem_text")) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + .margin({ + top: $r("app.float.wh_value_12") + }) + } + + ListItem() { + DialogFingerPrintComponent({ fingerprintSha256: this.userInfoPresenter.certInfo.fingerprintSha256 }); + } + } + .height($r("app.float.CustomDialogExample_list_height_value")) + .margin({ + bottom: $r("app.float.CustomDialogExample_secListItem_Text_margin_left_value"), + left: $r("app.float.wh_value_24"), + right: $r("app.float.wh_value_24") + }) + .borderRadius($r("app.float.CustomDialogExample_list_borderRadius_value")) + .scrollBar(BarState.Auto); + + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceAround }) { + Button($r("app.string.CustomDialogExampleUser_Flex_firButton_text")) + .onClick(() => { + this.userInfoPresenterForAbstractList.updateUserTrustedCertificateList(); + this.isShowWarnDialog = false; + this.controller.close(); + }) + .backgroundColor($r("app.color.CustomDialogExample_Button_backgroundColor_FFFFFF")) + .fontSize($r("sys.float.ohos_id_text_size_button1")) + .width($r('app.float.wh_value_152')) + .height($r('app.float.wh_value_40')) + .fontColor($r("sys.color.ohos_id_color_text_hyperlink")) + Divider() + .strokeWidth(ConfigData.VERTICAL_DIVIDER_WIDTH) + .color($r("sys.color.ohos_id_color_list_separator")) + .vertical(true) + .height($r('app.float.wh_value_40')) + .opacity($r("app.float.opacity_0_2")) + Button($r("app.string.CustomDialogExampleUser_Flex_secButton_text")) + .onClick(() => { + this.isShowWarnDialog = true; + this.controller.close(); + }) + .backgroundColor($r("app.color.CustomDialogExample_Button_backgroundColor_FFFFFF")) + .fontSize($r("sys.float.ohos_id_text_size_button1")) + .width($r('app.float.wh_value_152')) + .height($r('app.float.wh_value_40')) + .fontColor($r("sys.color.ohos_id_color_warning")) + } + .height($r('app.float.wh_value_64')) + .padding({ + bottom: $r('app.float.wh_value_16') + }) + .margin({ + top: $r('app.float.wh_value_16'), + left: $r('app.float.wh_value_24'), + right: $r('app.float.wh_value_24') + }) + } + } +} + +@CustomDialog +@Component +struct CustomDialogExampleSystem { + controller: CustomDialogController; + @Link sysInfoPresenter: CMShowSysCaPresenter; + private isTrueButton: string = ''; + + build() { + Column() { + Text($r("app.string.CustomDialogExample_firText")) + .fontSize($r("sys.float.ohos_id_text_size_dialog_tittle")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Medium) + .margin({ + left: $r("app.float.CustomDialogExample_firText_margin_left_value"), + top: $r("app.float.CustomDialogExample_firText_margin_top_value") + }) + .alignSelf(ItemAlign.Start) + Text(this.sysInfoPresenter.certInfo.certAlias) + .fontSize($r("sys.float.ohos_id_text_size_body1")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Medium) + .margin({ + top: $r("app.float.wh_value_16"), + left: $r("app.float.CustomDialogExample_secText_margin_left_value") + }) + .alignSelf(ItemAlign.Start) + List() { + ListItem() { + Text($r("app.string.CustomDialogExample_firListItem_text")) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + } + + ListItem() { + DialogSubjectComponent({ map: this.sysInfoPresenter.certInfo.subjectNameMap }); + } + + ListItem() { + Text($r("app.string.CustomDialogExample_secListItem_text")) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + .margin({ + top: $r("app.float.wh_value_12") + }) + } + + ListItem() { + DialogIssuerComponent({ map: this.sysInfoPresenter.certInfo.issuerNameMap }); + } + + ListItem() { + Text($r("app.string.CustomDialogExample_thdListItem_text")) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + .margin({ + top: $r("app.float.wh_value_12") + }) + } + + ListItem() { + DialogDateComponent({ map: this.sysInfoPresenter.certInfo.dateMap }); + } + + ListItem() { + Text($r("app.string.CustomDialogExample_fouListItem_text")) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + .margin({ + top: $r("app.float.wh_value_12") + }) + } + + ListItem() { + DialogFingerPrintComponent({ fingerprintSha256: this.sysInfoPresenter.certInfo.fingerprintSha256 }); + } + } + .height($r("app.float.CustomDialogExample_list_height_value")) + .margin({ + left: $r("app.float.wh_value_24"), + top: $r("app.float.CustomDialogExample_list_margin_top_value"), + bottom: $r("app.float.CustomDialogExample_secListItem_Text_margin_left_value"), + right: $r("app.float.wh_value_24") + }) + .borderRadius($r("app.float.CustomDialogExample_list_borderRadius_value")) + .backgroundColor($r("app.color.CustomDialogExample_list_backgroundColor_FFFFFF")) + .scrollBar(BarState.Auto); + + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceAround }) { + Button($r("app.string.CustomDialogExample_Button_text")) + .onClick(() => { + this.controller.close(); + }) + .backgroundColor($r("app.color.CustomDialogExample_Button_backgroundColor_FFFFFF")) + .fontSize($r("sys.float.ohos_id_text_size_button1")) + .width($r('app.float.wh_value_152')) + .height($r('app.float.wh_value_40')) + .fontColor($r("sys.color.ohos_id_color_text_hyperlink")) + Divider() + .strokeWidth(ConfigData.VERTICAL_DIVIDER_WIDTH) + .color($r("sys.color.ohos_id_color_list_separator")) + .vertical(true) + .height($r('app.float.wh_value_40')) + .opacity($r("app.float.opacity_0_2")) + if (this.sysInfoPresenter.certInfo.status) { + Button($r("app.string.CustomDialogExample_Button_off")) + .onClick(() => { + this.sysInfoPresenter.setSystemCertificateStatus(this.sysInfoPresenter.certInfo.uri, false); + this.controller.close(); + }) + .backgroundColor($r("app.color.CustomDialogExample_Button_backgroundColor_FFFFFF")) + .fontSize($r("sys.float.ohos_id_text_size_button1")) + .width($r('app.float.wh_value_152')) + .height($r('app.float.wh_value_40')) + .fontColor($r("sys.color.ohos_id_color_text_hyperlink")) + } else { + Button($r("app.string.CustomDialogExample_Button_on")) + .onClick(() => { + this.sysInfoPresenter.setSystemCertificateStatus(this.sysInfoPresenter.certInfo.uri, true); + this.controller.close(); + }) + .backgroundColor($r("app.color.CustomDialogExample_Button_backgroundColor_FFFFFF")) + .fontSize($r("sys.float.ohos_id_text_size_button1")) + .width($r('app.float.wh_value_152')) + .height($r('app.float.wh_value_40')) + .fontColor($r("sys.color.ohos_id_color_text_hyperlink")) + } + } + .height($r('app.float.wh_value_64')) + .padding({ + bottom: $r('app.float.wh_value_16') + }) + .margin({ + top: $r('app.float.wh_value_16'), + left: $r('app.float.wh_value_24'), + right: $r('app.float.wh_value_24') + }) + } + } +} + +@Component +struct ComponentSystem { + private certAlias: string; + private subjectName: string; + private Status: boolean; + private Index : number; + private Uri: string; + isSwitchTouched : boolean = false; + @State isTouched: boolean = false; + @Link setStatus: CMShowSysCaPresenter; + dialogController: CustomDialogController = new CustomDialogController({ + builder: CustomDialogExampleSystem({ sysInfoPresenter: $setStatus }), + autoCancel: true, + alignment: DialogAlignment.Bottom, + offset: { dx: 0, dy: ConfigData.DIALOG_DY_OFFSET } + }) + + build() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Column() { + Text(this.certAlias) + .height($r("app.float.ComponentSystem_firText_height_value")) + .fontSize($r("sys.float.ohos_id_text_size_body1")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Medium) + .textAlign(TextAlign.Start) + .margin({top: $r("app.float.wh_value_10") }); + Text(this.subjectName) + .height($r("app.float.ComponentSystem_secText_height_value")) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_secondary")) + .fontWeight(FontWeight.Regular) + .textAlign(TextAlign.Start) + .margin({ top: $r("app.float.wh_value_2"), bottom: $r("app.float.wh_value_11") }); + }.alignItems(HorizontalAlign.Start); + Toggle({ type: ToggleType.Switch, isOn: this.setStatus.certList[this.Index].status }) + .width($r("app.float.ComponentSystem_Toggle_width_value")) + .height($r("app.float.ComponentSystem_Toggle_height_value")) + .selectedColor($r("app.color.ComponentSystem_Toggle_selectedColor_007DFF")) + .onChange((isOn: boolean) => { + if (isOn) { + console.info('Component status:' + isOn); + this.setStatus.setSystemCertificateStatus(this.Uri, true); + } else { + console.info('Component status:' + isOn); + this.setStatus.setSystemCertificateStatus(this.Uri, false); + } + }) + .offset({ x: ConfigData.SWITCH_BUTTON_X_OFFSET, y: 0 }) + } + .height($r("app.float.ComponentSystem_Flex_height_value")) + .borderRadius($r("app.float.ComponentSystem_Flex_borderRadius_value")) + .onClick(() => { + this.setStatus.getSystemTrustedCertificate(this.Uri); + console.info('this.setStatus.certInfo.status is:' + JSON.stringify(this.setStatus.certInfo)); + this.dialogController.open(); + }) + } +} + +@Component +struct ComponentUser { + private certAlias: string; + private subjectName: string; + private Index : number = -1; + private Uri: string; + @State StatusText : string | Resource = '' ; + @State isTouched: boolean = false; + @Link setStatus: CMShowUserCaPresenter; + @State mUserCaPresenterDetail: CMShowUserCaPresenter = CMShowUserCaPresenter.getInstance(); + @State @Watch("onShowDeleteWarnDialog") isShowWarning: boolean = false; + + dialogController: CustomDialogController = new CustomDialogController({ + builder: CustomDialogExampleUser({ isShowWarnDialog: $isShowWarning,userInfoPresenter: $mUserCaPresenterDetail, + userInfoPresenterForAbstractList: $setStatus }), + autoCancel: true, + cancel: () => { + this.setStatus.updateUserTrustedCertificateList(); + }, + alignment: DialogAlignment.Bottom, + offset: { dx: 0, dy: ConfigData.DIALOG_DY_OFFSET } + }) + + deleteWarnDialog: CustomDialogController = new CustomDialogController({ + builder: CustomDialogDeleteWarning({ + isShowWarnDialog: $isShowWarning, + deleteWarn: $mUserCaPresenterDetail, + mShowUserListPresenter: $setStatus }), + autoCancel: false, + alignment:DialogAlignment.Bottom, + offset: { dx: 0, dy: ConfigData.DIALOG_DY_OFFSET } + }) + + onShowDeleteWarnDialog() { + if(this.isShowWarning == true) { + this.deleteWarnDialog.open(); + } else { + this.dialogController.close(); + this.deleteWarnDialog.close(); + } + } + + aboutToAppear() { + LogUtil.info('in ComponentUser aboutToAppear'); + if (this.setStatus.certList[this.Index].status == true) { + this.StatusText = $r("app.string.CustomDialogExampleUser_Status_true"); + } else { + this.StatusText = $r("app.string.CustomDialogExampleUser_Status_false"); + } + } + + build() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Column() { + Text(this.certAlias) + .height($r("app.float.componentUser_firText_height_value")) + .fontSize($r("sys.float.ohos_id_text_size_body1")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Medium) + .textAlign(TextAlign.Start) + .margin({ top: $r("app.float.wh_value_10") }); + Text(this.subjectName) + .height($r("app.float.componentUser_secText_height_value")) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_primary")) + .fontWeight(FontWeight.Regular) + .textAlign(TextAlign.Start) + .margin({ top: $r("app.float.wh_value_2"), bottom: $r("app.float.wh_value_11") }); + }.alignItems(HorizontalAlign.Start); + Row() { + Text(this.StatusText) + .fontSize($r("sys.float.ohos_id_text_size_body2")) + .fontColor($r("sys.color.ohos_id_color_text_secondary")) + .textAlign(TextAlign.End) + .margin({ + right: $r("app.float.componentUser_thdText_margin_value") + }) + Image($r('app.media.ic_settings_arrow')) + .width($r("app.float.componentUser_image_width_value")) + .height($r("app.float.componentUser_image_height_value")) + .fillColor($r("sys.color.ohos_id_color_primary")) + .opacity($r("app.float.componentUser_image_opacity_value")); + } + } + .height($r("app.float.componentUser_flex_height_value")) + .borderRadius($r("app.float.componentUser_flex_borderRadius_value")) + .onClick(() => { + this.mUserCaPresenterDetail.getUserTrustedCertificate(this.Uri); + console.info('userCerInfo is:' + JSON.stringify(this.setStatus.certInfo)); + this.dialogController.open(); + }); + } +} + +@Entry +@Component +struct TrustedEvidence { + @State mShowSysCaPresenter: CMShowSysCaPresenter = CMShowSysCaPresenter.getInstance(); + @State mShowUserCaPresenter: CMShowUserCaPresenter = CMShowUserCaPresenter.getInstance(); + @State mFaPresenter: CMFaPresenter = CMFaPresenter.getInstance(); + @State isTouched: boolean = false; + @State currentIndex: number = 0 + @State fontColor: string | Resource = $r("app.color.TrustedEvidence_TabBuilder_fontColor_182431") + @State selectedFontColor: string | Resource = $r("app.color.font_color_007DFF") + private controller: TabsController = new TabsController(); + + @Builder TabBuilder(index: number) { + Column() { + Text(index == 0 ? $r('app.string.system') : $r('app.string.user')) + .fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize($r('app.float.TrustedEvidence_TabBuilder_Text_fontSize_value')) + .fontWeight(this.currentIndex === index ? FontWeight.Medium : FontWeight.Regular) + .alignSelf(ItemAlign.Center) + .margin({ + top: $r('app.float.TrustedEvidence_TabBuilder_Text_padding_top_value') + }) + if (this.currentIndex === index) { + Divider() + .width($r('app.float.TrustedEvidence_TabBuilder_Divider_width_value')) + .margin({ top: $r('app.float.TrustedEvidence_TabBuilder_Divider_padding_top_value') }) + .strokeWidth(2) + .color(this.selectedFontColor) + .alignSelf(ItemAlign.Center) + } + } + .width(ConfigData.WH_100_100) + } + + aboutToAppear() { + LogUtil.info('in aboutToAppear'); + this.mShowSysCaPresenter.updateSystemTrustedCertificateList(); + this.mShowUserCaPresenter.updateUserTrustedCertificateList(); + } + + onPageShow() { + let uri = globalThis.abilityWant.uri; + globalThis.abilityWant.uri = ""; + + if (uri === "certInstall") { + this.mFaPresenter.startInstall(); + } else if (uri === "requestAuthorize") { + this.mFaPresenter.startRequestAuth(globalThis.abilityWant.parameters.appUid); + } + } + + build() { + Column(){ + GridContainer({columns:12, sizeType: SizeType.Auto, gutter: vp2px(1) === 2 ? '12vp' : '0vp', + margin: vp2px(1) === 2 ? '24vp' : '0vp'}) { + Row() { + Column() { + HeadComponent({ headName: $r('app.string.trustedEvidence') }) + Column(){ + Tabs({ barPosition: BarPosition.Start, index: 0, controller: this.controller }) { + TabContent() { + List() { + ForEach(this.mShowSysCaPresenter.certList, (item, index) => { + ListItem() { + ComponentSystem({ certAlias: item.certAlias, subjectName: item.SubjectNameCN, Status: item.status, + Uri: item.uri, setStatus: $mShowSysCaPresenter, Index: index }) + } + }, item => JSON.stringify(item)) + } + .margin({ + left: $r("app.float.wh_value_12"), + right: $r("app.float.wh_value_12") + }) + .padding({ + left: $r("app.float.wh_value_12"), + top: $r("app.float.wh_value_4"), + bottom: $r("app.float.wh_value_4") + }) + .divider({ + strokeWidth: $r("app.float.sys_list_divider_strokeWidth_value"), + color: $r("app.color.sys_list_divider_color_000000"), + endMargin: '12vp' + }) + .borderRadius($r("sys.float.ohos_id_corner_radius_default_l")) + .backgroundColor($r("app.color.sys_list_backgroundColor_FFFFFF")) + .visibility(this.mShowSysCaPresenter.certList.length > 0 ? Visibility.Visible : Visibility.None); + } + .tabBar(this.TabBuilder(0)) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.isTouched = true; + } + if (event.type === TouchType.Up) { + this.isTouched = false; + } + }); + + TabContent() { + List() { + ForEach(this.mShowUserCaPresenter.certList, (item, index) => { + ListItem() { + ComponentUser({ certAlias: item.certAlias, subjectName: item.SubjectNameCN, Uri: item.uri, + setStatus: $mShowUserCaPresenter, Index: index }) + } + }, item => JSON.stringify(item)) + } + .margin({ + left: $r("app.float.wh_value_12"), + right: $r("app.float.wh_value_12") + }) + .padding({ + left: $r("app.float.wh_value_12"), + right: $r("app.float.wh_value_8"), + top: $r("app.float.wh_value_4"), + bottom: $r("app.float.wh_value_4") + }) + .divider({ + strokeWidth: $r("app.float.user_list_divider_strokeWidth_value"), + color: $r("app.color.user_list_divider_color_000000"), + endMargin: '3vp' + }) + .borderRadius($r("app.float.user_list_divider_borderRadius_value")) + .backgroundColor($r("app.color.user_list_backgroundColor_FFFFFF")) + .visibility(this.mShowUserCaPresenter.certList.length > 0 ? Visibility.Visible : Visibility.None) + } + .tabBar(this.TabBuilder(1)) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.isTouched = true; + } + if (event.type === TouchType.Up) { + this.isTouched = false; + } + }); + } + .vertical(false) + .scrollable(true) + .barMode(BarMode.Fixed) + .barWidth($r("app.float.tabs_barWidth_value")) + .barHeight($r("app.float.tabs_barHeight_value")) + .animationDuration(400) + .width(ConfigData.WH_100_100) + .backgroundColor($r("app.color.TrustedEvidence_tabs_backgroundColor_F1F3F5")) + .onChange((index: number) => { + this.currentIndex = index + }); + } + .height(ConfigData.WH_94_100) + .width(ConfigData.WH_100_100); + } + .backgroundColor($r("sys.color.ohos_id_color_sub_background")) + .width(ConfigData.WH_100_100) + .height(ConfigData.WH_100_100) + .useSizeType({ + xs: { span: 12, offset: 0 }, sm: { span: 12, offset: 0 }, + md: { span: 12, offset: 0 }, lg: { span: 8, offset: 2 } + }); + + Column() { + } + .width(ConfigData.WH_100_100) + .height(ConfigData.WH_100_100) + .useSizeType({ + xs: { span: 0, offset: 12 }, sm: { span: 0, offset: 12 }, + md: { span: 0, offset: 12 }, lg: { span: 2, offset: 10 } + }); + } + .width(ConfigData.WH_100_100) + .height(ConfigData.WH_100_100); + } + .width(ConfigData.WH_100_100) + .height(ConfigData.WH_100_100); + } + .backgroundColor($r("sys.color.ohos_id_color_sub_background")) + .width(ConfigData.WH_100_100) + .height(ConfigData.WH_100_100); + } +} diff --git a/cer_manager/product/phone/src/main/ets/presenter/CMAppCredAuthPresenter.ets b/cer_manager/product/phone/src/main/ets/presenter/CMAppCredAuthPresenter.ets new file mode 100644 index 0000000000000000000000000000000000000000..e8b22b8ccc9cd3b84ed1af09e252b658af15bd16 --- /dev/null +++ b/cer_manager/product/phone/src/main/ets/presenter/CMAppCredAuthPresenter.ets @@ -0,0 +1,103 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import certManagerModel from '../model/CertMangerModel'; +import BundleModel from '../model/BundleModel'; +import { CMModelErrorCode, CMModelOptType } from '../model/CertMangerModel'; +import { CredentialAbstractVo } from '../model/CertManagerVo/CredentialAbstractVo'; +import router from '@system.router'; + +const TAG = "CMAppCredAuthPresenter Presenter: "; +const SUCCESS = 0; +const FAIL = -1; + +export default class CMAppCredAuthPresenter { + private static sInstance: CMAppCredAuthPresenter; + optType: CMModelOptType = CMModelOptType.CM_MODEL_OPT_UNKNOWN; + credList: CredentialAbstractVo[] = []; + appName: string = ''; + + public static getInstance(): CMAppCredAuthPresenter { + if (CMAppCredAuthPresenter.sInstance == null) { + CMAppCredAuthPresenter.sInstance = new CMAppCredAuthPresenter(); + } + return CMAppCredAuthPresenter.sInstance; + } + + onAboutToAppear() { + + } + + aboutToDisappear() { + this.optType = CMModelOptType.CM_MODEL_OPT_UNKNOWN; + this.credList = []; + } + + UpdateAppNameFromUid(uid) { + console.log("getAppNameFromUid start uid = " + uid); + BundleModel.getAppInfoList(uid, (errCode, appInfo) => { + console.log("getAppNameFromUid success, appInfo = " + appInfo); + if (!errCode) { + this.appName = appInfo.AppName; + } else { + console.log("getAppNameFromUid fail, uid = " + uid); + } + }) + } + + updateAppCredList() { + certManagerModel.getCertOrCredList(CMModelOptType.CM_MODEL_OPT_APP_CRED, (errCode, credList) => { + if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) { + this.credList = credList; + console.log("updateSystemTrustedCertificateList inin :" + JSON.stringify(credList)); + } else { + console.log("updateSystemTrustedCertificateList fail"); + } + }); + } + + requestAuthorize(uri, appUid) { + console.log(TAG + "requestAuthorize start uri :" + uri + "appUid: " + appUid); + let want = globalThis.abilityWant; + + certManagerModel.setAppAuth(CMModelOptType.CM_MODEL_OPT_APP_CRED, uri, appUid, + true, (errCode, data) => { + router.clear(); + if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) { + console.log("requestAuthorize success data: " + data); + want.parameters.authUri = data; + globalThis.certManagerAbilityContext.terminateSelfWithResult({ + resultCode: SUCCESS, + want: want + }); + } else { + console.log("requestAuthorize fail"); + globalThis.certManagerAbilityContext.terminateSelfWithResult({ + resultCode: FAIL, + want: want + }); + } + }); + } + + cancelProcess() { + console.log("cancelProcess start"); + router.clear(); + globalThis.certManagerAbilityContext.terminateSelfWithResult({ + resultCode: FAIL, + want: globalThis.abilityWant + }); + } +} \ No newline at end of file diff --git a/cer_manager/product/phone/src/main/ets/presenter/CMFaPresenter.ets b/cer_manager/product/phone/src/main/ets/presenter/CMFaPresenter.ets new file mode 100644 index 0000000000000000000000000000000000000000..11c3f314a791bb8eede6a1d9ee0b57720231c234 --- /dev/null +++ b/cer_manager/product/phone/src/main/ets/presenter/CMFaPresenter.ets @@ -0,0 +1,115 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import router from '@system.router'; +import certManagerModel from '../model/CertMangerModel' +import FileIoModel from '../model/FileIoModel' +import { CMModelErrorCode, CMModelOptType } from '../model/CertMangerModel' + +const TAG = "CMFaPresenter: "; +const PAGE_URI_PWD_INPUT = 'pages/certPwdInput'; +const PAGE_URI_ALIAS_INPUT = 'pages/certInstallAliasInput'; + +export default class CMFaPresenter { + private static sInstance: CMFaPresenter; + + public static getInstance(): CMFaPresenter { + if (CMFaPresenter.sInstance == null) { + CMFaPresenter.sInstance = new CMFaPresenter(); + } + return CMFaPresenter.sInstance; + } + + onAboutToAppear() { + + } + + aboutToDisappear() { + } + + routeToNext(fileUri: string) { + console.info(TAG + 'routeToNext fileUri: ' + fileUri); + FileIoModel.getMediaFileSuffix(fileUri, (suffix) => { + if (suffix) { + if ((suffix == "cer") || (suffix == "pem")) { + router.push({ + uri: PAGE_URI_ALIAS_INPUT, + params: { + uri: fileUri, + suffix: suffix + } + }); + } else { + router.push({ + uri: PAGE_URI_PWD_INPUT, + params: { + uri: fileUri, + suffix: suffix + } + }); + } + } + }) + } + + startInstall() { + globalThis.certManagerAbilityContext.startAbilityForResult( + { + bundleName: "com.ohos.filepicker", + abilityName: "MainAbility", + parameters: { + 'startMode': 'choose', + } + }, + { + windowMode: 102 + } + ) + .then((data) => { + if (!data.resultCode) { + this.routeToNext(data.want.parameters.result) + } + }) + .catch((error) => { + console.log(TAG + 'start filePicker err: ' + error); + }) + } + + startRequestAuth(uri) { + router.replace({ + uri: "pages/requestAuth", params: { + appUid: uri, + } + }) + } + + uninstallAllCert() { + certManagerModel.delAllCertOrCred(CMModelOptType.CM_MODEL_OPT_USER_CA, (errCode) => { + if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) { + console.log(TAG + 'uninstallAllCert CM_MODEL_OPT_USER_CA success'); + } else { + console.log(TAG + 'uninstallAllCert CM_MODEL_OPT_USER_CA failed'); + } + }); + + certManagerModel.delAllCertOrCred(CMModelOptType.CM_MODEL_OPT_APP_CRED, (errCode) => { + if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) { + console.log(TAG + 'uninstallAllCert CM_MODEL_OPT_APP_CRED success'); + } else { + console.log(TAG + 'uninstallAllCert CM_MODEL_OPT_APP_CRED failed'); + } + }); + } +} \ No newline at end of file diff --git a/cer_manager/product/phone/src/main/ets/presenter/CMInstallPresenter.ets b/cer_manager/product/phone/src/main/ets/presenter/CMInstallPresenter.ets new file mode 100644 index 0000000000000000000000000000000000000000..38de858cdc85f59946c21144923e340b873194f7 --- /dev/null +++ b/cer_manager/product/phone/src/main/ets/presenter/CMInstallPresenter.ets @@ -0,0 +1,73 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import certManagerModel from '../model/CertMangerModel' +import FileIoModel from '../model/FileIoModel' +import { CMModelErrorCode, CMModelOptType } from '../model/CertMangerModel' +import router from '@system.router'; + +const TAG = "CMInstallPresenter: "; + +export default class CMInstallPresenter { + private static sInstance: CMInstallPresenter; + optType: CMModelOptType = CMModelOptType.CM_MODEL_OPT_UNKNOWN; + + public static getInstance(): CMInstallPresenter { + if (CMInstallPresenter.sInstance == null) { + CMInstallPresenter.sInstance = new CMInstallPresenter(); + } + return CMInstallPresenter.sInstance; + } + + onAboutToAppear() { + + } + + aboutToDisappear() { + this.optType = CMModelOptType.CM_MODEL_OPT_UNKNOWN; + } + + updateCertFileType(suffix) { + console.info(TAG + 'updateCertFileType suffix: ' + suffix) + if ((suffix == "cer") || (suffix == "pem")) { + this.optType = CMModelOptType.CM_MODEL_OPT_USER_CA; + } else if ((suffix == "p12") || (suffix == "jks") || (suffix == "pfx")) { + this.optType = CMModelOptType.CM_MODEL_OPT_APP_CRED; + } + } + + getFileDataFromUri(uri, callback) { + FileIoModel.getMediaFileData(uri, (data) => { + callback(data) + }) + + } + + installCert(uri, alias, pwd, suffix) { + console.info(TAG + 'installCert uri: ' + uri + 'alias: ' + alias + 'pwd: ' + pwd + 'suffix: ' + suffix) + this.updateCertFileType(suffix); + this.getFileDataFromUri(uri, (data) => { + certManagerModel.installCertOrCred(this.optType, alias, data, pwd, (errCode) => { + console.info(TAG + 'installCertOrCred result: ' + JSON.stringify(errCode)) + if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) { + console.info(TAG + 'installCert success'); + } else { + console.info(TAG + 'installCert failed'); + } + router.replace({ uri: "pages/certManagerFa" }); + }); + }) + } +} \ No newline at end of file diff --git a/cer_manager/product/phone/src/main/ets/presenter/CMShowAppCredPresenter.ets b/cer_manager/product/phone/src/main/ets/presenter/CMShowAppCredPresenter.ets new file mode 100644 index 0000000000000000000000000000000000000000..7c71bcaf73e3638380eff2436b8d515125eedd30 --- /dev/null +++ b/cer_manager/product/phone/src/main/ets/presenter/CMShowAppCredPresenter.ets @@ -0,0 +1,103 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import certManagerModel from '../model/CertMangerModel' +import bundleModel from '../model/BundleModel' +import { CMModelErrorCode, CMModelOptType } from '../model/CertMangerModel' +import { CredentialAbstractVo } from '../model/CertManagerVo/CredentialAbstractVo' +import { CredentialVo } from '../model/CertManagerVo/CredentialVo' +import { AppAuthorVo } from '../model/CertManagerVo/AppAuthorVo' + +export default class CMShowAppCredPresenter { + private static sInstance: CMShowAppCredPresenter; + credList: CredentialAbstractVo[] = []; + appInfoList: AppAuthorVo[] = []; + credInfo: CredentialVo = new CredentialVo("", "", "", 0, 0, null); + + public static getInstance(): CMShowAppCredPresenter { + if (CMShowAppCredPresenter.sInstance == null) { + CMShowAppCredPresenter.sInstance = new CMShowAppCredPresenter(); + } + return CMShowAppCredPresenter.sInstance; + } + + aboutToDisappear() { + this.credList = []; + this.credInfo = new CredentialVo("", "", "", 0, 0, null); + this.appInfoList = [] + } + + updateAppCredList() { + certManagerModel.getCertOrCredList(CMModelOptType.CM_MODEL_OPT_APP_CRED, (errCode, credList) => { + if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) { + this.credList = credList; + } else { + console.log("updateAppCredList error :" + JSON.stringify(errCode)); + } + }); + } + + getAppCred(uri) { + certManagerModel.getCertOrCred(CMModelOptType.CM_MODEL_OPT_APP_CRED, uri, (errCode, credInfo) => { + if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) { + this.credInfo = credInfo + } else { + console.log("getAppCred error :" + JSON.stringify(errCode)); + } + }); + } + + deleteAppCred(uri) { + certManagerModel.deleteCertOrCred(CMModelOptType.CM_MODEL_OPT_APP_CRED, uri, (errCode) => { + if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) { + this.updateAppCredList(); + } else { + console.log("deleteAppCred error :" + JSON.stringify(errCode)); + } + }) + } + + getAuthorizedAppList(uri) { + this.appInfoList = [] + certManagerModel.getAuthAppList(CMModelOptType.CM_MODEL_OPT_APP_CRED, uri, (errCode, appUidList) => { + if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) { + for (let i = 0; i < appUidList.length; i++) { + bundleModel.getAppInfoList(Number(appUidList[i]),(errCode,AppInfo) => { + if(errCode == CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) { + this.appInfoList.push(new AppAuthorVo(AppInfo.AppImage,appUidList[i], String(AppInfo.AppName), true)) + console.log("appInfoList111111111 :" + JSON.stringify(this.appInfoList)); + } + }) + } + } else { + console.log("getAuthorizedAppList error :" + JSON.stringify(errCode)); + } + }) + } + + removeGrantedAppList(uri) { + for (let i = 0; i < this.appInfoList.length; i++) { + if (!this.appInfoList[i].status) { + certManagerModel.setAppAuth(CMModelOptType.CM_MODEL_OPT_APP_CRED, uri, this.appInfoList[i].uid, false, (errCode) => { + if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) { + console.log("removeGrantedAppList succeed" + JSON.stringify(errCode)); + } else { + console.log("removeGrantedAppList error :" + JSON.stringify(errCode)); + } + }) + } + } + } +} \ No newline at end of file diff --git a/cer_manager/product/phone/src/main/ets/presenter/CMShowPrivateCredPresenter.ets b/cer_manager/product/phone/src/main/ets/presenter/CMShowPrivateCredPresenter.ets new file mode 100644 index 0000000000000000000000000000000000000000..ee82ee48ef8dbcf91d5d0429c4a750be871f3957 --- /dev/null +++ b/cer_manager/product/phone/src/main/ets/presenter/CMShowPrivateCredPresenter.ets @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import certManagerModel from '../model/CertMangerModel' +import { CMModelErrorCode, CMModelOptType } from '../model/CertMangerModel' +import { CredentialAbstractVo } from '../model/CertManagerVo/CredentialAbstractVo' +import { CredentialVo } from '../model/CertManagerVo/CredentialVo' + +export default class CMShowPrivateCredPresenter { + private static sInstance: CMShowPrivateCredPresenter; + credList: CredentialAbstractVo[] = []; + credInfo: CredentialVo = new CredentialVo("", "", "", 0, 0, null); + + public static getInstance(): CMShowPrivateCredPresenter { + if (CMShowPrivateCredPresenter.sInstance == null) { + CMShowPrivateCredPresenter.sInstance = new CMShowPrivateCredPresenter(); + } + return CMShowPrivateCredPresenter.sInstance; + } + + aboutToDisappear() { + this.credList = []; + this.credInfo = new CredentialVo("", "", "", 0, 0, null); + } + + updatePrivateCredList() { + certManagerModel.getCertOrCredList(CMModelOptType.CM_MODEL_OPT_PRIVATE_CRED, (errCode, credList) => { + if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) { + this.credList = credList; + } else { + console.log("updatePrivateCredList error :" + JSON.stringify(errCode)); + } + }); + } + + getPrivateCred(uri) { + certManagerModel.getCertOrCred(CMModelOptType.CM_MODEL_OPT_PRIVATE_CRED, uri, (errCode, credInfo) => { + if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) { + this.credInfo = credInfo + } else { + console.log("getPrivateCred error :" + JSON.stringify(errCode)); + } + }); + } +} \ No newline at end of file diff --git a/cer_manager/product/phone/src/main/ets/presenter/CMShowSysCaPresenter.ets b/cer_manager/product/phone/src/main/ets/presenter/CMShowSysCaPresenter.ets new file mode 100644 index 0000000000000000000000000000000000000000..4157df62f7359eec286ec9eaa45ba639e7a581e2 --- /dev/null +++ b/cer_manager/product/phone/src/main/ets/presenter/CMShowSysCaPresenter.ets @@ -0,0 +1,77 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import certManagerModel from '../model/CertMangerModel' +import { CMModelErrorCode, CMModelOptType } from '../model/CertMangerModel' +import { CertAbstractVo } from '../model/CertManagerVo/CertAbstractVo' +import { CertInfoVo } from '../model/CertManagerVo/CertInfoVo' + +const TAG = "CMShowSysCa Presenter: "; + +export default class CMShowSysCaPresenter { + private static sInstance: CMShowSysCaPresenter; + certList: CertAbstractVo[] = []; + certInfo: CertInfoVo = new CertInfoVo("", "", false, "", "", "", "", "", "", null, null, null, null); + + public static getInstance(): CMShowSysCaPresenter { + if (CMShowSysCaPresenter.sInstance == null) { + CMShowSysCaPresenter.sInstance = new CMShowSysCaPresenter(); + } + return CMShowSysCaPresenter.sInstance; + } + + onAboutToAppear() { + this.updateSystemTrustedCertificateList(); + } + + aboutToDisappear() { + this.certList = []; + this.certInfo = new CertInfoVo("", "", false, "", "", "", "", "", "", null, null, null, null); + } + + updateSystemTrustedCertificateList() { + certManagerModel.getCertOrCredList(CMModelOptType.CM_MODEL_OPT_SYSTEM_CA, (errCode, certList) => { + if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) { + this.certList = certList; + console.log("updateSystemTrustedCertificateList inin :" + JSON.stringify(certList)); + } else { + console.info(TAG + 'updateSystemTrustedCertificateList fail,errCode is' + errCode); + } + }); + } + + getSystemTrustedCertificate(uri) { + certManagerModel.getCertOrCred(CMModelOptType.CM_MODEL_OPT_SYSTEM_CA, uri, (errCode, certInfo) => { + if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) { + console.info(TAG + 'getSystemTrustedCertificate success,errCode is ' + errCode + ' certInfo is' + + JSON.stringify(certInfo)); + this.certInfo = certInfo; + } else { + console.info(TAG + 'getSystemTrustedCertificate fail,errCode is' + errCode); + } + }); + } + + setSystemCertificateStatus(uri, status) { + certManagerModel.setCertStatus(CMModelOptType.CM_MODEL_OPT_SYSTEM_CA, uri, status, (errCode) => { + if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) { + console.info(TAG + 'setSystemCertificateStatus success,errCode is' + errCode); + this.updateSystemTrustedCertificateList(); + } else { + console.info(TAG + 'setSystemCertificateStatus fail,errCode is' + errCode); + } + }) + } +} \ No newline at end of file diff --git a/cer_manager/product/phone/src/main/ets/presenter/CMShowUserCaPresenter.ets b/cer_manager/product/phone/src/main/ets/presenter/CMShowUserCaPresenter.ets new file mode 100644 index 0000000000000000000000000000000000000000..935b784fa0d93d31944aa839688a7bfddfddf110 --- /dev/null +++ b/cer_manager/product/phone/src/main/ets/presenter/CMShowUserCaPresenter.ets @@ -0,0 +1,86 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import certManagerModel from '../model/CertMangerModel' +import { CMModelErrorCode, CMModelOptType } from '../model/CertMangerModel' +import { CertAbstractVo } from '../model/CertManagerVo/CertAbstractVo' +import { CertInfoVo } from '../model/CertManagerVo/CertInfoVo' + +const TAG = "CMFaShowUserCa Presenter: "; + +export default class CMShowUserCaPresenter { + private static sInstance: CMShowUserCaPresenter; + certList: CertAbstractVo[] = []; + certInfo: CertInfoVo = new CertInfoVo("", "", false, "", "", "", "", "", "", null, null, null, null); + + public static getInstance(): CMShowUserCaPresenter { + if (CMShowUserCaPresenter.sInstance == null) { + CMShowUserCaPresenter.sInstance = new CMShowUserCaPresenter(); + } + return CMShowUserCaPresenter.sInstance; + } + + onAboutToAppear() { + + } + + aboutToDisappear() { + this.certList = []; + this.certInfo = new CertInfoVo("", "", false, "", "", "", "", "", "", null, null, null, null); + } + + updateUserTrustedCertificateList() { + certManagerModel.getCertOrCredList(CMModelOptType.CM_MODEL_OPT_USER_CA, (errCode, certList) => { + if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) { + this.certList = certList; + console.log("updateUserTrustedCertificateList inin :" + JSON.stringify(certList)); + } else { + console.info(TAG + 'updateUserTrustedCertificateList fail,errCode is ' + errCode); + } + }); + } + + getUserTrustedCertificate(uri) { + certManagerModel.getCertOrCred(CMModelOptType.CM_MODEL_OPT_USER_CA, uri, (errCode, certInfo) => { + if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) { + console.info(TAG + 'getUserTrustedCertificate success, errCode is ' + errCode + ' certInfo is' + + JSON.stringify(certInfo)); + this.certInfo = certInfo; + } else { + console.info(TAG + 'getUserTrustedCertificate fail, errCode is ' + errCode); + } + }); + } + + setUserCertificateStatus(uri, status) { + certManagerModel.setCertStatus(CMModelOptType.CM_MODEL_OPT_USER_CA, uri, status, (errCode) => { + if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) { + this.getUserTrustedCertificate(uri); + } else { + console.info(TAG + 'setUserCertificateStatus fail,errCode is ' + errCode) + } + }) + } + + deleteUserCertificate(uri) { + certManagerModel.deleteCertOrCred(CMModelOptType.CM_MODEL_OPT_USER_CA, uri, (errCode) => { + if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) { + this.updateUserTrustedCertificateList(); + } else { + console.info(TAG + 'deleteUserCertificate fail,errCode is ' + errCode); + } + }) + } +} \ No newline at end of file diff --git a/cer_manager/product/phone/src/main/ets/stub/certStubPromise.ts b/cer_manager/product/phone/src/main/ets/stub/certStubPromise.ts new file mode 100644 index 0000000000000000000000000000000000000000..8c80e0fca79a1e4210499289ee688ef5b1ab48e0 --- /dev/null +++ b/cer_manager/product/phone/src/main/ets/stub/certStubPromise.ts @@ -0,0 +1,652 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { CMResult, BusinessError, CMErrorCode, CMBlob, CMSignatureSpec, CertManagerStore } from './certStubStruct'; +import certStubUtil from './certStubUtil'; +import fileio from '@ohos.fileio'; + +var certUtil = new certStubUtil(); +const TAG = "CertManager Stub: "; +const certNum = 10 +const keyNum = 20 +const authorListA = ["20010027", "20010026", "10003", "20010013","20010033"] +const authorListB = ["20010033", "10003", "20010027"] +const authorListC = ["20010032", "20010013", "20010026", "10003"] + +export class CertStubPromise { + exceptFlag = 0; + uriBase = "uri://stub/certFile/" + type = "CM_URI_TYPE_APP_KEY" + uriCount = 0; + systemCertMap = new Map(); + userCertMap = new Map(); + uriToAlias = new Map(); + appCredMap = new Map(); + privateCredMap = new Map(); + uriToAppList = new Map(); + + constructor() { + let newCert; + + console.log(TAG + "getSystemTrustedCertificateList stub constructor start"); + newCert = certUtil.parseCertInfo(this.uriBase + this.uriCount.toString(), + "SystemRoot_1", true, new Uint8Array([0, 1, 2, 42, 100, 101, 102, 255])); + this.systemCertMap.set(this.uriBase + this.uriCount.toString(), newCert); + this.uriCount++; + + newCert = certUtil.parseCertInfo(this.uriBase + this.uriCount.toString(), + "SystemRoot_2", false, new Uint8Array([64, 1, 2, 42, 100, 123, 321, 255])); + this.systemCertMap.set(this.uriBase + this.uriCount.toString(), newCert); + this.uriCount++; + + newCert = certUtil.parseCertInfo(this.uriBase + this.uriCount.toString(), + "SystemRoot_3", true, new Uint8Array([54, 1, 123, 42, 100, 101, 102, 23])); + this.systemCertMap.set(this.uriBase + this.uriCount.toString(), newCert); + this.uriCount++; + + newCert = certUtil.parseCertInfo(this.uriBase + this.uriCount.toString(), + "UserRoot_1", true, new Uint8Array([0, 1, 2, 42, 100, 101, 102, 255])); + this.userCertMap.set("UserRoot_1", newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "UserRoot_1") + this.uriCount++; + + newCert = certUtil.parseCertInfo(this.uriBase + this.uriCount.toString(), + "UserRoot_2", false, new Uint8Array([0, 1, 2, 42, 100, 101, 102, 255])); + this.userCertMap.set("UserRoot_2", newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "UserRoot_2") + this.uriCount++; + + newCert = certUtil.parseCertInfo(this.uriBase + this.uriCount.toString(), + "UserRoot_3", true, new Uint8Array([0, 1, 2, 42, 100, 101, 102, 255])); + this.userCertMap.set("UserRoot_3", newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "UserRoot_3") + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "TheEncryptionForCCMPV1", this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([25, 5, 34, 45, 64, 78, 7, 8])); + this.appCredMap.set("ApptemRoot_1", newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "ApptemRoot_1") + this.uriToAppList.set(this.uriBase + this.uriCount.toString(), authorListA) + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "TheEncryptionForCCMPV2", this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([23, 1, 43, 42, 78, 90, 56, 12])); + this.appCredMap.set("ApptemRoot_2", newCert); + this.uriToAppList.set(this.uriBase + this.uriCount.toString(), authorListB) + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "ApptemRoot_2") + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "TheEncryptionForCCMPV3", this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([21, 1, 32, 645, 100, 101, 102, 23])); + this.appCredMap.set("ApptemRoot_3", newCert); + this.uriToAppList.set(this.uriBase + this.uriCount.toString(), authorListC) + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "ApptemRoot_3") + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "Huawei-Employee_WPA_EAPIEA", this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([32, 41, 54, 67, 77, 98, 91, 123])); + this.privateCredMap.set("PrivatetemRoot_1", newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "PrivatetemRoot_1") + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "Huawei-Employee_WPA_EAPIEB", this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([34, 65, 67, 68, 33, 77, 14, 18])); + this.privateCredMap.set("PrivatetemRoot_2", newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "PrivatetemRoot_2") + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "Huawei-Employee_WPA_EAPIEC", this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([12, 3, 54, 76, 8, 123, 43, 55])); + this.privateCredMap.set("PrivatetemRoot_3", newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "PrivatetemRoot_3") + this.uriCount++; + } + + getSystemTrustedCertificateList() { + return new Promise((resolve, reject) => { + let error: BusinessError; + let data: CMResult; + let certList = new Array(); + + if (!this.exceptFlag) { + console.log(TAG + "getSystemTrustedCertificateList stub start"); + this.systemCertMap.forEach((data, keyUri) => { + certList.push(this.systemCertMap.get(keyUri)) + }) + data = { + certList: certList + }; + resolve(data); + } else { + error = { + code: CMErrorCode.CMR_FAILURE, + }; + reject(error); + } + }) + } + + getSystemTrustedCertificate(certUri: string) { + return new Promise((resolve, reject) => { + let data: CMResult; + let error: BusinessError; + + if (this.systemCertMap.has(certUri)) { + data = { + certInfo: this.systemCertMap.get(certUri) + }; + resolve(data); + } else { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + }) + } + + setCertificateStatus(certUri: string, store: number, status: boolean) { + return new Promise((resolve, reject) => { + let error: BusinessError; + let alias; + + if ((!this.systemCertMap.has(certUri)) && + (!this.uriToAlias.has(certUri))) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + + if (store == CertManagerStore.CERT_MANAGER_SYSTEM_TRUSTED_STORE) { + this.systemCertMap.get(certUri).status = status; + resolve(); + } else if (store == CertManagerStore.CERT_MANAGER_USER_TRUSTED_STORE) { + alias = this.uriToAlias.get(certUri); + this.userCertMap.get(alias).status = status; + resolve(); + } else { + error = { + code: CMErrorCode.CMR_ERROR_NOT_SUPPORTED, + }; + reject(error); + } + }) + } + + installUserTrustedCertificate(certificate: CMBlob) { + return new Promise((resolve, reject) => { + let newCert = certUtil.parseCertInfo(this.uriBase + this.uriCount.toString(), + certificate.alias, true, certificate.inData); + this.userCertMap.set(certificate.alias, newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), certificate.alias) + this.uriCount++; + + resolve(); + }) + } + + uninstallAllUserTrustedCertificate() { + return new Promise((resolve, reject) => { + console.log(TAG + "uninstallAllUserTrustedCertificate stub in"); + this.userCertMap.clear(); + this.uriToAlias.clear(); + resolve(); + }) + } + + uninstallUserTrustedCertificate(certUri: string) { + return new Promise((resolve, reject) => { + let error: BusinessError; + let alias; + + if (!this.uriToAlias.has(certUri)) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + + alias = this.uriToAlias.get(certUri); + this.uriToAlias.delete(certUri); + this.userCertMap.delete(alias); + resolve(); + }) + } + + getUserTrustedCertificateList() { + return new Promise((resolve, reject) => { + let error: BusinessError; + let data: CMResult; + let certList = new Array(); + + if (!this.exceptFlag) { + this.userCertMap.forEach((data, keyAlias) => { + certList.push(this.userCertMap.get(keyAlias)) + }) + + data = { + certList: certList + }; + resolve(data); + } else { + error = { + code: CMErrorCode.CMR_FAILURE, + }; + reject(error); + } + }) + } + + getUserTrustedCertificate(certUri: string) { + return new Promise((resolve, reject) => { + let data: CMResult; + let error: BusinessError; + + if (this.uriToAlias.has(certUri)) { + let alias = this.uriToAlias.get(certUri); + data = { + certInfo: this.userCertMap.get(alias) + }; + resolve(data); + } else { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + }) + } + + installAppCertificate(keystore: Uint8Array, keystorePwd: string, certAlias: string) { + return new Promise((resolve, reject) => { + let newCred = certUtil.parseCredential(this.type, certAlias, this.uriBase + this.uriCount.toString(), + certNum, keyNum, keystore); + this.appCredMap.set(certAlias, newCred); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), certAlias) + this.uriCount++; + + resolve(); + }) + } + + installPrivateCertificate(keystore: Uint8Array, keystorePwd: string, certAlias: string) { + return new Promise((resolve, reject) => { + let newCred = certUtil.parseCredential("privateCred", certAlias, this.uriBase + this.uriCount.toString(), + 1, 1, keystore); + this.privateCredMap.set(certAlias, newCred); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), certAlias); + this.uriCount++; + + resolve(); + }) + } + + uninstallAllAppCertificate() { + return new Promise((resolve, reject) => { + console.log(TAG + "uninstallAllAppCertificate stub in"); + this.appCredMap.clear(); + this.privateCredMap.clear(); + + resolve(); + }) + } + + uninstallAppCertificate(keyUri: string) { + return new Promise((resolve, reject) => { + let alias; + let error: BusinessError; + + if (!this.uriToAlias.has(keyUri)) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + + alias = this.uriToAlias.get(keyUri); + this.uriToAlias.delete(keyUri); + this.appCredMap.delete(alias); + + resolve(); + }) + } + + uninstallPrivateCertificate(keyUri) { + return new Promise((resolve, reject) => { + let alias; + let error: BusinessError; + + if (!this.uriToAlias.has(keyUri)) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + + alias = this.uriToAlias.get(keyUri); + this.uriToAlias.delete(keyUri); + this.privateCredMap.delete(alias); + + resolve(); + }) + } + + getAppCertificateList() { + return new Promise((resolve, reject) => { + let error: BusinessError; + let data: CMResult; + let credList = new Array(); + + if (!this.exceptFlag) { + this.appCredMap.forEach((data, keyAlias) => { + credList.push(this.appCredMap.get(keyAlias)) + }) + + data = { + credentialList: credList + }; + resolve(data); + } else { + error = { + code: CMErrorCode.CMR_FAILURE, + }; + reject(error); + } + }) + } + + getPrivateCertificateList() { + return new Promise((resolve, reject) => { + let error: BusinessError; + let data: CMResult; + let credList = new Array(); + + if (!this.exceptFlag) { + this.privateCredMap.forEach((data, keyAlias) => { + credList.push(this.privateCredMap.get(keyAlias)) + }) + + data = { + credentialList: credList + }; + resolve(data); + } else { + error = { + code: CMErrorCode.CMR_FAILURE, + }; + reject(error); + } + }) + } + + getAppCertificate(keyUri: string) { + return new Promise((resolve, reject) => { + let data: CMResult; + let error: BusinessError; + + if (this.uriToAlias.has(keyUri)) { + let alias = this.uriToAlias.get(keyUri); + data = { + credential: this.appCredMap.get(alias) + }; + resolve(data); + } else { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + }) + } + + getPrivateCertificate(keyUri: string) { + return new Promise((resolve, reject) => { + let data: CMResult; + let error: BusinessError; + + if (this.uriToAlias.has(keyUri)) { + let alias = this.uriToAlias.get(keyUri); + data = { + credential: this.privateCredMap.get(alias) + }; + resolve(data); + } else { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + }) + } + + grantAppCertificate(keyUri: string, clientAppUid: string) { + return new Promise((resolve, reject) => { + let appList: Array; + let data: CMResult; + let error: BusinessError; + + console.log(TAG + "grantAppCertificate stub uri: " + keyUri + " clientAppUid: " + clientAppUid); + if (!this.uriToAlias.has(keyUri)) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + + if (this.uriToAppList.has(keyUri)) { + appList = this.uriToAppList.get(keyUri); + } else { + appList = new Array(); + } + + appList.push(clientAppUid); + this.uriToAppList.set(keyUri, appList) + data = { + authUri: "authUri-value" + }; + console.log(TAG + "grantAppCertificate stub uriToAppList: " + JSON.stringify(appList)); + + resolve(data); + }) + } + + isAuthorizedApp(keyUri: string) { + return new Promise((resolve, reject) => { + let data: CMResult; + data = { + isAuth: false + }; + resolve(data); + }) + } + + getAuthorizedAppList(keyUri: string) { + return new Promise((resolve, reject) => { + let data: CMResult; + let appList: Array; + + if ((!this.uriToAlias.has(keyUri)) || (!this.uriToAppList.has(keyUri))) { + data = { + appUidList: appList, + }; + resolve(data); + } + + appList = this.uriToAppList.get(keyUri); + + data = { + appUidList: appList + }; + resolve(data); + }) + } + + removeGrantedAppCertificate(keyUri: string, clientAppUid: string) { + return new Promise((resolve, reject) => { + let appList: Array; + + if ((!this.uriToAlias.has(keyUri)) || (!this.uriToAppList.has(keyUri))) { + let error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + + appList = this.uriToAppList.get(keyUri); + if (appList.indexOf(clientAppUid) != -1) { + appList = appList.filter(item => item != clientAppUid); + this.uriToAppList.set(keyUri, appList); + resolve(); + } else { + let error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + }) + } + + init(authUri: string, spec: CMSignatureSpec) { + return new Promise((resolve, reject) => { + let errorCode = CMErrorCode.CMR_SUCCESS; + let data: CMResult; + + resolve(); + }) + } + + update(handle: number, data: Uint8Array, token?: Uint8Array) { + return new Promise((resolve, reject) => { + let errorCode = CMErrorCode.CMR_SUCCESS; + let data: CMResult; + + resolve(); + }) + } + + finish(handle: number, signature?: Uint8Array) { + return new Promise((resolve, reject) => { + let errorCode = CMErrorCode.CMR_SUCCESS; + let data: CMResult; + + resolve(); + }) + } + + abort(handle: number) { + return new Promise((resolve, reject) => { + let errorCode = CMErrorCode.CMR_SUCCESS; + let data: CMResult; + + resolve(); + }) + } + + mapToJson(map) { + let obj = Object.create(null); + for (let [k, v] of map) { + obj[k] = v; + } + + return JSON.stringify(obj) + } + + jsonToMap(jsonString) { + console.log(TAG + "jsonToMap start"); + let map = new Map(); + let obj = JSON.parse(jsonString); + + for (let k of Object.keys(obj)) { + map.set(k, obj[k]) + } + return map; + } + + saveAllMaps() { + console.log(TAG + "saveAllMaps start"); + let dataList = [ + this.mapToJson(this.systemCertMap), + this.mapToJson(this.userCertMap), + this.mapToJson(this.uriToAlias), + this.mapToJson(this.appCredMap), + this.mapToJson(this.privateCredMap), + this.mapToJson(this.uriToAppList) + ]; + + let context = globalThis.certManagerAbilityContext; + let path = context.cacheDir; + path += '/certStubData' + try { + fileio.unlinkSync(path); + } catch (err) { + console.log(TAG + "saveAllMaps unlinkSync err: " + err); + } + let fd = fileio.openSync(path, 0o102, 0o666); + fileio.writeSync(fd, JSON.stringify(dataList)); + fileio.closeSync(fd); + console.log(TAG + "saveAllMaps end"); + } + + uint8ArrayToString(fileData) { + var dataString = ""; + for (var i = 0; i < fileData.length; i++) { + dataString += String.fromCharCode(fileData[i]); + } + return dataString + } + + restoreMapsFromJson(json) { + console.log(TAG + "restoreMapsFromJson start Json: " + json); + let dataList = JSON.parse(json); + this.systemCertMap = this.jsonToMap(dataList[0]); + this.userCertMap = this.jsonToMap(dataList[1]); + this.uriToAlias = this.jsonToMap(dataList[2]); + this.appCredMap = this.jsonToMap(dataList[3]); + this.privateCredMap = this.jsonToMap(dataList[4]); + this.uriToAppList = this.jsonToMap(dataList[5]); + console.log(TAG + "restoreMapsFromJson end"); + } + + restoreAllMaps() { + console.log(TAG + "getAllMaps start"); + let context = globalThis.certManagerAbilityContext; + let path = context.cacheDir; + path += '/certStubData' + + try { + let fd = fileio.openSync(path, 0o002, 0o666); + console.log(TAG + "getAllMaps fd: " + fd); + let stat = fileio.fstatSync(fd); + let size = stat.size; + let buf = new ArrayBuffer(size); + + fileio.read(fd, buf, (err, data) => { + if (data) { + this.restoreMapsFromJson(this.uint8ArrayToString(new Uint8Array(data.buffer))); + } + fileio.closeSync(fd); + }); + } catch(err) { + console.log(TAG + "getAllMaps err: " + err); + } + + console.log(TAG + "getAllMaps end"); + } +} + +let certStub = new CertStubPromise(); + +export default certStub as CertStubPromise; \ No newline at end of file diff --git a/cer_manager/product/phone/src/main/ets/stub/certStubStruct.ts b/cer_manager/product/phone/src/main/ets/stub/certStubStruct.ts new file mode 100644 index 0000000000000000000000000000000000000000..e5e059f2a12453a7d32ffaf7b7b004079e38d988 --- /dev/null +++ b/cer_manager/product/phone/src/main/ets/stub/certStubStruct.ts @@ -0,0 +1,161 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export interface CertInfo { + uri: string, + certAlias: string, + status: boolean, + issuerName: string, + subjectName: string, + serial: string, + notBefore: string, + notAfter: string, + fingerprintSha256: string, + cert: Uint8Array +} + +export interface certAbstract { + uri: string, + certAlias: string, + status: boolean, + subjectName: string, +} + +export interface CMResult { + certList?: Array, + certInfo?: CertInfo, + credentialList?:Array, + credential?: Credential, + appUidList?: Array + authUri?: string, + outData?: Uint8Array, + isAuth?: boolean +} + +export interface CMHandle { + errorCode: number, + handle: number; + token?: Uint8Array; +} + +export interface Credential { + type: string, + alias: string, + keyUri: string, + certNum: number, + keyNum: number, + credData: Uint8Array +} + +export interface CredentialAbstract { + type: string, + alias: string, + keyUri: string +} + +export interface CMContext { + userId: string, + uid: string, + packageName: string +}; + +export interface CMBlob { + readonly inData?: Uint8Array, + readonly alias?: string +}; + +export interface CMKeyProperties { + type: string; // Type of the key, must be CM_URI_TYPE_APP_KEY or CM_URI_TYPE_WLAN_KEY + alg: string; + size: number; + padding: string; + purpose: string; + digest: string; + authType: string; + authTimeout: string; +}; + +export interface CMSignatureSpec { + alg: string; + padding: string; + digest: string; + authToken: Uint8Array; // required only for user authentication +}; + +export enum CertManagerStore { + CERT_MANAGER_CREDENTIAL_STORE = 0, /* credential certificate store for end entity certificates. */ + CERT_MANAGER_SYSTEM_TRUSTED_STORE = 1, /* read only, updated by system only. */ + CERT_MANAGER_USER_TRUSTED_STORE = 2, /* modifiable by applications and user. */ + CERT_MANAGER_APPLICATION_TRUSTED_STORE = 3, /* application specific trusted certificate store; modifiable by the application only. */ +} + +export enum CMErrorCode { + CMR_SUCCESS = 0, + CMR_FAILURE = -1, + CMR_ERROR_INSTALL_CERTIFICATE = -2, + CMR_ERROR_SET_STATUS = -3, + CMR_ERROR_INVALID_ARGUMENT = -3, + CMR_ERROR_INVALID_STORE = -4, + CMR_ERROR_NOT_SUPPORTED = -5, + CMR_ERROR_UNINSTALL = -6, + CMR_ERROR_NO_PERMISSION = -7, + CMR_ERROR_INSUFFICIENT_DATA = -8, + CMR_ERROR_GET_CERTIRICATE = -9, + CMR_ERROR_STORAGE_FAILURE = -10, + CMR_ERROR_HARDWARE_FAILURE = -11, + CMR_ERROR_ALREADY_EXISTS = -12, + CMR_ERROR_NOT_EXIST = -13, + CMR_ERROR_NULL_POINTER = -14, + CMR_ERROR_FILE_SIZE_FAIL = -15, + CMR_ERROR_READ_FILE_FAIL = -16, + CMR_ERROR_INVALID_PUBLIC_KEY = -17, + CMR_ERROR_INVALID_PRIVATE_KEY = -18, + CMR_ERROR_INVALID_KEY_INFO = -19, + CMR_ERROR_REMOVE_CERTIFICATE_FAIL = -20, + CMR_ERROR_OPEN_FILE_FAIL = -21, + CMR_ERROR_INVALID_KEY_FILE = -22, + CMR_ERROR_IPC_MSG_FAIL = -23, + CMR_ERROR_REQUEST_OVERFLOWS = -24, + CMR_ERROR_PARAM_NOT_EXIST = -25, + CMR_ERROR_CRYPTO_ENGINE_ERROR = -26, + CMR_ERROR_COMMUNICATION_TIMEOUT = -27, + CMR_ERROR_IPC_INIT_FAIL = -28, + CMR_ERROR_IPC_DLOPEN_FAIL = -29, + CMR_ERROR_EFUSE_READ_FAIL = -30, + + CMR_ERROR_CHECK_GET_ALG_FAIL = -100, + CMR_ERROR_CHECK_GET_KEY_SIZE_FAIL = -101, + CMR_ERROR_CHECK_GET_PADDING_FAIL = -102, + CMR_ERROR_INVALID_DIGEST = -117, + + CMR_ERROR_INTERNAL_ERROR = -999, + CMR_ERROR_UNKNOWN_ERROR = -1000, +} + +export interface BusinessError { + /** + * Defines the basic error code. + * @since 6 + */ + code: number; +} + +export interface AsyncCallback { + /** + * Defines the callback data. + * @since 6 + */ + (err: BusinessError, data: T): void; +} \ No newline at end of file diff --git a/cer_manager/product/phone/src/main/ets/stub/certStubUtil.ts b/cer_manager/product/phone/src/main/ets/stub/certStubUtil.ts new file mode 100644 index 0000000000000000000000000000000000000000..a1a07d8efcce2b1556e80c81c9f85213eef3d40f --- /dev/null +++ b/cer_manager/product/phone/src/main/ets/stub/certStubUtil.ts @@ -0,0 +1,149 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { CertInfo, certAbstract, CMResult, CMContext, AsyncCallback, BusinessError, CMHandle, + Credential, CredentialAbstract, CMErrorCode, CMBlob, CMKeyProperties, CMSignatureSpec } from './certStubStruct' + +export default class certStubUtil { + constructor() { + } + +parseCertInfo(uri: string, certAlias: string, status: boolean, cert: Uint8Array): CertInfo { + let certInfo: CertInfo; + + certInfo = { + uri: uri, + certAlias: certAlias, + status: status, + issuerName: "CN=SwissSign Gold CA - G2,OU=,O=SwissSign CA", + subjectName: "CN=SwissSign Gold CA - G2,OU=,O=SwissSign CA", + serial: "BB401C43F55E4FB0", + notBefore: "1979/5/24", + notAfter: "2030/5/24", + fingerprintSha256: "D8:C5:38:8A:B7:30:1B:1B:6E:D4:7A:E6:45:25:3A:6F:9F:1A:27:61", + cert: cert + } + + return certInfo; +} + +parseCertAbstract(uri: string, certAlias: string, status: boolean): certAbstract { + let result: certAbstract; + + result = { + uri: uri, + certAlias: certAlias, + status: status, + subjectName: "CN=SwissSign Gold CA - G2,OU=,O=SwissSign", + } + + return result; +} + + +parseCMHandle(errorCode: number, handle: number, token: Uint8Array): CMHandle { + let result: CMHandle; + + result = { + errorCode: errorCode, + handle: handle, + token: token, + } + + return result; +} + +parseCredential(type: string, alias: string, keyUri: string, certNum: number, + keyNum: number, credData: Uint8Array): Credential { + let result: Credential; + + result = { + type: type, + alias: alias, + keyUri: keyUri, + certNum: certNum, + keyNum: keyNum, + credData: credData + } + + return result; +} + +parseCredentialAbstract(type: string, alias: string, keyUri: string): CredentialAbstract { + let result: CredentialAbstract; + + result = { + type: type, + alias: alias, + keyUri: keyUri + } + + return result; +} + +parseCMContext(userId: string, uid: string, packageName: string): CMContext { + let result: CMContext; + + result = { + userId: userId, + uid: uid, + packageName: packageName + } + + return result; +} + +parseCMBlob(inData: Uint8Array, alias: string): CMBlob { + let result: CMBlob; + + result = { + inData: inData, + alias: alias + } + + return result; +} + +parseCMKeyProperties(): CMKeyProperties { + let result: CMKeyProperties; + + result = { + type: "CM_URI_TYPE_APP_KEY", // Type of the key, must be CM_URI_TYPE_APP_KEY or CM_URI_TYPE_WLAN_KEY + alg: "alg", + size: 375, + padding: "padding purpose", + purpose: "purpose property", + digest: "digest property", + authType: "Sha-256", + authTimeout: "30" + } + + return result; +} + +parseCMSignatureSpec(alg: string, padding: string, digest: string, authToken: Uint8Array): CMSignatureSpec { + let result: CMSignatureSpec; + + result = { + alg: alg, + padding: padding, + digest: digest, + authToken: authToken // required only for user authentication + } + + return result; +} + +} \ No newline at end of file diff --git a/cer_manager/product/phone/src/main/module.json5 b/cer_manager/product/phone/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..081c9ae107efb1c82a641923353beab850972ecf --- /dev/null +++ b/cer_manager/product/phone/src/main/module.json5 @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "module": { + "name": "phone", + "type": "feature", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:mainability_description", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:mainability_description", + "icon": "$media:icon", + "label": "$string:entry_MainAbility", + "visible": true, + "launchType": "singleton" + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.GET_BUNDLE_INFO", + "reason": "$string:bundle_info_permission_reason" + }, + { + "name": "ohos.permission.READ_MEDIA", + "reason": "$string:read_media_permission_reason" + } + ] + } +} \ No newline at end of file diff --git a/cer_manager/product/phone/src/main/resources/base/element/color.json b/cer_manager/product/phone/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..2cb0964a3110cf149f7a6066031781d2b9c23a31 --- /dev/null +++ b/cer_manager/product/phone/src/main/resources/base/element/color.json @@ -0,0 +1,272 @@ +{ + "color": [ + { + "name": "color_333333_grey", + "value": "#333333" + }, + { + "name": "color_666666_grey", + "value": "#666666" + }, + { + "name": "color_999999_grey", + "value": "#999999" + }, + { + "name": "color_E3E3E3_grey", + "value": "#E3E3E3" + }, + { + "name": "color_D8D8D8_grey", + "value": "#D8D8D8" + }, + { + "name": "color_button_grey", + "value": "#1824310D" + }, + { + "name": "color_00000000_transparent", + "value": "#00000000" + }, + { + "name": "volume_bg_color", + "value": "#CCFFFFFF" + }, + { + "name": "white_bg_color", + "value": "#FFFFFF" + }, + { + "name": "font_color_182431", + "value": "#182431" + }, + { + "name": "font_color_007DFF", + "value": "#007DFF" + }, + { + "name": "search_no_result_text_color", + "value": "$color:font_color_182431" + }, + { + "name": "search_result_text_color", + "value": "$color:font_color_182431" + }, + { + "name": "search_result_text_color_highlight", + "value": "$color:font_color_007DFF" + }, + { + "name": "bluetooth_text_color_highlight", + "value": "$color:font_color_007DFF" + }, + { + "name": "FAFAFA", + "value": "#FAFAFA" + }, + { + "name": "DCEAF9", + "value": "#DCEAF9" + }, + { + "name": "4C89F0", + "value": "#4C89F0" + }, + { + "name": "D1D0DB", + "value": "#D1D0DB" + }, + { + "name": "cm_del_all_font_color", + "value": "#007DFF" + }, + { + "name": "cm_del_all_cancel_button_color", + "value": "#007DFF" + }, + { + "name": "cm_del_all_delete_button_color", + "value": "#FA2A2D" + }, + { + "name": "request_auth_font_color", + "value": "#182431" + }, + { + "name": "request_auth_background_color", + "value": "#FFFFFF" + }, + { + "name": "request_auth_bt_font_color", + "value": "#4C89F0" + }, + { + "name": "request_auth_color", + "value": "#E5E5E5" + }, + { + "name": "install_cancel_bt_font_color", + "value": "#007DFF" + }, + { + "name": "install_cancel_bt_bg_color", + "value": "#0d182431" + }, + { + "name": "install_confirm_bt_font_color", + "value": "#ffffffff" + }, + { + "name": "install_confirm_bt_bg_color", + "value": "#007DFF" + }, + { + "name": "install_confirm_bt_bg_disable_color", + "value": "#66007DFF" + }, + { + "name": "install_info_font_color", + "value": "#E6000000" + }, + { + "name": "credentials_app_name_color", + "value": "#182431" + }, + { + "name": "credentials_app_Toggle_selectColor", + "value": "#007DFF" + }, + { + "name": "credentials_app_title_color", + "value": "#182431" + }, + { + "name": "credentials_app_list_backgroundColor", + "value": "#FFFFFF" + }, + { + "name": "credentials_app_finishColor", + "value": "#4C89F0" + }, + { + "name": "credentials_app_finish_backgroundColor", + "value": "#FFFFFF" + }, + { + "name": "credentials_detail_keyNum_fontColor", + "value": "#000000" + }, + { + "name": "credentials_detail_close_fontColor", + "value": "#4C89F0" + }, + { + "name": "warning_delete_fontColor", + "value": "#FF0000" + }, + { + "name": "public_delete_fontColor", + "value": "#CD5C5C" + }, + { + "name": "evidenceList_TabBuilder_fontColor_182431", + "value": "#182431" + }, + { + "name": "Evidence_color", + "value": "#0D000000" + }, + { + "name": "Evidence_backgroundColor", + "value": "#F1F3F5" + }, + { + "name": "sys_list_divider_color_000000", + "value": "#0D000000" + }, + { + "name": "TrustedEvidence_TabBuilder_fontColor_182431", + "value": "#182431" + }, + { + "name": "sys_list_backgroundColor_FFFFFF", + "value": "#FFFFFF" + }, + { + "name": "user_list_divider_color_000000", + "value": "#0D000000" + }, + { + "name": "user_list_backgroundColor_FFFFFF", + "value": "#FFFFFF" + }, + { + "name": "componentUser_text_fontColor_182431", + "value": "#182431" + }, + { + "name": "ComponentSystem_text_fontColor_182431", + "value": "#182431" + }, + { + "name": "ComponentSystem_Toggle_selectedColor_007DFF", + "value": "#007DFF" + }, + { + "name": "CustomDialogExample_text_fontColor_182431", + "value": "#182431" + }, + { + "name": "CustomDialogExample_list_backgroundColor_FFFFFF", + "value": "#FFFFFF" + }, + { + "name": "CustomDialogExample_Button_backgroundColor_FFFFFF", + "value": "#FFFFFF" + }, + { + "name": "CustomDialogExample_Button_fontColor_4C89F0", + "value": "#4C89F0" + }, + { + "name": "CustomDialogExampleUser_text_fontColor_182431", + "value": "#182431" + }, + { + "name": "CustomDialogExampleUser_Flex_Toggle_selectedColor_007DFF", + "value": "#007DFF" + }, + { + "name": "CustomDialogExampleUser_Flex_firButton_backgroundColor_FFFFFF", + "value": "#FFFFFF" + }, + { + "name": "CustomDialogExampleUser_Flex_firButton_fontColor_4C89F0", + "value": "#4C89F0" + }, + { + "name": "CustomDialogExampleUser_warning_secButton_fontColor_FF0000", + "value": "#FF0000" + }, + { + "name": "CustomDialogExampleUser_Flex_secButton_backgroundColor_FFFFFF", + "value": "#FFFFFF" + }, + { + "name": "CustomDialogExampleUser_Flex_secButton_fontColor_FF0000", + "value": "#FF0000" + }, + { + "name": "DialogSubjectComponent_Text_fontColor_182431", + "value": "#182431" + }, + { + "name": "CertManager_Divider_Color_182431", + "value": "#182431" + }, + { + "name": "TrustedEvidence_tabs_backgroundColor_F1F3F5", + "value": "#F1F3F5" + } + ] +} \ No newline at end of file diff --git a/cer_manager/product/phone/src/main/resources/base/element/float.json b/cer_manager/product/phone/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..70bc6a483a3608aa1c0603a6ef6b2a5406c0cc4e --- /dev/null +++ b/cer_manager/product/phone/src/main/resources/base/element/float.json @@ -0,0 +1,1680 @@ +{ + "float": [ + { + "name": "wh_value_0", + "value": "0vp" + }, + { + "name": "wh_value_1", + "value": "1vp" + }, + { + "name": "wh_value_1_5", + "value": "1.5vp" + }, + { + "name": "wh_value_2", + "value": "2vp" + }, + { + "name": "wh_value_3", + "value": "3vp" + }, + { + "name": "wh_value_4", + "value": "4vp" + }, + { + "name": "wh_value_5", + "value": "5vp" + }, + { + "name": "wh_value_6", + "value": "6vp" + }, + { + "name": "wh_value_8", + "value": "8vp" + }, + { + "name": "wh_value_9", + "value": "9vp" + }, + { + "name": "wh_value_10", + "value": "10vp" + }, + { + "name": "wh_value_11", + "value": "11vp" + }, + { + "name": "wh_value_12", + "value": "12vp" + }, + { + "name": "wh_value_13", + "value": "13vp" + }, + { + "name": "wh_value_15", + "value": "15vp" + }, + { + "name": "wh_value_16", + "value": "16vp" + }, + { + "name": "wh_value_18", + "value": "18vp" + }, + { + "name": "wh_value_19", + "value": "19vp" + }, + { + "name": "wh_value_20", + "value": "20vp" + }, + { + "name": "wh_value_21", + "value": "21vp" + }, + { + "name": "wh_value_22", + "value": "22vp" + }, + { + "name": "wh_value_24", + "value": "24vp" + }, + { + "name": "wh_value_26", + "value": "26vp" + }, + { + "name": "wh_value_28", + "value": "28vp" + }, + { + "name": "wh_value_30", + "value": "30vp" + }, + { + "name": "wh_value_32", + "value": "32vp" + }, + { + "name": "wh_value_33", + "value": "33vp" + }, + { + "name": "wh_value_40", + "value": "40vp" + }, + { + "name": "wh_value_44", + "value": "44vp" + }, + { + "name": "wh_value_48", + "value": "48vp" + }, + { + "name": "wh_value_50", + "value": "50vp" + }, + { + "name": "wh_value_52", + "value": "52vp" + }, + { + "name": "wh_value_56", + "value": "56vp" + }, + { + "name": "wh_value_60", + "value": "60vp" + }, + { + "name": "wh_value_64", + "value": "64vp" + }, + { + "name": "wh_value_65", + "value": "65vp" + }, + { + "name": "wh_value_67", + "value": "67vp" + }, + { + "name": "wh_value_70", + "value": "70vp" + }, + { + "name": "wh_value_80", + "value": "80vp" + }, + { + "name": "wh_value_96", + "value": "96vp" + }, + { + "name": "wh_value_100", + "value": "100vp" + }, + { + "name": "wh_value_109", + "value": "109vp" + }, + { + "name": "wh_value_118", + "value": "118vp" + }, + { + "name": "wh_value_119", + "value": "119vp" + }, + { + "name": "wh_value_120", + "value": "120vp" + }, + { + "name": "wh_value_130", + "value": "1300vp" + }, + { + "name": "wh_value_152", + "value": "152vp" + }, + { + "name": "wh_value_160", + "value": "160vp" + }, + { + "name": "wh_value_200", + "value": "200vp" + }, + { + "name": "wh_value_208", + "value": "208vp" + }, + { + "name": "wh_value_210", + "value": "210vp" + }, + { + "name": "wh_value_212", + "value": "212vp" + }, + { + "name": "wh_value_216", + "value": "216vp" + }, + { + "name": "wh_value_230", + "value": "230vp" + }, + { + "name": "wh_value_248", + "value": "248vp" + }, + { + "name": "wh_value_250", + "value": "250vp" + }, + { + "name": "wh_value_263", + "value": "263vp" + }, + { + "name": "wh_value_280", + "value": "280vp" + }, + { + "name": "wh_value_298", + "value": "298vp" + }, + { + "name": "wh_value_336", + "value": "336vp" + }, + { + "name": "wh_value_362", + "value": "362vp" + }, + { + "name": "wh_value_390", + "value": "390vp" + }, + { + "name": "wh_value_400", + "value": "400vp" + }, + { + "name": "wh_value_410", + "value": "410vp" + }, + { + "name": "wh_value_620", + "value": "620vp" + }, + { + "name": "wh_value_720", + "value": "720vp" + }, + { + "name": "font_35", + "value": "35fp" + }, + { + "name": "font_10", + "value": "10fp" + }, + { + "name": "font_12", + "value": "12fp" + }, + { + "name": "font_14", + "value": "14fp" + }, + { + "name": "font_16", + "value": "16fp" + }, + { + "name": "font_17", + "value": "17fp" + }, + { + "name": "font_18", + "value": "18fp" + }, + { + "name": "font_20", + "value": "20fp" + }, + { + "name": "font_21", + "value": "21fp" + }, + { + "name": "font_22", + "value": "22fp" + }, + { + "name": "font_24", + "value": "24fp" + }, + { + "name": "font_28", + "value": "28fp" + }, + { + "name": "font_30", + "value": "30fp" + }, + { + "name": "font_50", + "value": "50fp" + }, + { + "name": "lineHeight_19", + "value": "19vp" + }, + { + "name": "lineHeight_21", + "value": "21vp" + }, + { + "name": "lineHeight_22", + "value": "22vp" + }, + { + "name": "lineHeight_33", + "value": "33vp" + }, + { + "name": "lineHeight_41", + "value": "41vp" + }, + { + "name": "distance_1", + "value": "1vp" + }, + { + "name": "distance_2", + "value": "2vp" + }, + { + "name": "distance_4", + "value": "4vp" + }, + { + "name": "distance_6", + "value": "6vp" + }, + { + "name": "distance_8", + "value": "8vp" + }, + { + "name": "distance_9", + "value": "9vp" + }, + { + "name": "distance_9_5", + "value": "9.5vp" + }, + { + "name": "distance_10", + "value": "10vp" + }, + { + "name": "distance_11", + "value": "11vp" + }, + { + "name": "distance_11_5", + "value": "11.5vp" + }, + { + "name": "distance_12", + "value": "12vp" + }, + { + "name": "distance_13", + "value": "13vp" + }, + { + "name": "distance_14", + "value": "14vp" + }, + { + "name": "distance_15", + "value": "15vp" + }, + { + "name": "distance_16", + "value": "16vp" + }, + { + "name": "distance_17", + "value": "17vp" + }, + { + "name": "distance_18", + "value": "18vp" + }, + { + "name": "distance_19", + "value": "19vp" + }, + { + "name": "distance_19_5", + "value": "19.5vp" + }, + { + "name": "distance_20", + "value": "20vp" + }, + { + "name": "distance_21", + "value": "21vp" + }, + { + "name": "distance_22_5", + "value": "22.5vp" + }, + { + "name": "distance_24", + "value": "24vp" + }, + { + "name": "distance_26", + "value": "26vp" + }, + { + "name": "distance_27_5", + "value": "27.5vp" + }, + { + "name": "distance_30", + "value": "30vp" + }, + { + "name": "distance_32", + "value": "32vp" + }, + { + "name": "distance_36", + "value": "36vp" + }, + { + "name": "distance_48", + "value": "48vp" + }, + { + "name": "distance_64", + "value": "64vp" + }, + { + "name": "distance_66", + "value": "66vp" + }, + { + "name": "distance_80", + "value": "80vp" + }, + { + "name": "distance_96", + "value": "96vp" + }, + { + "name": "sys_corner_radius_clicked", + "value": "8vp" + }, + { + "name": "sys_elements_margin_vertical_l", + "value": "16vp" + }, + { + "name": "sys_elements_margin_vertical_m", + "value": "8vp" + }, + { + "name": "sys_elements_margin_horizontal_l", + "value": "16vp" + }, + { + "name": "sys_elements_margin_horizontal_m", + "value": "16vp" + }, + { + "name": "page_margin_horizontal", + "value": "24vp" + }, + { + "name": "square_click_image_size", + "value": "48vp" + }, + { + "name": "control_common_font_size", + "value": "20fp" + }, + { + "name": "item_common_vertical_margin", + "value": "20vp" + }, + { + "name": "item_common_horizontal_margin", + "value": "24vp" + }, + { + "name": "item_icon_size", + "value": "24vp" + }, + { + "name": "item_arrow_width", + "value": "12vp" + }, + { + "name": "slider_text_padding_left", + "value": "5vp" + }, + { + "name": "page_header_height", + "value": "56vp" + }, + { + "name": "volume_border_radius", + "value": "15vp" + }, + { + "name": "radius_12", + "value": "12vp" + }, + { + "name": "radius_20", + "value": "20vp" + }, + { + "name": "radius_24", + "value": "24vp" + }, + { + "name": "radius_32", + "value": "32vp" + }, + { + "name": "radius_40", + "value": "40vp" + }, + { + "name": "search_placeholder_font", + "value": "22fp" + }, + { + "name": "search_input_height", + "value": "40vp" + }, + { + "name": "search_input_margin_start", + "value": "64vp" + }, + { + "name": "search_input_horizontal_margin", + "value": "8vp" + }, + { + "name": "search_input_border_radius", + "value": "20vp" + }, + { + "name": "search_no_result_image_size", + "value": "160vp" + }, + { + "name": "search_no_result_text_font_size", + "value": "14fp" + }, + { + "name": "search_no_result_margin_top", + "value": "174vp" + }, + { + "name": "search_item_height", + "value": "72vp" + }, + { + "name": "search_result_item_title_font_size", + "value": "16vp" + }, + { + "name": "search_result_item_summary_font_size", + "value": "14fp" + }, + { + "name": "slider_image_width", + "value": "40vp" + }, + { + "name": "slider_image_height", + "value": "40vp" + }, + { + "name": "slider_image_margin", + "value": "15vp" + }, + { + "name": "audio_subtitle_font", + "value": "18fp" + }, + { + "name": "audio_subtitle_margin_left", + "value": "10vp" + }, + { + "name": "audio_subtitle_margin_bottom", + "value": "5vp" + }, + { + "name": "audio_title_summary_margin_left", + "value": "15vp" + }, + { + "name": "audio_summary_subtitle_margin_bottom", + "value": "10vp" + }, + { + "name": "audio_subtitle_margin_top", + "value": "10vp" + }, + { + "name": "audio_sound_mode_outer_height", + "value": "280vp" + }, + { + "name": "audio_sound_mode_inner_padding_top", + "value": "15vp" + }, + { + "name": "audio_sound_mode_inner_padding_bottom", + "value": "15vp" + }, + { + "name": "audio_sound_mode_outer_padding", + "value": "16vp" + }, + { + "name": "audio_sound_mode_item_inner_padding_top", + "value": "5vp" + }, + { + "name": "audio_sound_mode_border_width", + "value": "1vp" + }, + { + "name": "audio_sound_mode_border_radius", + "value": "15vp" + }, + { + "name": "audio_sound_mode_image_size", + "value": "40vp" + }, + { + "name": "audio_sound_mode_text_margin_top", + "value": "16vp" + }, + { + "name": "audio_sound_mode_font_size", + "value": "20fp" + }, + { + "name": "audio_sound_mode_radio_size", + "value": "36vp" + }, + { + "name": "audio_image_common_size", + "value": "50vp" + }, + { + "name": "audio_image_margin_right", + "value": "10vp" + }, + { + "name": "audio_subtitle_font_size", + "value": "18fp" + }, + { + "name": "audio_margin_left", + "value": "15vp" + }, + { + "name": "audio_start_end_margin_left", + "value": "15vp" + }, + { + "name": "audio_icon_height", + "value": "60vp" + }, + { + "name": "audio_no_icon_height", + "value": "70vp" + }, + { + "name": "audio_slider_height", + "value": "250vp" + }, + { + "name": "audio_volume_height", + "value": "280vp" + }, + { + "name": "audio_border_width", + "value": "1vp" + }, + { + "name": "audio_border_radius", + "value": "15vp" + }, + { + "name": "audio_volume_component_padding", + "value": "16vp" + }, + { + "name": "restore_factory_font_size", + "value": "20fp" + }, + { + "name": "restore_factory_button_width", + "value": "186vp" + }, + { + "name": "restore_factory_button_height", + "value": "40vp" + }, + { + "name": "switch_title_subtitle_size", + "value": "20fp" + }, + { + "name": "switch_component_margin", + "value": "12vp" + }, + { + "name": "switch_toggle_width", + "value": "36vp" + }, + { + "name": "switch_toggle_height", + "value": "20vp" + }, + { + "name": "switch_component_height", + "value": "70vp" + }, + { + "name": "application_common_size", + "value": "45vp" + }, + { + "name": "application_button_subtitle_size", + "value": "16fp" + }, + { + "name": "application_button_height", + "value": "40vp" + }, + { + "name": "storage_common_margin", + "value": "15vp" + }, + { + "name": "location_font_size", + "value": "16fp" + }, + { + "name": "location_common_margin", + "value": "15vp" + }, + { + "name": "storage_data_panel_height", + "value": "230vp" + }, + { + "name": "password_list_item_height", + "value": "48vp" + }, + { + "name": "password_list_item_title_font_size", + "value": "16vp" + }, + { + "name": "password_input_message_vertical_margin", + "value": "20vp" + }, + { + "name": "password_count_down_view_vertical_margin", + "value": "20vp" + }, + { + "name": "password_input_button_space", + "value": "10vp" + }, + { + "name": "password_input_button_margin_top", + "value": "40vp" + }, + { + "name": "radio_component_height", + "value": "30vp" + }, + { + "name": "radio_component_margin_bottom_right", + "value": "15vp" + }, + { + "name": "dataPanel_distance", + "value": "320vp" + }, + { + "name": "dataPanel_proportion_font_size", + "value": "66.67fp" + }, + { + "name": "dataPanel_percent_font_size", + "value": "17.78fp" + }, + { + "name": "dataPanel_used_font_size", + "value": "17.78fp" + }, + { + "name": "location_toggle_width", + "value": "36vp" + }, + { + "name": "location_toggle_height", + "value": "20vp" + }, + { + "name": "location_toggle_margin", + "value": "12vp" + }, + { + "name": "wh_value_72", + "value": "72vp" + }, + { + "name": "switch_summary_margin", + "value": "2vp" + }, + { + "name": "single_item_height", + "value": "48vp" + }, + { + "name": "wh_value_240", + "value": "240vp" + }, + { + "name": "wh_value_245", + "value": "245vp" + }, + { + "name": "wh_value_260", + "value": "260vp" + }, + { + "name": "wh_value_288", + "value": "288vp" + }, + { + "name": "wh_value_324", + "value": "324vp" + }, + { + "name": "opacity_0_2", + "value": "0.2" + }, + { + "name": "paired_device_button_width", + "value": "186vp" + }, + { + "name": "component_button_width", + "value": "263vp" + }, + { + "name": "component_button_width_phone", + "value": "148vp" + }, + { + "name": "pinCode_font_size", + "value": "32fp" + }, + { + "name": "deviceName_button_width", + "value": "263vp" + }, + { + "name": "applicationInfo_button_width", + "value": "324vp" + }, + { + "name": "passwordSetting_button_width", + "value": "261vp" + }, + { + "name": "dialog_16", + "value": "0vp" + }, + { + "name": "dialog_118", + "value": "118vp" + }, + { + "name": "wh_4", + "value": "4vp" + }, + { + "name": "wh_10", + "value": "10vp" + }, + { + "name": "wh_20", + "value": "20vp" + }, + { + "name": "wh_23", + "value": "23vp" + }, + { + "name": "wh_24", + "value": "24vp" + }, + { + "name": "wh_35", + "value": "16vp" + }, + { + "name": "wh_37", + "value": "0vp" + }, + { + "name": "wh_42", + "value": "42vp" + }, + { + "name": "wh_48", + "value": "52vp" + }, + { + "name": "wh_192", + "value": "192vp" + }, + { + "name": "wh_205", + "value": "205vp" + }, + { + "name": "wh_263", + "value": "263vp" + }, + { + "name": "wh_600", + "value": "600vp" + }, + { + "name": "wh_hed_14", + "value": "0vp" + }, + { + "name": "padding_24", + "value": "24vp" + }, + { + "name": "padding_26", + "value": "26vp" + }, + { + "name": "wh_padding_32", + "value": "32vp" + }, + { + "name": "wh_padding_33", + "value": "33vp" + }, + { + "name": "wh_padding_35", + "value": "35vp" + }, + { + "name": "wh_padding_48", + "value": "48vp" + }, + { + "name": "wh_padding_112", + "value": "112vp" + }, + { + "name": "wh_padding_128", + "value": "128vp" + }, + { + "name": "wh_padding_212", + "value": "212vp" + }, + { + "name": "dataPanel_proportion_font_size_1", + "value": "60fp" + }, + { + "name": "dataPanel_percent_font_size_1", + "value": "16vp" + }, + { + "name": "dataPanel_used_font_size_1", + "value": "14vp" + }, + { + "name": "divider_wh", + "value": "0.5vp" + }, + { + "name": "progress_bottom", + "value": "24vp" + }, + { + "name": "head_font_20", + "value": "20vp" + }, + { + "name": "opacity_100_60", + "value": "0.6" + }, + { + "name": "request_auth_radio_width", + "value": "36vp" + }, + { + "name": "request_auth_radio_height", + "value": "20vp" + }, + { + "name": "request_auth_dialog_height", + "value": "500vp" + }, + { + "name": "request_auth_divider_endMargin", + "value": "15vp" + }, + { + "name": "request_auth_borderRadius", + "value": "24vp" + }, + { + "name": "request_auth_strokeWidth", + "value": "1" + }, + { + "name": "credentials_app_image_wh", + "value": "40vp" + }, + { + "name": "credentials_app_image_hg", + "value": "40vp" + }, + { + "name": "credentials_app_image_margin", + "value": "50vp" + }, + { + "name": "credentials_app_name_margin", + "value": "16vp" + }, + { + "name": "credentials_app_Toggle_margin", + "value": "35vp" + }, + { + "name": "credentials_app_Toggle_wh", + "value": "36vp" + }, + { + "name": "credentials_app_Toggle_hg", + "value": "20vp" + }, + { + "name": "credentials_app_title_margin_bottom", + "value": "10vp" + }, + { + "name": "credentials_app_title_margin_left", + "value": "16vp" + }, + { + "name": "credentials_app_title_margin_top", + "value": "24vp" + }, + { + "name": "credentials_app_ListItem_margin_top", + "value": "30vp" + }, + { + "name": "credentials_app_List_margin_bottom", + "value": "20vp" + }, + { + "name": "credentials_app_Flex_margin_bottom", + "value": "20vp" + }, + { + "name": "credentials_app_dialog_margin_top", + "value": "31vp" + }, + { + "name": "credentials_app_list_hg", + "value": "360vp" + }, + { + "name": "credentials_app_list_margin_top", + "value": "20vp" + }, + { + "name": "credentials_app_list_padding_top", + "value": "4vp" + }, + { + "name": "credentials_app_list_padding_bottom", + "value": "14vp" + }, + { + "name": "credentials_app_list_borderRadius", + "value": "24vp" + }, + { + "name": "credentials_app_finish_margin_top", + "value": "10vp" + }, + { + "name": "credentials_app_finish_margin_bottom", + "value": "20vp" + }, + { + "name": "private_detail_title_margin_left", + "value": "16vp" + }, + { + "name": "private_detail_title_margin_top", + "value": "24vp" + }, + { + "name": "private_detail_title_margin_bottom", + "value": "20vp" + }, + { + "name": "private_detail_Text_margin_bottom", + "value": "10vp" + }, + { + "name": "private_detail_opacity", + "value": "0.7" + }, + { + "name": "private_detail_keyNum_margin_left", + "value": "30vp" + }, + { + "name": "private_detail_close_margin", + "value": "24vp" + }, + { + "name": "private_detail_margin", + "value": "10vp" + }, + { + "name": "managerAuthApp_hg", + "value": "33vp" + }, + { + "name": "managerAuthApp_image_wh", + "value": "12vp" + }, + { + "name": "managerAuthApp_image_hg", + "value": "24vp" + }, + { + "name": "managerAuthApp_image_margin", + "value": "24vp" + }, + { + "name": "managerAuthApp_image_opacity", + "value": "0.2" + }, + { + "name": "managerAuthApp_margin", + "value": "6vp" + }, + { + "name": "publicDetailsCancel_marginTop", + "value": "20vp" + }, + { + "name": "publicDetailsCancel_marginBottom", + "value": "24vp" + }, + { + "name": "publicList_hg", + "value": "33vp" + }, + { + "name": "publicList_margin", + "value": "12vp" + }, + { + "name": "publicList_image_wh", + "value": "12vp" + }, + { + "name": "publicList_image_hg", + "value": "24vp" + }, + { + "name": "publicList_image_margin", + "value": "12vp" + }, + { + "name": "publicList_image_opacity", + "value": "0.2" + }, + { + "name": "publicList_height", + "value": "64vp" + }, + { + "name": "publicList_borderRadius", + "value": "24vp" + }, + { + "name": "publicList_item_hg", + "value": "96vp" + }, + { + "name": "Evidence_wh", + "value": "672vp" + }, + { + "name": "Evidence_margin", + "value": "24vp" + }, + { + "name": "Evidence_strokeWidth", + "value": "1" + }, + { + "name": "Evidence_startMargin", + "value": "15vp" + }, + { + "name": "Evidence_endMargin", + "value": "15vp" + }, + { + "name": "Evidence_borderRadius", + "value": "24vp" + }, + { + "name": "Evidence_barWidth", + "value": "672vp" + }, + { + "name": "Evidence_barHeight", + "value": "56vp" + }, + { + "name": "evidenceList_TabBuilder_Text_fontSize_value", + "value": "20vp" + }, + { + "name": "evidenceList_TabBuilder_Text_padding_left_value", + "value": "57vp" + }, + { + "name": "evidenceList_TabBuilder_Text_padding_top_value", + "value": "22vp" + }, + { + "name": "evidenceList_TabBuilder_Text_padding_opacity_value", + "value": "0.6" + }, + { + "name": "evidenceList_TabBuilder_Divider_width_value", + "value": "25vp" + }, + { + "name": "evidenceList_TabBuilder_Divider_padding_left_value", + "value": "57vp" + }, + { + "name": "evidenceList_TabBuilder_Divider_padding_top_value", + "value": "5vp" + }, + { + "name": "TrustedEvidence_TabBuilder_Text_fontSize_value", + "value": "16vp" + }, + { + "name": "TrustedEvidence_TabBuilder_Text_padding_left_value", + "value": "57vp" + }, + { + "name": "TrustedEvidence_TabBuilder_Text_padding_top_value", + "value": "18vp" + }, + { + "name": "TrustedEvidence_TabBuilder_Text_padding_opacity_value", + "value": "0.6" + }, + { + "name": "TrustedEvidence_TabBuilder_Divider_width_value", + "value": "48vp" + }, + { + "name": "TrustedEvidence_TabBuilder_Divider_padding_left_value", + "value": "57vp" + }, + { + "name": "TrustedEvidence_TabBuilder_Divider_padding_top_value", + "value": "7vp" + }, + { + "name": "sys_list_divider_strokeWidth_value", + "value": "1" + }, + { + "name": "sys_list_divider_startMargin_value", + "value": "24vp" + }, + { + "name": "sys_list_divider_endMargin_value", + "value": "24vp" + }, + { + "name": "sys_list_divider_borderRadius_value", + "value": "24vp" + }, + { + "name": "user_list_divider_strokeWidth_value", + "value": "1" + }, + { + "name": "user_list_divider_startMargin_value", + "value": "24vp" + }, + { + "name": "user_list_divider_endMargin_value", + "value": "24vp" + }, + { + "name": "user_list_divider_borderRadius_value", + "value": "24vp" + }, + { + "name": "tabs_barWidth_value", + "value": "192vp" + }, + { + "name": "tabs_barHeight_value", + "value": "56vp" + }, + { + "name": "componentUser_firText_height_value", + "value": "22vp" + }, + { + "name": "componentUser_firText_fontSize_value", + "value": "22vp" + }, + { + "name": "componentUser_firText_margin_left_value", + "value": "24vp" + }, + { + "name": "componentUser_secText_height_value", + "value": "19vp" + }, + { + "name": "componentUser_secText_fontSize_value", + "value": "18vp" + }, + { + "name": "componentUser_secText_margin_left_value", + "value": "24vp" + }, + { + "name": "componentUser_secText_opacity_value", + "value": "0.6" + }, + { + "name": "componentUser_thdText_fontSize_value", + "value": "18vp" + }, + { + "name": "componentUser_thdText_margin_value", + "value": "4vp" + }, + { + "name": "componentUser_thdText_opacity_value", + "value": "0.6" + }, + { + "name": "componentUser_image_width_value", + "value": "12vp" + }, + { + "name": "componentUser_image_height_value", + "value": "24vp" + }, + { + "name": "componentUser_image_margin_right_value", + "value": "24vp" + }, + { + "name": "componentUser_image_opacity_value", + "value": "0.2" + }, + { + "name": "componentUser_flex_height_value", + "value": "64vp" + }, + { + "name": "componentUser_flex_borderRadius_value", + "value": "24vp" + }, + { + "name": "ComponentSystem_firText_height_value", + "value": "22vp" + }, + { + "name": "ComponentSystem_firText_fontSize_value", + "value": "22vp" + }, + { + "name": "ComponentSystem_firText_margin_left_value", + "value": "24vp" + }, + { + "name": "ComponentSystem_secText_height_value", + "value": "19vp" + }, + { + "name": "ComponentSystem_secText_fontSize_value", + "value": "18vp" + }, + { + "name": "ComponentSystem_secText_margin_left_value", + "value": "24vp" + }, + { + "name": "ComponentSystem_secText_opacity_value", + "value": "0.6" + }, + { + "name": "ComponentSystem_Toggle_margin_right_value", + "value": "24vp" + }, + { + "name": "ComponentSystem_Toggle_width_value", + "value": "36vp" + }, + { + "name": "ComponentSystem_Toggle_height_value", + "value": "20vp" + }, + { + "name": "ComponentSystem_Flex_height_value", + "value": "64vp" + }, + { + "name": "ComponentSystem_Flex_borderRadius_value", + "value": "24vp" + }, + { + "name": "CustomDialogExample_firText_fontSize_value", + "value": "24vp" + }, + { + "name": "CustomDialogExample_firText_margin_top_value", + "value": "18vp" + }, + { + "name": "CustomDialogExample_firText_margin_left_value", + "value": "24vp" + }, + { + "name": "CustomDialogExample_secText_fontSize_value", + "value": "24vp" + }, + { + "name": "CustomDialogExample_secText_margin_top_value", + "value": "24vp" + }, + { + "name": "CustomDialogExample_secText_margin_left_value", + "value": "24vp" + }, + { + "name": "CustomDialogExample_firListItem_Text_fontSize_value", + "value": "17vp" + }, + { + "name": "CustomDialogExample_firListItem_Text_margin_left_value", + "value": "24vp" + }, + { + "name": "CustomDialogExample_firListItem_Text_margin_bottom_value", + "value": "6vp" + }, + { + "name": "CustomDialogExample_secListItem_Text_fontSize_value", + "value": "17vp" + }, + { + "name": "CustomDialogExample_secListItem_Text_margin_left_value", + "value": "20vp" + }, + { + "name": "CustomDialogExample_secListItem_Text_margin_top_value", + "value": "13vp" + }, + { + "name": "CustomDialogExample_secListItem_Text_margin_bottom_value", + "value": "8vp" + }, + { + "name": "CustomDialogExample_thdListItem_Text_fontSize_value", + "value": "17vp" + }, + { + "name": "CustomDialogExample_thdListItem_Text_margin_left_value", + "value": "20vp" + }, + { + "name": "CustomDialogExample_thdListItem_Text_margin_top_value", + "value": "13vp" + }, + { + "name": "CustomDialogExample_thdListItem_Text_margin_bottom_value", + "value": "8vp" + }, + { + "name": "CustomDialogExample_list_height_value", + "value": "342vp" + }, + { + "name": "CustomDialogExample_list_margin_top_value", + "value": "21vp" + }, + { + "name": "CustomDialogExample_list_padding_top_value", + "value": "4vp" + }, + { + "name": "CustomDialogExample_list_padding_bottom_value", + "value": "4vp" + }, + { + "name": "CustomDialogExample_list_borderRadius_value", + "value": "24vp" + }, + { + "name": "CustomDialogExample_Column_margin_top_value", + "value": "6vp" + }, + { + "name": "CustomDialogExample_Button_margin_top_value", + "value": "2vp" + }, + { + "name": "CustomDialogExample_Column_height_value", + "value": "576vp" + }, + { + "name": "CustomDialogExampleUser_Flex_firText_fontSize_value", + "value": "22vp" + }, + { + "name": "CustomDialogExampleUser_Flex_firText_margin_left_value", + "value": "16vp" + }, + { + "name": "CustomDialogExampleUser_Flex_secText_fontSize_value", + "value": "18vp" + }, + { + "name": "CustomDialogExampleUser_Flex_secText_margin_left_value", + "value": "16vp" + }, + { + "name": "CustomDialogExampleUser_Flex_secText_opacity_value", + "value": "0.6" + }, + { + "name": "CustomDialogExampleUser_Flex_Toggle_margin_right_value", + "value": "37vp" + }, + { + "name": "CustomDialogExampleUser_Flex_Toggle_width_value", + "value": "36vp" + }, + { + "name": "CustomDialogExampleUser_Flex_Toggle_height_value", + "value": "20vp" + }, + { + "name": "CustomDialogExampleUser_Flex_height_value", + "value": "64vp" + }, + { + "name": "CustomDialogExampleUser_Flex_margin_top_value", + "value": "24vp" + }, + { + "name": "CustomDialogExampleUser_list_height_value", + "value": "374vp" + }, + { + "name": "CustomDialogExampleUser_list_padding_bottom_value", + "value": "14vp" + }, + { + "name": "CustomDialogExampleUser_Column_margin_top_value", + "value": "6vp" + }, + { + "name": "CustomDialogExampleUser_Flex_Button_margin_top_value", + "value": "10vp" + }, + { + "name": "CustomDialogExampleUser_Column_felx_height_value", + "value": "80vp" + }, + { + "name": "CustomDialogExampleUser_Column_height_value", + "value": "614vp" + }, + { + "name": "DialogSubjectComponent_Text_fontSize_value", + "value": "17vp" + }, + { + "name": "DialogSubjectComponent_Text_margin_left_value", + "value": "20vp" + }, + { + "name": "DialogSubjectComponent_Text_margin_top_value", + "value": "10vp" + }, + { + "name": "authorDialog_size", + "value": "500vp" + }, + { + "name": "appDialog_size", + "value": "340vp" + }, + { + "name": "privateDialog_size", + "value": "260vp" + }, + { + "name": "deleteAllDialog_size", + "value": "160vp" + } + ] +} \ No newline at end of file diff --git a/cer_manager/product/phone/src/main/resources/base/element/string.json b/cer_manager/product/phone/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..9428289c02b9017f8f847d9db2c5458efaa2f339 --- /dev/null +++ b/cer_manager/product/phone/src/main/resources/base/element/string.json @@ -0,0 +1,294 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "证书管理FA" + }, + { + "name": "mainability_description", + "value": "ETS_Empty Feature Ability" + }, + { + "name": "bundle_info_permission_reason", + "value": "need to get bundle info from uid" + }, + { + "name": "read_media_permission_reason", + "value": "need to get file obj from media" + }, + { + "name": "version", + "value": "版本 " + }, + { + "name": "certificateTab", + "value": "证书与凭据" + }, + { + "name": "certificateManage", + "value": "证书管理" + }, + { + "name": "trustedEvidence", + "value": "受信任的证书" + }, + { + "name": "userEvidence", + "value": "凭据列表" + }, + { + "name": "installInStorageDevice", + "value": "从存储设备安装" + }, + { + "name": "installCertificateFailed", + "value": "从存储设备安装失败" + }, + { + "name": "certificatePwdTab", + "value": "提取证书" + }, + { + "name": "certificateAliasTab", + "value": "设置证书" + }, + { + "name": "certificatePwdInfo", + "value": "输入证书密码以提取" + }, + { + "name": "certificateAliasInfo", + "value": "输入证书名称" + }, + { + "name": "deleteAllCred", + "value": "删除所有证书与凭据" + }, + + + { + "name": "deleteAllCredDialogTitle", + "value": "删除所有证书与凭据" + }, + { + "name": "deleteAllCredDialogMessage", + "value": "所有用户证书与凭据将被永久删除。是否删除?" + }, + { + "name": "deleteAllCredCancel", + "value": "取消" + }, + { + "name": "deleteAllCredDelete", + "value": "删除" + }, + { + "name": "pickCredToAuth", + "value": "选择证书授权" + }, + { + "name": "requestAuthMsg", + "value": "应用\"%s\"请求使用证书。选择一个证书可让该应用对服务器使用此身份凭证。该应用已将请求服务标识为\"localhost\",您只应向信任的应用授予使用证书的权限。" + }, + { + "name": "requestAuthCancel", + "value": "拒绝" + }, + { + "name": "requestAuthFinish", + "value": "授权" + }, + { + "name": "requestFailPromptMsg", + "value": "授权失败,无效AppUid" + }, + { + "name": "installPwdInputCancel", + "value": "取消" + }, + { + "name": "installPwdInputConfirm", + "value": "提取" + }, + { + "name": "installAliasInputCancel", + "value": "取消" + }, + { + "name": "installAliasInputConfirm", + "value": "确定" + }, + { + "name": "installAliasInputInfo", + "value": "注:此证书颁发者可能会检查进出设备的所有流量\n该数据包包含:CA证书" + }, + { + "name": "managerAuthApp", + "value": "管理授权应用" + }, + { + "name": "cancelAuthApp", + "value": "取消" + }, + { + "name": "finishAuthApp", + "value": "完成" + }, + { + "name": "evidenceDetails", + "value": "凭据详情" + }, + { + "name": "entryContains", + "value": "此条目包含:" + }, + { + "name": "keyNum", + "value": " %s个用户密钥" + }, + { + "name": "userCerNum", + "value": " %s个用户证书" + }, + { + "name": "privateDetailsClose", + "value": "关闭" + }, + { + "name": "publicDetailsCancel", + "value": "取消" + }, + { + "name": "publicDetailsDelete", + "value": "删除" + }, + { + "name": "warning_title", + "value": "删除凭据" + }, + { + "name": "warning_message", + "value": "删除后,被授权此凭据的应用将无法正常使用。是否删除?" + }, + { + "name": "warning_cancel", + "value": "取消" + }, + { + "name": "warning_delete", + "value": "删除" + }, + { + "name": "tabName_public", + "value": "公共" + }, + { + "name": "tabName_private", + "value": "私有" + }, + { + "name": "system", + "value": "系统" + }, + { + "name": "user", + "value": "用户" + }, + { + "name": "CustomDialogExample_firText", + "value": "证书详情" + }, + { + "name": "CustomDialogExample_firListItem_text", + "value": "颁发给:" + }, + { + "name": "CustomDialogExample_secListItem_text", + "value": "颁发者:" + }, + { + "name": "CustomDialogExample_thdListItem_text", + "value": "有效期:" + }, + { + "name": "CustomDialogExample_Button_text", + "value": "取消" + }, + { + "name": "CustomDialogExample_Button_on", + "value": "启用" + }, + { + "name": "CustomDialogExample_Button_off", + "value": "禁用" + }, + { + "name": "CustomDialogExampleUser_Status_true", + "value": "已启用" + }, + { + "name": "CustomDialogExampleUser_Status_false", + "value": "已禁用" + }, + { + "name": "CustomDialogExampleUser_Flex_firButton_text", + "value": "取消" + }, + { + "name": "CustomDialogExampleUser_Flex_secButton_text", + "value": "删除" + }, + { + "name": "CustomDialogExampleUser_warning_Button_text", + "value": "取消" + }, + { + "name": "CustomDialogExampleUser_warning_Button_title_text", + "value": "删除证书" + }, + { + "name": "CustomDialogExampleUser_warning_Button_message_text", + "value": "删除后,被授权此证书的应用将无法正常使用。是否删除?" + }, + { + "name": "CustomDialogExampleUser_warning_firButton_text", + "value": "取消" + }, + { + "name": "CustomDialogExampleUser_warning_secButton_text", + "value": "删除" + }, + { + "name": "DialogSubjectComponent_firText", + "value": "常用名称:" + }, + { + "name": "DialogSubjectComponent_secText", + "value": "组织:" + }, + { + "name": "DialogSubjectComponent_thdText", + "value": "组织单位:" + }, + { + "name": "DialogSubjectComponent_fouText", + "value": "序列号:" + }, + { + "name": "DialogSubjectComponent_fifText", + "value": "颁发时间:" + }, + { + "name": "DialogSubjectComponent_sixText", + "value": "有效期至:" + }, + { + "name": "CustomDialogExample_fouListItem_text", + "value": "指纹:" + }, + { + "name": "CustomDialogExample_FingerPrint_text", + "value": "SHA-256 指纹:" + } + ] +} \ No newline at end of file diff --git a/cer_manager/product/phone/src/main/resources/base/media/ic_back.svg b/cer_manager/product/phone/src/main/resources/base/media/ic_back.svg new file mode 100644 index 0000000000000000000000000000000000000000..50e4ecd57e4c97b837c830ed7823348a367368f4 --- /dev/null +++ b/cer_manager/product/phone/src/main/resources/base/media/ic_back.svg @@ -0,0 +1,13 @@ + + + Public/ic_public_back + + + + + + + + + + \ No newline at end of file diff --git a/cer_manager/product/phone/src/main/resources/base/media/ic_close.svg b/cer_manager/product/phone/src/main/resources/base/media/ic_close.svg new file mode 100644 index 0000000000000000000000000000000000000000..e895e8115781be6fed23a875584f2ac7f024adbf --- /dev/null +++ b/cer_manager/product/phone/src/main/resources/base/media/ic_close.svg @@ -0,0 +1,3 @@ + + +_ic \ No newline at end of file diff --git a/cer_manager/product/phone/src/main/resources/base/media/ic_delete.svg b/cer_manager/product/phone/src/main/resources/base/media/ic_delete.svg new file mode 100644 index 0000000000000000000000000000000000000000..17176152fca3adb917c6b3e13faf346c98a26051 --- /dev/null +++ b/cer_manager/product/phone/src/main/resources/base/media/ic_delete.svg @@ -0,0 +1,13 @@ + + + xxxhdpi/ic_delete + + + + + + + + + + \ No newline at end of file diff --git a/cer_manager/product/phone/src/main/resources/base/media/ic_move.svg b/cer_manager/product/phone/src/main/resources/base/media/ic_move.svg new file mode 100644 index 0000000000000000000000000000000000000000..578b6e5f25115861bdbd922925bc9418fcef87f3 --- /dev/null +++ b/cer_manager/product/phone/src/main/resources/base/media/ic_move.svg @@ -0,0 +1 @@ +ic \ No newline at end of file diff --git a/cer_manager/product/phone/src/main/resources/base/media/ic_public_cancel.svg b/cer_manager/product/phone/src/main/resources/base/media/ic_public_cancel.svg new file mode 100644 index 0000000000000000000000000000000000000000..7885cdc3c832582c70ac5e7032a92ad39d30c334 --- /dev/null +++ b/cer_manager/product/phone/src/main/resources/base/media/ic_public_cancel.svg @@ -0,0 +1,13 @@ + + + Public/ic_public_cancel + + + + + + + + + + \ No newline at end of file diff --git a/cer_manager/product/phone/src/main/resources/base/media/ic_public_close.svg b/cer_manager/product/phone/src/main/resources/base/media/ic_public_close.svg new file mode 100644 index 0000000000000000000000000000000000000000..cc18043aa68518e60f90954030ad82f97648d244 --- /dev/null +++ b/cer_manager/product/phone/src/main/resources/base/media/ic_public_close.svg @@ -0,0 +1,13 @@ + + + Public/ic_public_close + + + + + + + + + + \ No newline at end of file diff --git a/cer_manager/product/phone/src/main/resources/base/media/ic_settings_arrow.svg b/cer_manager/product/phone/src/main/resources/base/media/ic_settings_arrow.svg new file mode 100644 index 0000000000000000000000000000000000000000..ff6293ce432d79ed6c50d61d430ee79fe2e2dad2 --- /dev/null +++ b/cer_manager/product/phone/src/main/resources/base/media/ic_settings_arrow.svg @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + diff --git a/cer_manager/product/phone/src/main/resources/base/media/icon.png b/cer_manager/product/phone/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/cer_manager/product/phone/src/main/resources/base/media/icon.png differ diff --git a/cer_manager/product/phone/src/main/resources/base/media/icon_default.png b/cer_manager/product/phone/src/main/resources/base/media/icon_default.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/cer_manager/product/phone/src/main/resources/base/media/icon_default.png differ diff --git a/cer_manager/product/phone/src/main/resources/base/profile/main_pages.json b/cer_manager/product/phone/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..c7c5c8d187aaeaeb55bc451da5c702f24f14328e --- /dev/null +++ b/cer_manager/product/phone/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,10 @@ +{ + "src": [ + "pages/certManagerFa", + "pages/certPwdInput", + "pages/trustedCa", + "pages/cerEvidenceFa", + "pages/requestAuth", + "pages/certInstallAliasInput" + ] +} diff --git a/cer_manager/product/phone/src/main/resources/en_US/element/string.json b/cer_manager/product/phone/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..c6e9eb533896dd598f14805913e857caa7f1cf09 --- /dev/null +++ b/cer_manager/product/phone/src/main/resources/en_US/element/string.json @@ -0,0 +1,286 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "Certificate Manager FA" + }, + { + "name": "mainability_description", + "value": "ETS_Empty Feature Ability" + }, + { + "name": "version", + "value": "Version " + }, + { + "name": "certificateTab", + "value": "Certificate and Credential" + }, + { + "name": "certificateManage", + "value": "Certificate Manager" + }, + { + "name": "trustedEvidence", + "value": "Trusted Certificate" + }, + { + "name": "userEvidence", + "value": "Credential List" + }, + { + "name": "installInStorageDevice", + "value": "Install From Storage" + }, + { + "name": "installCertificateFailed", + "value": "Install From Storage Failed" + }, + { + "name": "certificatePwdTab", + "value": "Get Certificated" + }, + { + "name": "certificateAliasTab", + "value": "Set Certificated" + }, + { + "name": "certificatePwdInfo", + "value": "Input Password" + }, + { + "name": "certificateAliasInfo", + "value": "Input Certificate Alias" + }, + { + "name": "deleteAllCred", + "value": "Delete All Credentials and Certificates" + }, + + + { + "name": "deleteAllCredDialogTitle", + "value": "Delete All Credentials and Certificates" + }, + { + "name": "deleteAllCredDialogMessage", + "value": "All credentials and certificates will be deleted. Whether or not to delete?" + }, + { + "name": "deleteAllCredCancel", + "value": "Cancel" + }, + { + "name": "deleteAllCredDelete", + "value": "Delete" + }, + { + "name": "pickCredToAuth", + "value": "Select credential" + }, + { + "name": "requestAuthMsg", + "value": "Application \"%s\" Request a certificate. Selecting a certificate allows the app to use this identity credential for the server. The app has identified the requested service as \"localhost\", You should only grant permission to use certificates to trusted apps." + }, + { + "name": "requestAuthCancel", + "value": "Reject" + }, + { + "name": "requestAuthFinish", + "value": "Authorize" + }, + { + "name": "requestFailPromptMsg", + "value": "Authorize failed , invalid AppUid" + }, + { + "name": "installPwdInputCancel", + "value": "Cancel" + }, + { + "name": "installPwdInputConfirm", + "value": "Extract" + }, + { + "name": "installAliasInputCancel", + "value": "Cancel" + }, + { + "name": "installAliasInputConfirm", + "value": "Confirm" + }, + { + "name": "installAliasInputInfo", + "value": "Attention: This certificate issuer may check all traffic entering and leaving the device\nThe packets contain:CA certificate" + }, + { + "name": "managerAuthApp", + "value": "Manage Authorized Applications" + }, + { + "name": "cancelAuthApp", + "value": "Cancel" + }, + { + "name": "finishAuthApp", + "value": "Finish" + }, + { + "name": "evidenceDetails", + "value": "Credential details" + }, + { + "name": "entryContains", + "value": "This item contains:" + }, + { + "name": "keyNum", + "value": " %s user keys" + }, + { + "name": "userCerNum", + "value": " %s user certificates" + }, + { + "name": "privateDetailsClose", + "value": "Close" + }, + { + "name": "publicDetailsCancel", + "value": "Cancel" + }, + { + "name": "publicDetailsDelete", + "value": "Delete" + }, + { + "name": "warning_title", + "value": "Delete certificate" + }, + { + "name": "warning_message", + "value": "After deletion, the application authorized with this certificate will not work normally. Whether or not to delete?" + }, + { + "name": "warning_cancel", + "value": "Cancel" + }, + { + "name": "warning_delete", + "value": "Delete" + }, + { + "name": "tabName_public", + "value": "Public" + }, + { + "name": "tabName_private", + "value": "Private" + }, + { + "name": "system", + "value": "System" + }, + { + "name": "user", + "value": "User" + }, + { + "name": "CustomDialogExample_firText", + "value": "Certificate Detail" + }, + { + "name": "CustomDialogExample_firListItem_text", + "value": "Issued to:" + }, + { + "name": "CustomDialogExample_secListItem_text", + "value": "Issued by:" + }, + { + "name": "CustomDialogExample_thdListItem_text", + "value": "Validity:" + }, + { + "name": "CustomDialogExample_Button_text", + "value": "Cancel" + }, + { + "name": "CustomDialogExample_Button_on", + "value": "Enable" + }, + { + "name": "CustomDialogExample_Button_off", + "value": "Disable" + }, + { + "name": "CustomDialogExampleUser_Status_true", + "value": "Enabled" + }, + { + "name": "CustomDialogExampleUser_Status_false", + "value": "Disabled" + }, + { + "name": "CustomDialogExampleUser_Flex_firButton_text", + "value": "Cancel" + }, + { + "name": "CustomDialogExampleUser_Flex_secButton_text", + "value": "Delete" + }, + { + "name": "CustomDialogExampleUser_warning_Button_text", + "value": "Cancel" + }, + { + "name": "CustomDialogExampleUser_warning_Button_title_text", + "value": "Delete certificate" + }, + { + "name": "CustomDialogExampleUser_warning_Button_message_text", + "value": "After deletion, the application authorized with this certificate will not work normally. Whether or not to delete?" + }, + { + "name": "CustomDialogExampleUser_warning_firButton_text", + "value": "Cancel" + }, + { + "name": "CustomDialogExampleUser_warning_secButton_text", + "value": "Delete" + }, + { + "name": "DialogSubjectComponent_firText", + "value": "Common name:" + }, + { + "name": "DialogSubjectComponent_secText", + "value": "Organization:" + }, + { + "name": "DialogSubjectComponent_thdText", + "value": "Organizational unit:" + }, + { + "name": "DialogSubjectComponent_fouText", + "value": "Serial number:" + }, + { + "name": "DialogSubjectComponent_fifText", + "value": "Issued on:" + }, + { + "name": "DialogSubjectComponent_sixText", + "value": "Expires on:" + }, + { + "name": "CustomDialogExample_fouListItem_text", + "value": "Fingerprints:" + }, + { + "name": "CustomDialogExample_FingerPrint_text", + "value": "SHA-256 fingerprints:" + } + ] +} \ No newline at end of file diff --git a/cer_manager/product/phone/src/main/resources/phone/element/float.json b/cer_manager/product/phone/src/main/resources/phone/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..9bab66c2a7548f6453edc65cce1093e34dd6cb51 --- /dev/null +++ b/cer_manager/product/phone/src/main/resources/phone/element/float.json @@ -0,0 +1,1008 @@ +{ + "float": [ + { + "name": "wh_value_0", + "value": "0vp" + }, + { + "name": "wh_value_1", + "value": "1vp" + }, + { + "name": "wh_value_1_5", + "value": "1.5vp" + }, + { + "name": "wh_value_3", + "value": "3vp" + }, + { + "name": "wh_value_4", + "value": "4vp" + }, + { + "name": "wh_value_5", + "value": "5vp" + }, + { + "name": "wh_value_6", + "value": "6vp" + }, + { + "name": "wh_value_8", + "value": "8vp" + }, + { + "name": "wh_value_9", + "value": "9vp" + }, + { + "name": "wh_value_10", + "value": "10vp" + }, + { + "name": "wh_value_11", + "value": "11vp" + }, + { + "name": "wh_value_12", + "value": "12vp" + }, + { + "name": "wh_value_13", + "value": "13vp" + }, + { + "name": "wh_value_15", + "value": "15vp" + }, + { + "name": "wh_value_16", + "value": "16vp" + }, + { + "name": "wh_value_18", + "value": "18vp" + }, + { + "name": "wh_value_19", + "value": "19vp" + }, + { + "name": "wh_value_20", + "value": "20vp" + }, + { + "name": "wh_value_21", + "value": "21vp" + }, + { + "name": "wh_value_22", + "value": "22vp" + }, + { + "name": "wh_value_24", + "value": "24vp" + }, + { + "name": "wh_value_26", + "value": "26vp" + }, + { + "name": "wh_value_28", + "value": "28vp" + }, + { + "name": "wh_value_30", + "value": "30vp" + }, + { + "name": "wh_value_32", + "value": "32vp" + }, + { + "name": "wh_value_33", + "value": "28vp" + }, + { + "name": "wh_value_40", + "value": "40vp" + }, + { + "name": "wh_value_44", + "value": "44vp" + }, + { + "name": "wh_value_48", + "value": "48vp" + }, + { + "name": "wh_value_50", + "value": "50vp" + }, + { + "name": "wh_value_52", + "value": "52vp" + }, + { + "name": "wh_value_56", + "value": "56vp" + }, + { + "name": "wh_value_60", + "value": "60vp" + }, + { + "name": "wh_value_64", + "value": "64vp" + }, + { + "name": "wh_value_65", + "value": "65vp" + }, + { + "name": "wh_value_67", + "value": "67vp" + }, + { + "name": "wh_value_70", + "value": "70vp" + }, + { + "name": "wh_value_80", + "value": "80vp" + }, + { + "name": "wh_value_96", + "value": "96vp" + }, + { + "name": "wh_value_100", + "value": "100vp" + }, + { + "name": "wh_value_109", + "value": "109vp" + }, + { + "name": "wh_value_118", + "value": "118vp" + }, + { + "name": "wh_value_119", + "value": "119vp" + }, + { + "name": "wh_value_120", + "value": "120vp" + }, + { + "name": "wh_value_130", + "value": "1300vp" + }, + { + "name": "wh_value_152", + "value": "152vp" + }, + { + "name": "wh_value_160", + "value": "144vp" + }, + { + "name": "wh_value_200", + "value": "200vp" + }, + { + "name": "wh_value_210", + "value": "210vp" + }, + { + "name": "wh_value_212", + "value": "280vp" + }, + { + "name": "wh_value_216", + "value": "216vp" + }, + { + "name": "wh_value_230", + "value": "230vp" + }, + { + "name": "wh_value_250", + "value": "250vp" + }, + { + "name": "wh_value_263", + "value": "150vp" + }, + { + "name": "wh_value_280", + "value": "280vp" + }, + { + "name": "wh_value_336", + "value": "336vp" + }, + { + "name": "wh_value_362", + "value": "288vp" + }, + { + "name": "wh_value_390", + "value": "390vp" + }, + { + "name": "wh_value_400", + "value": "400vp" + }, + { + "name": "wh_value_410", + "value": "336vp" + }, + { + "name": "wh_value_620", + "value": "620vp" + }, + { + "name": "wh_value_720", + "value": "720vp" + }, + { + "name": "font_35", + "value": "35fp" + }, + { + "name": "font_10", + "value": "10fp" + }, + { + "name": "font_14", + "value": "14fp" + }, + { + "name": "font_16", + "value": "16fp" + }, + { + "name": "font_18", + "value": "18fp" + }, + { + "name": "font_20", + "value": "20fp" + }, + { + "name": "font_21", + "value": "21fp" + }, + { + "name": "font_22", + "value": "22fp" + }, + { + "name": "font_24", + "value": "24fp" + }, + { + "name": "font_28", + "value": "28fp" + }, + { + "name": "font_30", + "value": "30fp" + }, + { + "name": "font_50", + "value": "50fp" + }, + { + "name": "lineHeight_19", + "value": "19vp" + }, + { + "name": "lineHeight_21", + "value": "21vp" + }, + { + "name": "lineHeight_22", + "value": "22vp" + }, + { + "name": "lineHeight_33", + "value": "33vp" + }, + { + "name": "lineHeight_41", + "value": "41vp" + }, + { + "name": "distance_1", + "value": "1vp" + }, + { + "name": "distance_2", + "value": "2vp" + }, + { + "name": "distance_4", + "value": "4vp" + }, + { + "name": "distance_6", + "value": "6vp" + }, + { + "name": "distance_8", + "value": "8vp" + }, + { + "name": "distance_9", + "value": "9vp" + }, + { + "name": "distance_9_5", + "value": "9.5vp" + }, + { + "name": "distance_10", + "value": "10vp" + }, + { + "name": "distance_11", + "value": "11vp" + }, + { + "name": "distance_11_5", + "value": "11.5vp" + }, + { + "name": "distance_12", + "value": "12vp" + }, + { + "name": "distance_13", + "value": "13vp" + }, + { + "name": "distance_14", + "value": "14vp" + }, + { + "name": "distance_15", + "value": "15vp" + }, + { + "name": "distance_16", + "value": "16vp" + }, + { + "name": "distance_17", + "value": "17vp" + }, + { + "name": "distance_18", + "value": "18vp" + }, + { + "name": "distance_19", + "value": "19vp" + }, + { + "name": "distance_19_5", + "value": "19.5vp" + }, + { + "name": "distance_20", + "value": "20vp" + }, + { + "name": "distance_21", + "value": "21vp" + }, + { + "name": "distance_22_5", + "value": "22.5vp" + }, + { + "name": "distance_24", + "value": "24vp" + }, + { + "name": "distance_26", + "value": "26vp" + }, + { + "name": "distance_30", + "value": "30vp" + }, + { + "name": "distance_32", + "value": "32vp" + }, + { + "name": "distance_36", + "value": "36vp" + }, + { + "name": "distance_56", + "value": "56vp" + }, + { + "name": "distance_64", + "value": "64vp" + }, + { + "name": "distance_66", + "value": "66vp" + }, + { + "name": "distance_80", + "value": "80vp" + }, + { + "name": "distance_96", + "value": "96vp" + }, + { + "name": "sys_corner_radius_clicked", + "value": "8vp" + }, + { + "name": "sys_elements_margin_vertical_l", + "value": "16vp" + }, + { + "name": "sys_elements_margin_vertical_m", + "value": "8vp" + }, + { + "name": "sys_elements_margin_horizontal_l", + "value": "16vp" + }, + { + "name": "sys_elements_margin_horizontal_m", + "value": "16vp" + }, + { + "name": "page_margin_horizontal", + "value": "24vp" + }, + { + "name": "square_click_image_size", + "value": "48vp" + }, + { + "name": "control_common_font_size", + "value": "20fp" + }, + { + "name": "item_common_vertical_margin", + "value": "20vp" + }, + { + "name": "item_common_horizontal_margin", + "value": "24vp" + }, + { + "name": "item_icon_size", + "value": "24vp" + }, + { + "name": "item_arrow_width", + "value": "12vp" + }, + { + "name": "slider_text_padding_left", + "value": "5vp" + }, + { + "name": "page_header_height", + "value": "56vp" + }, + { + "name": "volume_border_radius", + "value": "15vp" + }, + { + "name": "radius_12", + "value": "12vp" + }, + { + "name": "radius_20", + "value": "20vp" + }, + { + "name": "radius_24", + "value": "24vp" + }, + { + "name": "radius_32", + "value": "32vp" + }, + { + "name": "radius_40", + "value": "40vp" + }, + { + "name": "search_placeholder_font", + "value": "22fp" + }, + { + "name": "search_input_height", + "value": "40vp" + }, + { + "name": "search_input_margin_start", + "value": "64vp" + }, + { + "name": "search_input_horizontal_margin", + "value": "8vp" + }, + { + "name": "search_input_border_radius", + "value": "20vp" + }, + { + "name": "search_no_result_image_size", + "value": "160vp" + }, + { + "name": "search_no_result_text_font_size", + "value": "14fp" + }, + { + "name": "search_no_result_margin_top", + "value": "174vp" + }, + { + "name": "search_item_height", + "value": "72vp" + }, + { + "name": "search_result_item_title_font_size", + "value": "16vp" + }, + { + "name": "search_result_item_summary_font_size", + "value": "14fp" + }, + { + "name": "slider_image_width", + "value": "40vp" + }, + { + "name": "slider_image_height", + "value": "40vp" + }, + { + "name": "slider_image_margin", + "value": "15vp" + }, + { + "name": "audio_subtitle_font", + "value": "18fp" + }, + { + "name": "audio_subtitle_margin_left", + "value": "10vp" + }, + { + "name": "audio_subtitle_margin_bottom", + "value": "5vp" + }, + { + "name": "audio_title_summary_margin_left", + "value": "15vp" + }, + { + "name": "audio_summary_subtitle_margin_bottom", + "value": "10vp" + }, + { + "name": "audio_subtitle_margin_top", + "value": "10vp" + }, + { + "name": "audio_sound_mode_outer_height", + "value": "280vp" + }, + { + "name": "audio_sound_mode_inner_padding_top", + "value": "15vp" + }, + { + "name": "audio_sound_mode_inner_padding_bottom", + "value": "15vp" + }, + { + "name": "audio_sound_mode_outer_padding", + "value": "16vp" + }, + { + "name": "audio_sound_mode_item_inner_padding_top", + "value": "5vp" + }, + { + "name": "audio_sound_mode_border_width", + "value": "1vp" + }, + { + "name": "audio_sound_mode_border_radius", + "value": "15vp" + }, + { + "name": "audio_sound_mode_image_size", + "value": "40vp" + }, + { + "name": "audio_sound_mode_text_margin_top", + "value": "16vp" + }, + { + "name": "audio_sound_mode_font_size", + "value": "20fp" + }, + { + "name": "audio_sound_mode_radio_size", + "value": "36vp" + }, + { + "name": "audio_image_common_size", + "value": "50vp" + }, + { + "name": "audio_image_margin_right", + "value": "10vp" + }, + { + "name": "audio_subtitle_font_size", + "value": "18fp" + }, + { + "name": "audio_margin_left", + "value": "15vp" + }, + { + "name": "audio_start_end_margin_left", + "value": "15vp" + }, + { + "name": "audio_icon_height", + "value": "60vp" + }, + { + "name": "audio_no_icon_height", + "value": "70vp" + }, + { + "name": "audio_slider_height", + "value": "250vp" + }, + { + "name": "audio_volume_height", + "value": "280vp" + }, + { + "name": "audio_border_width", + "value": "1vp" + }, + { + "name": "audio_border_radius", + "value": "15vp" + }, + { + "name": "audio_volume_component_padding", + "value": "16vp" + }, + { + "name": "restore_factory_font_size", + "value": "20fp" + }, + { + "name": "restore_factory_button_width", + "value": "186vp" + }, + { + "name": "restore_factory_button_height", + "value": "40vp" + }, + { + "name": "switch_title_subtitle_size", + "value": "20fp" + }, + { + "name": "switch_component_margin", + "value": "12vp" + }, + { + "name": "switch_toggle_width", + "value": "36vp" + }, + { + "name": "switch_toggle_height", + "value": "20vp" + }, + { + "name": "switch_component_height", + "value": "70vp" + }, + { + "name": "application_common_size", + "value": "45vp" + }, + { + "name": "application_button_subtitle_size", + "value": "16fp" + }, + { + "name": "application_button_height", + "value": "40vp" + }, + { + "name": "storage_common_margin", + "value": "15vp" + }, + { + "name": "location_font_size", + "value": "16fp" + }, + { + "name": "location_common_margin", + "value": "15vp" + }, + { + "name": "storage_data_panel_height", + "value": "230vp" + }, + { + "name": "password_list_item_height", + "value": "48vp" + }, + { + "name": "password_list_item_title_font_size", + "value": "16vp" + }, + { + "name": "password_input_message_vertical_margin", + "value": "20vp" + }, + { + "name": "password_count_down_view_vertical_margin", + "value": "20vp" + }, + { + "name": "password_input_button_space", + "value": "10vp" + }, + { + "name": "password_input_button_margin_top", + "value": "40vp" + }, + { + "name": "radio_component_height", + "value": "30vp" + }, + { + "name": "radio_component_margin_bottom_right", + "value": "15vp" + }, + { + "name": "dataPanel_distance", + "value": "320vp" + }, + { + "name": "dataPanel_proportion_font_size", + "value": "66.67fp" + }, + { + "name": "dataPanel_percent_font_size", + "value": "17.78fp" + }, + { + "name": "dataPanel_used_font_size", + "value": "17.78fp" + }, + { + "name": "location_toggle_width", + "value": "36vp" + }, + { + "name": "location_toggle_height", + "value": "20vp" + }, + { + "name": "location_toggle_margin", + "value": "12vp" + }, + { + "name": "wh_value_72", + "value": "72vp" + }, + { + "name": "switch_summary_margin", + "value": "2vp" + }, + { + "name": "single_item_height", + "value": "48vp" + }, + { + "name": "wh_value_240", + "value": "240vp" + }, + { + "name": "wh_value_245", + "value": "245vp" + }, + { + "name": "wh_value_260", + "value": "260vp" + }, + { + "name": "wh_value_288", + "value": "288vp" + }, + { + "name": "wh_value_324", + "value": "324vp" + }, + { + "name": "divider_opacity", + "value": "0.2" + }, + { + "name": "paired_device_button_width", + "value": "186vp" + }, + { + "name": "component_button_width", + "value": "263vp" + }, + { + "name": "component_button_width_phone", + "value": "148vp" + }, + { + "name": "pinCode_font_size", + "value": "32fp" + }, + { + "name": "deviceName_button_width", + "value": "150vp" + }, + { + "name": "applicationInfo_button_width", + "value": "324vp" + }, + { + "name": "passwordSetting_button_width", + "value": "261vp" + }, + { + "name": "dialog_16", + "value": "16vp" + }, + { + "name": "dialog_118", + "value": "92vp" + }, + { + "name": "wh_4", + "value": "8vp" + }, + { + "name": "wh_10", + "value": "16vp" + }, + { + "name": "wh_20", + "value": "8vp" + }, + { + "name": "wh_23", + "value": "16vp" + }, + { + "name": "wh_24", + "value": "12vp" + }, + { + "name": "wh_35", + "value": "16vp" + }, + { + "name": "wh_37", + "value": "37vp" + }, + { + "name": "wh_42", + "value": "22vp" + }, + { + "name": "wh_48", + "value": "48vp" + }, + { + "name": "wh_192", + "value": "192vp" + }, + { + "name": "wh_205", + "value": "292vp" + }, + { + "name": "wh_263", + "value": "186vp" + }, + { + "name": "wh_hed_14", + "value": "14vp" + }, + { + "name": "wh_600", + "value": "600vp" + }, + { + "name": "padding_24", + "value": "24vp" + }, + { + "name": "padding_26", + "value": "14vp" + }, + { + "name": "wh_padding_32", + "value": "25vp" + }, + { + "name": "wh_padding_33", + "value": "20vp" + }, + { + "name": "wh_padding_35", + "value": "35vp" + }, + { + "name": "wh_padding_48", + "value": "24vp" + }, + { + "name": "wh_padding_112", + "value": "112vp" + }, + { + "name": "wh_padding_128", + "value": "128vp" + }, + { + "name": "wh_padding_212", + "value": "272vp" + }, + { + "name": "dataPanel_proportion_font_size_1", + "value": "60fp" + }, + { + "name": "dataPanel_percent_font_size_1", + "value": "16fp" + }, + { + "name": "dataPanel_used_font_size_1", + "value": "14fp" + }, + { + "name": "divider_wh", + "value": "0.5vp" + }, + { + "name": "progress_bottom", + "value": "127vp" + }, + { + "name": "head_font_24", + "value": "20vp" + } + ] +} \ No newline at end of file diff --git a/cer_manager/product/phone/src/main/resources/phone/element/string.json b/cer_manager/product/phone/src/main/resources/phone/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..21e88731004f474ad7811c1e1f4c8e1ce8436334 --- /dev/null +++ b/cer_manager/product/phone/src/main/resources/phone/element/string.json @@ -0,0 +1,48 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "证书管理FA" + }, + { + "name": "mainability_description", + "value": "ETS_Empty Feature Ability" + }, + { + "name": "certificateTab", + "value": "证书与凭据" + }, + { + "name": "certificateManage", + "value": "证书管理" + }, + { + "name": "trustedEvidence", + "value": "受信任的证书" + }, + { + "name": "userEvidence", + "value": "凭据列表" + }, + { + "name": "installInStorageDevice", + "value": "从存储设备安装" + }, + { + "name": "installCertificateFailed", + "value": "从存储设备安装失败" + }, + { + "name": "certificatePwdTab", + "value": "提取证书" + }, + { + "name": "certificatePwdInfo", + "value": "输入证书密码以提取" + }, + { + "name": "deleteAllCred", + "value": "删除所有凭据" + } + ] +} \ No newline at end of file diff --git a/cer_xts/BUILD.gn b/cer_xts/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..0c23f9e14583fcf9c2e30b7db33bae95fc057fbd --- /dev/null +++ b/cer_xts/BUILD.gn @@ -0,0 +1,25 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +group("cer_xts") { + testonly = true + if (is_standard_system) { + deps = [ + "cer_xts_multi_user:ActsCerTestMultiUser", + "cer_xts_system:ActsCerTestSystem", + "cer_xts_user:ActsCerTestUser", + ] + } +} diff --git a/cer_xts/cer_xts_multi_user/AppScope/app.json b/cer_xts/cer_xts_multi_user/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..fd74232896079bceb1491c925ee4e7f256401806 --- /dev/null +++ b/cer_xts/cer_xts_multi_user/AppScope/app.json @@ -0,0 +1,19 @@ +{ + "app": { + "bundleName": "com.example.cer_xts_multi_user", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "distributedNotificationEnabled": true, + "keepAlive" : true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} \ No newline at end of file diff --git a/cer_xts/cer_xts_multi_user/AppScope/resources/base/element/string.json b/cer_xts/cer_xts_multi_user/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..eddf099a370034aefb60aee9470ac7c598c5ac00 --- /dev/null +++ b/cer_xts/cer_xts_multi_user/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "AppSelectorTest" + } + ] +} \ No newline at end of file diff --git a/cer_xts/cer_xts_multi_user/AppScope/resources/base/media/app_icon.png b/cer_xts/cer_xts_multi_user/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/cer_xts/cer_xts_multi_user/AppScope/resources/base/media/app_icon.png differ diff --git a/cer_xts/cer_xts_multi_user/BUILD.gn b/cer_xts/cer_xts_multi_user/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..66d8c6aa0402d0f002ec44d0ff07eeecdf5dc27f --- /dev/null +++ b/cer_xts/cer_xts_multi_user/BUILD.gn @@ -0,0 +1,41 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsCerTestMultiUser") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":cer_xts_multi_user_js_assets", + ":cer_xts_multi_user_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsCerTestMultiUser" +} + +ohos_app_scope("cer_xts_multi_user_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("cer_xts_multi_user_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("cer_xts_multi_user_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":cer_xts_multi_user_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/cer_xts/cer_xts_multi_user/Test.json b/cer_xts/cer_xts_multi_user/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..ba04b9733973b792e5f01ef8be756cafe8ca2ecc --- /dev/null +++ b/cer_xts/cer_xts_multi_user/Test.json @@ -0,0 +1,32 @@ +{ + "description": "Configuration for aceceshi Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "600000", + "bundle-name": "com.example.cer_xts_multi_user", + "module-name": "entry", + "shell-timeout": "600000", + "testcase-timeout":"100000" + }, + "kits": [ + { + "type": "ShellKit", + "run-command": [ + "acm create -n user101 -t normal", + "acm switch -i 101" + ], + "teardown-command": [ + "acm switch -i 100", + "acm delete -i 101" + ] + }, + { + "test-file-name": [ + "ActsCerTestMultiUser.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} + diff --git a/cer_xts/cer_xts_multi_user/entry/src/main/ets/Application/AbilityStage.ts b/cer_xts/cer_xts_multi_user/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..0190fb0606f5b60fafe51d094ef1b3c8d69d1da4 --- /dev/null +++ b/cer_xts/cer_xts_multi_user/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/cer_xts/cer_xts_multi_user/entry/src/main/ets/MainAbility/MainAbility.ts b/cer_xts/cer_xts_multi_user/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..4f7032fc67a34d783772b9e2d2396a32ac9dd263 --- /dev/null +++ b/cer_xts/cer_xts_multi_user/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,62 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import Ability from '@ohos.application.Ability' + import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + import { Hypium } from 'hypium/index' + import testsuite from '../test/List.test' + + export default class TestAbility extends Ability { + onCreate(want, launchParam) { + console.log('TestAbility onCreate') + // var abilityDelegator: any + // abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + // var abilityDelegatorArguments: any + // abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + // console.info('start run testcase!!!') + // Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + globalThis.abilityContext = this.context; + } + + onDestroy() { + console.log('TestAbility onDestroy') + } + + onWindowStageCreate(windowStage) { + console.log('TestAbility onWindowStageCreate') + windowStage.setUIContent(this.context, 'MainAbility/pages/index', null) + + } + + onWindowStageDestroy() { + console.log('TestAbility onWindowStageDestroy') + } + + onForeground() { + console.log('TestAbility onForeground') + setTimeout(()=>{ + console.info('in setTimeout') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + },2000) + } + + onBackground() { + console.log('TestAbility onBackground') + } + }; \ No newline at end of file diff --git a/cer_xts/cer_xts_multi_user/entry/src/main/ets/MainAbility/pages/index.ets b/cer_xts/cer_xts_multi_user/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..f166cb4984bdce1942383d40ac5f305fefdc595c --- /dev/null +++ b/cer_xts/cer_xts_multi_user/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,48 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import router from '@ohos.router'; + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/cer_xts/cer_xts_multi_user/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/cer_xts/cer_xts_multi_user/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..1b4c5782a516e02419cea30fcbeb81283cb3f2cd --- /dev/null +++ b/cer_xts/cer_xts_multi_user/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log("onAbilityCreateCallback"); +} + +async function addAbilityMonitorCallback(err: any) { + console.info("addAbilityMonitorCallback : " + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info("OpenHarmonyTestRunner OnPrepare ") + } + + async onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var MainAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility' + let lMonitor = { + abilityName: MainAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/cer_xts/cer_xts_multi_user/entry/src/main/ets/pages/index.ets b/cer_xts/cer_xts_multi_user/entry/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..f166cb4984bdce1942383d40ac5f305fefdc595c --- /dev/null +++ b/cer_xts/cer_xts_multi_user/entry/src/main/ets/pages/index.ets @@ -0,0 +1,48 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import router from '@ohos.router'; + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/cer_xts/cer_xts_multi_user/entry/src/main/ets/stub/certStubCallback.ts b/cer_xts/cer_xts_multi_user/entry/src/main/ets/stub/certStubCallback.ts new file mode 100644 index 0000000000000000000000000000000000000000..8053b61422c3e90ec86fe344201085a8519a5c08 --- /dev/null +++ b/cer_xts/cer_xts_multi_user/entry/src/main/ets/stub/certStubCallback.ts @@ -0,0 +1,638 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + import { CMResult, BusinessError, CMErrorCode, CertBlob, CMSignatureSpec, CertManagerStore, CMHandle} from './certStubStruct'; + import bundle from '@ohos.bundle' + import certStubUtil from './certStubUtil'; + + var certUtil = new certStubUtil(); + const TAG = "CertManager Stub: "; + const certNum = 10 + const keyNum = 20 + const authorListA = ["121", "23123", "3123", "676"] + const authorListB = ["232", "878", "6756", "089"] + const authorListC = ["3434", "545", "7687", "023"] + + export class CertStubPromise { + exceptFlag = 0; + uriBase = "uri://stub/certFile/" + type = "CM_URI_TYPE_APP_KEY" + uriCount = 0; + systemCertMap = new Map(); + userCertMap = new Map(); + uriToAlias = new Map(); + appCredMap = new Map(); + privateCredMap = new Map(); + uriToAppList = new Map(); + + constructor() { + let newCert; + + console.log(TAG + "getSystemTrustedCertificateList stub constructor start"); + newCert = certUtil.parseCertInfo(this.uriBase + this.uriCount.toString(), + "SystemRoot_1", true, new Uint8Array([0, 1, 2, 42, 100, 101, 102, 255])); + this.systemCertMap.set(this.uriBase + this.uriCount.toString(), newCert); + this.uriCount++; + + newCert = certUtil.parseCertInfo(this.uriBase + this.uriCount.toString(), + "SystemRoot_2", false, new Uint8Array([64, 1, 2, 42, 100, 123, 321, 255])); + this.systemCertMap.set(this.uriBase + this.uriCount.toString(), newCert); + this.uriCount++; + + newCert = certUtil.parseCertInfo(this.uriBase + this.uriCount.toString(), + "SystemRoot_3", true, new Uint8Array([54, 1, 123, 42, 100, 101, 102, 23])); + this.systemCertMap.set(this.uriBase + this.uriCount.toString(), newCert); + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "TheEncryptionForCCMPV1", this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([25, 5, 34, 45, 64, 78, 7, 8])); + this.appCredMap.set("ApptemRoot_1", newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "ApptemRoot_1") + this.uriToAppList.set(this.uriBase + this.uriCount.toString(), authorListA) + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "TheEncryptionForCCMPV2", this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([23, 1, 43, 42, 78, 90, 56, 12])); + this.appCredMap.set("ApptemRoot_2", newCert); + this.uriToAppList.set(this.uriBase + this.uriCount.toString(), authorListB) + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "ApptemRoot_2") + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "TheEncryptionForCCMPV3", this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([21, 1, 32, 645, 100, 101, 102, 23])); + this.appCredMap.set("ApptemRoot_3", newCert); + this.uriToAppList.set(this.uriBase + this.uriCount.toString(), authorListC) + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "ApptemRoot_3") + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "Huawei-Employee_WPA_EAPIEA", this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([32, 41, 54, 67, 77, 98, 91, 123])); + this.privateCredMap.set("PrivatetemRoot_1", newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "PrivatetemRoot_1") + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "Huawei-Employee_WPA_EAPIEB", this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([34, 65, 67, 68, 33, 77, 14, 18])); + this.privateCredMap.set("PrivatetemRoot_2", newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "PrivatetemRoot_2") + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "Huawei-Employee_WPA_EAPIEC", this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([12, 3, 54, 76, 8, 123, 43, 55])); + this.privateCredMap.set("PrivatetemRoot_3", newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "PrivatetemRoot_3") + this.uriCount++; + } + + getSystemTrustedCertificateList(callback) { + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + let data: CMResult; + let certList = new Array(); + + if (!this.exceptFlag) { + console.log(TAG + "getSystemTrustedCertificateList stub start"); + this.systemCertMap.forEach((data, keyUri) => { + certList.push(this.systemCertMap.get(keyUri)) + }) + data = { + certList: certList + }; + callback(error, data); + } else { + error = { + code: CMErrorCode.CMR_FAILURE, + }; + callback(error, null); + } + } + + getSystemTrustedCertificate(certUri: string, callback) { + let data: CMResult; + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + + if (this.systemCertMap.has(certUri)) { + data = { + certInfo: this.systemCertMap.get(certUri) + }; + callback(error, data); + } else { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + callback(error, null); + } + } + + setCertificateStatus(certUri: string, store: number, status: boolean, callback) { + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + let alias; + + if ((!this.systemCertMap.has(certUri)) && + (!this.uriToAlias.has(certUri))) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + callback(error, null); + } + console.log('store is:' + store) + if (store == CertManagerStore.CERT_MANAGER_SYSTEM_TRUSTED_STORE) { + this.systemCertMap.get(certUri).status = status; + console.log('status is:' + status) + callback(error, null); + } else if (store == CertManagerStore.CERT_MANAGER_USER_TRUSTED_STORE) { + alias = this.uriToAlias.get(certUri); + this.userCertMap.get(alias).status = status; + callback(error, null); + } else { + error = { + code: CMErrorCode.CMR_ERROR_NOT_SUPPORTED, + }; + callback(error, null); + } + } + + installUserTrustedCertificate(certificate: CertBlob, callback) { + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + if (certificate.alias.length > 64) { + error = { + code: CMErrorCode.CMR_ERROR_INVALID_ARGUMENT, + }; + callback(error, null); + } + + let newCert = certUtil.parseCertInfo(this.uriBase + this.uriCount.toString(), + certificate.alias, true, certificate.inData); + this.userCertMap.set(certificate.alias, newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), certificate.alias) + this.uriCount++; + + callback(error, null); + } + + uninstallAllUserTrustedCertificate(callback) { + console.log(TAG + "uninstallAllUserTrustedCertificate stub in"); + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + + this.userCertMap.clear(); + this.uriToAlias.clear(); + callback(error, null); + } + + uninstallUserTrustedCertificate(certUri: string, callback) { + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + let alias; + + if (!this.uriToAlias.has(certUri)) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + callback(error, null); + } + + alias = this.uriToAlias.get(certUri); + this.uriToAlias.delete(certUri); + this.userCertMap.delete(alias); + callback(error, null); + } + + getUserTrustedCertificateList(callback) { + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + let data: CMResult; + let certList = new Array(); + + + if (!this.exceptFlag) { + this.userCertMap.forEach((data, keyAlias) => { + certList.push(this.userCertMap.get(keyAlias)) + }) + + data = { + certList: certList + }; + callback(error, data); + } else { + error = { + code: CMErrorCode.CMR_FAILURE, + }; + callback(error, null); + } + } + + getUserTrustedCertificate(certUri: string, callback) { + let data: CMResult; + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + + if (this.uriToAlias.has(certUri)) { + let alias = this.uriToAlias.get(certUri); + data = { + certInfo: this.userCertMap.get(alias) + }; + callback(error, data); + } else { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + callback(error, null); + } + } + + installAppCertificate(keystore: Uint8Array, keystorePwd: string, certAlias: string, callback) { + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + if (keystorePwd.length > 64||certAlias.length > 64) { + error = { + code: CMErrorCode.CMR_ERROR_INVALID_ARGUMENT, + }; + callback(error) + } + let newCred = certUtil.parseCredential(this.type, certAlias, this.uriBase + this.uriCount.toString(), + certNum, keyNum, keystore); + this.appCredMap.set(certAlias, newCred); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), certAlias) + this.uriCount++; + + callback(error); + } + + installPrivateCertificate(keystore: Uint8Array, keystorePwd: string, certAlias: string, callback) { + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + let data: CMResult; + + if (keystorePwd.length > 64 || certAlias.length > 64) { + error = { + code: CMErrorCode.CMR_ERROR_INVALID_ARGUMENT, + }; + callback(error) + } + let newCred = certUtil.parseCredential("privateCred", certAlias, this.uriBase + this.uriCount.toString(), + 1, 1, keystore); + this.privateCredMap.set(certAlias, newCred); + let authUriRet = this.uriBase + this.uriCount.toString() + this.uriToAlias.set(authUriRet, certAlias); + this.uriCount++; + data = { + authUri: authUriRet + } + callback(error, data); + } + + updatePrivateCertificate(type: string, keyUri: string, certificate: CertBlob, callback) { + console.log(TAG + "updatePrivateCertificate stub in"); + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + if (!this.uriToAlias.has(keyUri)) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + callback(error) + } + this.uninstallPrivateCertificate(keyUri, (err)=>{ + let keystorePwd = '123456' + let certAlias = certificate.alias + this.installPrivateCertificate(certificate.inData, keystorePwd, certAlias, (err)=>{ + callback(error, null) + }) + }) + } + + uninstallAllAppCertificate(callback) { + console.log(TAG + "uninstallAllAppCertificate stub in"); + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + + this.appCredMap.clear(); + this.privateCredMap.clear(); + + callback(error, null); + } + + uninstallAppCertificate(keyUri: string, callback) { + let alias; + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + + if (!this.uriToAlias.has(keyUri)) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + callback(error, null); + } + + alias = this.uriToAlias.get(keyUri); + this.uriToAlias.delete(keyUri); + this.appCredMap.delete(alias); + + callback(error, null); + } + + uninstallPrivateCertificate(keyUri, callback) { + let alias; + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + + if (!this.uriToAlias.has(keyUri)) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + callback(error, null); + } + + alias = this.uriToAlias.get(keyUri); + this.uriToAlias.delete(keyUri); + this.privateCredMap.delete(alias); + + callback(error, null); + } + + getAppCertificateList(callback) { + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + let data: CMResult; + let credList = new Array(); + + if (!this.exceptFlag) { + this.appCredMap.forEach((data, keyAlias) => { + credList.push(this.appCredMap.get(keyAlias)) + }) + + data = { + credentialList: credList + }; + callback(error, data); + } else { + error = { + code: CMErrorCode.CMR_FAILURE, + }; + callback(error, null); + } + } + + getPrivateCertificateList(callback) { + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + let data: CMResult; + let credList = new Array(); + + if (!this.exceptFlag) { + this.privateCredMap.forEach((data, keyAlias) => { + credList.push(this.privateCredMap.get(keyAlias)) + }) + + data = { + credentialList: credList + }; + callback(error, data); + } else { + error = { + code: CMErrorCode.CMR_FAILURE, + }; + callback(error, null); + } + } + + getAppCertificate(keyUri: string, callback) { + let data: CMResult; + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + + if (this.uriToAlias.has(keyUri)) { + let alias = this.uriToAlias.get(keyUri); + data = { + credential: this.appCredMap.get(alias) + }; + callback(error, data); + } else { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + callback(error, null); + } + } + + getPrivateCertificate(keyUri: string, callback) { + let data: CMResult; + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + + if (this.uriToAlias.has(keyUri)) { + let alias = this.uriToAlias.get(keyUri); + data = { + credential: this.privateCredMap.get(alias) + }; + callback(error, data); + } else { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + callback(error, null); + } + } + + grantAppCertificate(keyUri: string, clientAppUid: string, callback) { + let appList: Array; + let data: CMResult; + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + + console.log(TAG + "grantAppCertificate stub uri: " + keyUri + " clientAppUid: " + clientAppUid); + if (!this.uriToAlias.has(keyUri)) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + callback(error, null); + } + + if (this.uriToAppList.has(keyUri)) { + appList = this.uriToAppList.get(keyUri); + } else { + appList = new Array(); + } + + appList.push(clientAppUid); + this.uriToAppList.set(keyUri, appList) + data = { + authUri: "authUri-value" + }; + console.log(TAG + "grantAppCertificate stub uriToAppList: " + JSON.stringify(appList)); + + callback(error, data); + } + + async isAuthorizedApp(keyUri: string, callback) { + let data: CMResult; + let dataRet: CMResult; + let appList: Array; + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + data = { + isAuth: false + }; + if(keyUri.length > 64 || keyUri == 'keyUriError' || keyUri == ''){ + let errorRet: BusinessError = { + code: CMErrorCode.CMR_FAILURE + }; + callback(errorRet, undefined); + }else{ + if (this.uriToAppList.has(keyUri)) { + appList = this.uriToAppList.get(keyUri); + } else { + appList = new Array(); + } + let sign = true; + let bundleInfo = await bundle.getBundleInfo("com.example.cerxts", bundle.BundleFlag.GET_BUNDLE_DEFAULT) + let clientAppUid = bundleInfo.uid.toString() + for (let i = 0; i < appList.length; i++) { + if (appList[i] == clientAppUid) { + dataRet = { + isAuth: true + }; + sign = false + callback(error, dataRet); + break + } + } + if(sign){ + data = { + isAuth: false + }; + callback(error, data); + } + } + } + + getAuthorizedAppList(keyUri: string, callback) { + let data: CMResult; + let appList: Array; + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + + if ((!this.uriToAlias.has(keyUri)) || (!this.uriToAppList.has(keyUri))) { + data = { + appUidList: appList, + }; + callback(error, data); + } + + appList = this.uriToAppList.get(keyUri); + + data = { + appUidList: appList + }; + callback(error, data); + } + + init(authUri: string, spec: CMSignatureSpec, callback) { + let error = { + code: CMErrorCode.CMR_SUCCESS, + }; + let data: CMHandle; + data = { + errorCode: error.code, + handle: 1 + } + callback(error, data); + } + + update(handle: number, data: Uint8Array, token: Uint8Array, callback) { + let error = { + code: CMErrorCode.CMR_SUCCESS, + }; + let dataRet: CMResult; + dataRet = { + } + callback(error, dataRet); + } + + finish(handle: number, signature: Uint8Array, callback) { + let error = { + code: CMErrorCode.CMR_SUCCESS, + }; + let dataRet: CMResult; + dataRet = { + } + callback(error, dataRet); + } + + about(handle: number, callback) { + let error = { + code: CMErrorCode.CMR_SUCCESS, + }; + let dataRet: CMResult; + dataRet = { + } + callback(error, dataRet); + } + + removeGrantedAppCertificate(keyUri: string, clientAppUid: string, callback) { + let appList: Array; + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + + if ((!this.uriToAlias.has(keyUri)) || (!this.uriToAppList.has(keyUri))) { + let error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + callback(error, null); + } + + appList = this.uriToAppList.get(keyUri); + if (appList.indexOf(clientAppUid) != -1) { + appList = appList.filter(item => item != clientAppUid); + this.uriToAppList.set(keyUri, appList); + callback(error, null); + } else { + let error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + callback(error, null); + } + } + } + + let certStub = new CertStubPromise(); + + export default certStub as CertStubPromise; + \ No newline at end of file diff --git a/cer_xts/cer_xts_multi_user/entry/src/main/ets/stub/certStubPromise.ts b/cer_xts/cer_xts_multi_user/entry/src/main/ets/stub/certStubPromise.ts new file mode 100644 index 0000000000000000000000000000000000000000..237c4a14f39edcf2a778b23971cd2f4dde67e366 --- /dev/null +++ b/cer_xts/cer_xts_multi_user/entry/src/main/ets/stub/certStubPromise.ts @@ -0,0 +1,754 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + import { CMResult, BusinessError, CMErrorCode, CertBlob, CMSignatureSpec, CertManagerStore, CMHandle, + CMKeyProperties} from './certStubStruct'; +import bundle from '@ohos.bundle' +import certStubUtil from './certStubUtil'; +import fileio from '@ohos.fileio'; + +var certUtil = new certStubUtil(); +const TAG = "CertManager Stub: "; +const certNum = 10 +const keyNum = 20 +const authorListA = ["121", "23123", "3123", "676"] +const authorListB = ["232", "878", "6756", "089"] +const authorListC = ["3434", "545", "7687", "023"] +globalThis.exceptFlag = 0 + +export class CertStubPromise { + uriBase = "uri://stub/certFile/" + type = "CM_URI_TYPE_APP_KEY" + uriCount = 0; + systemCertMap = new Map(); + userCertMap = new Map(); + uriToAlias = new Map(); + appCredMap = new Map(); + privateCredMap = new Map(); + uriToAppList = new Map(); + + constructor() { + let newCert; + + console.log(TAG + "getSystemTrustedCertificateList stub constructor start"); + newCert = certUtil.parseCertInfo(this.uriBase + this.uriCount.toString(), + "SystemRoot_1", true, new Uint8Array([0, 1, 2, 42, 100, 101, 102, 255])); + this.systemCertMap.set(this.uriBase + this.uriCount.toString(), newCert); + this.uriCount++; + + newCert = certUtil.parseCertInfo(this.uriBase + this.uriCount.toString(), + "SystemRoot_2", false, new Uint8Array([64, 1, 2, 42, 100, 123, 321, 255])); + this.systemCertMap.set(this.uriBase + this.uriCount.toString(), newCert); + this.uriCount++; + + newCert = certUtil.parseCertInfo(this.uriBase + this.uriCount.toString(), + "SystemRoot_3", true, new Uint8Array([54, 1, 123, 42, 100, 101, 102, 23])); + this.systemCertMap.set(this.uriBase + this.uriCount.toString(), newCert); + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "TheEncryptionForCCMPV1", this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([25, 5, 34, 45, 64, 78, 7, 8])); + this.appCredMap.set("ApptemRoot_1", newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "ApptemRoot_1") + this.uriToAppList.set(this.uriBase + this.uriCount.toString(), authorListA) + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "TheEncryptionForCCMPV2", this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([23, 1, 43, 42, 78, 90, 56, 12])); + this.appCredMap.set("ApptemRoot_2", newCert); + this.uriToAppList.set(this.uriBase + this.uriCount.toString(), authorListB) + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "ApptemRoot_2") + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "TheEncryptionForCCMPV3", this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([21, 1, 32, 645, 100, 101, 102, 23])); + this.appCredMap.set("ApptemRoot_3", newCert); + this.uriToAppList.set(this.uriBase + this.uriCount.toString(), authorListC) + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "ApptemRoot_3") + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "Huawei-Employee_WPA_EAPIEA", this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([32, 41, 54, 67, 77, 98, 91, 123])); + this.privateCredMap.set("PrivatetemRoot_1", newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "PrivatetemRoot_1") + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "Huawei-Employee_WPA_EAPIEB", this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([34, 65, 67, 68, 33, 77, 14, 18])); + this.privateCredMap.set("PrivatetemRoot_2", newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "PrivatetemRoot_2") + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "Huawei-Employee_WPA_EAPIEC", this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([12, 3, 54, 76, 8, 123, 43, 55])); + this.privateCredMap.set("PrivatetemRoot_3", newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "PrivatetemRoot_3") + this.uriCount++; + } + + getSystemTrustedCertificateList() { + return new Promise((resolve, reject) => { + let error: BusinessError; + let data: CMResult; + let certList = new Array(); + + if (!globalThis.exceptFlag) { + console.log(TAG + "getSystemTrustedCertificateList stub start"); + this.systemCertMap.forEach((data, keyUri) => { + certList.push(this.systemCertMap.get(keyUri)) + }) + data = { + certList: certList + }; + resolve(data); + } else { + error = { + code: CMErrorCode.CMR_FAILURE, + }; + reject(error); + } + }) + } + + getSystemTrustedCertificate(certUri: string) { + return new Promise((resolve, reject) => { + let data: CMResult; + let error: BusinessError; + + if (this.systemCertMap.has(certUri)) { + data = { + certInfo: this.systemCertMap.get(certUri) + }; + resolve(data); + } else { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + }) + } + + setCertificateStatus(certUri: string, store: number, status: boolean) { + return new Promise((resolve, reject) => { + let error: BusinessError; + let alias; + + if ((!this.systemCertMap.has(certUri)) && + (!this.uriToAlias.has(certUri))) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + + if (store == CertManagerStore.CERT_MANAGER_SYSTEM_TRUSTED_STORE) { + this.systemCertMap.get(certUri).status = status; + resolve(); + } else if (store == CertManagerStore.CERT_MANAGER_USER_TRUSTED_STORE) { + alias = this.uriToAlias.get(certUri); + this.userCertMap.get(alias).status = status; + resolve(); + } else { + error = { + code: CMErrorCode.CMR_ERROR_NOT_SUPPORTED, + }; + reject(error); + } + }) + } + + installUserTrustedCertificate(certificate: CertBlob) { + return new Promise((resolve, reject) => { + let error: BusinessError; + + if (this.userCertMap.size == 64) { + error = { + code: CMErrorCode.CMR_ERROR_STORAGE_FAILURE, + }; + reject(error) + } + + if (certificate.alias.length > 64) { + error = { + code: CMErrorCode.CMR_ERROR_INVALID_ARGUMENT, + }; + reject(error) + } + let newCert = certUtil.parseCertInfo(this.uriBase + this.uriCount.toString(), + certificate.alias, true, certificate.inData); + this.userCertMap.set(certificate.alias, newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), certificate.alias) + this.uriCount++; + + resolve(); + }) + } + + uninstallAllUserTrustedCertificate() { + return new Promise((resolve, reject) => { + console.log(TAG + "uninstallAllUserTrustedCertificate stub in"); + this.userCertMap.clear(); + this.uriToAlias.clear(); + resolve(); + }) + } + + uninstallUserTrustedCertificate(certUri: string) { + return new Promise((resolve, reject) => { + let error: BusinessError; + let alias; + + if (!this.uriToAlias.has(certUri)) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + + alias = this.uriToAlias.get(certUri); + this.uriToAlias.delete(certUri); + this.userCertMap.delete(alias); + resolve(); + }) + } + + getUserTrustedCertificateList() { + return new Promise((resolve, reject) => { + let error: BusinessError; + let data: CMResult; + let certList = new Array(); + + if (!globalThis.exceptFlag) { + this.userCertMap.forEach((data, keyAlias) => { + certList.push(this.userCertMap.get(keyAlias)) + }) + + data = { + certList: certList + }; + resolve(data); + } else { + error = { + code: CMErrorCode.CMR_FAILURE, + }; + reject(error); + } + }) + } + + getUserTrustedCertificate(certUri: string) { + return new Promise((resolve, reject) => { + let data: CMResult; + let error: BusinessError; + + if (this.uriToAlias.has(certUri)) { + let alias = this.uriToAlias.get(certUri); + data = { + certInfo: this.userCertMap.get(alias) + }; + resolve(data); + } else { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + }) + } + + installAppCertificate(keystore: Uint8Array, keystorePwd: string, certAlias: string) { + return new Promise((resolve, reject) => { + let error: BusinessError; + if (this.appCredMap.size == 64) { + error = { + code: CMErrorCode.CMR_ERROR_STORAGE_FAILURE, + }; + reject(error) + } + if (keystorePwd.length > 64||certAlias.length > 64) { + error = { + code: CMErrorCode.CMR_ERROR_INVALID_ARGUMENT, + }; + reject(error) + } + let newCred = certUtil.parseCredential(this.type, certAlias, this.uriBase + this.uriCount.toString(), + certNum, keyNum, keystore); + this.appCredMap.set(certAlias, newCred); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), certAlias) + this.uriCount++; + + resolve(); + }) + } + + installPrivateCertificate(keystore: Uint8Array, keystorePwd: string, certAlias: string) { + return new Promise((resolve, reject) => { + let error: BusinessError; + let data: CMResult; + + if (this.privateCredMap.size == 64) { + error = { + code: CMErrorCode.CMR_ERROR_STORAGE_FAILURE, + }; + reject(error) + } + if (keystorePwd.length > 64 || certAlias.length > 64) { + error = { + code: CMErrorCode.CMR_ERROR_INVALID_ARGUMENT, + }; + reject(error) + } + let newCred = certUtil.parseCredential("privateCred", certAlias, this.uriBase + this.uriCount.toString(), + 1, 1, keystore); + this.privateCredMap.set(certAlias, newCred); + let authUriRet = this.uriBase + this.uriCount.toString() + this.uriToAlias.set(authUriRet, certAlias); + this.uriCount++; + data = { + authUri: authUriRet + } + resolve(data); + }) + } + + updatePrivateCertificate(type: string, keyUri: string, certificate: CertBlob) { + return new Promise((resolve, reject) => { + let error: BusinessError + console.log(TAG + "updatePrivateCertificate stub in"); + if (!this.uriToAlias.has(keyUri)) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + this.uninstallPrivateCertificate(keyUri) + let keystorePwd = '123456' + let certAlias = certificate.alias + this.installPrivateCertificate(certificate.inData, keystorePwd, certAlias) + resolve(); + }) + } + + uninstallAllAppCertificate() { + return new Promise((resolve, reject) => { + console.log(TAG + "uninstallAllAppCertificate stub in"); + this.appCredMap.clear(); + this.privateCredMap.clear(); + + resolve(); + }) + } + + uninstallAppCertificate(keyUri: string) { + return new Promise((resolve, reject) => { + let alias; + let error: BusinessError; + + if (!this.uriToAlias.has(keyUri)) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + + alias = this.uriToAlias.get(keyUri); + this.uriToAlias.delete(keyUri); + this.appCredMap.delete(alias); + + resolve(); + }) + } + + uninstallPrivateCertificate(keyUri) { + return new Promise((resolve, reject) => { + let alias; + let error: BusinessError; + + if (!this.uriToAlias.has(keyUri)) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + + alias = this.uriToAlias.get(keyUri); + this.uriToAlias.delete(keyUri); + this.privateCredMap.delete(alias); + + resolve(); + }) + } + + getAppCertificateList() { + return new Promise((resolve, reject) => { + let error: BusinessError; + let data: CMResult; + let credList = new Array(); + + if (!globalThis.exceptFlag) { + this.appCredMap.forEach((data, keyAlias) => { + credList.push(this.appCredMap.get(keyAlias)) + }) + + data = { + credentialList: credList + }; + resolve(data); + } else { + error = { + code: CMErrorCode.CMR_FAILURE, + }; + reject(error); + } + }) + } + + getPrivateCertificateList() { + return new Promise((resolve, reject) => { + let error: BusinessError; + let data: CMResult; + let credList = new Array(); + + if (!globalThis.exceptFlag) { + this.privateCredMap.forEach((data, keyAlias) => { + credList.push(this.privateCredMap.get(keyAlias)) + }) + + data = { + credentialList: credList + }; + resolve(data); + } else { + error = { + code: CMErrorCode.CMR_FAILURE, + }; + reject(error); + } + }) + } + + getAppCertificate(keyUri: string) { + return new Promise((resolve, reject) => { + let data: CMResult; + let error: BusinessError; + + if (this.uriToAlias.has(keyUri)) { + let alias = this.uriToAlias.get(keyUri); + data = { + credential: this.appCredMap.get(alias) + }; + resolve(data); + } else { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + }) + } + + getPrivateCertificate(keyUri: string) { + return new Promise((resolve, reject) => { + let data: CMResult; + let error: BusinessError; + + if (this.uriToAlias.has(keyUri)) { + let alias = this.uriToAlias.get(keyUri); + data = { + credential: this.privateCredMap.get(alias) + }; + resolve(data); + } else { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + }) + } + + grantAppCertificate(keyUri: string, clientAppUid: string) { + return new Promise((resolve, reject) => { + let appList: Array; + let data: CMResult; + let error: BusinessError; + + console.log(TAG + "grantAppCertificate stub uri: " + keyUri + " clientAppUid: " + clientAppUid); + if (!this.uriToAlias.has(keyUri)) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + + if (this.uriToAppList.has(keyUri)) { + appList = this.uriToAppList.get(keyUri); + } else { + appList = new Array(); + } + + appList.push(clientAppUid); + this.uriToAppList.set(keyUri, appList) + data = { + authUri: "authUri-value" + }; + console.log(TAG + "grantAppCertificate stub uriToAppList: " + JSON.stringify(appList)); + + resolve(data); + }) + } + + isAuthorizedApp(keyUri: string) { + return new Promise(async (resolve, reject) => { + if(keyUri.length > 64 || keyUri == 'keyUriError' || keyUri == ''){ + let err: BusinessError = { + code: CMErrorCode.CMR_FAILURE + }; + reject(err); + }else{ + let data: CMResult; + let dataRet: CMResult; + let appList: Array; + + if (this.uriToAppList.has(keyUri)) { + appList = this.uriToAppList.get(keyUri); + } else { + appList = new Array(); + } + let sign = true; + let bundleInfo = await bundle.getBundleInfo("com.example.cerxts", bundle.BundleFlag.GET_BUNDLE_DEFAULT) + let clientAppUid = bundleInfo.uid.toString() + for (let i = 0; i < appList.length; i++) { + if (appList[i] == clientAppUid) { + dataRet = { + isAuth: true + }; + sign = false + resolve(dataRet) + break + } + } + if(sign){ + data = { + isAuth: false + }; + resolve(data); + } + } + }) + } + + generatePrivateCertificate(keyAlias: string, keyProperties: CMKeyProperties) { + return new Promise((resolve, reject) => { + if(keyProperties.type != 'CM_URI_TYPE_APP_KEY' && keyProperties.type != 'CM_URI_TYPE_WLAN_KEY' || + keyAlias.length > 64){ + let error: BusinessError = { + code: CMErrorCode.CMR_FAILURE + }; + reject(error) + } + let data: CMResult; + data = { + outData: new Uint8Array([0, 1, 2, 42, 100, 101, 102, 255]) + }; + resolve(data); + }) + } + + getAuthorizedAppList(keyUri: string) { + return new Promise((resolve, reject) => { + let data: CMResult; + let appList: Array; + + if ((!this.uriToAlias.has(keyUri)) || (!this.uriToAppList.has(keyUri))) { + data = { + appUidList: appList, + }; + resolve(data); + } + + appList = this.uriToAppList.get(keyUri); + + data = { + appUidList: appList + }; + resolve(data); + }) + } + + removeGrantedAppCertificate(keyUri: string, clientAppUid: string) { + return new Promise((resolve, reject) => { + let appList: Array; + + if ((!this.uriToAlias.has(keyUri)) || (!this.uriToAppList.has(keyUri))) { + let error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + + appList = this.uriToAppList.get(keyUri); + if (appList.indexOf(clientAppUid) != -1) { + appList = appList.filter(item => item != clientAppUid); + this.uriToAppList.set(keyUri, appList); + resolve(); + } else { + let error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + }) + } + + init(authUri: string, spec: CMSignatureSpec) { + return new Promise((resolve, reject) => { + let errCode = CMErrorCode.CMR_SUCCESS; + let data: CMHandle; + data = { + errorCode: errCode, + handle: 1 + } + + resolve(data); + }) + } + + update(handle: number, data: Uint8Array, token?: Uint8Array) { + return new Promise((resolve, reject) => { + let errCode = CMErrorCode.CMR_SUCCESS; + let data: CMResult; + data = { + + } + + resolve(data); + }) + } + + finish(handle: number, signature?: Uint8Array) { + return new Promise((resolve, reject) => { + let errorCode = CMErrorCode.CMR_SUCCESS; + let data: CMResult; + + resolve(); + }) + } + + abort(handle: number) { + return new Promise((resolve, reject) => { + let errorCode = CMErrorCode.CMR_SUCCESS; + let data: CMResult; + + resolve(); + }) + } + + mapToJson(map) { + let obj = Object.create(null); + for (let [k, v] of map) { + obj[k] = v; + } + + return JSON.stringify(obj) + } + + jsonToMap(jsonString) { + console.log(TAG + "jsonToMap start"); + let map = new Map(); + let obj = JSON.parse(jsonString); + + for (let k of Object.keys(obj)) { + map.set(k, obj[k]) + } + return map; + } + + saveAllMaps() { + console.log(TAG + "saveAllMaps start"); + let dataList = [ + this.mapToJson(this.systemCertMap), + this.mapToJson(this.userCertMap), + this.mapToJson(this.uriToAlias), + this.mapToJson(this.appCredMap), + this.mapToJson(this.privateCredMap), + this.mapToJson(this.uriToAppList) + ]; + + let context = globalThis.certManagerAbilityContext; + let path = context.cacheDir; + path += '/certStubData' + try { + fileio.unlinkSync(path); + } catch (err) { + console.log(TAG + "saveAllMaps unlinkSync err: " + err); + } + let fd = fileio.openSync(path, 0o102, 0o666); + fileio.writeSync(fd, JSON.stringify(dataList)); + fileio.closeSync(fd); + console.log(TAG + "saveAllMaps end"); + } + + uint8ArrayToString(fileData) { + var dataString = ""; + for (var i = 0; i < fileData.length; i++) { + dataString += String.fromCharCode(fileData[i]); + } + return dataString + } + + restoreMapsFromJson(json) { + console.log(TAG + "restoreMapsFromJson start Json: " + json); + let dataList = JSON.parse(json); + this.systemCertMap = this.jsonToMap(dataList[0]); + this.userCertMap = this.jsonToMap(dataList[1]); + this.uriToAlias = this.jsonToMap(dataList[2]); + this.appCredMap = this.jsonToMap(dataList[3]); + this.privateCredMap = this.jsonToMap(dataList[4]); + this.uriToAppList = this.jsonToMap(dataList[5]); + console.log(TAG + "restoreMapsFromJson end"); + } + + restoreAllMaps() { + console.log(TAG + "getAllMaps start"); + let context = globalThis.certManagerAbilityContext; + let path = context.cacheDir; + path += '/certStubData' + + try { + let fd = fileio.openSync(path, 0o002, 0o666); + console.log(TAG + "getAllMaps fd: " + fd); + let stat = fileio.fstatSync(fd); + let size = stat.size; + let buf = new ArrayBuffer(size); + + fileio.read(fd, buf, (err, data) => { + if (data) { + this.restoreMapsFromJson(this.uint8ArrayToString(new Uint8Array(data.buffer))); + } + fileio.closeSync(fd); + }); + } catch(err) { + console.log(TAG + "getAllMaps err: " + err); + } + + console.log(TAG + "getAllMaps end"); + } +} + +let certStub = new CertStubPromise(); + +export default certStub as CertStubPromise; diff --git a/cer_xts/cer_xts_multi_user/entry/src/main/ets/stub/certStubStruct.ets b/cer_xts/cer_xts_multi_user/entry/src/main/ets/stub/certStubStruct.ets new file mode 100644 index 0000000000000000000000000000000000000000..78c417c798e6145f591227aa9beace447e535f61 --- /dev/null +++ b/cer_xts/cer_xts_multi_user/entry/src/main/ets/stub/certStubStruct.ets @@ -0,0 +1,161 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export interface CertInfo { + uri: string, + certAlias: string, + status: boolean, + issuerName: string, + subjectName: string, + serial: string, + notBefore: string, + notAfter: string, + fingerprintSha256: string, + cert: Uint8Array +} + +export interface certAbstract { + uri: string, + certAlias: string, + status: boolean, + subjectName: string, +} + +export interface CMResult { + certList?: Array, + certInfo?: CertInfo, + credentialList?:Array, + credential?: Credential, + appUidList?: Array + authUri?: string, + outData?: Uint8Array, + isAuth?: boolean +} + +export interface CMHandle { + errorCode: number, + handle: number; + token?: Uint8Array; +} + +export interface Credential { + type: string, + alias: string, + keyUri: string, + certNum: number, + keyNum: number, + credData: Uint8Array +} + +export interface CredentialAbstract { + type: string, + alias: string, + keyUri: string +} + +export interface CMContext { + userId: string, + uid: string, + packageName: string +}; + +export interface CertBlob { + readonly inData?: Uint8Array, + readonly alias?: string +}; + +export interface CMKeyProperties { + type: string; // Type of the key, must be CM_URI_TYPE_APP_KEY or CM_URI_TYPE_WLAN_KEY + alg: string; + size: number; + padding: string; + purpose: string; + digest: string; + authType: string; + authTimeout: string; +}; + +export interface CMSignatureSpec { + alg: string; + padding: string; + digest: string; + authToken: Uint8Array; // required only for user authentication +}; + +export enum CertManagerStore { + CERT_MANAGER_CREDENTIAL_STORE = 0, /* credential certificate store for end entity certificates. */ + CERT_MANAGER_SYSTEM_TRUSTED_STORE = 1, /* read only, updated by system only. */ + CERT_MANAGER_USER_TRUSTED_STORE = 2, /* modifiable by applications and user. */ + CERT_MANAGER_APPLICATION_TRUSTED_STORE = 3, /* application specific trusted certificate store; modifiable by the application only. */ +} + +export enum CMErrorCode { + CMR_SUCCESS = 0, + CMR_FAILURE = -1, + CMR_ERROR_INSTALL_CERTIFICATE = -2, + CMR_ERROR_SET_STATUS = -3, + CMR_ERROR_INVALID_ARGUMENT = -3, + CMR_ERROR_INVALID_STORE = -4, + CMR_ERROR_NOT_SUPPORTED = -5, + CMR_ERROR_UNINSTALL = -6, + CMR_ERROR_NO_PERMISSION = -7, + CMR_ERROR_INSUFFICIENT_DATA = -8, + CMR_ERROR_GET_CERTIRICATE = -9, + CMR_ERROR_STORAGE_FAILURE = -10, + CMR_ERROR_HARDWARE_FAILURE = -11, + CMR_ERROR_ALREADY_EXISTS = -12, + CMR_ERROR_NOT_EXIST = -13, + CMR_ERROR_NULL_POINTER = -14, + CMR_ERROR_FILE_SIZE_FAIL = -15, + CMR_ERROR_READ_FILE_FAIL = -16, + CMR_ERROR_INVALID_PUBLIC_KEY = -17, + CMR_ERROR_INVALID_PRIVATE_KEY = -18, + CMR_ERROR_INVALID_KEY_INFO = -19, + CMR_ERROR_REMOVE_CERTIFICATE_FAIL = -20, + CMR_ERROR_OPEN_FILE_FAIL = -21, + CMR_ERROR_INVALID_KEY_FILE = -22, + CMR_ERROR_IPC_MSG_FAIL = -23, + CMR_ERROR_REQUEST_OVERFLOWS = -24, + CMR_ERROR_PARAM_NOT_EXIST = -25, + CMR_ERROR_CRYPTO_ENGINE_ERROR = -26, + CMR_ERROR_COMMUNICATION_TIMEOUT = -27, + CMR_ERROR_IPC_INIT_FAIL = -28, + CMR_ERROR_IPC_DLOPEN_FAIL = -29, + CMR_ERROR_EFUSE_READ_FAIL = -30, + + CMR_ERROR_CHECK_GET_ALG_FAIL = -100, + CMR_ERROR_CHECK_GET_KEY_SIZE_FAIL = -101, + CMR_ERROR_CHECK_GET_PADDING_FAIL = -102, + CMR_ERROR_INVALID_DIGEST = -117, + + CMR_ERROR_INTERNAL_ERROR = -999, + CMR_ERROR_UNKNOWN_ERROR = -1000, +} + +export interface BusinessError { + /** + * Defines the basic error code. + * @since 6 + */ + code: number; +} + +export interface AsyncCallback { + /** + * Defines the callback data. + * @since 6 + */ + (err: BusinessError, data: T): void; +} diff --git a/cer_xts/cer_xts_multi_user/entry/src/main/ets/stub/certStubUtil.ets b/cer_xts/cer_xts_multi_user/entry/src/main/ets/stub/certStubUtil.ets new file mode 100644 index 0000000000000000000000000000000000000000..28b63a6c020158a331bc9d2928d2020ceb494ebf --- /dev/null +++ b/cer_xts/cer_xts_multi_user/entry/src/main/ets/stub/certStubUtil.ets @@ -0,0 +1,149 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { CertInfo, certAbstract, CMResult, CMContext, AsyncCallback, BusinessError, CMHandle, + Credential, CredentialAbstract, CMErrorCode, CertBlob, CMKeyProperties, CMSignatureSpec } from './certStubStruct' + +export default class certStubUtil { + constructor() { + } + + parseCertInfo(uri: string, certAlias: string, status: boolean, cert: Uint8Array): CertInfo { + let certInfo: CertInfo; + + certInfo = { + uri: uri, + certAlias: certAlias, + status: status, + issuerName: "CN = OpenHarmony Application Root CA,OU = OpenHarmony Team,O = OpenHarmony,C = CN", + subjectName: "CN = OpenHarmony Application Root CA,OU = OpenHarmony Team,O = OpenHarmony,C = CN", + serial: "0fe1388b", + notBefore: "2021/2/2", + notAfter: "2049/12/31", + fingerprintSha256: "23:b7:4d:a0:2f:00:a0:2a:16:c8:8d:bc:4c:71:ea:fd:7e:53:95:09", + cert: cert + } + + return certInfo; + } + + parseCertAbstract(uri: string, certAlias: string, status: boolean): certAbstract { + let result: certAbstract; + + result = { + uri: uri, + certAlias: certAlias, + status: status, + subjectName: "CN=SwissSign Gold CA - G2,OU=,O=SwissSign", + } + + return result; + } + + + parseCMHandle(errorCode: number, handle: number, token: Uint8Array): CMHandle { + let result: CMHandle; + + result = { + errorCode: errorCode, + handle: handle, + token: token, + } + + return result; + } + + parseCredential(type: string, alias: string, keyUri: string, certNum: number, + keyNum: number, credData: Uint8Array): Credential { + let result: Credential; + + result = { + type: type, + alias: alias, + keyUri: keyUri, + certNum: certNum, + keyNum: keyNum, + credData: credData + } + + return result; + } + + parseCredentialAbstract(type: string, alias: string, keyUri: string): CredentialAbstract { + let result: CredentialAbstract; + + result = { + type: type, + alias: alias, + keyUri: keyUri + } + + return result; + } + + parseCMContext(userId: string, uid: string, packageName: string): CMContext { + let result: CMContext; + + result = { + userId: userId, + uid: uid, + packageName: packageName + } + + return result; + } + + parseCertBlob(inData: Uint8Array, alias: string): CertBlob { + let result: CertBlob; + + result = { + inData: inData, + alias: alias + } + + return result; + } + + parseCMKeyProperties(): CMKeyProperties { + let result: CMKeyProperties; + + result = { + type: "CM_URI_TYPE_APP_KEY", // Type of the key, must be CM_URI_TYPE_APP_KEY or CM_URI_TYPE_WLAN_KEY + alg: "alg", + size: 375, + padding: "padding purpose", + purpose: "purpose property", + digest: "digest property", + authType: "Sha-256", + authTimeout: "30" + } + + return result; + } + + parseCMSignatureSpec(alg: string, padding: string, digest: string, authToken: Uint8Array): CMSignatureSpec { + let result: CMSignatureSpec; + + result = { + alg: alg, + padding: padding, + digest: digest, + authToken: authToken // required only for user authentication + } + + return result; + } + +} diff --git a/cer_xts/cer_xts_multi_user/entry/src/main/ets/test/Ability.test.ets b/cer_xts/cer_xts_multi_user/entry/src/main/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..070080118d178ebb1f5ee4aed646d24b0f955690 --- /dev/null +++ b/cer_xts/cer_xts_multi_user/entry/src/main/ets/test/Ability.test.ets @@ -0,0 +1,1272 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index' + import certStubPromise from './../stub/certStubPromise' + import certStubCallback from './../stub/certStubCallback' + import { CMSignatureSpec, CMErrorCode, CMKeyProperties, CertBlob } from './../stub/certStubStruct' + import fileio from '@ohos.fileio' + import bundle from '@ohos.bundle' + + var certFileArray: Uint8Array + + function loadInstallFile(CertName: string) { + let path = globalThis.abilityContext.cacheDir + path = path + '/' + CertName + console.log('SEC_CertificateManagement_Interface_Js path is:' + path) + let fd = fileio.openSync(path, 0o102, 0o666); + console.log('SEC_CertificateManagement_Interface_Js fd is:' + fd) + let stat = fileio.fstatSync(fd); + let size = stat.size; + let buf = new ArrayBuffer(size); + fileio.read(fd, buf, (err, data) => { + if (data) { + certFileArray = new Uint8Array(data.buffer); + } + }); + } + + var clientAppUidStr = '' + + function getClientAppUid() { + return new Promise(async (resolve) => { + if (clientAppUidStr == '') { + let bundleInfo = await bundle.getBundleInfo("com.example.cer_xts_multi_user", bundle.BundleFlag.GET_BUNDLE_DEFAULT) + let clientAppUid = bundleInfo.uid + clientAppUidStr = clientAppUid.toString() + } + resolve(clientAppUidStr) + }) + } + + async function installTestUserTrustedCAPromise(CertName: string) { + loadInstallFile(CertName) + await certStubPromise.installUserTrustedCertificate({ + inData: certFileArray, + alias: 'UserCert' + }) + } + + async function installTestUserTrustedCACallback(CertName: string) { + loadInstallFile(CertName) + certStubCallback.installUserTrustedCertificate({ + inData: certFileArray, + alias: 'UserCert' + }, (err, data) => { + console.log('in installUserTrustedCertificate callback') + }) + } + + var keyStore: Uint8Array + async function getGeneratePrivateCert() { + let keyAlias = 'generateKeyAlias' + let keyProperties: CMKeyProperties + keyProperties = { + type: 'CM_URI_TYPE_APP_KEY', + alg: 'string', + size: 1, + padding: 'string', + purpose: 'string', + digest: 'string', + authType: 'string', + authTimeout: 'string', + } + let cmResult = await certStubPromise.generatePrivateCertificate(keyAlias, keyProperties) + keyStore = cmResult.outData + } + + export default function abilityTest() { + describe('CertificateMultiUserXTSTest', function () { + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GetSystemCAList + * @tc.desc Test for CmGetCertList js interface - system root certificate - get the certificate + * list normally (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_GetSystemCAList_0003 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetSystemCAList_0003', 0, async function (done) { + try { + let result = await certStubPromise.getSystemTrustedCertificateList() + expect(result.certList[0].uri).assertEqual('uri://stub/certFile/0') + expect(result.certList[0].certAlias).assertEqual('SystemRoot_1') + expect(result.certList[0].status).assertEqual(true) + expect(result.certList[0].subjectName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + expect(result.certList[1].uri).assertEqual('uri://stub/certFile/1') + expect(result.certList[1].certAlias).assertEqual('SystemRoot_2') + expect(result.certList[1].status).assertEqual(false) + expect(result.certList[1].subjectName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + expect(result.certList[2].uri).assertEqual('uri://stub/certFile/2') + expect(result.certList[2].certAlias).assertEqual('SystemRoot_3') + expect(result.certList[2].status).assertEqual(true) + expect(result.certList[2].subjectName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + done() + } catch (error) { + console.log('getSystemTrustedCertificateList failed' + JSON.stringify(error.code)) + expect().assertFail() + done() + } + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GetSystemCAList + * @tc.desc Test for CmGetCertList js interface - system root certificate - get the certificate + * list normally (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_GetSystemCAList_0007 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetSystemCAList_0007', 0, async function (done) { + certStubCallback.getSystemTrustedCertificateList((err, data) => { + expect(data.certList[0].uri).assertEqual('uri://stub/certFile/0') + expect(data.certList[0].certAlias).assertEqual('SystemRoot_1') + expect(data.certList[0].status).assertEqual(true) + expect(data.certList[0].subjectName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + expect(data.certList[1].uri).assertEqual('uri://stub/certFile/1') + expect(data.certList[1].certAlias).assertEqual('SystemRoot_2') + expect(data.certList[1].status).assertEqual(false) + expect(data.certList[1].subjectName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + expect(data.certList[2].uri).assertEqual('uri://stub/certFile/2') + expect(data.certList[2].certAlias).assertEqual('SystemRoot_3') + expect(data.certList[2].status).assertEqual(true) + expect(data.certList[2].subjectName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + expect(err.code).assertEqual(0) + done() + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GetSystemCAList + * @tc.desc Test for CmGetCertInfo js interface - system root certificate - get the certificate + * info normally (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_GetSystemCAInfo_0003 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetSystemCAInfo_0003', 0, async function (done) { + try { + let Listresult = await certStubPromise.getSystemTrustedCertificateList() + let Inforesult = await certStubPromise.getSystemTrustedCertificate(Listresult.certList[0].uri) + console.log('uri is:' + JSON.stringify(Inforesult.certInfo.uri)) + expect(Inforesult.certInfo.uri).assertEqual('uri://stub/certFile/0') + expect(Inforesult.certInfo.certAlias).assertEqual('SystemRoot_1') + expect(Inforesult.certInfo.status).assertEqual(true) + expect(Inforesult.certInfo.subjectName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + expect(Inforesult.certInfo.fingerprintSha256).assertEqual('23:b7:4d:a0:2f:00:a0:2a:16:c8:8d:' + + 'bc:4c:71:ea:fd:7e:53:95:09') + expect(Inforesult.certInfo.serial).assertEqual('0fe1388b') + expect(Inforesult.certInfo.issuerName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + expect(Inforesult.certInfo.notBefore).assertEqual('2021/2/2') + expect(Inforesult.certInfo.notAfter).assertEqual('2049/12/31') + done() + } catch (error) { + console.log('getSystemTrustedCertificate failed' + JSON.stringify(error.code)) + expect().assertFail() + done() + } + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GetSystemCAList + * @tc.desc Test for CmGetCertInfo js interface - system root certificate - get the certificate + * info normally (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_GetSystemCAInfo_0007 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetSystemCAInfo_0007', 0, async function (done) { + certStubCallback.getSystemTrustedCertificateList((err, Listresult) => { + certStubCallback.getSystemTrustedCertificate(Listresult.certList[0].uri, (err, data) => { + expect(data.certInfo.uri).assertEqual('uri://stub/certFile/0') + expect(data.certInfo.certAlias).assertEqual('SystemRoot_1') + expect(data.certInfo.status).assertEqual(true) + expect(data.certInfo.subjectName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + expect(data.certInfo.fingerprintSha256).assertEqual('23:b7:4d:a0:2f:00:a0:2a:16:c8:8d:' + + 'bc:4c:71:ea:fd:7e:53:95:09') + expect(data.certInfo.serial).assertEqual('0fe1388b') + expect(data.certInfo.issuerName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + expect(data.certInfo.notBefore).assertEqual('2021/2/2') + expect(data.certInfo.notAfter).assertEqual('2049/12/31') + expect(err.code).assertEqual(CMErrorCode.CMR_SUCCESS) + done() + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_SetCertificateStatus + * @tc.desc Test for CmSetCertStatus js interface - system root certificate - set the certificate + * status normally (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0007 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0007', 0, async function (done) { + try { + let Listresult = await certStubPromise.getSystemTrustedCertificateList() + await certStubPromise.setCertificateStatus(Listresult.certList[0].uri, 1, false) + expect(Listresult.certList[0].status).assertEqual(false) + done() + } catch (error) { + console.log('setCertificateStatus failed' + JSON.stringify(error.code)) + expect().assertFail() + done() + } + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_SetCertificateStatus + * @tc.desc Test for CmSetCertStatus js interface - system root certificate - set the certificate + * status normally (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0008 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0008', 0, async function (done) { + try { + let Listresult = await certStubPromise.getSystemTrustedCertificateList() + await certStubPromise.setCertificateStatus(Listresult.certList[0].uri, 1, true) + expect(Listresult.certList[0].status).assertEqual(true) + done() + } catch (error) { + console.log('setCertificateStatus failed' + JSON.stringify(error.code)) + expect().assertFail() + done() + } + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_SetCertificateStatus + * @tc.desc Test for CmSetCertStatus js interface - system root certificate - set the certificate + * status normally (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0017 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0017', 0, async function (done) { + certStubCallback.getSystemTrustedCertificateList((err, Listresult) => { + certStubCallback.setCertificateStatus(Listresult.certList[0].uri, 1, false, (err, data) => { + expect(Listresult.certList[0].status).assertEqual(false) + expect(err.code).assertEqual(0) + done() + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_SetCertificateStatus + * @tc.desc Test for CmSetCertStatus js interface - system root certificate - set the certificate + * status normally (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0018 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0018', 0, async function (done) { + certStubCallback.getSystemTrustedCertificateList((err, Listresult) => { + certStubCallback.setCertificateStatus(Listresult.certList[1].uri, 1, true, (err, data) => { + expect(Listresult.certList[1].status).assertEqual(true) + expect(err.code).assertEqual(0) + done() + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GetUserCAList + * @tc.desc Test for CmGetCertList js interface - user root certificate - get the certificate + * list normally (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_GetUserCAList_0003 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetUserCAList_0003', 0, async function (done) { + try { + installTestUserTrustedCAPromise('rootca.cer') + let result = await certStubPromise.getUserTrustedCertificateList() + console.log('result is:' + JSON.stringify(result)) + expect(result.certList[0].certAlias).assertEqual('UserCert') + expect(result.certList[0].status).assertEqual(true) + expect(result.certList[0].subjectName) + .assertEqual('CN = OpenHarmony Application Root CA,OU = OpenHarmony Team,O = OpenHarmony,C = CN') + await certStubPromise.uninstallUserTrustedCertificate(result.certList[0].uri) + done() + } catch (error) { + console.log('getUserTrustedCertificateList failed' + JSON.stringify(error.code)) + expect().assertFail() + done() + } + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GetUserCAList + * @tc.desc Test for CmGetCertList js interface - user root certificate - get the certificate + * list normally (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_GetUserCAList_0007 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetUserCAList_0007', 0, async function (done) { + installTestUserTrustedCACallback('rootca.cer') + certStubCallback.getUserTrustedCertificateList((err, result) => { + expect(result.certList[0].certAlias).assertEqual('UserCert') + expect(result.certList[0].status).assertEqual(true) + expect(result.certList[0].subjectName) + .assertEqual('CN = OpenHarmony Application Root CA,OU = OpenHarmony Team,O = OpenHarmony,C = CN') + expect(err.code).assertEqual(0) + certStubCallback.uninstallUserTrustedCertificate(result.certList[0].uri, (err, data) => { + done() + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GetUserCAInfo + * @tc.desc Test for CmGetCertInfo js interface - user root certificate - get the certificate + * info normally (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_GetUserCAInfo_0003 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetUserCAInfo_0003', 0, async function (done) { + try { + installTestUserTrustedCAPromise('rootca.cer') + let Listresult = await certStubPromise.getUserTrustedCertificateList() + let Inforesult = await certStubPromise.getUserTrustedCertificate(Listresult.certList[0].uri) + expect(Inforesult.certInfo.certAlias).assertEqual('UserCert') + expect(Inforesult.certInfo.status).assertEqual(true) + expect(Inforesult.certInfo.subjectName).assertEqual('CN = OpenHarmony Application Root CA,' + + 'OU = OpenHarmony Team,O = OpenHarmony,C = CN') + expect(Inforesult.certInfo.fingerprintSha256).assertEqual('23:b7:4d:a0:2f:00:a0:2a:16:c8:8d:bc:' + + '4c:71:ea:fd:7e:53:95:09') + expect(Inforesult.certInfo.serial).assertEqual('0fe1388b') + expect(Inforesult.certInfo.issuerName).assertEqual('CN = OpenHarmony Application Root CA,' + + 'OU = OpenHarmony Team,O = OpenHarmony,C = CN') + expect(Inforesult.certInfo.notBefore).assertEqual('2021/2/2') + expect(Inforesult.certInfo.notAfter).assertEqual('2049/12/31') + await certStubPromise.uninstallUserTrustedCertificate(Listresult.certList[0].uri) + done() + } catch (error) { + console.log('getUserTrustedCertificate failed' + JSON.stringify(error.code)) + expect().assertFail() + done() + } + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GetUserCAInfo + * @tc.desc Test for CmGetCertInfo js interface - user root certificate - get the certificate + * info normally (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_GetUserCAInfo_0007 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetUserCAInfo_0007', 0, async function (done) { + installTestUserTrustedCACallback('rootca.cer') + certStubCallback.getUserTrustedCertificateList((err, Listresult) => { + certStubCallback.getUserTrustedCertificate(Listresult.certList[0].uri, (err, data) => { + expect(data.certInfo.certAlias).assertEqual('UserCert') + expect(data.certInfo.status).assertEqual(true) + expect(data.certInfo.subjectName).assertEqual('CN = OpenHarmony Application Root CA,' + + 'OU = OpenHarmony Team,O = OpenHarmony,C = CN') + expect(data.certInfo.fingerprintSha256).assertEqual('23:b7:4d:a0:2f:00:a0:2a:16:c8:8d:bc:' + + '4c:71:ea:fd:7e:53:95:09') + expect(data.certInfo.serial).assertEqual('0fe1388b') + expect(data.certInfo.issuerName).assertEqual('CN = OpenHarmony Application Root CA,' + + 'OU = OpenHarmony Team,O = OpenHarmony,C = CN') + expect(data.certInfo.notBefore).assertEqual('2021/2/2') + expect(data.certInfo.notAfter).assertEqual('2049/12/31') + expect(err.code).assertEqual(0) + certStubCallback.uninstallUserTrustedCertificate(Listresult.certList[0].uri, (err, data) => { + done() + }) + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_UninstallUserCertificate + * @tc.desc Test for CmUninstallCert js interface - user root certificate - uninstall the certificate + * normally (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_UninstallUserCertificate_0002 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_UninstallUserCertificate_0002', 0, async function (done) { + try { + installTestUserTrustedCAPromise('rootca.cer') + let Listresulte = await certStubPromise.getUserTrustedCertificateList() + await certStubPromise.uninstallUserTrustedCertificate(Listresulte.certList[0].uri) + Listresulte = await certStubPromise.getUserTrustedCertificateList() + for (let i = 0; i < Listresulte.certList.length; i++) { + if (Listresulte.certList[i].certAlias == 'UserCert') { + expect().assertFail() + } + } + done() + } catch (error) { + console.log('uninstallUserTrustedCertificate failed' + JSON.stringify(error.code)) + expect().assertFail() + done() + } + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_UninstallUserCertificate + * @tc.desc Test for CmUninstallCert js interface - user root certificate - uninstall the certificate + * normally (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_UninstallUserCertificate_0002 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_UninstallUserCertificate_0006', 0, async function (done) { + installTestUserTrustedCACallback('rootca.cer') + certStubCallback.getUserTrustedCertificateList((err, data) => { + certStubCallback.uninstallUserTrustedCertificate(data.certList[0].uri, (err, data) => { + certStubCallback.getUserTrustedCertificateList((err, data) => { + for (let i = 0; i < data.certList.length; i++) { + if (data.certList[i].certAlias == 'UserCert') { + expect().assertFail() + } + } + done() + }) + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_UserCertificateInstall + * @tc.desc Multi-user installation user certificate promise form. + * @tc.number SEC_CertificateManagement_Interface_Js_UserCertificateInstall_0010 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Func_UserCertificateInstall_0010', 0, async function (done) { + loadInstallFile('rootca.cer') + await certStubPromise.installUserTrustedCertificate({ + inData: certFileArray, + alias: 'userCer10' + }) + let userCerInstall = false + let keyUri = '' + let resultList = await certStubPromise.getUserTrustedCertificateList() + console.log('resultList is:' + JSON.stringify(resultList)) + for (var i = 0; i < resultList.certList.length; i++) { + if (resultList.certList[i].certAlias == 'userCer10') { + console.log('userCer01 install success') + userCerInstall = true + keyUri = resultList.certList[i].uri + break + } + } + expect(userCerInstall).assertTrue() + await certStubPromise.uninstallUserTrustedCertificate(keyUri) + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_UserCertificateInstall + * @tc.desc Multi-user installation user certificate callback form. + * @tc.number SEC_CertificateManagement_Interface_Js_UserCertificateInstall_0011 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Func_UserCertificateInstall_0011', 0, async function (done) { + loadInstallFile('rootca.cer') + let userCerInstall = false + let keyUri = '' + certStubCallback.installUserTrustedCertificate({ + inData: certFileArray, + alias: 'userCer11' + }, (err) => { + expect(err.code).assertEqual(0) + certStubCallback.getUserTrustedCertificateList((err, data) => { + for (var i = 0; i < data.certList.length; i++) { + if (data.certList[i].certAlias == 'userCer11') { + console.log('userCer02 install success') + userCerInstall = true + keyUri = data.certList[i].uri + break + } + } + expect(userCerInstall).assertTrue() + certStubCallback.uninstallUserTrustedCertificate(keyUri, (err) => { + expect(err.code).assertEqual(0) + done() + }) + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_BusinessCertificateInstall + * @tc.desc Multi-user installation business certificate promise form. + * @tc.number SEC_CertificateManagement_Interface_Js_BusinessCertificateInstall_0010 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_BusinessCertificateInstall_0010', 0, async function (done) { + loadInstallFile('appca.p12') + let keystorePwd = "123456" + let certAlias = "AppCer10" + let appCerInstall = false + let keyUri = '' + await certStubPromise.installAppCertificate(certFileArray, keystorePwd, certAlias) + let resultList = await certStubPromise.getAppCertificateList() + console.log('resultList is:' + JSON.stringify(resultList)) + for (var i = 0; i < resultList.credentialList.length; i++) { + if (resultList.credentialList[i].alias == certAlias) { + console.log('AppCer01 install SUCCESS') + appCerInstall = true + keyUri = resultList.credentialList[i].keyUri + break; + } + } + expect(appCerInstall).assertTrue() + await certStubPromise.uninstallAppCertificate(keyUri) + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_BusinessCertificateInstall + * @tc.desc Multi-user installation business certificate callback form. + * @tc.number SEC_CertificateManagement_Interface_Js_BusinessCertificateInstall_0011 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_BusinessCertificateInstall_0011', 0, async function (done) { + loadInstallFile('appca.p12') + let keystorePwd = "123456" + let certAlias = "AppCer02" + let appCerInstall = false + var keyUri = '' + certStubCallback.installAppCertificate(certFileArray, keystorePwd, certAlias, (err) => { + expect(err.code).assertEqual(0) + certStubCallback.getAppCertificateList((err, data) => { + for (var i = 0; i < data.credentialList.length; i++) { + if (data.credentialList[i].alias == certAlias) { + console.log('AppCer02 install success') + appCerInstall = true + keyUri = data.credentialList[i].keyUri + break; + } + } + expect(appCerInstall).assertTrue() + certStubCallback.uninstallAppCertificate(keyUri, (err) => { + expect(err.code).assertEqual(0) + done() + }) + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_PrivateCertificateInstall + * @tc.desc Multi-user installation private certificate promise form. + * @tc.number SEC_CertificateManagement_Interface_Js_PrivateCertificateInstall_0010 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_PrivateCertificateInstall_0010', 0, async function (done) { + getGeneratePrivateCert() + let keyStorePwd = "123456" + let certAlias = "PrivateCert10" + let privateCerInstall = false + await certStubPromise.installPrivateCertificate(keyStore, keyStorePwd, certAlias) + let resultList = await certStubPromise.getPrivateCertificateList() + console.log('resultList is:' + JSON.stringify(resultList)) + for (var i = 0; i < resultList.credentialList.length; i++) { + if (resultList.credentialList[i].alias == certAlias) { + console.log('Find the installed private certificate alias') + privateCerInstall = true + break; + } + } + expect(privateCerInstall).assertTrue() + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_PrivateCertificateInstall + * @tc.desc Multi-user installation private certificate callback form. + * @tc.number SEC_CertificateManagement_Interface_Js_PrivateCertificateInstall_0011 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_PrivateCertificateInstall_0011', 0, async function (done) { + getGeneratePrivateCert() + let keyStorePwd = "123456" + let certAlias = "PrivateCer11" + let privateCerInstall = false + certStubCallback.installPrivateCertificate(keyStore, keyStorePwd, certAlias, (err) => { + expect(err.code).assertEqual(0) + certStubCallback.getPrivateCertificateList((err, data) => { + for (var i = 0; i < data.credentialList.length; i++) { + if (data.credentialList[i].alias == certAlias) { + console.log('Find the installed private certificate alias') + privateCerInstall = true + break; + } + } + expect(privateCerInstall).assertTrue() + done() + }) + }) + }) + + /** + * @tc.name GetAppCertificateList0003 + * @tc.desc Test for GetAppCertificateList JS interface - app certificate - get + the certificate list normally promise. + * @tc.number SEC_CertificateManagement_Interface_Js_GetAppCertificateList_0003 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetAppCertificateList_0003', 0, async function (done) { + try { + loadInstallFile('appca.p12') + let keystorePwd = "123456" + var keyUri = "" + let appCerInstall = false + await certStubPromise.installAppCertificate(certFileArray, keystorePwd, "GetAppCertificateList003") + let result = await certStubPromise.getAppCertificateList() + for (let j = 0; j < result.credentialList.length; j++) { + if (result.credentialList[j].alias == "GetAppCertificateList003") { + keyUri = result.credentialList[j].keyUri + appCerInstall = true + break + } + } + expect(appCerInstall).assertEqual(true) + } catch (error) { + console.info("getAppCertificateList_0003 err" + JSON.stringify(error.code)) + expect().assertFail(); + done(); + } + certStubPromise.uninstallAppCertificate(keyUri) + done() + }) + + /** + * @tc.name GetAppCertificateList0006 + * @tc.desc Test for GetAppCertificateList JS interface - app certificate - get + the certificate list normally (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_GetAppCertificateList_0006 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetAppCertificateList_0006', 0, async function (done) { + loadInstallFile('appca.p12') + let keystorePwd = "123456" + var keyUri = "" + let appCerInstall = false + certStubCallback.installAppCertificate(certFileArray, keystorePwd, "GetAppCertificateList0006", (err) => { + certStubCallback.getAppCertificateList((err, data) => { + for (let j = 0; j < data.credentialList.length; j++) { + if (data.credentialList[j].alias == "GetAppCertificateList0006") { + keyUri = data.credentialList[j].keyUri + appCerInstall = true + } + } + expect(appCerInstall).assertEqual(true) + certStubCallback.uninstallAppCertificate(keyUri, (err) => { + done() + }) + }) + }) + }) + + /** + * @tc.name GetAppCertifiCate0003 + * @tc.desc Test for GetAppCertifiCate JS interface - app certificate - get + the certificate Info normally (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_GetAppCertifiCate_0003 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetAppCertifiCate_0003', 0, async function (done) { + try { + loadInstallFile('appca.p12') + let keystorePwd = "123456" + var keyUri = "" + let appCerInstall = false + await certStubPromise.installAppCertificate(certFileArray, keystorePwd, "GetAppCertifiCate0003") + let result = await certStubPromise.getAppCertificateList() + for (let j = 0; j < result.credentialList.length; j++) { + if (result.credentialList[j].alias == "GetAppCertifiCate0003") { + keyUri = result.credentialList[j].keyUri + appCerInstall = true + } + } + var AppCertificate = await certStubPromise.getAppCertificate(keyUri) + expect(appCerInstall).assertEqual(true) + expect(AppCertificate.credential.alias).assertEqual("GetAppCertifiCate0003") + certStubPromise.uninstallAppCertificate(keyUri) + + done(); + } catch (err) { + console.info("getAppCertificate_0003 err" + JSON.stringify(err)) + expect().assertFail(); + done(); + } + }) + + /** + * @tc.name GetAppCertifiCate0008 + * @tc.desc Test for GetAppCertifiCate JS interface - app certificate - get + the certificate Info normally (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_GetAppCertifiCate_0008 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetAppCertifiCate_0008', 0, async function (done) { + loadInstallFile('appca.p12') + let keystorePwd = "123456" + var keyUri = "" + let appCerInstall = false + await certStubPromise.installAppCertificate(certFileArray, keystorePwd, "GetAppCertifiCate0008") + for (var i = 0; i < 5; i++) { + try { + let result = await certStubPromise.getAppCertificateList() + for (let j = 0; j < result.credentialList.length; j++) { + if (result.credentialList[j].alias == "GetAppCertifiCate0008") { + keyUri = result.credentialList[j].keyUri + appCerInstall = true + break + } + } + let AppCertificate = await certStubPromise.getAppCertificate(keyUri) + expect(AppCertificate.credential.alias).assertEqual("GetAppCertifiCate0008") + expect(appCerInstall).assertEqual(true) + } catch (error) { + console.log('getAppCertificateList_0008 failed' + JSON.stringify(error.code)) + expect().assertFail() + done() + } + } + certStubPromise.uninstallAppCertificate(keyUri) + done() + }) + + /** + * @tc.name GetPrivateCertificateList0003 + * @tc.desc Test for GetPrivateCertificateList JS interface - private certificate - get + the certificate list normally (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_GetPrivateCertificateList_0003 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetPrivateCertificateList_0003', 0, async function (done) { + try { + getGeneratePrivateCert() + let keyStorePwd = "123456" + let certAlias = "PrivateCer03" + certStubPromise.installPrivateCertificate(keyStore, keyStorePwd, certAlias) + var PrivateCertificateList = await certStubPromise.getPrivateCertificateList() + expect(PrivateCertificateList.credentialList[0].type).assertEqual("CM_URI_TYPE_APP_KEY") + expect(PrivateCertificateList.credentialList[0].alias).assertEqual("Huawei-Employee_WPA_EAPIEA") + done(); + } catch (err) { + console.info("getPrivateCertificateList_0003 err" + JSON.stringify(err)) + expect().assertFail(); + done(); + } + }) + + /** + * @tc.name GetPrivateCertificateList0006 + * @tc.desc Test for GetPrivateCertificateList JS interface - private certificate - get + the certificate list normally (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_GetPrivateCertificateList_0006 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetPrivateCertificateList_0006', 0, async function (done) { + getGeneratePrivateCert() + let keyStorePwd = "123456" + let certAlias = "PrivateCer06" + certStubCallback.installPrivateCertificate(keyStore, keyStorePwd, certAlias, (err) => { + certStubCallback.getPrivateCertificateList((err, data) => { + expect(err.code).assertEqual(0) + expect(data.credentialList[0].type).assertEqual("CM_URI_TYPE_APP_KEY") + expect(data.credentialList[0].alias).assertEqual("Huawei-Employee_WPA_EAPIEA") + done(); + }) + }) + }) + + /** + * @tc.name GetPrivateCertifiCate0003 + * @tc.desc Test for GetPrivateCertifiCate JS interface - private certificate - get + the certificate Info normally (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_GetPrivateCertifiCate_0003 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetPrivateCertifiCate_0003', 0, async function (done) { + try { + getGeneratePrivateCert() + let keystorePwd = "123456" + let appCerInstall = false + let cmResult = await certStubPromise.installPrivateCertificate(keyStore, keystorePwd, "GetPrivateList0003") + let keyUri = cmResult.authUri + var PrivateCertificateList = await certStubPromise.getPrivateCertificateList() + for (let j = 0; j < PrivateCertificateList.credentialList.length; j++) { + if (PrivateCertificateList.credentialList[j].alias == "GetPrivateList0003") { + appCerInstall = true + break + } + } + expect(appCerInstall).assertEqual(true) + await certStubPromise.uninstallPrivateCertificate(keyUri) + done(); + } catch (err) { + console.info("getPrivateCertificateList_0300 err" + JSON.stringify(err)) + expect().assertFail(); + done(); + } + }) + + /** + * @tc.name GetPrivateCertifiCate0008 + * @tc.desc Test for GetPrivateCertifiCate JS interface - private certificate - get + the certificate Info normally (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_GetPrivateCertifiCate_0008 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetPrivateCertifiCate_0008', 0, async function (done) { + getGeneratePrivateCert() + let keyStorePwd = "123456" + let appCerInstall = false + certStubCallback.installPrivateCertificate(keyStore, keyStorePwd, "GetPrivateList0008", (err, cmResult) => { + let keyUri = cmResult.authUri + certStubCallback.getPrivateCertificateList((err, data) => { + for (let j = 0; j < data.credentialList.length; j++) { + if (data.credentialList[j].alias == "GetPrivateList0008") { + appCerInstall = true + break + } + } + expect(appCerInstall).assertEqual(true) + certStubCallback.uninstallPrivateCertificate(keyUri, (err) => { + done(); + }) + }) + }) + }) + + /** + * @tc.name GetAuthorizedAppList0003 + * @tc.desc Test for GetAuthorizedAppList JS interface - app certificate - get + the authorized application list normally (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_GetAuthorizedAppList_0003 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetAuthorizedAppList_0003', 0, async function (done) { + try { + loadInstallFile('appca.p12') + let keystorePwd = "123456" + var keyUri = "" + let appCerInstall = false + await certStubPromise.installAppCertificate(certFileArray, keystorePwd, "GetAuthorizedAppList0001") + let result = await certStubPromise.getAppCertificateList() + console.info("result1111" + JSON.stringify(result)) + for (let j = 0; j < result.credentialList.length; j++) { + if (result.credentialList[j].alias == "GetAuthorizedAppList0001") { + keyUri = result.credentialList[j].keyUri + appCerInstall = true + } + } + console.info("keyUri1111111" + keyUri) + await certStubPromise.getAuthorizedAppList(keyUri) + expect(appCerInstall).assertEqual(true) + certStubPromise.uninstallAppCertificate(keyUri) + done(); + } catch (err) { + console.info("GetAuthorizedAppList_0001 err" + JSON.stringify(err.code)) + expect().assertFail(); + done(); + } + }) + + /** + * @tc.name GetAuthorizedAppList0008 + * @tc.desc Test for GetAuthorizedAppList JS interface - app certificate - get + the authorized application list normally (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_GetAuthorizedAppList_0008 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetAuthorizedAppList_0008', 0, async function (done) { + loadInstallFile('appca.p12') + let keystorePwd = "123456" + var keyUri = "" + let appCerInstall = false + certStubCallback.installAppCertificate(certFileArray, keystorePwd, "GetAuthorizedAppList0008", (err) => { + certStubCallback.getAppCertificateList((err, data) => { + for (let j = 0; j < data.credentialList.length; j++) { + if (data.credentialList[j].alias == "GetAuthorizedAppList0008") { + keyUri = data.credentialList[j].keyUri + appCerInstall = true + break; + } + } + expect(appCerInstall).assertEqual(true) + certStubCallback.getAuthorizedAppList(keyUri, (err, data) => { + expect(err.code).assertEqual(0) + certStubCallback.uninstallAppCertificate(keyUri, (err) => { + done() + }) + }) + }) + }) + }) + + /** + * @tc.name UninstallAppCertificate0002 + * @tc.desc Delete the app certificate (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_UninstallAppCertificate_0002 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_UninstallAppCertificate_0002', 0, async function (done) { + try { + loadInstallFile('appca.p12') + let keystorePwd = "123456" + var keyUri = "" + let appCerInstall = false + await certStubPromise.installAppCertificate(certFileArray, keystorePwd, "UninstallAppCertificate0002") + let result = await certStubPromise.getAppCertificateList() + for (let j = 0; j < result.credentialList.length; j++) { + if (result.credentialList[j].alias == "UninstallAppCertificate0002") { + keyUri = result.credentialList[j].keyUri + break + } + } + await certStubPromise.uninstallAppCertificate(keyUri) + let AppCertificateList = await certStubPromise.getAppCertificateList() + for (let i = 0; i < AppCertificateList.credentialList.length; i++) { + if (AppCertificateList.credentialList[i].alias == "UninstallAppCertificate0002") { + expect().assertFail() + } + } + done(); + } catch (err) { + console.info("uninstallAppCertificate_0002 err" + JSON.stringify(err)) + expect().assertFail(); + done(); + } + }) + + /** + * @tc.name UninstallAppCertificate0008 + * @tc.desc Delete the app certificate (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_UninstallAppCertificate_0008 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_UninstallAppCertificate_0008', 0, async function (done) { + loadInstallFile('appca.p12') + let keystorePwd = "123456" + var keyUri = "" + certStubCallback.installAppCertificate(certFileArray, keystorePwd, "UninstallAppCertificate0008", (err) => { + certStubCallback.getAppCertificateList((err, data) => { + for (let j = 0; j < data.credentialList.length; j++) { + if (data.credentialList[j].alias == "UninstallAppCertificate0008") { + keyUri = data.credentialList[j].keyUri + break; + } + } + certStubCallback.uninstallAppCertificate(keyUri, (err, data) => { + certStubCallback.getAppCertificateList((err, data) => { + for (let i = 0; i < data.credentialList.length; i++) { + if (data.credentialList[i].alias == "UninstallAppCertificate0008") { + expect().assertFail() + } + } + done() + }) + }) + }) + }) + }) + + /** + * @tc.name RemoveGrantedAppCertificate0002 + * @tc.desc Test for RemoveGrantedAppCertificate JS interface - app certificate - Save the application + authorization status normally (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_RemoveGrantedAppCertificate_0002 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_RemoveGrantedAppCertificate_0002', 0, async function (done) { + await certStubPromise.uninstallAllAppCertificate() + loadInstallFile('appca.p12') + let keystorePwd = "123456" + let certAlias = "RemoveGrantedAppCert" + await certStubPromise.installAppCertificate(certFileArray, keystorePwd, certAlias) + let cmResult = await certStubPromise.getAppCertificateList() + let credentialList = cmResult.credentialList + let appKeyUri = credentialList[0].keyUri + clientAppUidStr = await getClientAppUid() + console.log('SEC_CertificateManagement_Interface_Js uid is ' + clientAppUidStr) + await certStubPromise.grantAppCertificate(appKeyUri, clientAppUidStr) + await certStubPromise.removeGrantedAppCertificate(appKeyUri, clientAppUidStr) + cmResult = await certStubPromise.getAuthorizedAppList(appKeyUri) + let appUidList = cmResult.appUidList + let findSign = false + for (let i = 0; i < appUidList.length; i++) { + if (appUidList[i] == clientAppUidStr) { + findSign = true + break + } + } + expect(findSign).assertFalse() + await certStubPromise.uninstallAppCertificate(appKeyUri) + console.log("SEC_CertificateManagement_Interface_Js_RemoveGrantedAppCertificate_0002 end") + done() + }) + + /** + * @tc.name RemoveGrantedAppCertificate0003 + * @tc.desc Test for RemoveGrantedAppCertificate JS interface - app certificate - Save the application + authorization status normally (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_RemoveGrantedAppCertificate_0003 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_RemoveGrantedAppCertificate_0003', 0, async function (done) { + certStubCallback.uninstallAllAppCertificate((err) => { + let keystorePwd = "123456" + let certAlias = "RemoveGrantedAppCert" + let appKeyUri = '' + certStubCallback.installAppCertificate(certFileArray, keystorePwd, certAlias, (err) => { + expect(err.code).assertEqual(0) + certStubCallback.getAppCertificateList(async (err, cmResult) => { + let credentialList = cmResult.credentialList + appKeyUri = credentialList[0].keyUri + clientAppUidStr = await getClientAppUid() + console.log('SEC_CertificateManagement_Interface_Js uid is' + clientAppUidStr) + certStubCallback.grantAppCertificate(appKeyUri, clientAppUidStr, async (err) => { + expect(err.code).assertEqual(0) + certStubCallback.removeGrantedAppCertificate(appKeyUri, clientAppUidStr, (err) => { + expect(err.code).assertEqual(0) + certStubCallback.getAuthorizedAppList(appKeyUri, (err, cmResult) => { + let appUidList = cmResult.appUidList + let findSign = false + for (let i = 0; i < appUidList.length; i++) { + if (appUidList[i] == clientAppUidStr) { + findSign = true + break + } + } + expect(findSign).assertFalse() + certStubCallback.uninstallAppCertificate(appKeyUri, (err) => { + expect(err.code).assertEqual(0) + console.log("SEC_CertificateManagement_Interface_Js_CertificateIsAuthorized_0003 end") + done() + }) + }) + }) + }) + }) + }) + }) + }) + }) + } + \ No newline at end of file diff --git a/cer_xts/cer_xts_multi_user/entry/src/main/ets/test/List.test.ets b/cer_xts/cer_xts_multi_user/entry/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..8828f3c461f6224c1f8532e6e299c7b1facc2824 --- /dev/null +++ b/cer_xts/cer_xts_multi_user/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import abilityTest from './Ability.test' + +export default function testsuite() { + abilityTest() +} \ No newline at end of file diff --git a/cer_xts/cer_xts_multi_user/entry/src/main/module.json b/cer_xts/cer_xts_multi_user/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..035cdc75464278063f3d80f9fc859ac37d6b8b61 --- /dev/null +++ b/cer_xts/cer_xts_multi_user/entry/src/main/module.json @@ -0,0 +1,37 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:entry_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/cer_xts/cer_xts_multi_user/entry/src/main/resources/base/element/string.json b/cer_xts/cer_xts_multi_user/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..bb1ef26e3b6592242b9ab7ea5b9613dd896b372a --- /dev/null +++ b/cer_xts/cer_xts_multi_user/entry/src/main/resources/base/element/string.json @@ -0,0 +1,40 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "MainAbility2_desc", + "value": "description" + }, + { + "name": "MainAbility2_label", + "value": "label" + }, + { + "name": "MainAbility3_desc", + "value": "description" + }, + { + "name": "MainAbility3_label", + "value": "label" + }, + { + "name": "app_name", + "value": "actsstartrunnertest" + }, + { + "name": "description_application", + "value": "demo for test" + } + ] +} \ No newline at end of file diff --git a/cer_xts/cer_xts_multi_user/entry/src/main/resources/base/media/icon.png b/cer_xts/cer_xts_multi_user/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/cer_xts/cer_xts_multi_user/entry/src/main/resources/base/media/icon.png differ diff --git a/cer_xts/cer_xts_multi_user/entry/src/main/resources/base/profile/main_pages.json b/cer_xts/cer_xts_multi_user/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..e291133c8b3c329611da5af30c299ec10589c7c2 --- /dev/null +++ b/cer_xts/cer_xts_multi_user/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/index" + ] +} \ No newline at end of file diff --git a/cer_xts/cer_xts_multi_user/signature/openharmony_sx.p7b b/cer_xts/cer_xts_multi_user/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/cer_xts/cer_xts_multi_user/signature/openharmony_sx.p7b differ diff --git a/cer_xts/cer_xts_system/AppScope/app.json b/cer_xts/cer_xts_system/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..da8005e94f0b4ade190ce8c08028c1e6d3517914 --- /dev/null +++ b/cer_xts/cer_xts_system/AppScope/app.json @@ -0,0 +1,19 @@ +{ + "app": { + "bundleName": "com.example.cerxts", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "distributedNotificationEnabled": true, + "keepAlive" : true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} \ No newline at end of file diff --git a/cer_xts/cer_xts_system/AppScope/resources/base/element/string.json b/cer_xts/cer_xts_system/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..eddf099a370034aefb60aee9470ac7c598c5ac00 --- /dev/null +++ b/cer_xts/cer_xts_system/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "AppSelectorTest" + } + ] +} \ No newline at end of file diff --git a/cer_xts/cer_xts_system/AppScope/resources/base/media/app_icon.png b/cer_xts/cer_xts_system/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/cer_xts/cer_xts_system/AppScope/resources/base/media/app_icon.png differ diff --git a/cer_xts/cer_xts_system/BUILD.gn b/cer_xts/cer_xts_system/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..bdaff1e03faecfb2f673615e1fde559531f29132 --- /dev/null +++ b/cer_xts/cer_xts_system/BUILD.gn @@ -0,0 +1,41 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsCerTestSystem") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":cer_xts_system_js_assets", + ":cer_xts_system_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsCerTestSystem" +} + +ohos_app_scope("cer_xts_system_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("cer_xts_system_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("cer_xts_system_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":cer_xts_system_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/cer_xts/cer_xts_system/Test.json b/cer_xts/cer_xts_system/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..39fd340166df18c70dba09735a401733419dcb7d --- /dev/null +++ b/cer_xts/cer_xts_system/Test.json @@ -0,0 +1,22 @@ +{ + "description": "Configuration for aceceshi Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "600000", + "bundle-name": "com.example.cerxts", + "module-name": "entry", + "shell-timeout": "600000", + "testcase-timeout":"100000" + }, + "kits": [ + { + "test-file-name": [ + "ActsCerTestSystem.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + + ] +} + diff --git a/cer_xts/cer_xts_system/entry/src/main/ets/Application/AbilityStage.ts b/cer_xts/cer_xts_system/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..0190fb0606f5b60fafe51d094ef1b3c8d69d1da4 --- /dev/null +++ b/cer_xts/cer_xts_system/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/cer_xts/cer_xts_system/entry/src/main/ets/MainAbility/MainAbility.ts b/cer_xts/cer_xts_system/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..4f7032fc67a34d783772b9e2d2396a32ac9dd263 --- /dev/null +++ b/cer_xts/cer_xts_system/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,62 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import Ability from '@ohos.application.Ability' + import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + import { Hypium } from 'hypium/index' + import testsuite from '../test/List.test' + + export default class TestAbility extends Ability { + onCreate(want, launchParam) { + console.log('TestAbility onCreate') + // var abilityDelegator: any + // abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + // var abilityDelegatorArguments: any + // abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + // console.info('start run testcase!!!') + // Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + globalThis.abilityContext = this.context; + } + + onDestroy() { + console.log('TestAbility onDestroy') + } + + onWindowStageCreate(windowStage) { + console.log('TestAbility onWindowStageCreate') + windowStage.setUIContent(this.context, 'MainAbility/pages/index', null) + + } + + onWindowStageDestroy() { + console.log('TestAbility onWindowStageDestroy') + } + + onForeground() { + console.log('TestAbility onForeground') + setTimeout(()=>{ + console.info('in setTimeout') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + },2000) + } + + onBackground() { + console.log('TestAbility onBackground') + } + }; \ No newline at end of file diff --git a/cer_xts/cer_xts_system/entry/src/main/ets/MainAbility/pages/index.ets b/cer_xts/cer_xts_system/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..769d08312592788380b50a790c706e9fb0189275 --- /dev/null +++ b/cer_xts/cer_xts_system/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct Index { + aboutToAppear() { + console.info('MainAbility index aboutToAppear') + } + + @State message: string = 'MainAbility' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/cer_xts/cer_xts_system/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/cer_xts/cer_xts_system/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..cd358a662986bb19d6e8c365deb5e0d5efc99780 --- /dev/null +++ b/cer_xts/cer_xts_system/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log("onAbilityCreateCallback"); +} + +async function addAbilityMonitorCallback(err: any) { + console.info("addAbilityMonitorCallback : " + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info("OpenHarmonyTestRunner OnPrepare ") + } + + async onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + globalThis.abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var MainAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility' + let lMonitor = { + abilityName: MainAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/cer_xts/cer_xts_system/entry/src/main/ets/pages/index.ets b/cer_xts/cer_xts_system/entry/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..f166cb4984bdce1942383d40ac5f305fefdc595c --- /dev/null +++ b/cer_xts/cer_xts_system/entry/src/main/ets/pages/index.ets @@ -0,0 +1,48 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import router from '@ohos.router'; + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/cer_xts/cer_xts_system/entry/src/main/ets/stub/certStubCallback.ts b/cer_xts/cer_xts_system/entry/src/main/ets/stub/certStubCallback.ts new file mode 100644 index 0000000000000000000000000000000000000000..8053b61422c3e90ec86fe344201085a8519a5c08 --- /dev/null +++ b/cer_xts/cer_xts_system/entry/src/main/ets/stub/certStubCallback.ts @@ -0,0 +1,638 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + import { CMResult, BusinessError, CMErrorCode, CertBlob, CMSignatureSpec, CertManagerStore, CMHandle} from './certStubStruct'; + import bundle from '@ohos.bundle' + import certStubUtil from './certStubUtil'; + + var certUtil = new certStubUtil(); + const TAG = "CertManager Stub: "; + const certNum = 10 + const keyNum = 20 + const authorListA = ["121", "23123", "3123", "676"] + const authorListB = ["232", "878", "6756", "089"] + const authorListC = ["3434", "545", "7687", "023"] + + export class CertStubPromise { + exceptFlag = 0; + uriBase = "uri://stub/certFile/" + type = "CM_URI_TYPE_APP_KEY" + uriCount = 0; + systemCertMap = new Map(); + userCertMap = new Map(); + uriToAlias = new Map(); + appCredMap = new Map(); + privateCredMap = new Map(); + uriToAppList = new Map(); + + constructor() { + let newCert; + + console.log(TAG + "getSystemTrustedCertificateList stub constructor start"); + newCert = certUtil.parseCertInfo(this.uriBase + this.uriCount.toString(), + "SystemRoot_1", true, new Uint8Array([0, 1, 2, 42, 100, 101, 102, 255])); + this.systemCertMap.set(this.uriBase + this.uriCount.toString(), newCert); + this.uriCount++; + + newCert = certUtil.parseCertInfo(this.uriBase + this.uriCount.toString(), + "SystemRoot_2", false, new Uint8Array([64, 1, 2, 42, 100, 123, 321, 255])); + this.systemCertMap.set(this.uriBase + this.uriCount.toString(), newCert); + this.uriCount++; + + newCert = certUtil.parseCertInfo(this.uriBase + this.uriCount.toString(), + "SystemRoot_3", true, new Uint8Array([54, 1, 123, 42, 100, 101, 102, 23])); + this.systemCertMap.set(this.uriBase + this.uriCount.toString(), newCert); + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "TheEncryptionForCCMPV1", this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([25, 5, 34, 45, 64, 78, 7, 8])); + this.appCredMap.set("ApptemRoot_1", newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "ApptemRoot_1") + this.uriToAppList.set(this.uriBase + this.uriCount.toString(), authorListA) + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "TheEncryptionForCCMPV2", this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([23, 1, 43, 42, 78, 90, 56, 12])); + this.appCredMap.set("ApptemRoot_2", newCert); + this.uriToAppList.set(this.uriBase + this.uriCount.toString(), authorListB) + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "ApptemRoot_2") + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "TheEncryptionForCCMPV3", this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([21, 1, 32, 645, 100, 101, 102, 23])); + this.appCredMap.set("ApptemRoot_3", newCert); + this.uriToAppList.set(this.uriBase + this.uriCount.toString(), authorListC) + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "ApptemRoot_3") + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "Huawei-Employee_WPA_EAPIEA", this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([32, 41, 54, 67, 77, 98, 91, 123])); + this.privateCredMap.set("PrivatetemRoot_1", newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "PrivatetemRoot_1") + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "Huawei-Employee_WPA_EAPIEB", this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([34, 65, 67, 68, 33, 77, 14, 18])); + this.privateCredMap.set("PrivatetemRoot_2", newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "PrivatetemRoot_2") + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "Huawei-Employee_WPA_EAPIEC", this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([12, 3, 54, 76, 8, 123, 43, 55])); + this.privateCredMap.set("PrivatetemRoot_3", newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "PrivatetemRoot_3") + this.uriCount++; + } + + getSystemTrustedCertificateList(callback) { + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + let data: CMResult; + let certList = new Array(); + + if (!this.exceptFlag) { + console.log(TAG + "getSystemTrustedCertificateList stub start"); + this.systemCertMap.forEach((data, keyUri) => { + certList.push(this.systemCertMap.get(keyUri)) + }) + data = { + certList: certList + }; + callback(error, data); + } else { + error = { + code: CMErrorCode.CMR_FAILURE, + }; + callback(error, null); + } + } + + getSystemTrustedCertificate(certUri: string, callback) { + let data: CMResult; + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + + if (this.systemCertMap.has(certUri)) { + data = { + certInfo: this.systemCertMap.get(certUri) + }; + callback(error, data); + } else { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + callback(error, null); + } + } + + setCertificateStatus(certUri: string, store: number, status: boolean, callback) { + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + let alias; + + if ((!this.systemCertMap.has(certUri)) && + (!this.uriToAlias.has(certUri))) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + callback(error, null); + } + console.log('store is:' + store) + if (store == CertManagerStore.CERT_MANAGER_SYSTEM_TRUSTED_STORE) { + this.systemCertMap.get(certUri).status = status; + console.log('status is:' + status) + callback(error, null); + } else if (store == CertManagerStore.CERT_MANAGER_USER_TRUSTED_STORE) { + alias = this.uriToAlias.get(certUri); + this.userCertMap.get(alias).status = status; + callback(error, null); + } else { + error = { + code: CMErrorCode.CMR_ERROR_NOT_SUPPORTED, + }; + callback(error, null); + } + } + + installUserTrustedCertificate(certificate: CertBlob, callback) { + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + if (certificate.alias.length > 64) { + error = { + code: CMErrorCode.CMR_ERROR_INVALID_ARGUMENT, + }; + callback(error, null); + } + + let newCert = certUtil.parseCertInfo(this.uriBase + this.uriCount.toString(), + certificate.alias, true, certificate.inData); + this.userCertMap.set(certificate.alias, newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), certificate.alias) + this.uriCount++; + + callback(error, null); + } + + uninstallAllUserTrustedCertificate(callback) { + console.log(TAG + "uninstallAllUserTrustedCertificate stub in"); + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + + this.userCertMap.clear(); + this.uriToAlias.clear(); + callback(error, null); + } + + uninstallUserTrustedCertificate(certUri: string, callback) { + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + let alias; + + if (!this.uriToAlias.has(certUri)) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + callback(error, null); + } + + alias = this.uriToAlias.get(certUri); + this.uriToAlias.delete(certUri); + this.userCertMap.delete(alias); + callback(error, null); + } + + getUserTrustedCertificateList(callback) { + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + let data: CMResult; + let certList = new Array(); + + + if (!this.exceptFlag) { + this.userCertMap.forEach((data, keyAlias) => { + certList.push(this.userCertMap.get(keyAlias)) + }) + + data = { + certList: certList + }; + callback(error, data); + } else { + error = { + code: CMErrorCode.CMR_FAILURE, + }; + callback(error, null); + } + } + + getUserTrustedCertificate(certUri: string, callback) { + let data: CMResult; + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + + if (this.uriToAlias.has(certUri)) { + let alias = this.uriToAlias.get(certUri); + data = { + certInfo: this.userCertMap.get(alias) + }; + callback(error, data); + } else { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + callback(error, null); + } + } + + installAppCertificate(keystore: Uint8Array, keystorePwd: string, certAlias: string, callback) { + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + if (keystorePwd.length > 64||certAlias.length > 64) { + error = { + code: CMErrorCode.CMR_ERROR_INVALID_ARGUMENT, + }; + callback(error) + } + let newCred = certUtil.parseCredential(this.type, certAlias, this.uriBase + this.uriCount.toString(), + certNum, keyNum, keystore); + this.appCredMap.set(certAlias, newCred); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), certAlias) + this.uriCount++; + + callback(error); + } + + installPrivateCertificate(keystore: Uint8Array, keystorePwd: string, certAlias: string, callback) { + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + let data: CMResult; + + if (keystorePwd.length > 64 || certAlias.length > 64) { + error = { + code: CMErrorCode.CMR_ERROR_INVALID_ARGUMENT, + }; + callback(error) + } + let newCred = certUtil.parseCredential("privateCred", certAlias, this.uriBase + this.uriCount.toString(), + 1, 1, keystore); + this.privateCredMap.set(certAlias, newCred); + let authUriRet = this.uriBase + this.uriCount.toString() + this.uriToAlias.set(authUriRet, certAlias); + this.uriCount++; + data = { + authUri: authUriRet + } + callback(error, data); + } + + updatePrivateCertificate(type: string, keyUri: string, certificate: CertBlob, callback) { + console.log(TAG + "updatePrivateCertificate stub in"); + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + if (!this.uriToAlias.has(keyUri)) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + callback(error) + } + this.uninstallPrivateCertificate(keyUri, (err)=>{ + let keystorePwd = '123456' + let certAlias = certificate.alias + this.installPrivateCertificate(certificate.inData, keystorePwd, certAlias, (err)=>{ + callback(error, null) + }) + }) + } + + uninstallAllAppCertificate(callback) { + console.log(TAG + "uninstallAllAppCertificate stub in"); + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + + this.appCredMap.clear(); + this.privateCredMap.clear(); + + callback(error, null); + } + + uninstallAppCertificate(keyUri: string, callback) { + let alias; + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + + if (!this.uriToAlias.has(keyUri)) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + callback(error, null); + } + + alias = this.uriToAlias.get(keyUri); + this.uriToAlias.delete(keyUri); + this.appCredMap.delete(alias); + + callback(error, null); + } + + uninstallPrivateCertificate(keyUri, callback) { + let alias; + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + + if (!this.uriToAlias.has(keyUri)) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + callback(error, null); + } + + alias = this.uriToAlias.get(keyUri); + this.uriToAlias.delete(keyUri); + this.privateCredMap.delete(alias); + + callback(error, null); + } + + getAppCertificateList(callback) { + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + let data: CMResult; + let credList = new Array(); + + if (!this.exceptFlag) { + this.appCredMap.forEach((data, keyAlias) => { + credList.push(this.appCredMap.get(keyAlias)) + }) + + data = { + credentialList: credList + }; + callback(error, data); + } else { + error = { + code: CMErrorCode.CMR_FAILURE, + }; + callback(error, null); + } + } + + getPrivateCertificateList(callback) { + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + let data: CMResult; + let credList = new Array(); + + if (!this.exceptFlag) { + this.privateCredMap.forEach((data, keyAlias) => { + credList.push(this.privateCredMap.get(keyAlias)) + }) + + data = { + credentialList: credList + }; + callback(error, data); + } else { + error = { + code: CMErrorCode.CMR_FAILURE, + }; + callback(error, null); + } + } + + getAppCertificate(keyUri: string, callback) { + let data: CMResult; + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + + if (this.uriToAlias.has(keyUri)) { + let alias = this.uriToAlias.get(keyUri); + data = { + credential: this.appCredMap.get(alias) + }; + callback(error, data); + } else { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + callback(error, null); + } + } + + getPrivateCertificate(keyUri: string, callback) { + let data: CMResult; + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + + if (this.uriToAlias.has(keyUri)) { + let alias = this.uriToAlias.get(keyUri); + data = { + credential: this.privateCredMap.get(alias) + }; + callback(error, data); + } else { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + callback(error, null); + } + } + + grantAppCertificate(keyUri: string, clientAppUid: string, callback) { + let appList: Array; + let data: CMResult; + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + + console.log(TAG + "grantAppCertificate stub uri: " + keyUri + " clientAppUid: " + clientAppUid); + if (!this.uriToAlias.has(keyUri)) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + callback(error, null); + } + + if (this.uriToAppList.has(keyUri)) { + appList = this.uriToAppList.get(keyUri); + } else { + appList = new Array(); + } + + appList.push(clientAppUid); + this.uriToAppList.set(keyUri, appList) + data = { + authUri: "authUri-value" + }; + console.log(TAG + "grantAppCertificate stub uriToAppList: " + JSON.stringify(appList)); + + callback(error, data); + } + + async isAuthorizedApp(keyUri: string, callback) { + let data: CMResult; + let dataRet: CMResult; + let appList: Array; + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + data = { + isAuth: false + }; + if(keyUri.length > 64 || keyUri == 'keyUriError' || keyUri == ''){ + let errorRet: BusinessError = { + code: CMErrorCode.CMR_FAILURE + }; + callback(errorRet, undefined); + }else{ + if (this.uriToAppList.has(keyUri)) { + appList = this.uriToAppList.get(keyUri); + } else { + appList = new Array(); + } + let sign = true; + let bundleInfo = await bundle.getBundleInfo("com.example.cerxts", bundle.BundleFlag.GET_BUNDLE_DEFAULT) + let clientAppUid = bundleInfo.uid.toString() + for (let i = 0; i < appList.length; i++) { + if (appList[i] == clientAppUid) { + dataRet = { + isAuth: true + }; + sign = false + callback(error, dataRet); + break + } + } + if(sign){ + data = { + isAuth: false + }; + callback(error, data); + } + } + } + + getAuthorizedAppList(keyUri: string, callback) { + let data: CMResult; + let appList: Array; + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + + if ((!this.uriToAlias.has(keyUri)) || (!this.uriToAppList.has(keyUri))) { + data = { + appUidList: appList, + }; + callback(error, data); + } + + appList = this.uriToAppList.get(keyUri); + + data = { + appUidList: appList + }; + callback(error, data); + } + + init(authUri: string, spec: CMSignatureSpec, callback) { + let error = { + code: CMErrorCode.CMR_SUCCESS, + }; + let data: CMHandle; + data = { + errorCode: error.code, + handle: 1 + } + callback(error, data); + } + + update(handle: number, data: Uint8Array, token: Uint8Array, callback) { + let error = { + code: CMErrorCode.CMR_SUCCESS, + }; + let dataRet: CMResult; + dataRet = { + } + callback(error, dataRet); + } + + finish(handle: number, signature: Uint8Array, callback) { + let error = { + code: CMErrorCode.CMR_SUCCESS, + }; + let dataRet: CMResult; + dataRet = { + } + callback(error, dataRet); + } + + about(handle: number, callback) { + let error = { + code: CMErrorCode.CMR_SUCCESS, + }; + let dataRet: CMResult; + dataRet = { + } + callback(error, dataRet); + } + + removeGrantedAppCertificate(keyUri: string, clientAppUid: string, callback) { + let appList: Array; + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + + if ((!this.uriToAlias.has(keyUri)) || (!this.uriToAppList.has(keyUri))) { + let error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + callback(error, null); + } + + appList = this.uriToAppList.get(keyUri); + if (appList.indexOf(clientAppUid) != -1) { + appList = appList.filter(item => item != clientAppUid); + this.uriToAppList.set(keyUri, appList); + callback(error, null); + } else { + let error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + callback(error, null); + } + } + } + + let certStub = new CertStubPromise(); + + export default certStub as CertStubPromise; + \ No newline at end of file diff --git a/cer_xts/cer_xts_system/entry/src/main/ets/stub/certStubPromise.ts b/cer_xts/cer_xts_system/entry/src/main/ets/stub/certStubPromise.ts new file mode 100644 index 0000000000000000000000000000000000000000..237c4a14f39edcf2a778b23971cd2f4dde67e366 --- /dev/null +++ b/cer_xts/cer_xts_system/entry/src/main/ets/stub/certStubPromise.ts @@ -0,0 +1,754 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + import { CMResult, BusinessError, CMErrorCode, CertBlob, CMSignatureSpec, CertManagerStore, CMHandle, + CMKeyProperties} from './certStubStruct'; +import bundle from '@ohos.bundle' +import certStubUtil from './certStubUtil'; +import fileio from '@ohos.fileio'; + +var certUtil = new certStubUtil(); +const TAG = "CertManager Stub: "; +const certNum = 10 +const keyNum = 20 +const authorListA = ["121", "23123", "3123", "676"] +const authorListB = ["232", "878", "6756", "089"] +const authorListC = ["3434", "545", "7687", "023"] +globalThis.exceptFlag = 0 + +export class CertStubPromise { + uriBase = "uri://stub/certFile/" + type = "CM_URI_TYPE_APP_KEY" + uriCount = 0; + systemCertMap = new Map(); + userCertMap = new Map(); + uriToAlias = new Map(); + appCredMap = new Map(); + privateCredMap = new Map(); + uriToAppList = new Map(); + + constructor() { + let newCert; + + console.log(TAG + "getSystemTrustedCertificateList stub constructor start"); + newCert = certUtil.parseCertInfo(this.uriBase + this.uriCount.toString(), + "SystemRoot_1", true, new Uint8Array([0, 1, 2, 42, 100, 101, 102, 255])); + this.systemCertMap.set(this.uriBase + this.uriCount.toString(), newCert); + this.uriCount++; + + newCert = certUtil.parseCertInfo(this.uriBase + this.uriCount.toString(), + "SystemRoot_2", false, new Uint8Array([64, 1, 2, 42, 100, 123, 321, 255])); + this.systemCertMap.set(this.uriBase + this.uriCount.toString(), newCert); + this.uriCount++; + + newCert = certUtil.parseCertInfo(this.uriBase + this.uriCount.toString(), + "SystemRoot_3", true, new Uint8Array([54, 1, 123, 42, 100, 101, 102, 23])); + this.systemCertMap.set(this.uriBase + this.uriCount.toString(), newCert); + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "TheEncryptionForCCMPV1", this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([25, 5, 34, 45, 64, 78, 7, 8])); + this.appCredMap.set("ApptemRoot_1", newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "ApptemRoot_1") + this.uriToAppList.set(this.uriBase + this.uriCount.toString(), authorListA) + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "TheEncryptionForCCMPV2", this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([23, 1, 43, 42, 78, 90, 56, 12])); + this.appCredMap.set("ApptemRoot_2", newCert); + this.uriToAppList.set(this.uriBase + this.uriCount.toString(), authorListB) + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "ApptemRoot_2") + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "TheEncryptionForCCMPV3", this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([21, 1, 32, 645, 100, 101, 102, 23])); + this.appCredMap.set("ApptemRoot_3", newCert); + this.uriToAppList.set(this.uriBase + this.uriCount.toString(), authorListC) + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "ApptemRoot_3") + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "Huawei-Employee_WPA_EAPIEA", this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([32, 41, 54, 67, 77, 98, 91, 123])); + this.privateCredMap.set("PrivatetemRoot_1", newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "PrivatetemRoot_1") + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "Huawei-Employee_WPA_EAPIEB", this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([34, 65, 67, 68, 33, 77, 14, 18])); + this.privateCredMap.set("PrivatetemRoot_2", newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "PrivatetemRoot_2") + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "Huawei-Employee_WPA_EAPIEC", this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([12, 3, 54, 76, 8, 123, 43, 55])); + this.privateCredMap.set("PrivatetemRoot_3", newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "PrivatetemRoot_3") + this.uriCount++; + } + + getSystemTrustedCertificateList() { + return new Promise((resolve, reject) => { + let error: BusinessError; + let data: CMResult; + let certList = new Array(); + + if (!globalThis.exceptFlag) { + console.log(TAG + "getSystemTrustedCertificateList stub start"); + this.systemCertMap.forEach((data, keyUri) => { + certList.push(this.systemCertMap.get(keyUri)) + }) + data = { + certList: certList + }; + resolve(data); + } else { + error = { + code: CMErrorCode.CMR_FAILURE, + }; + reject(error); + } + }) + } + + getSystemTrustedCertificate(certUri: string) { + return new Promise((resolve, reject) => { + let data: CMResult; + let error: BusinessError; + + if (this.systemCertMap.has(certUri)) { + data = { + certInfo: this.systemCertMap.get(certUri) + }; + resolve(data); + } else { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + }) + } + + setCertificateStatus(certUri: string, store: number, status: boolean) { + return new Promise((resolve, reject) => { + let error: BusinessError; + let alias; + + if ((!this.systemCertMap.has(certUri)) && + (!this.uriToAlias.has(certUri))) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + + if (store == CertManagerStore.CERT_MANAGER_SYSTEM_TRUSTED_STORE) { + this.systemCertMap.get(certUri).status = status; + resolve(); + } else if (store == CertManagerStore.CERT_MANAGER_USER_TRUSTED_STORE) { + alias = this.uriToAlias.get(certUri); + this.userCertMap.get(alias).status = status; + resolve(); + } else { + error = { + code: CMErrorCode.CMR_ERROR_NOT_SUPPORTED, + }; + reject(error); + } + }) + } + + installUserTrustedCertificate(certificate: CertBlob) { + return new Promise((resolve, reject) => { + let error: BusinessError; + + if (this.userCertMap.size == 64) { + error = { + code: CMErrorCode.CMR_ERROR_STORAGE_FAILURE, + }; + reject(error) + } + + if (certificate.alias.length > 64) { + error = { + code: CMErrorCode.CMR_ERROR_INVALID_ARGUMENT, + }; + reject(error) + } + let newCert = certUtil.parseCertInfo(this.uriBase + this.uriCount.toString(), + certificate.alias, true, certificate.inData); + this.userCertMap.set(certificate.alias, newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), certificate.alias) + this.uriCount++; + + resolve(); + }) + } + + uninstallAllUserTrustedCertificate() { + return new Promise((resolve, reject) => { + console.log(TAG + "uninstallAllUserTrustedCertificate stub in"); + this.userCertMap.clear(); + this.uriToAlias.clear(); + resolve(); + }) + } + + uninstallUserTrustedCertificate(certUri: string) { + return new Promise((resolve, reject) => { + let error: BusinessError; + let alias; + + if (!this.uriToAlias.has(certUri)) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + + alias = this.uriToAlias.get(certUri); + this.uriToAlias.delete(certUri); + this.userCertMap.delete(alias); + resolve(); + }) + } + + getUserTrustedCertificateList() { + return new Promise((resolve, reject) => { + let error: BusinessError; + let data: CMResult; + let certList = new Array(); + + if (!globalThis.exceptFlag) { + this.userCertMap.forEach((data, keyAlias) => { + certList.push(this.userCertMap.get(keyAlias)) + }) + + data = { + certList: certList + }; + resolve(data); + } else { + error = { + code: CMErrorCode.CMR_FAILURE, + }; + reject(error); + } + }) + } + + getUserTrustedCertificate(certUri: string) { + return new Promise((resolve, reject) => { + let data: CMResult; + let error: BusinessError; + + if (this.uriToAlias.has(certUri)) { + let alias = this.uriToAlias.get(certUri); + data = { + certInfo: this.userCertMap.get(alias) + }; + resolve(data); + } else { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + }) + } + + installAppCertificate(keystore: Uint8Array, keystorePwd: string, certAlias: string) { + return new Promise((resolve, reject) => { + let error: BusinessError; + if (this.appCredMap.size == 64) { + error = { + code: CMErrorCode.CMR_ERROR_STORAGE_FAILURE, + }; + reject(error) + } + if (keystorePwd.length > 64||certAlias.length > 64) { + error = { + code: CMErrorCode.CMR_ERROR_INVALID_ARGUMENT, + }; + reject(error) + } + let newCred = certUtil.parseCredential(this.type, certAlias, this.uriBase + this.uriCount.toString(), + certNum, keyNum, keystore); + this.appCredMap.set(certAlias, newCred); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), certAlias) + this.uriCount++; + + resolve(); + }) + } + + installPrivateCertificate(keystore: Uint8Array, keystorePwd: string, certAlias: string) { + return new Promise((resolve, reject) => { + let error: BusinessError; + let data: CMResult; + + if (this.privateCredMap.size == 64) { + error = { + code: CMErrorCode.CMR_ERROR_STORAGE_FAILURE, + }; + reject(error) + } + if (keystorePwd.length > 64 || certAlias.length > 64) { + error = { + code: CMErrorCode.CMR_ERROR_INVALID_ARGUMENT, + }; + reject(error) + } + let newCred = certUtil.parseCredential("privateCred", certAlias, this.uriBase + this.uriCount.toString(), + 1, 1, keystore); + this.privateCredMap.set(certAlias, newCred); + let authUriRet = this.uriBase + this.uriCount.toString() + this.uriToAlias.set(authUriRet, certAlias); + this.uriCount++; + data = { + authUri: authUriRet + } + resolve(data); + }) + } + + updatePrivateCertificate(type: string, keyUri: string, certificate: CertBlob) { + return new Promise((resolve, reject) => { + let error: BusinessError + console.log(TAG + "updatePrivateCertificate stub in"); + if (!this.uriToAlias.has(keyUri)) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + this.uninstallPrivateCertificate(keyUri) + let keystorePwd = '123456' + let certAlias = certificate.alias + this.installPrivateCertificate(certificate.inData, keystorePwd, certAlias) + resolve(); + }) + } + + uninstallAllAppCertificate() { + return new Promise((resolve, reject) => { + console.log(TAG + "uninstallAllAppCertificate stub in"); + this.appCredMap.clear(); + this.privateCredMap.clear(); + + resolve(); + }) + } + + uninstallAppCertificate(keyUri: string) { + return new Promise((resolve, reject) => { + let alias; + let error: BusinessError; + + if (!this.uriToAlias.has(keyUri)) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + + alias = this.uriToAlias.get(keyUri); + this.uriToAlias.delete(keyUri); + this.appCredMap.delete(alias); + + resolve(); + }) + } + + uninstallPrivateCertificate(keyUri) { + return new Promise((resolve, reject) => { + let alias; + let error: BusinessError; + + if (!this.uriToAlias.has(keyUri)) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + + alias = this.uriToAlias.get(keyUri); + this.uriToAlias.delete(keyUri); + this.privateCredMap.delete(alias); + + resolve(); + }) + } + + getAppCertificateList() { + return new Promise((resolve, reject) => { + let error: BusinessError; + let data: CMResult; + let credList = new Array(); + + if (!globalThis.exceptFlag) { + this.appCredMap.forEach((data, keyAlias) => { + credList.push(this.appCredMap.get(keyAlias)) + }) + + data = { + credentialList: credList + }; + resolve(data); + } else { + error = { + code: CMErrorCode.CMR_FAILURE, + }; + reject(error); + } + }) + } + + getPrivateCertificateList() { + return new Promise((resolve, reject) => { + let error: BusinessError; + let data: CMResult; + let credList = new Array(); + + if (!globalThis.exceptFlag) { + this.privateCredMap.forEach((data, keyAlias) => { + credList.push(this.privateCredMap.get(keyAlias)) + }) + + data = { + credentialList: credList + }; + resolve(data); + } else { + error = { + code: CMErrorCode.CMR_FAILURE, + }; + reject(error); + } + }) + } + + getAppCertificate(keyUri: string) { + return new Promise((resolve, reject) => { + let data: CMResult; + let error: BusinessError; + + if (this.uriToAlias.has(keyUri)) { + let alias = this.uriToAlias.get(keyUri); + data = { + credential: this.appCredMap.get(alias) + }; + resolve(data); + } else { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + }) + } + + getPrivateCertificate(keyUri: string) { + return new Promise((resolve, reject) => { + let data: CMResult; + let error: BusinessError; + + if (this.uriToAlias.has(keyUri)) { + let alias = this.uriToAlias.get(keyUri); + data = { + credential: this.privateCredMap.get(alias) + }; + resolve(data); + } else { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + }) + } + + grantAppCertificate(keyUri: string, clientAppUid: string) { + return new Promise((resolve, reject) => { + let appList: Array; + let data: CMResult; + let error: BusinessError; + + console.log(TAG + "grantAppCertificate stub uri: " + keyUri + " clientAppUid: " + clientAppUid); + if (!this.uriToAlias.has(keyUri)) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + + if (this.uriToAppList.has(keyUri)) { + appList = this.uriToAppList.get(keyUri); + } else { + appList = new Array(); + } + + appList.push(clientAppUid); + this.uriToAppList.set(keyUri, appList) + data = { + authUri: "authUri-value" + }; + console.log(TAG + "grantAppCertificate stub uriToAppList: " + JSON.stringify(appList)); + + resolve(data); + }) + } + + isAuthorizedApp(keyUri: string) { + return new Promise(async (resolve, reject) => { + if(keyUri.length > 64 || keyUri == 'keyUriError' || keyUri == ''){ + let err: BusinessError = { + code: CMErrorCode.CMR_FAILURE + }; + reject(err); + }else{ + let data: CMResult; + let dataRet: CMResult; + let appList: Array; + + if (this.uriToAppList.has(keyUri)) { + appList = this.uriToAppList.get(keyUri); + } else { + appList = new Array(); + } + let sign = true; + let bundleInfo = await bundle.getBundleInfo("com.example.cerxts", bundle.BundleFlag.GET_BUNDLE_DEFAULT) + let clientAppUid = bundleInfo.uid.toString() + for (let i = 0; i < appList.length; i++) { + if (appList[i] == clientAppUid) { + dataRet = { + isAuth: true + }; + sign = false + resolve(dataRet) + break + } + } + if(sign){ + data = { + isAuth: false + }; + resolve(data); + } + } + }) + } + + generatePrivateCertificate(keyAlias: string, keyProperties: CMKeyProperties) { + return new Promise((resolve, reject) => { + if(keyProperties.type != 'CM_URI_TYPE_APP_KEY' && keyProperties.type != 'CM_URI_TYPE_WLAN_KEY' || + keyAlias.length > 64){ + let error: BusinessError = { + code: CMErrorCode.CMR_FAILURE + }; + reject(error) + } + let data: CMResult; + data = { + outData: new Uint8Array([0, 1, 2, 42, 100, 101, 102, 255]) + }; + resolve(data); + }) + } + + getAuthorizedAppList(keyUri: string) { + return new Promise((resolve, reject) => { + let data: CMResult; + let appList: Array; + + if ((!this.uriToAlias.has(keyUri)) || (!this.uriToAppList.has(keyUri))) { + data = { + appUidList: appList, + }; + resolve(data); + } + + appList = this.uriToAppList.get(keyUri); + + data = { + appUidList: appList + }; + resolve(data); + }) + } + + removeGrantedAppCertificate(keyUri: string, clientAppUid: string) { + return new Promise((resolve, reject) => { + let appList: Array; + + if ((!this.uriToAlias.has(keyUri)) || (!this.uriToAppList.has(keyUri))) { + let error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + + appList = this.uriToAppList.get(keyUri); + if (appList.indexOf(clientAppUid) != -1) { + appList = appList.filter(item => item != clientAppUid); + this.uriToAppList.set(keyUri, appList); + resolve(); + } else { + let error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + }) + } + + init(authUri: string, spec: CMSignatureSpec) { + return new Promise((resolve, reject) => { + let errCode = CMErrorCode.CMR_SUCCESS; + let data: CMHandle; + data = { + errorCode: errCode, + handle: 1 + } + + resolve(data); + }) + } + + update(handle: number, data: Uint8Array, token?: Uint8Array) { + return new Promise((resolve, reject) => { + let errCode = CMErrorCode.CMR_SUCCESS; + let data: CMResult; + data = { + + } + + resolve(data); + }) + } + + finish(handle: number, signature?: Uint8Array) { + return new Promise((resolve, reject) => { + let errorCode = CMErrorCode.CMR_SUCCESS; + let data: CMResult; + + resolve(); + }) + } + + abort(handle: number) { + return new Promise((resolve, reject) => { + let errorCode = CMErrorCode.CMR_SUCCESS; + let data: CMResult; + + resolve(); + }) + } + + mapToJson(map) { + let obj = Object.create(null); + for (let [k, v] of map) { + obj[k] = v; + } + + return JSON.stringify(obj) + } + + jsonToMap(jsonString) { + console.log(TAG + "jsonToMap start"); + let map = new Map(); + let obj = JSON.parse(jsonString); + + for (let k of Object.keys(obj)) { + map.set(k, obj[k]) + } + return map; + } + + saveAllMaps() { + console.log(TAG + "saveAllMaps start"); + let dataList = [ + this.mapToJson(this.systemCertMap), + this.mapToJson(this.userCertMap), + this.mapToJson(this.uriToAlias), + this.mapToJson(this.appCredMap), + this.mapToJson(this.privateCredMap), + this.mapToJson(this.uriToAppList) + ]; + + let context = globalThis.certManagerAbilityContext; + let path = context.cacheDir; + path += '/certStubData' + try { + fileio.unlinkSync(path); + } catch (err) { + console.log(TAG + "saveAllMaps unlinkSync err: " + err); + } + let fd = fileio.openSync(path, 0o102, 0o666); + fileio.writeSync(fd, JSON.stringify(dataList)); + fileio.closeSync(fd); + console.log(TAG + "saveAllMaps end"); + } + + uint8ArrayToString(fileData) { + var dataString = ""; + for (var i = 0; i < fileData.length; i++) { + dataString += String.fromCharCode(fileData[i]); + } + return dataString + } + + restoreMapsFromJson(json) { + console.log(TAG + "restoreMapsFromJson start Json: " + json); + let dataList = JSON.parse(json); + this.systemCertMap = this.jsonToMap(dataList[0]); + this.userCertMap = this.jsonToMap(dataList[1]); + this.uriToAlias = this.jsonToMap(dataList[2]); + this.appCredMap = this.jsonToMap(dataList[3]); + this.privateCredMap = this.jsonToMap(dataList[4]); + this.uriToAppList = this.jsonToMap(dataList[5]); + console.log(TAG + "restoreMapsFromJson end"); + } + + restoreAllMaps() { + console.log(TAG + "getAllMaps start"); + let context = globalThis.certManagerAbilityContext; + let path = context.cacheDir; + path += '/certStubData' + + try { + let fd = fileio.openSync(path, 0o002, 0o666); + console.log(TAG + "getAllMaps fd: " + fd); + let stat = fileio.fstatSync(fd); + let size = stat.size; + let buf = new ArrayBuffer(size); + + fileio.read(fd, buf, (err, data) => { + if (data) { + this.restoreMapsFromJson(this.uint8ArrayToString(new Uint8Array(data.buffer))); + } + fileio.closeSync(fd); + }); + } catch(err) { + console.log(TAG + "getAllMaps err: " + err); + } + + console.log(TAG + "getAllMaps end"); + } +} + +let certStub = new CertStubPromise(); + +export default certStub as CertStubPromise; diff --git a/cer_xts/cer_xts_system/entry/src/main/ets/stub/certStubStruct.ets b/cer_xts/cer_xts_system/entry/src/main/ets/stub/certStubStruct.ets new file mode 100644 index 0000000000000000000000000000000000000000..78c417c798e6145f591227aa9beace447e535f61 --- /dev/null +++ b/cer_xts/cer_xts_system/entry/src/main/ets/stub/certStubStruct.ets @@ -0,0 +1,161 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export interface CertInfo { + uri: string, + certAlias: string, + status: boolean, + issuerName: string, + subjectName: string, + serial: string, + notBefore: string, + notAfter: string, + fingerprintSha256: string, + cert: Uint8Array +} + +export interface certAbstract { + uri: string, + certAlias: string, + status: boolean, + subjectName: string, +} + +export interface CMResult { + certList?: Array, + certInfo?: CertInfo, + credentialList?:Array, + credential?: Credential, + appUidList?: Array + authUri?: string, + outData?: Uint8Array, + isAuth?: boolean +} + +export interface CMHandle { + errorCode: number, + handle: number; + token?: Uint8Array; +} + +export interface Credential { + type: string, + alias: string, + keyUri: string, + certNum: number, + keyNum: number, + credData: Uint8Array +} + +export interface CredentialAbstract { + type: string, + alias: string, + keyUri: string +} + +export interface CMContext { + userId: string, + uid: string, + packageName: string +}; + +export interface CertBlob { + readonly inData?: Uint8Array, + readonly alias?: string +}; + +export interface CMKeyProperties { + type: string; // Type of the key, must be CM_URI_TYPE_APP_KEY or CM_URI_TYPE_WLAN_KEY + alg: string; + size: number; + padding: string; + purpose: string; + digest: string; + authType: string; + authTimeout: string; +}; + +export interface CMSignatureSpec { + alg: string; + padding: string; + digest: string; + authToken: Uint8Array; // required only for user authentication +}; + +export enum CertManagerStore { + CERT_MANAGER_CREDENTIAL_STORE = 0, /* credential certificate store for end entity certificates. */ + CERT_MANAGER_SYSTEM_TRUSTED_STORE = 1, /* read only, updated by system only. */ + CERT_MANAGER_USER_TRUSTED_STORE = 2, /* modifiable by applications and user. */ + CERT_MANAGER_APPLICATION_TRUSTED_STORE = 3, /* application specific trusted certificate store; modifiable by the application only. */ +} + +export enum CMErrorCode { + CMR_SUCCESS = 0, + CMR_FAILURE = -1, + CMR_ERROR_INSTALL_CERTIFICATE = -2, + CMR_ERROR_SET_STATUS = -3, + CMR_ERROR_INVALID_ARGUMENT = -3, + CMR_ERROR_INVALID_STORE = -4, + CMR_ERROR_NOT_SUPPORTED = -5, + CMR_ERROR_UNINSTALL = -6, + CMR_ERROR_NO_PERMISSION = -7, + CMR_ERROR_INSUFFICIENT_DATA = -8, + CMR_ERROR_GET_CERTIRICATE = -9, + CMR_ERROR_STORAGE_FAILURE = -10, + CMR_ERROR_HARDWARE_FAILURE = -11, + CMR_ERROR_ALREADY_EXISTS = -12, + CMR_ERROR_NOT_EXIST = -13, + CMR_ERROR_NULL_POINTER = -14, + CMR_ERROR_FILE_SIZE_FAIL = -15, + CMR_ERROR_READ_FILE_FAIL = -16, + CMR_ERROR_INVALID_PUBLIC_KEY = -17, + CMR_ERROR_INVALID_PRIVATE_KEY = -18, + CMR_ERROR_INVALID_KEY_INFO = -19, + CMR_ERROR_REMOVE_CERTIFICATE_FAIL = -20, + CMR_ERROR_OPEN_FILE_FAIL = -21, + CMR_ERROR_INVALID_KEY_FILE = -22, + CMR_ERROR_IPC_MSG_FAIL = -23, + CMR_ERROR_REQUEST_OVERFLOWS = -24, + CMR_ERROR_PARAM_NOT_EXIST = -25, + CMR_ERROR_CRYPTO_ENGINE_ERROR = -26, + CMR_ERROR_COMMUNICATION_TIMEOUT = -27, + CMR_ERROR_IPC_INIT_FAIL = -28, + CMR_ERROR_IPC_DLOPEN_FAIL = -29, + CMR_ERROR_EFUSE_READ_FAIL = -30, + + CMR_ERROR_CHECK_GET_ALG_FAIL = -100, + CMR_ERROR_CHECK_GET_KEY_SIZE_FAIL = -101, + CMR_ERROR_CHECK_GET_PADDING_FAIL = -102, + CMR_ERROR_INVALID_DIGEST = -117, + + CMR_ERROR_INTERNAL_ERROR = -999, + CMR_ERROR_UNKNOWN_ERROR = -1000, +} + +export interface BusinessError { + /** + * Defines the basic error code. + * @since 6 + */ + code: number; +} + +export interface AsyncCallback { + /** + * Defines the callback data. + * @since 6 + */ + (err: BusinessError, data: T): void; +} diff --git a/cer_xts/cer_xts_system/entry/src/main/ets/stub/certStubUtil.ets b/cer_xts/cer_xts_system/entry/src/main/ets/stub/certStubUtil.ets new file mode 100644 index 0000000000000000000000000000000000000000..d73cb639cfe9483cfc5d44d9dde55b3d6038e3b0 --- /dev/null +++ b/cer_xts/cer_xts_system/entry/src/main/ets/stub/certStubUtil.ets @@ -0,0 +1,149 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { CertInfo, certAbstract, CMResult, CMContext, AsyncCallback, BusinessError, CMHandle, + Credential, CredentialAbstract, CMErrorCode, CertBlob, CMKeyProperties, CMSignatureSpec } from './certStubStruct' + +export default class certStubUtil { + constructor() { + } + +parseCertInfo(uri: string, certAlias: string, status: boolean, cert: Uint8Array): CertInfo { + let certInfo: CertInfo; + + certInfo = { + uri: uri, + certAlias: certAlias, + status: status, + issuerName: "CN = OpenHarmony Application Root CA,OU = OpenHarmony Team,O = OpenHarmony,C = CN", + subjectName: "CN = OpenHarmony Application Root CA,OU = OpenHarmony Team,O = OpenHarmony,C = CN", + serial: "0fe1388b", + notBefore: "2021/2/2", + notAfter: "2049/12/31", + fingerprintSha256: "23:b7:4d:a0:2f:00:a0:2a:16:c8:8d:bc:4c:71:ea:fd:7e:53:95:09", + cert: cert + } + + return certInfo; +} + +parseCertAbstract(uri: string, certAlias: string, status: boolean): certAbstract { + let result: certAbstract; + + result = { + uri: uri, + certAlias: certAlias, + status: status, + subjectName: "CN=SwissSign Gold CA - G2,OU=,O=SwissSign", + } + + return result; +} + + +parseCMHandle(errorCode: number, handle: number, token: Uint8Array): CMHandle { + let result: CMHandle; + + result = { + errorCode: errorCode, + handle: handle, + token: token, + } + + return result; +} + +parseCredential(type: string, alias: string, keyUri: string, certNum: number, + keyNum: number, credData: Uint8Array): Credential { + let result: Credential; + + result = { + type: type, + alias: alias, + keyUri: keyUri, + certNum: certNum, + keyNum: keyNum, + credData: credData + } + + return result; +} + +parseCredentialAbstract(type: string, alias: string, keyUri: string): CredentialAbstract { + let result: CredentialAbstract; + + result = { + type: type, + alias: alias, + keyUri: keyUri + } + + return result; +} + +parseCMContext(userId: string, uid: string, packageName: string): CMContext { + let result: CMContext; + + result = { + userId: userId, + uid: uid, + packageName: packageName + } + + return result; +} + +parseCertBlob(inData: Uint8Array, alias: string): CertBlob { + let result: CertBlob; + + result = { + inData: inData, + alias: alias + } + + return result; +} + +parseCMKeyProperties(): CMKeyProperties { + let result: CMKeyProperties; + + result = { + type: "CM_URI_TYPE_APP_KEY", // Type of the key, must be CM_URI_TYPE_APP_KEY or CM_URI_TYPE_WLAN_KEY + alg: "alg", + size: 375, + padding: "padding purpose", + purpose: "purpose property", + digest: "digest property", + authType: "Sha-256", + authTimeout: "30" + } + + return result; +} + +parseCMSignatureSpec(alg: string, padding: string, digest: string, authToken: Uint8Array): CMSignatureSpec { + let result: CMSignatureSpec; + + result = { + alg: alg, + padding: padding, + digest: digest, + authToken: authToken // required only for user authentication + } + + return result; +} + +} diff --git a/cer_xts/cer_xts_system/entry/src/main/ets/test/Ability.test.ets b/cer_xts/cer_xts_system/entry/src/main/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f32cec86a263d8b9bb9404b6569994cb9e4ac126 --- /dev/null +++ b/cer_xts/cer_xts_system/entry/src/main/ets/test/Ability.test.ets @@ -0,0 +1,4913 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import bundle from '@ohos.bundle' + import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index' + import certStubPromise from './../stub/certStubPromise' + import certStubCallback from './../stub/certStubCallback' + import { CMSignatureSpec, CMErrorCode, CMKeyProperties, CertBlob } from './../stub/certStubStruct' + import fileio from '@ohos.fileio' + + const CERTNUMLIMIT = 64 + + function sleep(time) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve(); + }, time) + }) + } + + var certFileArray: Uint8Array + + function loadInstallFile(CertName: string) { + let path = globalThis.abilityContext.cacheDir + path = path + '/' + CertName + console.log('SEC_CertificateManagement_Interface_Js path is:' + path) + let fd = fileio.openSync(path, 0o102, 0o666); + console.log('SEC_CertificateManagement_Interface_Js fd is:' + fd) + let stat = fileio.fstatSync(fd); + let size = stat.size; + let buf = new ArrayBuffer(size); + fileio.read(fd, buf, (err, data) => { + if (data) { + certFileArray = new Uint8Array(data.buffer); + } + }); + } + + + async function installTestUserTrustedCAPromise(CertName: string) { + loadInstallFile(CertName) + await certStubPromise.installUserTrustedCertificate({ + inData: certFileArray, + alias: 'UserCert' + }) + } + + async function installTestUserTrustedCACallback(CertName: string) { + loadInstallFile(CertName) + certStubCallback.installUserTrustedCertificate({ + inData: certFileArray, + alias: 'UserCert' + }, (err, data) => { + console.log('in installUserTrustedCertificate callback') + }) + } + + var clientAppUidStr = '' + + function getClientAppUid() { + return new Promise(async (resolve) => { + if (clientAppUidStr == '') { + let bundleInfo = await bundle.getBundleInfo("com.example.cerxts", bundle.BundleFlag.GET_BUNDLE_DEFAULT) + let clientAppUid = bundleInfo.uid + clientAppUidStr = clientAppUid.toString() + } + resolve(clientAppUidStr) + }) + } + + var keyStore: Uint8Array + async function getGeneratePrivateCert() { + let keyAlias = 'generateKeyAlias' + let keyProperties: CMKeyProperties + keyProperties = { + type: 'CM_URI_TYPE_APP_KEY', + alg: 'string', + size: 1, + padding: 'string', + purpose: 'string', + digest: 'string', + authType: 'string', + authTimeout: 'string', + } + let cmResult = await certStubPromise.generatePrivateCertificate(keyAlias, keyProperties) + keyStore = cmResult.outData + } + + export default function abilityTest() { + describe('CertificateSystemXTSTest', function () { + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GetSystemCAList + * @tc.desc Test for CmGetCertList js interface - system root certificate - get the certificate list normally (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_GetSystemCAList_0001 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level2 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetSystemCAList_0001', 0, async function (done) { + try { + let result = await certStubPromise.getSystemTrustedCertificateList() + expect(result.certList[0].uri).assertEqual('uri://stub/certFile/0') + expect(result.certList[0].certAlias).assertEqual('SystemRoot_1') + expect(result.certList[0].status).assertEqual(true) + expect(result.certList[0].subjectName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + expect(result.certList[1].uri).assertEqual('uri://stub/certFile/1') + expect(result.certList[1].certAlias).assertEqual('SystemRoot_2') + expect(result.certList[1].status).assertEqual(false) + expect(result.certList[1].subjectName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + expect(result.certList[2].uri).assertEqual('uri://stub/certFile/2') + expect(result.certList[2].certAlias).assertEqual('SystemRoot_3') + expect(result.certList[2].status).assertEqual(true) + expect(result.certList[2].subjectName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + done() + } catch (error) { + console.log('getSystemTrustedCertificateList failed' + JSON.stringify(error.code)) + expect().assertFail() + done() + } + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GetSystemCAList + * @tc.desc Test for CmGetCertList js interface - system root certificate - get the certificate list normally + * (promise, Cycle call five times). + * @tc.number SEC_CertificateManagement_Interface_Js_GetSystemCAList_0002 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetSystemCAList_0002', 0, async function (done) { + for (var i = 0; i < 5; i++) { + try { + let result = await certStubPromise.getSystemTrustedCertificateList() + expect(result.certList[0].uri).assertEqual('uri://stub/certFile/0') + expect(result.certList[0].certAlias).assertEqual('SystemRoot_1') + expect(result.certList[0].status).assertEqual(true) + expect(result.certList[0].subjectName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + expect(result.certList[1].uri).assertEqual('uri://stub/certFile/1') + expect(result.certList[1].certAlias).assertEqual('SystemRoot_2') + expect(result.certList[1].status).assertEqual(false) + expect(result.certList[1].subjectName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + expect(result.certList[2].uri).assertEqual('uri://stub/certFile/2') + expect(result.certList[2].certAlias).assertEqual('SystemRoot_3') + expect(result.certList[2].status).assertEqual(true) + expect(result.certList[2].subjectName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + } catch (error) { + console.log('getSystemTrustedCertificateList failed' + JSON.stringify(error.code)) + expect().assertFail() + done() + } + } + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GetSystemCAList + * @tc.desc Test for CmGetCertList js interface - system root certificate - get the certificate list normally (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_GetSystemCAList_0005 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level2 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetSystemCAList_0005', 0, async function (done) { + certStubCallback.getSystemTrustedCertificateList((err, data) => { + expect(data.certList[0].uri).assertEqual('uri://stub/certFile/0') + expect(data.certList[0].certAlias).assertEqual('SystemRoot_1') + expect(data.certList[0].status).assertEqual(true) + expect(data.certList[0].subjectName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + expect(data.certList[1].uri).assertEqual('uri://stub/certFile/1') + expect(data.certList[1].certAlias).assertEqual('SystemRoot_2') + expect(data.certList[1].status).assertEqual(false) + expect(data.certList[1].subjectName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + expect(data.certList[2].uri).assertEqual('uri://stub/certFile/2') + expect(data.certList[2].certAlias).assertEqual('SystemRoot_3') + expect(data.certList[2].status).assertEqual(true) + expect(data.certList[2].subjectName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + expect(err.code).assertEqual(0) + done() + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GetSystemCAList + * @tc.desc Test for CmGetCertList js interface - system root certificate - get the certificate list normally + * (callback, Cycle call five times). + * @tc.number SEC_CertificateManagement_Interface_Js_GetSystemCAList_0006 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetSystemCAList_0006', 0, async function (done) { + for (var i = 0; i < 5; i++) { + certStubCallback.getSystemTrustedCertificateList((err, data) => { + expect(data.certList[0].uri).assertEqual('uri://stub/certFile/0') + expect(data.certList[0].certAlias).assertEqual('SystemRoot_1') + expect(data.certList[0].status).assertEqual(true) + expect(data.certList[0].subjectName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + expect(data.certList[1].uri).assertEqual('uri://stub/certFile/1') + expect(data.certList[1].certAlias).assertEqual('SystemRoot_2') + expect(data.certList[1].status).assertEqual(false) + expect(data.certList[1].subjectName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + expect(data.certList[2].uri).assertEqual('uri://stub/certFile/2') + expect(data.certList[2].certAlias).assertEqual('SystemRoot_3') + expect(data.certList[2].status).assertEqual(true) + expect(data.certList[2].subjectName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + expect(err.code).assertEqual(0) + }) + sleep(500) + } + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GetSystemCAList + * @tc.desc Test for CmGetCertInfo js interface - system root certificate - get the certificate + * info normally (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_GetSystemCAInfo_0001 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level2 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetSystemCAInfo_0001', 0, async function (done) { + try { + let Listresult = await certStubPromise.getSystemTrustedCertificateList() + let Inforesult = await certStubPromise.getSystemTrustedCertificate(Listresult.certList[0].uri) + console.log('uri is:' + JSON.stringify(Inforesult.certInfo.uri)) + expect(Inforesult.certInfo.uri).assertEqual('uri://stub/certFile/0') + expect(Inforesult.certInfo.certAlias).assertEqual('SystemRoot_1') + expect(Inforesult.certInfo.status).assertEqual(true) + expect(Inforesult.certInfo.subjectName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + expect(Inforesult.certInfo.fingerprintSha256).assertEqual('23:b7:4d:a0:2f:00:a0:2a:16:c8:8d:' + + 'bc:4c:71:ea:fd:7e:53:95:09') + expect(Inforesult.certInfo.serial).assertEqual('0fe1388b') + expect(Inforesult.certInfo.issuerName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + expect(Inforesult.certInfo.notBefore).assertEqual('2021/2/2') + expect(Inforesult.certInfo.notAfter).assertEqual('2049/12/31') + done() + } catch (error) { + console.log('getSystemTrustedCertificate failed' + JSON.stringify(error.code)) + expect().assertFail() + done() + } + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GetSystemCAList + * @tc.desc Test for CmGetCertInfo js interface - system root certificate - get the certificate info normally + * (promise, Cycle call five times). + * @tc.number SEC_CertificateManagement_Interface_Js_GetSystemCAInfo_0002 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetSystemCAInfo_0002', 0, async function (done) { + for (var i = 0; i < 5; i++) { + try { + let Listresult = await certStubPromise.getSystemTrustedCertificateList() + let Inforesult = await certStubPromise.getSystemTrustedCertificate(Listresult.certList[0].uri) + console.log('uri is:' + JSON.stringify(Inforesult.certInfo.uri)) + expect(Inforesult.certInfo.uri).assertEqual('uri://stub/certFile/0') + expect(Inforesult.certInfo.certAlias).assertEqual('SystemRoot_1') + expect(Inforesult.certInfo.status).assertEqual(true) + expect(Inforesult.certInfo.subjectName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + expect(Inforesult.certInfo.fingerprintSha256).assertEqual('23:b7:4d:a0:2f:00:a0:2a:16:c8:8d:' + + 'bc:4c:71:ea:fd:7e:53:95:09') + expect(Inforesult.certInfo.serial).assertEqual('0fe1388b') + expect(Inforesult.certInfo.issuerName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + expect(Inforesult.certInfo.notBefore).assertEqual('2021/2/2') + expect(Inforesult.certInfo.notAfter).assertEqual('2049/12/31') + } catch (error) { + console.log('getSystemTrustedCertificate failed' + JSON.stringify(error.code)) + expect().assertFail() + done() + } + } + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GetSystemCAList + * @tc.desc Test for CmGetCertInfo js interface - system root certificate - get the certificate + * info unnormally (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_GetSystemCAInfo_0004 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetSystemCAInfo_0004', 0, async function (done) { + try { + await certStubPromise.getSystemTrustedCertificate('') + expect().assertFail() + done() + } catch (error) { + console.log('getSystemTrustedCertificate failed' + JSON.stringify(error.code)) + expect(error.code).assertEqual(-13) + done() + } + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GetSystemCAList + * @tc.desc Test for CmGetCertInfo js interface - system root certificate - get the certificate + * info normally (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_GetSystemCAInfo_0006 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level2 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetSystemCAInfo_0006', 0, async function (done) { + certStubCallback.getSystemTrustedCertificateList((err, Listresult) => { + certStubCallback.getSystemTrustedCertificate(Listresult.certList[0].uri, (err, data) => { + expect(data.certInfo.uri).assertEqual('uri://stub/certFile/0') + expect(data.certInfo.certAlias).assertEqual('SystemRoot_1') + expect(data.certInfo.status).assertEqual(true) + expect(data.certInfo.subjectName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + expect(data.certInfo.fingerprintSha256).assertEqual('23:b7:4d:a0:2f:00:a0:2a:16:c8:8d:' + + 'bc:4c:71:ea:fd:7e:53:95:09') + expect(data.certInfo.serial).assertEqual('0fe1388b') + expect(data.certInfo.issuerName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + expect(data.certInfo.notBefore).assertEqual('2021/2/2') + expect(data.certInfo.notAfter).assertEqual('2049/12/31') + expect(err.code).assertEqual(CMErrorCode.CMR_SUCCESS) + done() + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GetSystemCAList + * @tc.desc Test for CmGetCertInfo js interface - system root certificate - get the certificate info normally + * (callback, Cycle call five times). + * @tc.number SEC_CertificateManagement_Interface_Js_GetSystemCAInfo_0007 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetSystemCAInfo_0007', 0, async function (done) { + for (var i = 0; i < 5; i++) { + certStubCallback.getSystemTrustedCertificateList((err, Listresult) => { + certStubCallback.getSystemTrustedCertificate(Listresult.certList[0].uri, (err, data) => { + expect(data.certInfo.uri).assertEqual('uri://stub/certFile/0') + expect(data.certInfo.certAlias).assertEqual('SystemRoot_1') + expect(data.certInfo.status).assertEqual(true) + expect(data.certInfo.subjectName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + expect(data.certInfo.fingerprintSha256).assertEqual('23:b7:4d:a0:2f:00:a0:2a:16:c8:8d:' + + 'bc:4c:71:ea:fd:7e:53:95:09') + expect(data.certInfo.serial).assertEqual('0fe1388b') + expect(data.certInfo.issuerName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + expect(data.certInfo.notBefore).assertEqual('2021/2/2') + expect(data.certInfo.notAfter).assertEqual('2049/12/31') + expect(err.code).assertEqual(0) + }) + }) + sleep(500) + } + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GetSystemCAList + * @tc.desc Test for CmGetCertInfo js interface - system root certificate - get the certificate + * info unnormally (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_GetSystemCAInfo_0009 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetSystemCAInfo_0009', 0, async function (done) { + certStubCallback.getSystemTrustedCertificate('', (err, data) => { + expect(err.code).assertEqual(-13) + done() + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GetUserCAList + * @tc.desc Test for CmGetCertList js interface - user root certificate - get the certificate + * list normally (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_GetUserCAList_0001 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level2 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetUserCAList_0001', 0, async function (done) { + try { + installTestUserTrustedCAPromise('rootca.cer') + let result = await certStubPromise.getUserTrustedCertificateList() + console.log('result is:' + JSON.stringify(result)) + expect(result.certList[0].certAlias).assertEqual('UserCert') + expect(result.certList[0].status).assertEqual(true) + expect(result.certList[0].subjectName) + .assertEqual('CN = OpenHarmony Application Root CA,OU = OpenHarmony Team,O = OpenHarmony,C = CN') + await certStubPromise.uninstallUserTrustedCertificate(result.certList[0].uri) + done() + } catch (error) { + console.log('getUserTrustedCertificateList failed' + JSON.stringify(error.code)) + expect().assertFail() + done() + } + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GetUserCAList + * @tc.desc Test for CmGetCertList js interface - user root certificate - get the certificate list normally + * (promise, Cycle call five times). + * @tc.number SEC_CertificateManagement_Interface_Js_GetUserCAList_0002 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetUserCAList_0002', 0, async function (done) { + installTestUserTrustedCAPromise('rootca.cer') + for (var i = 0; i < 5; i++) { + try { + var result = await certStubPromise.getUserTrustedCertificateList() + expect(result.certList[0].certAlias).assertEqual('UserCert') + expect(result.certList[0].status).assertEqual(true) + expect(result.certList[0].subjectName) + .assertEqual('CN = OpenHarmony Application Root CA,OU = OpenHarmony Team,O = OpenHarmony,C = CN') + } catch (error) { + console.log('getUserTrustedCertificateList failed' + JSON.stringify(error.code)) + expect().assertFail() + done() + } + } + await certStubPromise.uninstallUserTrustedCertificate(result.certList[0].uri) + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GetUserCAList + * @tc.desc Test for CmGetCertList js interface - user root certificate - get the certificate + * list normally (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_GetUserCAList_0005 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level2 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetUserCAList_0005', 0, async function (done) { + installTestUserTrustedCACallback('rootca.cer') + certStubCallback.getUserTrustedCertificateList((err, result) => { + expect(result.certList[0].certAlias).assertEqual('UserCert') + expect(result.certList[0].status).assertEqual(true) + expect(result.certList[0].subjectName) + .assertEqual('CN = OpenHarmony Application Root CA,OU = OpenHarmony Team,O = OpenHarmony,C = CN') + expect(err.code).assertEqual(0) + certStubCallback.uninstallUserTrustedCertificate(result.certList[0].uri, (err, data) => { + done() + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GetUserCAList + * @tc.desc Test for CmGetCertList js interface - user root certificate - get the certificate list normally + * (promise, Cycle call five times). + * @tc.number SEC_CertificateManagement_Interface_Js_GetUserCAList_0006 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetUserCAList_0006', 0, async function (done) { + installTestUserTrustedCACallback('rootca.cer') + var Result + for (var i = 0; i < 5; i++) { + certStubCallback.getUserTrustedCertificateList((err, result) => { + Result = result + expect(result.certList[0].certAlias).assertEqual('UserCert') + expect(result.certList[0].status).assertEqual(true) + expect(result.certList[0].subjectName) + .assertEqual('CN = OpenHarmony Application Root CA,OU = OpenHarmony Team,O = OpenHarmony,C = CN') + expect(err.code).assertEqual(0) + }) + sleep(500) + } + certStubCallback.uninstallUserTrustedCertificate(Result.certList[0].uri, (err, data) => { + done() + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GetUserCAInfo + * @tc.desc Test for CmGetCertInfo js interface - user root certificate - get the certificate + * info normally (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_GetUserCAInfo_0001 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level2 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetUserCAInfo_0001', 0, async function (done) { + try { + installTestUserTrustedCAPromise('rootca.cer') + let Listresult = await certStubPromise.getUserTrustedCertificateList() + let Inforesult = await certStubPromise.getUserTrustedCertificate(Listresult.certList[0].uri) + expect(Inforesult.certInfo.certAlias).assertEqual('UserCert') + expect(Inforesult.certInfo.status).assertEqual(true) + expect(Inforesult.certInfo.subjectName).assertEqual('CN = OpenHarmony Application Root CA,' + + 'OU = OpenHarmony Team,O = OpenHarmony,C = CN') + expect(Inforesult.certInfo.fingerprintSha256).assertEqual('23:b7:4d:a0:2f:00:a0:2a:16:c8:8d:bc:' + + '4c:71:ea:fd:7e:53:95:09') + expect(Inforesult.certInfo.serial).assertEqual('0fe1388b') + expect(Inforesult.certInfo.issuerName).assertEqual('CN = OpenHarmony Application Root CA,' + + 'OU = OpenHarmony Team,O = OpenHarmony,C = CN') + expect(Inforesult.certInfo.notBefore).assertEqual('2021/2/2') + expect(Inforesult.certInfo.notAfter).assertEqual('2049/12/31') + await certStubPromise.uninstallUserTrustedCertificate(Listresult.certList[0].uri) + done() + } catch (error) { + console.log('getUserTrustedCertificate failed' + JSON.stringify(error.code)) + expect().assertFail() + done() + } + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GetUserCAInfo + * @tc.desc Test for CmGetCertInfo js interface - user root certificate - get the certificate info normally + * (promise, Cycle call five times). + * @tc.number SEC_CertificateManagement_Interface_Js_GetUserCAInfo_0002 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetUserCAInfo_0002', 0, async function (done) { + installTestUserTrustedCAPromise('rootca.cer') + for (var i = 0; i < 5; i++) { + try { + var Listresult = await certStubPromise.getUserTrustedCertificateList() + let Inforesult = await certStubPromise.getUserTrustedCertificate(Listresult.certList[0].uri) + expect(Inforesult.certInfo.certAlias).assertEqual('UserCert') + expect(Inforesult.certInfo.status).assertEqual(true) + expect(Inforesult.certInfo.subjectName).assertEqual('CN = OpenHarmony Application Root CA,' + + 'OU = OpenHarmony Team,O = OpenHarmony,C = CN') + expect(Inforesult.certInfo.fingerprintSha256).assertEqual('23:b7:4d:a0:2f:00:a0:2a:16:c8:8d:bc:' + + '4c:71:ea:fd:7e:53:95:09') + expect(Inforesult.certInfo.serial).assertEqual('0fe1388b') + expect(Inforesult.certInfo.issuerName).assertEqual('CN = OpenHarmony Application Root CA,' + + 'OU = OpenHarmony Team,O = OpenHarmony,C = CN') + expect(Inforesult.certInfo.notBefore).assertEqual('2021/2/2') + expect(Inforesult.certInfo.notAfter).assertEqual('2049/12/31') + } catch (error) { + console.log('getUserTrustedCertificate failed' + JSON.stringify(error.code)) + expect().assertFail() + done() + } + } + await certStubPromise.uninstallUserTrustedCertificate(Listresult.certList[0].uri) + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GetUserCAInfo + * @tc.desc Test for CmGetCertInfo js interface - user root certificate - get the certificate + * info unnormally (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_GetUserCAInfo_0004 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetUserCAInfo_0004', 0, async function (done) { + try { + await certStubPromise.getUserTrustedCertificate('') + expect().assertFail() + done() + } catch (error) { + console.log('getUserTrustedCertificate failed' + JSON.stringify(error.code)) + expect(error.code).assertEqual(-13) + done() + } + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GetUserCAInfo + * @tc.desc Test for CmGetCertInfo js interface - user root certificate - get the certificate + * info normally (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_GetUserCAInfo_0005 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level2 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetUserCAInfo_0005', 0, async function (done) { + installTestUserTrustedCACallback('rootca.cer') + certStubCallback.getUserTrustedCertificateList((err, Listresult) => { + certStubCallback.getUserTrustedCertificate(Listresult.certList[0].uri, (err, data) => { + expect(data.certInfo.certAlias).assertEqual('UserCert') + expect(data.certInfo.status).assertEqual(true) + expect(data.certInfo.subjectName).assertEqual('CN = OpenHarmony Application Root CA,' + + 'OU = OpenHarmony Team,O = OpenHarmony,C = CN') + expect(data.certInfo.fingerprintSha256).assertEqual('23:b7:4d:a0:2f:00:a0:2a:16:c8:8d:bc:' + + '4c:71:ea:fd:7e:53:95:09') + expect(data.certInfo.serial).assertEqual('0fe1388b') + expect(data.certInfo.issuerName).assertEqual('CN = OpenHarmony Application Root CA,' + + 'OU = OpenHarmony Team,O = OpenHarmony,C = CN') + expect(data.certInfo.notBefore).assertEqual('2021/2/2') + expect(data.certInfo.notAfter).assertEqual('2049/12/31') + expect(err.code).assertEqual(0) + certStubCallback.uninstallUserTrustedCertificate(Listresult.certList[0].uri, (err, data) => { + done() + }) + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GetUserCAInfo + * @tc.desc Test for CmGetCertInfo js interface - user root certificate - get the certificate info normally + * (callback, Cycle call five times). + * @tc.number SEC_CertificateManagement_Interface_Js_GetUserCAInfo_0006 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetUserCAInfo_0006', 0, async function (done) { + installTestUserTrustedCACallback('rootca.cer') + var Result + for (var i = 0; i < 5; i++) { + certStubCallback.getUserTrustedCertificateList((err, Listresult) => { + certStubCallback.getUserTrustedCertificate(Listresult.certList[0].uri, (err, data) => { + Result = data + expect(data.certInfo.certAlias).assertEqual('UserCert') + expect(data.certInfo.status).assertEqual(true) + expect(data.certInfo.subjectName).assertEqual('CN = OpenHarmony Application Root CA,' + + 'OU = OpenHarmony Team,O = OpenHarmony,C = CN') + expect(data.certInfo.fingerprintSha256).assertEqual('23:b7:4d:a0:2f:00:a0:2a:16:c8:8d:bc:' + + '4c:71:ea:fd:7e:53:95:09') + expect(data.certInfo.serial).assertEqual('0fe1388b') + expect(data.certInfo.issuerName).assertEqual('CN = OpenHarmony Application Root CA,' + + 'OU = OpenHarmony Team,O = OpenHarmony,C = CN') + expect(data.certInfo.notBefore).assertEqual('2021/2/2') + expect(data.certInfo.notAfter).assertEqual('2049/12/31') + expect(err.code).assertEqual(0) + done() + }) + }) + sleep(500) + } + certStubCallback.uninstallUserTrustedCertificate(Result.certList[0].uri, (err, data) => { + done() + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GetUserCAInfo + * @tc.desc Test for CmGetCertInfo js interface - user root certificate - get the certificate + * info normally (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_GetUserCAInfo_0008 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level2 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetUserCAInfo_0008', 0, async function (done) { + certStubCallback.getUserTrustedCertificate('', (err, data) => { + expect(err.code).assertEqual(-13) + done() + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_SetCertificateStatus + * @tc.desc Test for CmSetCertStatus js interface - system root certificate - set the certificate + * status normally (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0001 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level1 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0001', 0, async function (done) { + try { + let Listresult = await certStubPromise.getSystemTrustedCertificateList() + await certStubPromise.setCertificateStatus(Listresult.certList[0].uri, 1, false) + expect(Listresult.certList[0].status).assertEqual(false) + done() + } catch (error) { + console.log('setCertificateStatus failed' + JSON.stringify(error.code)) + expect().assertFail() + done() + } + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_SetCertificateStatus + * @tc.desc Test for CmSetCertStatus js interface - system root certificate - set the certificate + * status normally (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0002 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level1 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0002', 0, async function (done) { + try { + let Listresult = await certStubPromise.getSystemTrustedCertificateList() + await certStubPromise.setCertificateStatus(Listresult.certList[0].uri, 1, true) + expect(Listresult.certList[0].status).assertEqual(true) + done() + } catch (error) { + console.log('setCertificateStatus failed' + JSON.stringify(error.code)) + expect().assertFail() + done() + } + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_SetCertificateStatus + * @tc.desc Test for CmSetCertStatus js interface - user root certificate - set the certificate + * status normally (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0003 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level1 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0003', 0, async function (done) { + try { + installTestUserTrustedCAPromise('rootca.cer') + let Listresult = await certStubPromise.getUserTrustedCertificateList() + await certStubPromise.setCertificateStatus(Listresult.certList[0].uri, 2, false) + expect(Listresult.certList[0].status).assertEqual(false) + await certStubPromise.uninstallUserTrustedCertificate(Listresult.certList[0].uri) + done() + } catch (error) { + console.log('setCertificateStatus failed' + JSON.stringify(error.code)) + expect().assertFail() + done() + } + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_SetCertificateStatus + * @tc.desc Test for CmSetCertStatus js interface - user root certificate - set the certificate + * status normally (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0004 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level1 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0004', 0, async function (done) { + try { + installTestUserTrustedCAPromise('rootca.cer') + let Listresult = await certStubPromise.getUserTrustedCertificateList() + await certStubPromise.setCertificateStatus(Listresult.certList[0].uri, 2, true) + expect(Listresult.certList[0].status).assertEqual(true) + await certStubPromise.uninstallUserTrustedCertificate(Listresult.certList[0].uri) + done() + } catch (error) { + console.log('setCertificateStatus failed' + JSON.stringify(error.code)) + expect().assertFail() + done() + } + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_SetCertificateStatus + * @tc.desc Test for CmSetCertStatus js interface - system root certificate - set the certificate + * status normally (promise, Cycle call five times). + * @tc.number SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0005 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0005', 0, async function (done) { + for (var i = 0; i < 5; i++) { + try { + let Listresult = await certStubPromise.getSystemTrustedCertificateList() + await certStubPromise.setCertificateStatus(Listresult.certList[0].uri, 1, false) + expect(Listresult.certList[0].status).assertEqual(false) + } catch (error) { + console.log('setCertificateStatus failed' + JSON.stringify(error.code)) + expect().assertFail() + done() + } + } + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_SetCertificateStatus + * @tc.desc Test for CmSetCertStatus js interface - user root certificate - set the certificate + * status normally (promise, Cycle call five times). + * @tc.number SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0005 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0006', 0, async function (done) { + installTestUserTrustedCAPromise('rootca.cer') + for (var i = 0; i < 5; i++) { + try { + var Listresult = await certStubPromise.getUserTrustedCertificateList() + await certStubPromise.setCertificateStatus(Listresult.certList[0].uri, 2, false) + expect(Listresult.certList[0].status).assertEqual(false) + } catch (error) { + console.log('setCertificateStatus failed' + JSON.stringify(error.code)) + expect().assertFail() + done() + } + } + await certStubPromise.uninstallUserTrustedCertificate(Listresult.certList[0].uri) + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_SetCertificateStatus + * @tc.desc Test for CmSetCertStatus js interface - root certificate - set the certificate + * status unnormally (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0009 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0009', 0, async function (done) { + try { + await certStubPromise.setCertificateStatus('', 1, false) + expect().assertFail() + done() + } catch (error) { + console.log('SetCertificateStatus_0009 setCertificateStatus failed' + JSON.stringify(error.code)) + expect(error.code).assertEqual(-13) + done() + } + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_SetCertificateStatus + * @tc.desc Test for CmSetCertStatus js interface - system root certificate - set the certificate + * status unnormally (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0010 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0010', 0, async function (done) { + try { + let Listresult = await certStubPromise.getSystemTrustedCertificateList() + await certStubPromise.setCertificateStatus(Listresult.certList[0].uri, 0, false) + expect().assertFail() + done() + } catch (error) { + console.log('SetCertificateStatus_0010 setCertificateStatus failed' + JSON.stringify(error.code)) + expect(error.code).assertEqual(-5) + done() + } + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_SetCertificateStatus + * @tc.desc Test for CmSetCertStatus js interface - system root certificate - set the certificate + * status normally (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0001 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level1 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0011', 0, async function (done) { + certStubCallback.getSystemTrustedCertificateList((err, Listresult) => { + certStubCallback.setCertificateStatus(Listresult.certList[0].uri, 1, false, (err, data) => { + expect(Listresult.certList[0].status).assertEqual(false) + expect(err.code != CMErrorCode.CMR_FAILURE).assertTrue() + expect(err.code != CMErrorCode.CMR_ERROR_INSTALL_CERTIFICATE).assertTrue() + expect(err.code != CMErrorCode.CMR_ERROR_SET_STATUS).assertTrue() + expect(err.code != CMErrorCode.CMR_ERROR_INVALID_ARGUMENT).assertTrue() + expect(err.code != CMErrorCode.CMR_ERROR_INVALID_STORE).assertTrue() + expect(err.code != CMErrorCode.CMR_ERROR_NOT_SUPPORTED).assertTrue() + expect(err.code != CMErrorCode.CMR_ERROR_UNINSTALL).assertTrue() + expect(err.code != CMErrorCode.CMR_ERROR_NO_PERMISSION).assertTrue() + expect(err.code != CMErrorCode.CMR_ERROR_INSUFFICIENT_DATA).assertTrue() + expect(err.code != CMErrorCode.CMR_ERROR_GET_CERTIRICATE).assertTrue() + expect(err.code).assertEqual(0) + done() + }) + }) + }) + /** + * @tc.name SEC_CertificateManagement_Interface_Js_SetCertificateStatus + * @tc.desc Test for CmSetCertStatus js interface - system root certificate - set the certificate + * status normally (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0002 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level1 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0012', 0, async function (done) { + certStubCallback.getSystemTrustedCertificateList((err, Listresult) => { + certStubCallback.setCertificateStatus(Listresult.certList[1].uri, 1, true, (err, data) => { + expect(Listresult.certList[1].status).assertEqual(true) + expect(err.code != CMErrorCode.CMR_ERROR_STORAGE_FAILURE).assertTrue() + expect(err.code != CMErrorCode.CMR_ERROR_HARDWARE_FAILURE).assertTrue() + expect(err.code != CMErrorCode.CMR_ERROR_ALREADY_EXISTS).assertTrue() + expect(err.code != CMErrorCode.CMR_ERROR_NOT_EXIST).assertTrue() + expect(err.code != CMErrorCode.CMR_ERROR_NULL_POINTER).assertTrue() + expect(err.code != CMErrorCode.CMR_ERROR_FILE_SIZE_FAIL).assertTrue() + expect(err.code != CMErrorCode.CMR_ERROR_READ_FILE_FAIL).assertTrue() + expect(err.code != CMErrorCode.CMR_ERROR_INVALID_PUBLIC_KEY).assertTrue() + expect(err.code != CMErrorCode.CMR_ERROR_INVALID_PRIVATE_KEY).assertTrue() + expect(err.code != CMErrorCode.CMR_ERROR_INVALID_KEY_INFO).assertTrue() + expect(err.code).assertEqual(0) + done() + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_SetCertificateStatus + * @tc.desc Test for CmSetCertStatus js interface - user root certificate - set the certificate + * status normally (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0013 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level1 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0013', 0, async function (done) { + installTestUserTrustedCACallback('rootca.cer') + certStubCallback.getUserTrustedCertificateList((err, Listresult) => { + certStubCallback.setCertificateStatus(Listresult.certList[0].uri, 2, false, (err, data) => { + expect(Listresult.certList[0].status).assertEqual(false) + expect(err.code != CMErrorCode.CMR_ERROR_REMOVE_CERTIFICATE_FAIL).assertTrue() + expect(err.code != CMErrorCode.CMR_ERROR_OPEN_FILE_FAIL).assertTrue() + expect(err.code != CMErrorCode.CMR_ERROR_INVALID_KEY_FILE).assertTrue() + expect(err.code != CMErrorCode.CMR_ERROR_IPC_MSG_FAIL).assertTrue() + expect(err.code != CMErrorCode.CMR_ERROR_REQUEST_OVERFLOWS).assertTrue() + expect(err.code != CMErrorCode.CMR_ERROR_PARAM_NOT_EXIST).assertTrue() + expect(err.code != CMErrorCode.CMR_ERROR_CRYPTO_ENGINE_ERROR).assertTrue() + expect(err.code != CMErrorCode.CMR_ERROR_COMMUNICATION_TIMEOUT).assertTrue() + expect(err.code != CMErrorCode.CMR_ERROR_IPC_INIT_FAIL).assertTrue() + expect(err.code != CMErrorCode.CMR_ERROR_IPC_DLOPEN_FAIL).assertTrue() + expect(err.code).assertEqual(0) + certStubCallback.uninstallUserTrustedCertificate(Listresult.certList[0].uri, (err, data) => { + done() + }) + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_SetCertificateStatus + * @tc.desc Test for CmSetCertStatus js interface - user root certificate - set the certificate + * status normally (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0014 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level1 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0014', 0, async function (done) { + installTestUserTrustedCACallback('rootca.cer') + certStubCallback.getUserTrustedCertificateList((err, Listresult) => { + certStubCallback.setCertificateStatus(Listresult.certList[0].uri, 2, true, (err, data) => { + expect(Listresult.certList[0].status).assertEqual(true) + expect(err.code).assertEqual(0) + certStubCallback.uninstallUserTrustedCertificate(Listresult.certList[0].uri, (err, data) => { + done() + }) + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_SetCertificateStatus + * @tc.desc Test for CmSetCertStatus js interface - system root certificate - set the certificate + * status normally (callback, Cycle call five times). + * @tc.number SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0015 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0015', 0, async function (done) { + var result + installTestUserTrustedCACallback('rootca.cer') + for (var i = 0; i < 5; i++) { + certStubCallback.getSystemTrustedCertificateList((err, Listresult) => { + result = Listresult + certStubCallback.setCertificateStatus(Listresult.certList[0].uri, 1, false, (err, data) => { + expect(Listresult.certList[0].status).assertEqual(false) + expect(err.code).assertEqual(0) + }) + }) + sleep(500) + } + certStubCallback.uninstallUserTrustedCertificate(result.certList[0].uri, (err, data) => { + done() + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_SetCertificateStatus + * @tc.desc Test for CmSetCertStatus js interface - user root certificate - set the certificate + * status normally (callback, Cycle call five times). + * @tc.number SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0016 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0016', 0, async function (done) { + var result + installTestUserTrustedCACallback('rootca.cer') + for (var i = 0; i < 5; i++) { + certStubCallback.getUserTrustedCertificateList((err, Listresult) => { + result = Listresult + certStubCallback.setCertificateStatus(Listresult.certList[0].uri, 2, false, (err, data) => { + expect(Listresult.certList[0].status).assertEqual(false) + expect(err.code).assertEqual(0) + }) + }) + sleep(500) + } + certStubCallback.uninstallUserTrustedCertificate(result.certList[0].uri, (err, data) => { + done() + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_SetCertificateStatus + * @tc.desc Test for CmSetCertStatus js interface - root certificate - set the certificate + * status unnormally (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0019 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0019', 0, async function (done) { + certStubCallback.setCertificateStatus('', 1, false, (err, data) => { + expect(err.code).assertEqual(-13) + done() + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_SetCertificateStatus + * @tc.desc Test for CmSetCertStatus js interface - system root certificate - set the certificate + * status unnormally (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0020 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_SetCertificateStatus_0020', 0, async function (done) { + certStubCallback.getSystemTrustedCertificateList((err, Listresult) => { + certStubCallback.setCertificateStatus(Listresult.certList[0].uri, 0, false, (err, data) => { + expect(err.code).assertEqual(-5) + done() + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_UninstallUserCertificate + * @tc.desc Test for CmUninstallCert js interface - user root certificate - uninstall the certificate + * normally (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_UninstallUserCertificate_0001 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level1 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_UninstallUserCertificate_0001', 0, async function (done) { + try { + installTestUserTrustedCAPromise('rootca.cer') + let Listresulte = await certStubPromise.getUserTrustedCertificateList() + await certStubPromise.uninstallUserTrustedCertificate(Listresulte.certList[0].uri) + Listresulte = await certStubPromise.getUserTrustedCertificateList() + for (let i = 0; i < Listresulte.certList.length; i++) { + if (Listresulte.certList[i].certAlias == 'UserCert') { + expect().assertFail() + } + } + done() + } catch (error) { + console.log('uninstallUserTrustedCertificate failed' + JSON.stringify(error.code)) + expect().assertFail() + done() + } + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_UninstallUserCertificate + * @tc.desc Test for CmUninstallCert js interface - user root certificate - uninstall the certificate + * unnormally (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_UninstallUserCertificate_0003 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_UninstallUserCertificate_0003', 0, async function (done) { + try { + var URI + installTestUserTrustedCAPromise('rootca.cer') + let Listresulte = await certStubPromise.getUserTrustedCertificateList() + URI = Listresulte.certList[0].uri + await certStubPromise.uninstallUserTrustedCertificate(Listresulte.certList[0].uri) + Listresulte = await certStubPromise.getUserTrustedCertificateList() + for (let i = 0; i < Listresulte.certList.length; i++) { + if (Listresulte.certList[i].certAlias == 'UserCert') { + expect().assertFail() + } + } + await certStubPromise.uninstallUserTrustedCertificate(URI) + expect().assertFail() + done() + } catch (error) { + console.log('uninstallUserTrustedCertificate failed' + JSON.stringify(error.code)) + expect(error.code).assertEqual(-13) + done() + } + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_UninstallUserCertificate + * @tc.desc Test for CmUninstallCert js interface - user root certificate - uninstall the certificate + * unnormally (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_UninstallUserCertificate_0004 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_UninstallUserCertificate_0004', 0, async function (done) { + try { + await certStubPromise.uninstallUserTrustedCertificate('') + expect().assertFail() + done() + } catch (error) { + console.log('uninstallUserTrustedCertificate failed' + JSON.stringify(error.code)) + expect(error.code).assertEqual(-13) + done() + } + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_UninstallUserCertificate + * @tc.desc Test for CmUninstallCert js interface - user root certificate - uninstall the certificate + * normally (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_UninstallUserCertificate_0005 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level1 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_UninstallUserCertificate_0005', 0, async function (done) { + installTestUserTrustedCACallback('rootca.cer') + certStubCallback.getUserTrustedCertificateList((err, data) => { + certStubCallback.uninstallUserTrustedCertificate(data.certList[0].uri, (err, data) => { + certStubCallback.getUserTrustedCertificateList((err, data) => { + for (let i = 0; i < data.certList.length; i++) { + if (data.certList[i].certAlias == 'UserCert') { + expect().assertFail() + } + } + done() + }) + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_UninstallUserCertificate + * @tc.desc Test for CmUninstallCert js interface - user root certificate - uninstall the certificate + * unnormally (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_UninstallUserCertificate_0007 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_UninstallUserCertificate_0007', 0, async function (done) { + var URI + installTestUserTrustedCACallback('rootca.cer') + certStubCallback.getUserTrustedCertificateList((err, data) => { + certStubCallback.uninstallUserTrustedCertificate(data.certList[0].uri, (err, data) => { + certStubCallback.getUserTrustedCertificateList((err, data) => { + for (let i = 0; i < data.certList.length; i++) { + if (data.certList[i].certAlias == 'UserCert') { + expect().assertFail() + } + } + certStubCallback.uninstallUserTrustedCertificate(URI, (err, data) => { + expect(err.code).assertEqual(-13) + done() + }) + }) + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_UninstallUserCertificate + * @tc.desc Test for CmUninstallCert js interface - user root certificate - uninstall the certificate + * unnormally (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_UninstallUserCertificate_0008 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_UninstallUserCertificate_0008', 0, async function (done) { + certStubCallback.uninstallUserTrustedCertificate('', (err, data) => { + expect(err.code).assertEqual(-13) + done() + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_CertificateAuthorized + * @tc.desc Authorized business certificate promise form. + * @tc.number SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0001 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level2 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0001', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0001 start") + loadInstallFile('appca.p12') + let keystorePwd = "123456" + let certAlias = "AppCert" + await certStubPromise.installAppCertificate(certFileArray, keystorePwd, certAlias) + let cmResult = await certStubPromise.getAppCertificateList() + let credentialList = cmResult.credentialList + let appKeyUri = credentialList[0].keyUri + clientAppUidStr = await getClientAppUid() + console.log('SEC_CertificateManagement_Interface_Js uid ' + clientAppUidStr) + await certStubPromise.grantAppCertificate(appKeyUri, clientAppUidStr) + cmResult = await certStubPromise.getAuthorizedAppList(appKeyUri) + let appUidList = cmResult.appUidList + let findSign = false + for (let i = 0; i < appUidList.length; i++) { + if (appUidList[i] == clientAppUidStr) { + findSign = true + break + } + } + expect(findSign).assertTrue() + await certStubPromise.uninstallAppCertificate(appKeyUri) + console.log("SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0001 end") + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_CertificateAuthorized + * @tc.desc Authorized business certificate callback form. + * @tc.number SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0002 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level2 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0002', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0002 start") + loadInstallFile('appca.p12') + let keystorePwd = "123456" + let certAlias = "AppCert" + var appKeyUri = '' + certStubCallback.installAppCertificate(certFileArray, keystorePwd, certAlias, (err) => { + expect(err.code).assertEqual(0) + certStubCallback.getAppCertificateList(async (err, cmResult) => { + expect(err.code).assertEqual(0) + let credentialList = cmResult.credentialList + if (credentialList.length == 0) { + console.log("No business certificate exists") + done() + } + appKeyUri = credentialList[0].keyUri + clientAppUidStr = await getClientAppUid() + console.log('SEC_CertificateManagement_Interface_Js uid ' + clientAppUidStr) + certStubCallback.grantAppCertificate(appKeyUri, clientAppUidStr, async (err) => { + expect(err.code).assertEqual(0) + certStubCallback.getAuthorizedAppList(appKeyUri, (err, data) => { + let appUidList = data.appUidList + var findSign = false + for (let i = 0; i < appUidList.length; i++) { + if (appUidList[i] == clientAppUidStr) { + findSign = true + break + } + } + expect(findSign).assertTrue() + certStubCallback.uninstallAppCertificate(appKeyUri, (err) => { + expect(err.code).assertEqual(0) + console.log("SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0002 end") + done() + }) + }) + }) + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_CertificateAuthorized + * @tc.desc Repeatedly authorize the same certificate to the application promise form. + * @tc.number SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0003 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0003', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0003 start") + loadInstallFile('appca.p12') + let keystorePwd = "123456" + let certAlias = "AppCert" + await certStubPromise.installAppCertificate(certFileArray, keystorePwd, certAlias) + let cmResult = await certStubPromise.getAppCertificateList() + let credentialList = cmResult.credentialList + let appKeyUri = credentialList[0].keyUri + clientAppUidStr = await getClientAppUid() + console.log('SEC_CertificateManagement_Interface_Js uid ' + clientAppUidStr) + await certStubPromise.grantAppCertificate(appKeyUri, clientAppUidStr) + await certStubPromise.grantAppCertificate(appKeyUri, clientAppUidStr) + cmResult = await certStubPromise.getAuthorizedAppList(appKeyUri) + let appUidList = cmResult.appUidList + let findSign = false + for (let i = 0; i < appUidList.length; i++) { + if (appUidList[i] == clientAppUidStr) { + findSign = true + break + } + } + expect(findSign).assertTrue() + await certStubPromise.uninstallAppCertificate(appKeyUri) + console.log("SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0003 end") + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_CertificateAuthorized + * @tc.desc Repeatedly authorize the same certificate to the application callback forms. + * @tc.number SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0004 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0004', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0004 start") + loadInstallFile('appca.p12') + let keystorePwd = "123456" + let certAlias = "AppCert" + let appKeyUri = '' + certStubCallback.installAppCertificate(certFileArray, keystorePwd, certAlias, (err) => { + expect(err.code).assertEqual(0) + certStubCallback.getAppCertificateList(async (err, cmResult) => { + expect(err.code).assertEqual(0) + let credentialList = cmResult.credentialList + appKeyUri = credentialList[0].keyUri + clientAppUidStr = await getClientAppUid() + console.log('SEC_CertificateManagement_Interface_Js uid ' + clientAppUidStr) + certStubCallback.grantAppCertificate(appKeyUri, clientAppUidStr, async (err) => { + expect(err.code).assertEqual(0) + console.log("SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0003 " + JSON.stringify(err)) + certStubCallback.grantAppCertificate(appKeyUri, clientAppUidStr, async (err) => { + expect(err.code).assertEqual(0) + console.log("SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0003 " + JSON.stringify(err)) + certStubCallback.getAuthorizedAppList(appKeyUri, (err, data) => { + let appUidList = data.appUidList + var findSign = false + for (let i = 0; i < appUidList.length; i++) { + if (appUidList[i] == clientAppUidStr) { + findSign = true + break + } + } + expect(findSign).assertTrue() + certStubCallback.uninstallAppCertificate(appKeyUri, (err) => { + expect(err.code).assertEqual(0) + console.log("SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0004 end") + done() + }) + }) + }) + }) + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_CertificateAuthorized + * @tc.desc Authorize different certificates to the same application promise form. + * @tc.number SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0005 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0005', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0005 start") + loadInstallFile('appca.p12') + let keystorePwd = "123456" + let certAlias = "AppCert" + let certAliasOther = "AppCertOther" + await certStubPromise.installAppCertificate(certFileArray, keystorePwd, certAlias) + await certStubPromise.installAppCertificate(certFileArray, keystorePwd, certAliasOther) + let cmResult = await certStubPromise.getAppCertificateList() + let credentialList = cmResult.credentialList + let appKeyUriA = credentialList[0].keyUri + let appKeyUriB = credentialList[1].keyUri + clientAppUidStr = await getClientAppUid() + console.log('SEC_CertificateManagement_Interface_Js uid ' + clientAppUidStr) + await certStubPromise.grantAppCertificate(appKeyUriA, clientAppUidStr) + await certStubPromise.grantAppCertificate(appKeyUriB, clientAppUidStr) + cmResult = await certStubPromise.getAuthorizedAppList(appKeyUriA) + let appUidList = cmResult.appUidList + var findSign = false + for (let i = 0; i < appUidList.length; i++) { + if (appUidList[i] == clientAppUidStr) { + findSign = true + break + } + } + expect(findSign).assertTrue() + appUidList = cmResult.appUidList + findSign = false + for (let i = 0; i < appUidList.length; i++) { + if (appUidList[i] == clientAppUidStr) { + findSign = true + break + } + } + expect(findSign).assertTrue() + await certStubPromise.uninstallAppCertificate(appKeyUriA) + await certStubPromise.uninstallAppCertificate(appKeyUriB) + console.log("SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0005 end") + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_CertificateAuthorized + * @tc.desc Authorize different certificates to the same application callback forms + * @tc.number SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0006 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0006', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0006 start") + loadInstallFile('appca.p12') + let keystorePwd = "123456" + let certAlias = "AppCert" + let certAliasOther = "AppCertOther" + let appKeyUriA = '' + let appKeyUriB = '' + certStubCallback.uninstallAllAppCertificate((err) => { + certStubCallback.installAppCertificate(certFileArray, keystorePwd, certAlias, (err) => { + expect(err.code).assertEqual(0) + certStubCallback.installAppCertificate(certFileArray, keystorePwd, certAliasOther, (err) => { + expect(err.code).assertEqual(0) + certStubCallback.getAppCertificateList(async (err, cmResult) => { + let credentialList = cmResult.credentialList + appKeyUriA = credentialList[0].keyUri + appKeyUriB = credentialList[1].keyUri + clientAppUidStr = await getClientAppUid() + certStubCallback.grantAppCertificate(appKeyUriA, clientAppUidStr, async (err) => { + expect(err.code).assertEqual(0) + certStubCallback.getAuthorizedAppList(appKeyUriA, (err, cmResult) => { + let appUidList = cmResult.appUidList + let findSign = false + for (let i = 0; i < appUidList.length; i++) { + if (appUidList[i] == clientAppUidStr) { + findSign = true + break + } + } + expect(findSign).assertTrue() + certStubCallback.grantAppCertificate(appKeyUriB, clientAppUidStr, async (err) => { + expect(err.code).assertEqual(0) + certStubCallback.getAuthorizedAppList(appKeyUriA, (err, cmResult) => { + appUidList = cmResult.appUidList + findSign = false + for (let i = 0; i < appUidList.length; i++) { + if (appUidList[i] == clientAppUidStr) { + findSign = true + break + } + } + expect(findSign).assertTrue() + certStubCallback.uninstallAppCertificate(appKeyUriA, (err) => { + certStubCallback.uninstallAppCertificate(appKeyUriB, (err) => { + console.log("SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0002 end") + done() + }) + }) + }) + }) + }) + }) + }) + }) + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_CertificateAuthorized + * @tc.desc The authorization uri parameter is in the wrong form of the uri promise. + * @tc.number SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0007 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0007', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0007 start") + let appKeyUri = 'appkeyurierror' + clientAppUidStr = await getClientAppUid() + console.log('SEC_CertificateManagement_Interface_Js uid ' + clientAppUidStr) + try { + await certStubPromise.grantAppCertificate(appKeyUri, clientAppUidStr) + } catch (err) { + console.log('SEC_CertificateManagement_Interface_Js grantAppCertificate err ' + JSON.stringify(err)) + expect(err.code != 0).assertTrue() + console.log("SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0007 end") + done() + } + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_CertificateAuthorized + * @tc.desc The authorization uri parameter is in the wrong form of the uri callback. + * @tc.number SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0008 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0008', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0008 start") + let appKeyUri = 'appkeyurierror' + clientAppUidStr = await getClientAppUid() + console.log('SEC_CertificateManagement_Interface_Js uid ' + clientAppUidStr) + certStubCallback.grantAppCertificate(appKeyUri, clientAppUidStr, async (err) => { + expect(err.code != 0).assertTrue() + console.log("SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0008 end") + done() + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_CertificateAuthorized + * @tc.desc Authorization uri parameter timeout Exceeded length limit of 64 characters promise form. + * @tc.number SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0009 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0009', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0009 start") + let appKeyUri = 'appkeyurierrorappkeyurierrorappkeyurierrorappkeyurierrorappkeyurierror' + clientAppUidStr = await getClientAppUid() + console.log('SEC_CertificateManagement_Interface_Js uid ' + clientAppUidStr) + try { + await certStubPromise.grantAppCertificate(appKeyUri, clientAppUidStr) + } catch (err) { + expect(err.code != 0).assertTrue() + console.log("SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0009 end") + done() + } + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_CertificateAuthorized + * @tc.desc Authorization uri parameter timeout Exceeded length limit of 64 characters callback form. + * @tc.number SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0010 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0010', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0010 start") + let appKeyUri = 'appkeyurierrorappkeyurierrorappkeyurierrorappkeyurierrorappkeyurierror' + clientAppUidStr = await getClientAppUid() + console.log('SEC_CertificateManagement_Interface_Js uid ' + clientAppUidStr) + certStubCallback.grantAppCertificate(appKeyUri, clientAppUidStr, async (err) => { + expect(err.code != 0).assertTrue() + console.log("SEC_CertificateManagement_Interface_Js_CertificateAuthorized_0010 end") + done() + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_CertificateIsAuthorized + * @tc.desc Query whether the certificate authorizes the current application promise form. + * @tc.number SEC_CertificateManagement_Interface_Js_CertificateIsAuthorized_0001 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_CertificateIsAuthorized_0001', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_CertificateIsAuthorized_0001 start") + loadInstallFile('appca.p12') + let keystorePwd = "123456" + let certAlias = "AppCert" + await certStubPromise.installAppCertificate(certFileArray, keystorePwd, certAlias) + let cmResult = await certStubPromise.getAppCertificateList() + let credentialList = cmResult.credentialList + let appKeyUri = credentialList[0].keyUri + clientAppUidStr = await getClientAppUid() + console.log('SEC_CertificateManagement_Interface_Js uid ' + clientAppUidStr) + await certStubPromise.grantAppCertificate(appKeyUri, clientAppUidStr) + cmResult = await certStubPromise.isAuthorizedApp(appKeyUri) + expect(cmResult.isAuth).assertTrue() + await certStubPromise.uninstallAppCertificate(appKeyUri) + console.log("SEC_CertificateManagement_Interface_Js_CertificateIsAuthorized_0001 end") + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_CertificateIsAuthorized + * @tc.desc Query whether the certificate authorizes the current application callback form. + * @tc.number SEC_CertificateManagement_Interface_Js_CertificateIsAuthorized_0002 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_CertificateIsAuthorized_0002', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_CertificateIsAuthorized_0002 start") + let keystorePwd = "123456" + let certAlias = "AppCert" + let appKeyUri = '' + certStubCallback.installAppCertificate(certFileArray, keystorePwd, certAlias, (err) => { + expect(err.code).assertEqual(0) + certStubCallback.getAppCertificateList(async (err, cmResult) => { + let credentialList = cmResult.credentialList + appKeyUri = credentialList[0].keyUri + clientAppUidStr = await getClientAppUid() + console.log('SEC_CertificateManagement_Interface_Js uid ' + clientAppUidStr) + certStubCallback.grantAppCertificate(appKeyUri, clientAppUidStr, async (err) => { + expect(err.code).assertEqual(0) + certStubCallback.isAuthorizedApp(appKeyUri, (err, data) => { + expect(err.code).assertEqual(0) + expect(data.isAuth).assertTrue() + certStubCallback.removeGrantedAppCertificate(appKeyUri, clientAppUidStr, (err) => { + expect(err.code).assertEqual(0) + certStubCallback.uninstallAppCertificate(appKeyUri, (err) => { + expect(err.code).assertEqual(0) + console.log("SEC_CertificateManagement_Interface_Js_CertificateIsAuthorized_0002 end") + done() + }) + }) + }) + }) + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_CertificateIsAuthorized + * @tc.desc Query whether the certificate authorizes the current application, where The key uri parameter + * is empty, the uri parameter is wrong, exceeds the length limit of 64 characters promise form. + * @tc.number SEC_CertificateManagement_Interface_Js_CertificateIsAuthorized_0003 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_CertificateIsAuthorized_0003', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_CertificateIsAuthorized_0003 start") + loadInstallFile('appca.p12') + let keystorePwd = "123456" + let certAlias = "AppCert" + await certStubPromise.installAppCertificate(certFileArray, keystorePwd, certAlias) + let cmResult = await certStubPromise.getAppCertificateList() + let credentialList = cmResult.credentialList + let appKeyUri = credentialList[0].keyUri + clientAppUidStr = await getClientAppUid() + console.log('SEC_CertificateManagement_Interface_Js uid ' + clientAppUidStr) + await certStubPromise.grantAppCertificate(appKeyUri, clientAppUidStr) + try { + await certStubPromise.isAuthorizedApp('') + } catch (err) { + console.log('SEC_CertificateManagement_Interface_Js err' + JSON.stringify(err)) + expect(err.code != 0).assertTrue() + await certStubPromise.uninstallAppCertificate(appKeyUri) + console.log("SEC_CertificateManagement_Interface_Js_CertificateIsAuthorized_0003 end") + done() + } + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_CertificateIsAuthorized + * @tc.desc Query whether the certificate authorizes the current application, where The key uri parameter + * is empty, the uri parameter is wrong, exceeds the length limit of 64 characters callback form. + * @tc.number SEC_CertificateManagement_Interface_Js_CertificateIsAuthorized_0004 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_CertificateIsAuthorized_0004', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_CertificateIsAuthorized_0004 start") + let keystorePwd = "123456" + let certAlias = "AppCert" + let appKeyUri = '' + certStubCallback.installAppCertificate(certFileArray, keystorePwd, certAlias, (err) => { + expect(err.code).assertEqual(0) + certStubCallback.getAppCertificateList(async (err, cmResult) => { + expect(err.code).assertEqual(0) + let credentialList = cmResult.credentialList + appKeyUri = credentialList[0].keyUri + clientAppUidStr = await getClientAppUid() + console.log('SEC_CertificateManagement_Interface_Js uid ' + clientAppUidStr) + certStubCallback.grantAppCertificate(appKeyUri, clientAppUidStr, async (err) => { + expect(err.code).assertEqual(0) + certStubCallback.isAuthorizedApp('', (err) => { + expect(err.code != 0).assertTrue() + let keyUriExceed = 'keyUriExceedkeyUriExceedkeyUriExceedkeyUriExceedkeyUriExceedUriEx' + certStubCallback.isAuthorizedApp(keyUriExceed, (err) => { + expect(err.code != 0).assertTrue() + let keyUriError = 'keyUriError' + certStubCallback.isAuthorizedApp(keyUriError, (err) => { + expect(err.code != 0).assertTrue() + certStubCallback.removeGrantedAppCertificate(appKeyUri, clientAppUidStr, (err) => { + expect(err.code).assertEqual(0) + certStubCallback.uninstallAppCertificate(appKeyUri, (err) => { + expect(err.code).assertEqual(0) + console.log("SEC_CertificateManagement_Interface_Js_CertificateIsAuthorized_0004 end") + done() + }) + }) + }) + }) + }) + }) + }) + }) + }) + + /** + * @tc.name GetAppCertificateList0001 + * @tc.desc Test for GetAppCertificateList JS interface - app certificate - get + the certificate list normally promise. + * @tc.number SEC_CertificateManagement_Interface_Js_GetAppCertificateList_0001 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level1 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetAppCertificateList_0001', 0, async function (done) { + try { + loadInstallFile('appca.p12') + let keystorePwd = "123456" + var keyUri = "" + let appCerInstall = false + await certStubPromise.installAppCertificate(certFileArray, keystorePwd, "GetAppCertificateList001") + let result = await certStubPromise.getAppCertificateList() + for (let j = 0; j < result.credentialList.length; j++) { + if (result.credentialList[j].alias == "GetAppCertificateList001") { + keyUri = result.credentialList[j].keyUri + appCerInstall = true + break + } + } + expect(appCerInstall).assertEqual(true) + } catch (error) { + console.info("getAppCertificateList_0001 err" + JSON.stringify(error.code)) + expect().assertFail(); + done(); + } + certStubPromise.uninstallAppCertificate(keyUri) + done() + }) + + /** + * @tc.name GetAppCertificateList0002 + * @tc.desc Test for GetAppCertificateList JS interface - app certificate - get + the certificate list normally (promise,Cycle call five times). + * @tc.number SEC_CertificateManagement_Interface_Js_GetAppCertificateList_0002 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetAppCertificateList_0002', 0, async function (done) { + loadInstallFile('appca.p12') + let keystorePwd = "123456" + var keyUri = "" + let appCerInstall = false + await certStubPromise.installAppCertificate(certFileArray, keystorePwd, "GetAppCertificateList002") + for (var i = 0; i < 5; i++) { + try { + let result = await certStubPromise.getAppCertificateList() + for (let j = 0; j < result.credentialList.length; j++) { + if (result.credentialList[j].alias == "GetAppCertificateList002") { + keyUri = result.credentialList[j].keyUri + appCerInstall = true + break + } + } + expect(appCerInstall).assertEqual(true) + } catch (error) { + console.log('getAppCertificateList_0002 failed' + JSON.stringify(error.code)) + expect().assertFail() + done() + } + } + certStubPromise.uninstallAppCertificate(keyUri) + done() + }) + + /** + * @tc.name GetAppCertificateList0004 + * @tc.desc Test for GetAppCertificateList JS interface - app certificate - get + the certificate list normally (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_GetAppCertificateList_0004 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level1 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetAppCertificateList_0004', 0, async function (done) { + loadInstallFile('appca.p12') + let keystorePwd = "123456" + var keyUri = "" + let appCerInstall = false + certStubCallback.installAppCertificate(certFileArray, keystorePwd, "GetAppCertificateList0004", (err) => { + certStubCallback.getAppCertificateList((err, data) => { + for (let j = 0; j < data.credentialList.length; j++) { + if (data.credentialList[j].alias == "GetAppCertificateList0004") { + keyUri = data.credentialList[j].keyUri + appCerInstall = true + } + } + expect(appCerInstall).assertEqual(true) + certStubCallback.uninstallAppCertificate(keyUri, (err) => { + done() + }) + }) + }) + }) + + /** + * @tc.name GetAppCertificateList0005 + * @tc.desc Test for GetAppCertificateList JS interface - app certificate - get + the certificate list normally (callback,Cycle call five times). + * @tc.number SEC_CertificateManagement_Interface_Js_GetAppCertificateList_0005 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetAppCertificateList_0005', 0, async function (done) { + loadInstallFile('appca.p12') + let keystorePwd = "123456" + var keyUri = "" + let appCerInstall = false + certStubCallback.installAppCertificate(certFileArray, keystorePwd, "GetAppCertificateList0005", (err) => { + for (var i = 0; i < 5; i++) { + certStubCallback.getAppCertificateList((err, data) => { + for (let j = 0; j < data.credentialList.length; j++) { + if (data.credentialList[j].alias == "GetAppCertificateList0005") { + keyUri = data.credentialList[j].keyUri + appCerInstall = true + break; + } + } + expect(appCerInstall).assertEqual(true) + }) + sleep(500) + } + certStubCallback.uninstallAppCertificate(keyUri, (err) => { + done() + }) + }) + }) + + /** + * @tc.name GetAppCertifiCate0001 + * @tc.desc Test for GetAppCertifiCate JS interface - app certificate - get + the certificate Info normally (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_GetAppCertifiCate_0001 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level2 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetAppCertifiCate_0001', 0, async function (done) { + try { + loadInstallFile('appca.p12') + let keystorePwd = "123456" + var keyUri = "" + let appCerInstall = false + await certStubPromise.installAppCertificate(certFileArray, keystorePwd, "GetAppCertifiCate0001") + let result = await certStubPromise.getAppCertificateList() + for (let j = 0; j < result.credentialList.length; j++) { + if (result.credentialList[j].alias == "GetAppCertifiCate0001") { + keyUri = result.credentialList[j].keyUri + appCerInstall = true + } + } + var AppCertificate = await certStubPromise.getAppCertificate(keyUri) + expect(appCerInstall).assertEqual(true) + expect(AppCertificate.credential.alias).assertEqual("GetAppCertifiCate0001") + certStubPromise.uninstallAppCertificate(keyUri) + + done(); + } catch (err) { + console.info("getAppCertificate_0100 err" + JSON.stringify(err)) + expect().assertFail(); + done(); + } + }) + + /** + * @tc.name GetAppCertifiCate0002 + * @tc.desc Test for GetAppCertifiCate JS interface - app certificate - get + the certificate Info normally (promise,Cycle call five times). + * @tc.number SEC_CertificateManagement_Interface_Js_GetAppCertifiCate_0002 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetAppCertifiCate_0002', 0, async function (done) { + loadInstallFile('appca.p12') + let keystorePwd = "123456" + var keyUri = "" + let appCerInstall = false + await certStubPromise.installAppCertificate(certFileArray, keystorePwd, "GetAppCertifiCate0002") + for (var i = 0; i < 5; i++) { + try { + let result = await certStubPromise.getAppCertificateList() + for (let j = 0; j < result.credentialList.length; j++) { + if (result.credentialList[j].alias == "GetAppCertifiCate0002") { + keyUri = result.credentialList[j].keyUri + appCerInstall = true + break + } + } + let AppCertificate = await certStubPromise.getAppCertificate(keyUri) + expect(AppCertificate.credential.alias).assertEqual("GetAppCertifiCate0002") + expect(appCerInstall).assertEqual(true) + } catch (error) { + console.log('getAppCertificateList_0002 failed' + JSON.stringify(error.code)) + expect().assertFail() + done() + } + } + certStubPromise.uninstallAppCertificate(keyUri) + done() + }) + + /** + * @tc.name GetAppCertifiCate0004 + * @tc.desc Test for GetAppCertifiCate JS interface - app certificate - get + the certificate Info unusually (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_GetAppCertifiCate_0004 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetAppCertifiCate_0004', 0, async function (done) { + try { + await certStubPromise.getAppCertificate('') + expect().assertFail() + done() + } catch (error) { + console.log('getAppCertificate failed' + JSON.stringify(error.code)) + expect(error.code).assertEqual(-13) + done() + } + }) + + /** + * @tc.name GetAppCertifiCate0005 + * @tc.desc Test for GetAppCertifiCate JS interface - app certificate - get + the certificate Info unusually (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_GetAppCertifiCate_0005 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level2 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetAppCertifiCate_0005', 0, async function (done) { + certStubCallback.getAppCertificate('', (err, data) => { + expect(err.code).assertEqual(-13) + done() + }) + }) + + /** + * @tc.name GetAppCertifiCate0006 + * @tc.desc Test for GetAppCertifiCate JS interface - app certificate - get + the certificate Info normally (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_GetAppCertifiCate_0006 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level2 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetAppCertifiCate_0006', 0, async function (done) { + loadInstallFile('appca.p12') + let keystorePwd = "123456" + var keyUri = "" + let appCerInstall = false + certStubCallback.installAppCertificate(certFileArray, keystorePwd, "GetAppCertifiCate0006", (err) => { + certStubCallback.getAppCertificateList((err, data) => { + for (let j = 0; j < data.credentialList.length; j++) { + if (data.credentialList[j].alias == "GetAppCertifiCate0006") { + keyUri = data.credentialList[j].keyUri + appCerInstall = true + break; + } + } + expect(appCerInstall).assertEqual(true) + certStubCallback.getAppCertificate(keyUri, (err, data) => { + expect(data.credential.alias).assertEqual("GetAppCertifiCate0006") + certStubCallback.uninstallAppCertificate(keyUri, (err) => { + done() + }) + }) + }) + }) + }) + + /** + * @tc.name GetAppCertifiCate0007 + * @tc.desc Test for GetAppCertifiCate JS interface - app certificate - get + the certificate Info normally (callback,Cycle call five times). + * @tc.number SEC_CertificateManagement_Interface_Js_GetAppCertifiCate_0007 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetAppCertifiCate_0007', 0, async function (done) { + loadInstallFile('appca.p12') + let keystorePwd = "123456" + var keyUri = "" + let appCerInstall = false + certStubCallback.installAppCertificate(certFileArray, keystorePwd, "GetAppCertificateList0007", (err) => { + for (var i = 0; i < 5; i++) { + certStubCallback.getAppCertificateList((err, data) => { + for (let j = 0; j < data.credentialList.length; j++) { + if (data.credentialList[j].alias == "GetAppCertificateList0007") { + keyUri = data.credentialList[j].keyUri + appCerInstall = true + break; + } + } + expect(appCerInstall).assertEqual(true) + certStubCallback.getAppCertificate(keyUri, (err, data) => { + expect(data.credential.alias).assertEqual("GetAppCertificateList0007") + certStubCallback.uninstallAppCertificate(keyUri, (err) => { + done() + }) + }) + }) + } + }) + }) + + /** + * @tc.name GetPrivateCertificateList0001 + * @tc.desc Test for GetPrivateCertificateList JS interface - private certificate - get + the certificate list normally (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_GetPrivateCertificateList_0001 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level1 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetPrivateCertificateList_0001', 0, async function (done) { + try { + getGeneratePrivateCert() + let keystorePwd = "123456" + let appCerInstall = false + let cmResult = await certStubPromise.installPrivateCertificate(keyStore, keystorePwd, "GetPrivateList0001") + let keyUri = cmResult.authUri + var PrivateCertificateList = await certStubPromise.getPrivateCertificateList() + for (let j = 0; j < PrivateCertificateList.credentialList.length; j++) { + if (PrivateCertificateList.credentialList[j].alias == "GetPrivateList0001") { + appCerInstall = true + break + } + } + expect(appCerInstall).assertEqual(true) + await certStubPromise.uninstallPrivateCertificate(keyUri) + done(); + } catch (err) { + console.info("getPrivateCertificateList_0100 err" + JSON.stringify(err)) + expect().assertFail(); + done(); + } + }) + + /** + * @tc.name GetPrivateCertificateList0002 + * @tc.desc Test for GetPrivateCertificateList JS interface - private certificate - get + the certificate list normally (promise,Cycle call five times). + * @tc.number SEC_CertificateManagement_Interface_Js_GetPrivateCertificateList_0002 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetPrivateCertificateList_0002', 0, async function (done) { + getGeneratePrivateCert() + let keystorePwd = "123456" + let appCerInstall = false + let cmResult = await certStubPromise.installPrivateCertificate(keyStore, keystorePwd, "GetPrivateList0002") + let keyUri = cmResult.authUri + for (var i = 0; i < 5; i++) { + try { + var PrivateCertificateList = await certStubPromise.getPrivateCertificateList() + for (let j = 0; j < PrivateCertificateList.credentialList.length; j++) { + if (PrivateCertificateList.credentialList[j].alias == "GetPrivateList0002") { + appCerInstall = true + break + } + } + expect(appCerInstall).assertEqual(true) + } catch (error) { + console.log('getPrivateCertificateList failed' + JSON.stringify(error.code)) + expect().assertFail() + done() + } + } + await certStubPromise.uninstallPrivateCertificate(keyUri) + done() + }) + + /** + * @tc.name GetPrivateCertificateList0004 + * @tc.desc Test for GetPrivateCertificateList JS interface - private certificate - get + the certificate list normally (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_GetPrivateCertificateList_0004 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level1 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetPrivateCertificateList_0004', 0, async function (done) { + getGeneratePrivateCert() + let keyStorePwd = "123456" + let appCerInstall = false + certStubCallback.installPrivateCertificate(keyStore, keyStorePwd, "GetPrivateList0004", (err, cmResult) => { + let keyUri = cmResult.authUri + certStubCallback.getPrivateCertificateList((err, data) => { + for (let j = 0; j < data.credentialList.length; j++) { + if (data.credentialList[j].alias == "GetPrivateList0004") { + appCerInstall = true + break + } + } + expect(appCerInstall).assertEqual(true) + certStubCallback.uninstallPrivateCertificate(keyUri, (err) => { + done(); + }) + }) + }) + }) + + /** + * @tc.name GetPrivateCertificateList0005 + * @tc.desc Test for GetPrivateCertificateList JS interface - private certificate - get + the certificate list normally (callback,Cycle call five times). + * @tc.number SEC_CertificateManagement_Interface_Js_GetPrivateCertificateList_0005 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetPrivateCertificateList_0005', 0, async function (done) { + getGeneratePrivateCert() + let keyStorePwd = "123456" + let appCerInstall = false + certStubCallback.installPrivateCertificate(keyStore, keyStorePwd, "GetPrivateList0004", (err, cmResult) => { + let keyUri = cmResult.authUri + for (var i = 0; i < 5; i++) { + certStubCallback.getPrivateCertificateList((err, data) => { + for (let j = 0; j < data.credentialList.length; j++) { + if (data.credentialList[j].alias == "GetPrivateList0004") { + appCerInstall = true + break + } + } + expect(appCerInstall).assertEqual(true) + }) + sleep(500) + } + certStubCallback.uninstallPrivateCertificate(keyUri, (err) => { + done(); + }) + }) + }) + + /** + * @tc.name GetPrivateCertifiCate0001 + * @tc.desc Test for GetPrivateCertifiCate JS interface - private certificate - get + the certificate Info normally (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_GetPrivateCertifiCate_0001 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level2 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetPrivateCertifiCate_0001', 0, async function (done) { + try { + getGeneratePrivateCert() + let keystorePwd = "123456" + let cmResult = await certStubPromise.installPrivateCertificate(keyStore, keystorePwd, "GetPrivateCate0001") + let keyUri = cmResult.authUri + var PrivateCertificate = await certStubPromise.getPrivateCertificate(keyUri) + await certStubPromise.uninstallPrivateCertificate(keyUri) + expect(PrivateCertificate.credential.alias).assertEqual("GetPrivateCate0001") + done(); + } catch (err) { + console.info("getPrivateCertificate_0100 err" + JSON.stringify(err)) + expect().assertFail(); + done(); + } + }) + + /** + * @tc.name GetPrivateCertifiCate0002 + * @tc.desc Test for GetPrivateCertifiCate JS interface - private certificate - get + the certificate Info normally (promise,Cycle call five times). + * @tc.number SEC_CertificateManagement_Interface_Js_GetPrivateCertifiCate_0002 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetPrivateCertifiCate_0002', 0, async function (done) { + getGeneratePrivateCert() + let keystorePwd = "123456" + let cmResult = await certStubPromise.installPrivateCertificate(keyStore, keystorePwd, "GetPrivateCate0002") + let keyUri = cmResult.authUri + for (var i = 0; i < 5; i++) { + try { + var PrivateCertificate = await certStubPromise.getPrivateCertificate(keyUri) + expect(PrivateCertificate.credential.alias).assertEqual("GetPrivateCate0002") + } catch (err) { + console.info("getPrivateCertificate_0200 err" + JSON.stringify(err)) + expect().assertFail(); + done(); + } + } + await certStubPromise.uninstallPrivateCertificate(keyUri) + done() + }) + + /** + * @tc.name GetPrivateCertifiCate0004 + * @tc.desc Test for GetPrivateCertifiCate JS interface - private certificate - get + the certificate Info unusually (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_GetPrivateCertifiCate_0004 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetPrivateCertifiCate_0004', 0, async function (done) { + try { + await certStubPromise.getPrivateCertificate('') + expect().assertFail() + done() + } catch (error) { + console.log('getPrivateCertificate failed' + JSON.stringify(error.code)) + expect(error.code).assertEqual(-13) + done() + } + }) + + /** + * @tc.name GetPrivateCertifiCate0005 + * @tc.desc Test for GetPrivateCertifiCate JS interface - private certificate - get + the certificate Info unusually (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_GetPrivateCertifiCate_0005 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level2 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetPrivateCertifiCate_0005', 0, async function (done) { + certStubCallback.getPrivateCertificate('', (err, data) => { + expect(err.code).assertEqual(-13) + done() + }) + }) + + /** + * @tc.name GetPrivateCertifiCate0006 + * @tc.desc Test for GetPrivateCertifiCate JS interface - private certificate - get + the certificate Info normally (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_GetPrivateCertifiCate_0006 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level2 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetPrivateCertifiCate_0006', 0, async function (done) { + getGeneratePrivateCert() + let keyStorePwd = "123456" + certStubCallback.installPrivateCertificate(keyStore, keyStorePwd, "GetPrivateCate0006", (err, cmResult) => { + let keyUri = cmResult.authUri + certStubCallback.getPrivateCertificate(keyUri, (err, data) => { + expect(err.code).assertEqual(0) + expect(data.credential.alias).assertEqual("GetPrivateCate0006") + certStubCallback.uninstallPrivateCertificate(keyUri, (err) => { + done(); + }) + }) + }) + }) + + /** + * @tc.name GetPrivateCertifiCate0007 + * @tc.desc Test for GetPrivateCertifiCate JS interface - private certificate - get + the certificate Info normally (callback,Cycle call five times). + * @tc.number SEC_CertificateManagement_Interface_Js_GetPrivateCertifiCate_0007 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetPrivateCertifiCate_0007', 0, async function (done) { + getGeneratePrivateCert() + let keyStorePwd = "123456" + certStubCallback.installPrivateCertificate(keyStore, keyStorePwd, "GetPrivateCate0007", (err, cmResult) => { + let keyUri = cmResult.authUri + for (var i = 0; i < 5; i++) { + certStubCallback.getPrivateCertificate(keyUri, (err, data) => { + expect(err.code).assertEqual(0) + expect(data.credential.alias).assertEqual("GetPrivateCate0007") + }) + } + certStubCallback.uninstallPrivateCertificate(keyUri, (err) => { + done(); + }) + }) + }) + + /** + * @tc.name GetAuthorizedAppList0001 + * @tc.desc Test for GetAuthorizedAppList JS interface - app certificate - get + the authorized application list normally (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_GetAuthorizedAppList_0001 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level1 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetAuthorizedAppList_0001', 0, async function (done) { + try { + loadInstallFile('appca.p12') + let keystorePwd = "123456" + var keyUri = "" + let appCerInstall = false + await certStubPromise.installAppCertificate(certFileArray, keystorePwd, "GetAuthorizedAppList0001") + let result = await certStubPromise.getAppCertificateList() + console.info("result1111" + JSON.stringify(result)) + for (let j = 0; j < result.credentialList.length; j++) { + if (result.credentialList[j].alias == "GetAuthorizedAppList0001") { + keyUri = result.credentialList[j].keyUri + appCerInstall = true + } + } + console.info("keyUri1111111" + keyUri) + await certStubPromise.getAuthorizedAppList(keyUri) + expect(appCerInstall).assertEqual(true) + certStubPromise.uninstallAppCertificate(keyUri) + done(); + } catch (err) { + console.info("GetAuthorizedAppList_0001 err" + JSON.stringify(err.code)) + expect().assertFail(); + done(); + } + }) + + /** + * @tc.name GetAuthorizedAppList0002 + * @tc.desc Test for GetAuthorizedAppList JS interface - app certificate - get + the authorized application list normally (promise,Cycle call five times). + * @tc.number SEC_CertificateManagement_Interface_Js_GetAuthorizedAppList_0002 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level1 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetAuthorizedAppList_0002', 0, async function (done) { + loadInstallFile('appca.p12') + let keystorePwd = "123456" + var keyUri = "" + let appCerInstall = false + await certStubPromise.installAppCertificate(certFileArray, keystorePwd, "GetAuthorizedAppList0002") + for (var i = 0; i < 5; i++) { + try { + let result = await certStubPromise.getAppCertificateList() + for (let j = 0; j < result.credentialList.length; j++) { + if (result.credentialList[j].alias == "GetAuthorizedAppList0002") { + keyUri = result.credentialList[j].keyUri + appCerInstall = true + } + } + await certStubPromise.getAuthorizedAppList(keyUri) + expect(appCerInstall).assertEqual(true) + certStubPromise.uninstallAppCertificate(keyUri) + done(); + } catch (error) { + console.log('AuthorizedAppList_0002 failed' + JSON.stringify(error.code)) + expect().assertFail() + done() + } + } + }) + + /** + * @tc.name GetAuthorizedAppList0004 + * @tc.desc Test for GetAuthorizedAppList JS interface - app certificate - get + the authorized application list unusually (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_GetAuthorizedAppList_0004 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level1 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetAuthorizedAppList_0004', 0, async function (done) { + try { + await certStubPromise.getAuthorizedAppList('') + done() + } catch (error) { + console.log('getAuthorizedAppList failed' + JSON.stringify(error.code)) + expect(error.code).assertEqual(-13) + done() + } + }) + + /** + * @tc.name GetAuthorizedAppList0005 + * @tc.desc Test for GetAuthorizedAppList JS interface - app certificate - get + the authorized application list unusually (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_GetAuthorizedAppList_0005 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level1 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetAuthorizedAppList_0005', 0, async function (done) { + certStubCallback.getAuthorizedAppList('', (err, data) => { + expect(err.code).assertEqual(0) + done() + }) + }) + + /** + * @tc.name GetAuthorizedAppList0006 + * @tc.desc Test for GetAuthorizedAppList JS interface - app certificate - get + the authorized application list normally (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_GetAuthorizedAppList_0006 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level1 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetAuthorizedAppList_0006', 0, async function (done) { + loadInstallFile('appca.p12') + let keystorePwd = "123456" + var keyUri = "" + let appCerInstall = false + certStubCallback.installAppCertificate(certFileArray, keystorePwd, "GetAuthorizedAppList0006", (err) => { + certStubCallback.getAppCertificateList((err, data) => { + for (let j = 0; j < data.credentialList.length; j++) { + if (data.credentialList[j].alias == "GetAuthorizedAppList0006") { + keyUri = data.credentialList[j].keyUri + appCerInstall = true + break; + } + } + expect(appCerInstall).assertEqual(true) + certStubCallback.getAuthorizedAppList(keyUri, (err, data) => { + expect(err.code).assertEqual(0) + certStubCallback.uninstallAppCertificate(keyUri, (err) => { + done() + }) + }) + }) + }) + }) + + /** + * @tc.name GetAuthorizedAppList0007 + * @tc.desc Test for GetAuthorizedAppList JS interface - app certificate - get + the authorized application list normally (callback,Cycle call five times). + * @tc.number SEC_CertificateManagement_Interface_Js_GetAuthorizedAppList_0007 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level1 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetAuthorizedAppList_0007', 0, async function (done) { + loadInstallFile('appca.p12') + let keystorePwd = "123456" + var keyUri = "" + let appCerInstall = false + certStubCallback.installAppCertificate(certFileArray, keystorePwd, "GetAuthorizedAppList0007", (err) => { + for (var i = 0; i < 5; i++) { + certStubCallback.getAppCertificateList((err, data) => { + for (let j = 0; j < data.credentialList.length; j++) { + if (data.credentialList[j].alias == "GetAuthorizedAppList0007") { + keyUri = data.credentialList[j].keyUri + appCerInstall = true + break; + } + } + expect(appCerInstall).assertEqual(true) + certStubCallback.getAuthorizedAppList(keyUri, (err, data) => { + expect(err.code).assertEqual(0) + }) + }) + sleep(500) + } + certStubCallback.uninstallAppCertificate(keyUri, (err) => { + done() + }) + }) + }) + + /** + * @tc.name RemoveGrantedAppCertificate0001 + * @tc.desc Test for RemoveGrantedAppCertificate JS interface - app certificate - Save the application + authorization status normally (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_RemoveGrantedAppCertificate_0001 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level1 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_RemoveGrantedAppCertificate_0001', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_RemoveGrantedAppCertificate_0001 start") + loadInstallFile('appca.p12') + let keystorePwd = "123456" + let certAlias = "RemoveGrantedAppCert" + await certStubPromise.installAppCertificate(certFileArray, keystorePwd, certAlias) + let cmResult = await certStubPromise.getAppCertificateList() + let credentialList = cmResult.credentialList + let appKeyUri = credentialList[0].keyUri + clientAppUidStr = await getClientAppUid() + console.log('SEC_CertificateManagement_Interface_Js uid is ' + clientAppUidStr) + await certStubPromise.grantAppCertificate(appKeyUri, clientAppUidStr) + await certStubPromise.removeGrantedAppCertificate(appKeyUri, clientAppUidStr) + cmResult = await certStubPromise.getAuthorizedAppList(appKeyUri) + let appUidList = cmResult.appUidList + let findSign = false + for (let i = 0; i < appUidList.length; i++) { + if (appUidList[i] == clientAppUidStr) { + findSign = true + break + } + } + expect(findSign).assertFalse() + await certStubPromise.uninstallAppCertificate(appKeyUri) + console.log("SEC_CertificateManagement_Interface_Js_RemoveGrantedAppCertificate_0001 end") + done() + }) + + /** + * @tc.name RemoveGrantedAppCertificate0004 + * @tc.desc Test for RemoveGrantedAppCertificate JS interface - app certificate - Save the application + authorization status normally (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_RemoveGrantedAppCertificate_0004 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level1 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_RemoveGrantedAppCertificate_0004', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_RemoveGrantedAppCertificate_0004 start") + let keystorePwd = "123456" + let certAlias = "RemoveGrantedAppCert" + let appKeyUri = '' + certStubCallback.installAppCertificate(certFileArray, keystorePwd, certAlias, (err) => { + expect(err.code).assertEqual(0) + certStubCallback.getAppCertificateList(async (err, cmResult) => { + let credentialList = cmResult.credentialList + appKeyUri = credentialList[0].keyUri + clientAppUidStr = await getClientAppUid() + console.log('SEC_CertificateManagement_Interface_Js uid is' + clientAppUidStr) + certStubCallback.grantAppCertificate(appKeyUri, clientAppUidStr, async (err) => { + expect(err.code).assertEqual(0) + certStubCallback.removeGrantedAppCertificate(appKeyUri, clientAppUidStr, (err) => { + expect(err.code).assertEqual(0) + certStubCallback.getAuthorizedAppList(appKeyUri, (err, cmResult) => { + let appUidList = cmResult.appUidList + let findSign = false + for (let i = 0; i < appUidList.length; i++) { + if (appUidList[i] == clientAppUidStr) { + findSign = true + break + } + } + expect(findSign).assertFalse() + certStubCallback.uninstallAppCertificate(appKeyUri, (err) => { + expect(err.code).assertEqual(0) + console.log("SEC_CertificateManagement_Interface_Js_RemoveGrantedAppCertificate_0004 end") + done() + }) + }) + }) + }) + }) + }) + }) + + /** + * @tc.name RemoveGrantedAppCertificate0005 + * @tc.desc Test for RemoveGrantedAppCertificate JS interface - app certificate - Save the application + authorization status unusually (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_RemoveGrantedAppCertificate_0005 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level1 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_RemoveGrantedAppCertificate_0005', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_RemoveGrantedAppCertificate_0005 start") + let keystorePwd = "123456" + let certAlias = "RemoveGrantedAppCert" + let appKeyUri = '' + certStubCallback.installAppCertificate(certFileArray, keystorePwd, certAlias, (err) => { + expect(err.code).assertEqual(0) + certStubCallback.getAppCertificateList(async (err, cmResult) => { + let credentialList = cmResult.credentialList + appKeyUri = credentialList[0].keyUri + clientAppUidStr = await getClientAppUid() + console.log('SEC_CertificateManagement_Interface_Js uid is' + clientAppUidStr) + certStubCallback.grantAppCertificate(appKeyUri, clientAppUidStr, async (err) => { + expect(err.code).assertEqual(0) + certStubCallback.removeGrantedAppCertificate(appKeyUri, clientAppUidStr, (err) => { + expect(err.code).assertEqual(0) + certStubCallback.getAuthorizedAppList(appKeyUri, (err, cmResult) => { + let appUidList = cmResult.appUidList + let findSign = false + for (let i = 0; i < appUidList.length; i++) { + if (appUidList[i] == clientAppUidStr) { + findSign = true + break + } + } + expect(findSign).assertFalse() + certStubCallback.removeGrantedAppCertificate(appKeyUri, clientAppUidStr, (err) => { + expect(err.code != 0).assertTrue() + certStubCallback.uninstallAppCertificate(appKeyUri, (err) => { + expect(err.code).assertEqual(0) + console.log("SEC_CertificateManagement_Interface_Js_CertificateIsAuthorized_0005 end") + done() + }) + }) + }) + }) + }) + }) + }) + }) + + /** + * @tc.name RemoveGrantedAppCertificate0006 + * @tc.desc Test for RemoveGrantedAppCertificate JS interface - app certificate - Save the application + authorization status unusually (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_RemoveGrantedAppCertificate_0006 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level1 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_RemoveGrantedAppCertificate_0006', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_RemoveGrantedAppCertificate_0006 start") + loadInstallFile('appca.p12') + let keystorePwd = "123456" + let certAlias = "RemoveGrantedAppCert" + await certStubPromise.installAppCertificate(certFileArray, keystorePwd, certAlias) + let cmResult = await certStubPromise.getAppCertificateList() + let credentialList = cmResult.credentialList + let appKeyUri = credentialList[0].keyUri + clientAppUidStr = await getClientAppUid() + console.log('SEC_CertificateManagement_Interface_Js uid is ' + clientAppUidStr) + await certStubPromise.grantAppCertificate(appKeyUri, clientAppUidStr) + await certStubPromise.removeGrantedAppCertificate(appKeyUri, clientAppUidStr) + try { + await certStubPromise.removeGrantedAppCertificate(appKeyUri, clientAppUidStr) + } catch (err) { + expect(err.code != 0).assertTrue() + cmResult = await certStubPromise.getAuthorizedAppList(appKeyUri) + let appUidList = cmResult.appUidList + let findSign = false + for (let i = 0; i < appUidList.length; i++) { + if (appUidList[i] == clientAppUidStr) { + findSign = true + break + } + } + expect(findSign).assertFalse() + await certStubPromise.uninstallAppCertificate(appKeyUri) + console.log("SEC_CertificateManagement_Interface_Js_RemoveGrantedAppCertificate_0006 end") + done() + } + }) + + /** + * @tc.name RemoveGrantedAppCertificate0007 + * @tc.desc Test for RemoveGrantedAppCertificate JS interface - app certificate - Save the application + authorization status unusually (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_RemoveGrantedAppCertificate_0007 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level1 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_RemoveGrantedAppCertificate_0007', 0, async function (done) { + try { + await certStubPromise.removeGrantedAppCertificate("", "") + expect().assertFail() + done() + } catch (error) { + console.log('RemoveGrantedAppCertificate_0007 failed' + JSON.stringify(error.code)) + expect(error.code != 0).assertTrue() + done() + } + }) + + /** + * @tc.name RemoveGrantedAppCertificate0008 + * @tc.desc Test for RemoveGrantedAppCertificate JS interface - app certificate - Save the application + authorization status unusually (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_RemoveGrantedAppCertificate_0008 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level1 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_RemoveGrantedAppCertificate_0008', 0, async function (done) { + certStubCallback.removeGrantedAppCertificate("", "", (error, data) => { + expect(error.code != 0).assertTrue() + done() + }) + }) + + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_CertVerifySignature + * @tc.desc Sign/Verify initialize promise form. + * @tc.number SEC_CertificateManagement_Interface_Js_CertVerifySignature_0001 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_CertVerifySignature_0001', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_CertVerifySignature_0001 start") + loadInstallFile('appca.p12') + let keystorePwd = "123456" + let certAlias = "AppCert" + let appKeyUri = '' + await certStubPromise.installAppCertificate(certFileArray, keystorePwd, certAlias) + let cmResult = await certStubPromise.getAppCertificateList() + let credentialList = cmResult.credentialList + appKeyUri = credentialList[0].keyUri + let bundleInfo = await bundle.getBundleInfo("com.example.cerxts", bundle.BundleFlag.GET_BUNDLE_DEFAULT) + let clientAppUid = bundleInfo.uid + let clientAppUidStr = clientAppUid.toString() + console.log('SEC_CertificateManagement_Interface_Js uid ' + clientAppUidStr) + cmResult = await certStubPromise.grantAppCertificate(appKeyUri, clientAppUidStr) + let authUri = cmResult.authUri + expect(authUri != '').assertTrue() + let spec: CMSignatureSpec + spec = { + alg: 'alg', + padding: 'padding', + digest: 'digest', + authToken: new Uint8Array([0, 1, 2, 42, 100, 101, 102, 255]) + } + let cmHandle = await certStubPromise.init(authUri, spec) + console.log('SEC_CertificateManagement_Interface_Js cmHandle' + JSON.stringify(cmHandle)) + expect(cmHandle.handle != undefined).assertTrue() + await certStubPromise.uninstallAppCertificate(appKeyUri) + console.log("SEC_CertificateManagement_Interface_Js_CertVerifySignature_0001 end") + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_CertVerifySignature + * @tc.desc Sign/Verify initialize callback form. + * @tc.number SEC_CertificateManagement_Interface_Js_CertVerifySignature_0002 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_CertVerifySignature_0002', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_CertVerifySignature_0002 start") + loadInstallFile('appca.p12') + let keystorePwd = "123456" + let certAlias = "AppCert" + let appKeyUri = '' + certStubCallback.installAppCertificate(certFileArray, keystorePwd, certAlias, (err) => { + expect(err.code).assertEqual(0) + certStubCallback.getAppCertificateList(async (err, cmResult) => { + expect(err.code).assertEqual(0) + let credentialList = cmResult.credentialList + appKeyUri = credentialList[0].keyUri + let bundleInfo = await bundle.getBundleInfo("com.example.cerxts", bundle.BundleFlag.GET_BUNDLE_DEFAULT) + let clientAppUid = bundleInfo.uid + let clientAppUidStr = clientAppUid.toString() + console.log('SEC_CertificateManagement_Interface_Js uid ' + clientAppUidStr) + certStubCallback.grantAppCertificate(appKeyUri, clientAppUidStr, (err, data) => { + console.log('SEC_CertificateManagement_Interface_Js err' + JSON.stringify(err)) + expect(err.code).assertEqual(0) + let authUri = data.authUri + expect(authUri != '').assertTrue() + let spec: CMSignatureSpec + spec = { + alg: 'alg', + padding: 'padding', + digest: 'digest', + authToken: new Uint8Array([0, 1, 2, 42, 100, 101, 102, 255]) + } + certStubCallback.init(authUri, spec, (err, data) => { + console.log('SEC_CertificateManagement_Interface_Js err' + JSON.stringify(err)) + expect(err.code).assertEqual(0) + console.log('SEC_CertificateManagement_Interface_Js cmHandle' + JSON.stringify(data)) + expect(data.handle != undefined).assertTrue() + certStubCallback.uninstallAppCertificate(appKeyUri, (err) => { + expect(err.code).assertEqual(0) + console.log("SEC_CertificateManagement_Interface_Js_CertVerifySignature_0002 end") + done() + }) + }) + }) + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_CertVerifySignature + * @tc.desc Sign/Verify update promise form. + * @tc.number SEC_CertificateManagement_Interface_Js_CertVerifySignature_0003 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_CertVerifySignature_0003', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_CertVerifySignature_0003 start") + loadInstallFile('appca.p12') + let keystorePwd = "123456" + let certAlias = "AppCert" + await certStubPromise.installAppCertificate(certFileArray, keystorePwd, certAlias) + let cmResult = await certStubPromise.getAppCertificateList() + let credentialList = cmResult.credentialList + let appKeyUri = credentialList[0].keyUri + let bundleInfo = await bundle.getBundleInfo("com.example.cerxts", bundle.BundleFlag.GET_BUNDLE_DEFAULT) + let clientAppUid = bundleInfo.uid + let clientAppUidStr = clientAppUid.toString() + console.log('SEC_CertificateManagement_Interface_Js uid ' + clientAppUidStr) + cmResult = await certStubPromise.grantAppCertificate(appKeyUri, clientAppUidStr) + let authUri = cmResult.authUri + expect(authUri != '').assertTrue() + let cmSignatureSpec: CMSignatureSpec + cmSignatureSpec = { + alg: 'alg', + padding: 'padding', + digest: 'digest', + authToken: new Uint8Array([0, 1, 2, 42, 100, 101, 102, 255]) + } + let cmHandle = await certStubPromise.init(authUri, cmSignatureSpec) + console.log('SEC_CertificateManagement_Interface_Js cmHandle' + JSON.stringify(cmHandle)) + expect(cmHandle.handle != undefined).assertTrue() + let handle = cmHandle.handle + let data = new Uint8Array([0, 1, 2, 42, 100, 101, 102, 255]) + let token = new Uint8Array([0, 1, 2, 42, 100, 101, 102, 255]) + await certStubPromise.update(handle, data, token) + await certStubPromise.finish(handle) + await certStubPromise.uninstallAppCertificate(appKeyUri) + console.log("SEC_CertificateManagement_Interface_Js_CertVerifySignature_0003 end") + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_CertVerifySignature + * @tc.desc Sign/Verify update callback form. + * @tc.number SEC_CertificateManagement_Interface_Js_CertVerifySignature_0004 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_CertVerifySignature_0004', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_CertVerifySignature_0004 start") + loadInstallFile('appca.p12') + let keystorePwd = "123456" + let certAlias = "AppCert" + let appKeyUri = '' + certStubCallback.installAppCertificate(certFileArray, keystorePwd, certAlias, (err) => { + expect(err.code).assertEqual(0) + certStubCallback.getAppCertificateList(async (err, cmResult) => { + let credentialList = cmResult.credentialList + appKeyUri = credentialList[0].keyUri + let bundleInfo = await bundle.getBundleInfo("com.example.cerxts", bundle.BundleFlag.GET_BUNDLE_DEFAULT) + let clientAppUid = bundleInfo.uid + let clientAppUidStr = clientAppUid.toString() + console.log('SEC_CertificateManagement_Interface_Js uid ' + clientAppUidStr) + certStubCallback.grantAppCertificate(appKeyUri, clientAppUidStr, (err, data) => { + console.log('SEC_CertificateManagement_Interface_Js err' + JSON.stringify(err)) + let authUri = data.authUri + expect(authUri != '').assertTrue() + let cmSignatureSpec: CMSignatureSpec + cmSignatureSpec = { + alg: 'alg', + padding: 'padding', + digest: 'digest', + authToken: new Uint8Array([0, 1, 2, 42, 100, 101, 102, 255]) + } + certStubCallback.init(authUri, cmSignatureSpec, (err, data) => { + console.log('SEC_CertificateManagement_Interface_Js err' + JSON.stringify(err)) + expect(err.code).assertEqual(0) + console.log('SEC_CertificateManagement_Interface_Js cmHandle' + JSON.stringify(data)) + expect(data.handle != undefined).assertTrue() + certStubCallback.update(data.handle, new Uint8Array([0, 1, 2, 42, 100, 101, 102, 255]), + new Uint8Array([0, 1, 2, 42, 100, 101, 102, 255]), (err, cmResult) => { + expect(err.code).assertEqual(0) + certStubCallback.finish(data.handle, new Uint8Array([0, 1, 2, 42, 100, 101, 102, 255]), + (err, data) => { + expect(err.code).assertEqual(0) + certStubCallback.uninstallAppCertificate(appKeyUri, (err) => { + expect(err.code).assertEqual(0) + console.log("SEC_CertificateManagement_Interface_Js_CertVerifySignature_0004 end") + done() + }) + }) + }) + }) + }) + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_CertVerifySignature + * @tc.desc Sign/Verify discard promise form. + * @tc.number SEC_CertificateManagement_Interface_Js_CertVerifySignature_0005 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_CertVerifySignature_0005', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_CertVerifySignature_0005 start") + loadInstallFile('appca.p12') + let keystorePwd = "123456" + let certAlias = "AppCert" + await certStubPromise.installAppCertificate(certFileArray, keystorePwd, certAlias) + let cmResult = await certStubPromise.getAppCertificateList() + let credentialList = cmResult.credentialList + let appKeyUri = credentialList[0].keyUri + let bundleInfo = await bundle.getBundleInfo("com.example.cerxts", bundle.BundleFlag.GET_BUNDLE_DEFAULT) + let clientAppUid = bundleInfo.uid + let clientAppUidStr = clientAppUid.toString() + console.log('SEC_CertificateManagement_Interface_Js uid ' + clientAppUidStr) + cmResult = await certStubPromise.grantAppCertificate(appKeyUri, clientAppUidStr) + let authUri = cmResult.authUri + expect(authUri != '').assertTrue() + let cmSignatureSpec: CMSignatureSpec + cmSignatureSpec = { + alg: 'string', + padding: 'string', + digest: 'string', + authToken: new Uint8Array([0, 1, 2, 42, 100, 101, 102, 255]) + } + let cmHandle = await certStubPromise.init(authUri, cmSignatureSpec) + console.log('SEC_CertificateManagement_Interface_Js cmHandle' + JSON.stringify(cmHandle)) + expect(cmHandle.handle != undefined).assertTrue() + await certStubPromise.abort(cmHandle.handle) + await certStubPromise.uninstallAppCertificate(appKeyUri) + console.log("SEC_CertificateManagement_Interface_Js_CertVerifySignature_0005 end") + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_CertVerifySignature + * @tc.desc Sign/Verify discard callback form. + * @tc.number SEC_CertificateManagement_Interface_Js_CertVerifySignature_0006 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_CertVerifySignature_0006', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_CertVerifySignature_0006 start") + loadInstallFile('appca.p12') + let keystorePwd = "123456" + let certAlias = "AppCert" + let appKeyUri = '' + certStubCallback.installAppCertificate(certFileArray, keystorePwd, certAlias, (err) => { + expect(err.code).assertEqual(0) + certStubCallback.getAppCertificateList(async (err, cmResult) => { + let credentialList = cmResult.credentialList + appKeyUri = credentialList[0].keyUri + let bundleInfo = await bundle.getBundleInfo("com.example.cerxts", bundle.BundleFlag.GET_BUNDLE_DEFAULT) + let clientAppUid = bundleInfo.uid + let clientAppUidStr = clientAppUid.toString() + console.log('SEC_CertificateManagement_Interface_Js uid ' + clientAppUidStr) + certStubCallback.grantAppCertificate(appKeyUri, clientAppUidStr, (err, data) => { + console.log('SEC_CertificateManagement_Interface_Js err' + JSON.stringify(err)) + expect(err.code).assertEqual(0) + let authUri = data.authUri + expect(authUri != '').assertTrue() + let spec: CMSignatureSpec + spec = { + alg: 'alg', + padding: 'padding', + digest: 'digest', + authToken: new Uint8Array([0, 1, 2, 42, 100, 101, 102, 255]) + } + certStubCallback.init(authUri, spec, (err, data) => { + expect(err.code).assertEqual(0) + let handle = data.handle + expect(handle != undefined).assertTrue() + certStubCallback.about(handle, (err, data) => { + expect(err.code).assertEqual(0) + certStubCallback.uninstallAppCertificate(appKeyUri, (err) => { + expect(err.code).assertEqual(0) + console.log("SEC_CertificateManagement_Interface_Js_CertVerifySignature_0006 end") + done() + }) + }) + }) + }) + }) + }) + }) + + /** + * @tc.name UninstallAppCertificate0001 + * @tc.desc Delete the app certificate normally(promise). + * @tc.number SEC_CertificateManagement_Interface_Js_UninstallAppCertificate_0001 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_UninstallAppCertificate_0001', 0, async function (done) { + try { + loadInstallFile('appca.p12') + let keystorePwd = "123456" + var keyUri = "" + let appCerInstall = false + await certStubPromise.installAppCertificate(certFileArray, keystorePwd, "UninstallAppCertificate0001") + let result = await certStubPromise.getAppCertificateList() + for (let j = 0; j < result.credentialList.length; j++) { + if (result.credentialList[j].alias == "UninstallAppCertificate0001") { + keyUri = result.credentialList[j].keyUri + break + } + } + await certStubPromise.uninstallAppCertificate(keyUri) + let AppCertificateList = await certStubPromise.getAppCertificateList() + for (let i = 0; i < AppCertificateList.credentialList.length; i++) { + if (AppCertificateList.credentialList[i].alias == "UninstallAppCertificate0001") { + expect().assertFail() + } + } + done(); + } catch (err) { + console.info("uninstallAppCertificate_0001 err" + JSON.stringify(err)) + expect().assertFail(); + done(); + } + }) + + /** + * @tc.name UninstallAppCertificate0003 + * @tc.desc Delete the app certificate unusually(promise). + * @tc.number SEC_CertificateManagement_Interface_Js_UninstallAppCertificate_0003 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_UninstallAppCertificate_0003', 0, async function (done) { + try { + loadInstallFile('appca.p12') + let keystorePwd = "123456" + var keyUri = "" + let appCerInstall = false + await certStubPromise.installAppCertificate(certFileArray, keystorePwd, "UninstallAppCertificate0003") + let result = await certStubPromise.getAppCertificateList() + for (let j = 0; j < result.credentialList.length; j++) { + if (result.credentialList[j].alias == "UninstallAppCertificate0003") { + keyUri = result.credentialList[j].keyUri + break + } + } + await certStubPromise.uninstallAppCertificate(keyUri) + let AppCertificateList = await certStubPromise.getAppCertificateList() + for (let i = 0; i < AppCertificateList.credentialList.length; i++) { + if (AppCertificateList.credentialList[i].alias == "UninstallAppCertificate0003") { + expect().assertFail() + } + } + await certStubPromise.uninstallAppCertificate(keyUri) + done(); + } catch (err) { + console.info("uninstallAppCertificate_0003 err" + JSON.stringify(err)) + expect(err.code).assertEqual(-13) + done(); + } + }) + + /** + * @tc.name UninstallAppCertificate0004 + * @tc.desc Delete the app certificate unusually(callback). + * @tc.number SEC_CertificateManagement_Interface_Js_UninstallAppCertificate_0004 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_UninstallAppCertificate_0004', 0, async function (done) { + loadInstallFile('appca.p12') + let keystorePwd = "123456" + var keyUri = "" + certStubCallback.installAppCertificate(certFileArray, keystorePwd, "UninstallAppCertificate0004", (err) => { + certStubCallback.getAppCertificateList((err, data) => { + for (let j = 0; j < data.credentialList.length; j++) { + if (data.credentialList[j].alias == "UninstallAppCertificate0004") { + keyUri = data.credentialList[j].keyUri + break; + } + } + certStubCallback.uninstallAppCertificate(keyUri, (err, data) => { + certStubCallback.getAppCertificateList((err, data) => { + for (let i = 0; i < data.credentialList.length; i++) { + if (data.credentialList[i].alias == "UninstallAppCertificate0004") { + expect().assertFail() + } + } + certStubCallback.uninstallAppCertificate(keyUri, (err, data) => { + console.info("UninstallAppCertificate_0004 err" + JSON.stringify(err)) + expect(err.code).assertEqual(-13) + done(); + }) + }) + }) + }) + }) + }) + + /** + * @tc.name UninstallAppCertificate0005 + * @tc.desc Delete the app certificate unusually(promise). + * @tc.number SEC_CertificateManagement_Interface_Js_UninstallAppCertificate_0005 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_UninstallAppCertificate_0005', 0, async function (done) { + try { + await certStubPromise.uninstallAppCertificate("") + expect().assertFail() + done(); + } catch (err) { + console.info("uninstallAppCertificate_0005 err" + JSON.stringify(err)) + expect(err.code).assertEqual(-13) + done(); + } + }) + + /** + * @tc.name UninstallAppCertificate0006 + * @tc.desc Delete the app certificate unusually(callback). + * @tc.number SEC_CertificateManagement_Interface_Js_UninstallAppCertificate_0006 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_UninstallAppCertificate_0006', 0, async function (done) { + certStubCallback.uninstallAppCertificate('', (err, data) => { + expect(err.code).assertEqual(-13) + done() + }) + }) + + /** + * @tc.name UninstallAppCertificate0001 + * @tc.desc Delete the app certificate normally(callback). + * @tc.number SEC_CertificateManagement_Interface_Js_UninstallAppCertificate_0001 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_UninstallAppCertificate_0007', 0, async function (done) { + loadInstallFile('appca.p12') + let keystorePwd = "123456" + var keyUri = "" + certStubCallback.installAppCertificate(certFileArray, keystorePwd, "UninstallAppCertificate0007", (err) => { + certStubCallback.getAppCertificateList((err, data) => { + for (let j = 0; j < data.credentialList.length; j++) { + if (data.credentialList[j].alias == "UninstallAppCertificate0007") { + keyUri = data.credentialList[j].keyUri + break; + } + } + certStubCallback.uninstallAppCertificate(keyUri, (err, data) => { + certStubCallback.getAppCertificateList((err, data) => { + for (let i = 0; i < data.credentialList.length; i++) { + if (data.credentialList[i].alias == "UninstallAppCertificate0007") { + expect().assertFail() + } + } + done() + }) + }) + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_UserCertificateInstall + * @tc.desc Install the user certificate, each parameter is valid in the form of promise. + * @tc.number SEC_CertificateManagement_Interface_Js_UserCertificateInstall_0001 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level2 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_UserCertificateInstall_0001', 0, async function (done) { + loadInstallFile('rootca.cer') + await certStubPromise.installUserTrustedCertificate({ + inData: certFileArray, + alias: 'userCer01' + }) + let userCerInstall = false + let keyUri = '' + let resultList = await certStubPromise.getUserTrustedCertificateList() + console.log('resultList is:' + JSON.stringify(resultList)) + for (var i = 0; i < resultList.certList.length; i++) { + if (resultList.certList[i].certAlias == 'userCer01') { + console.log('userCer01 install success') + userCerInstall = true + keyUri = resultList.certList[i].uri + break + } + } + expect(userCerInstall).assertTrue() + await certStubPromise.uninstallUserTrustedCertificate(keyUri) + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_UserCertificateInstall + * @tc.desc Install the user certificate, each parameter is valid in the form of callback. + * @tc.number SEC_CertificateManagement_Interface_Js_UserCertificateInstall_0002 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level2 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_UserCertificateInstall_0002', 0, async function (done) { + loadInstallFile('rootca.cer') + let userCerInstall = false + let keyUri = '' + certStubCallback.installUserTrustedCertificate({ + inData: certFileArray, + alias: 'userCer02' + }, (err) => { + expect(err.code).assertEqual(0) + certStubCallback.getUserTrustedCertificateList((err, data) => { + for (var i = 0; i < data.certList.length; i++) { + if (data.certList[i].certAlias == 'userCer02') { + console.log('userCer02 install success') + userCerInstall = true + keyUri = data.certList[i].uri + break + } + } + expect(userCerInstall).assertTrue() + certStubCallback.uninstallUserTrustedCertificate(keyUri, (err) => { + expect(err.code).assertEqual(0) + done() + }) + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_UserCertificateInstall + * @tc.desc Install different user certificates, each parameter is valid and the alias alias is the same, + * overwriting the installation promise form. + * @tc.number SEC_CertificateManagement_Interface_Js_UserCertificateInstall_0003 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_UserCertificateInstall_0003', 0, async function (done) { + loadInstallFile('rootca.cer') + await certStubPromise.installUserTrustedCertificate({ + inData: certFileArray, + alias: 'userCer03' + }) + await certStubPromise.installUserTrustedCertificate({ + inData: certFileArray, + alias: 'userCer03' + }) + let userCerInstall = false + let count = 0 + let keyUri = '' + let resultList = await certStubPromise.getUserTrustedCertificateList() + console.log('resultList is:' + JSON.stringify(resultList)) + for (var i = 0; i < resultList.certList.length; i++) { + if (resultList.certList[i].certAlias == 'userCer03') { + console.log('userCer01 install success') + userCerInstall = true + keyUri = resultList.certList[i].uri + count++ + } + } + expect(userCerInstall).assertTrue() + expect(count).assertEqual(1) + await certStubPromise.uninstallUserTrustedCertificate(keyUri) + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_UserCertificateInstall + * @tc.desc Install different user certificates, each parameter is valid and the alias alias is the same, + * overwriting the installation callback form. + * @tc.number SEC_CertificateManagement_Interface_Js_UserCertificateInstall_0004 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_UserCertificateInstall_0004', 0, async function (done) { + loadInstallFile('rootca.cer') + let userCerInstall = false + let count = 0 + let keyUri = '' + certStubCallback.installUserTrustedCertificate({ + inData: certFileArray, + alias: 'userCer04' + }, (err) => { + expect(err.code).assertEqual(0) + certStubCallback.installUserTrustedCertificate({ + inData: certFileArray, + alias: 'userCer04' + }, (err) => { + expect(err.code).assertEqual(0) + certStubCallback.getUserTrustedCertificateList((err, data) => { + for (var i = 0; i < data.certList.length; i++) { + if (data.certList[i].certAlias == 'userCer04') { + console.log('userCer02 install success') + userCerInstall = true + keyUri = data.certList[i].uri + count++ + } + } + expect(userCerInstall).assertTrue() + expect(count).assertEqual(1) + certStubCallback.uninstallUserTrustedCertificate(keyUri, (err) => { + expect(err.code).assertEqual(0) + done() + }) + }) + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_UserCertificateInstall + * @tc.desc Install the user certificate multiple times, each parameter is valid and the alias alias + * is different in promise form. + * @tc.number SEC_CertificateManagement_Interface_Js_UserCertificateInstall_0005 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_UserCertificateInstall_0005', 0, async function (done) { + loadInstallFile('rootca.cer') + await certStubPromise.installUserTrustedCertificate({ + inData: certFileArray, + alias: 'userCer05-1' + }) + await certStubPromise.installUserTrustedCertificate({ + inData: certFileArray, + alias: 'userCer05-2' + }) + let userCerInstall = false + let userCerInstallSec = false + let keyUriFir = '' + let keyUriSec = '' + let resultList = await certStubPromise.getUserTrustedCertificateList() + console.log('resultList is:' + JSON.stringify(resultList)) + for (var i = 0; i < resultList.certList.length; i++) { + if (resultList.certList[i].certAlias == 'userCer05-1') { + console.log('userCer05-1 install success') + userCerInstall = true + keyUriFir = resultList.certList[i].uri + } + if (resultList.certList[i].certAlias == 'userCer05-2') { + console.log('userCer05-2 install success') + userCerInstallSec = true + keyUriSec = resultList.certList[i].uri + } + } + expect(userCerInstall).assertTrue() + expect(userCerInstallSec).assertTrue() + await certStubPromise.uninstallUserTrustedCertificate(keyUriFir) + await certStubPromise.uninstallUserTrustedCertificate(keyUriSec) + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_UserCertificateInstall + * @tc.desc Install the user certificate multiple times, each parameter is valid and the alias alias + * is different in callback form. + * @tc.number SEC_CertificateManagement_Interface_Js_UserCertificateInstall_0006 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_UserCertificateInstall_0006', 0, async function (done) { + loadInstallFile('rootca.cer') + let userCerInstall = false + let userCerInstallSec = false + let keyUriFir = '' + let keyUriSec = '' + certStubCallback.installUserTrustedCertificate({ + inData: certFileArray, + alias: 'userCer06-1' + }, (err) => { + expect(err.code).assertEqual(0) + certStubCallback.installUserTrustedCertificate({ + inData: certFileArray, + alias: 'userCer06-2' + }, (err) => { + expect(err.code).assertEqual(0) + certStubCallback.getUserTrustedCertificateList((err, data) => { + for (var i = 0; i < data.certList.length; i++) { + if (data.certList[i].certAlias == 'userCer06-1') { + console.log('userCer06-1 install success') + userCerInstall = true + keyUriFir = data.certList[i].uri + } + if (data.certList[i].certAlias == 'userCer06-2') { + console.log('userCer06-2 install success') + userCerInstallSec = true + keyUriSec = data.certList[i].uri + } + } + expect(userCerInstall).assertTrue() + expect(userCerInstallSec).assertTrue() + certStubCallback.uninstallUserTrustedCertificate(keyUriFir, (err) => { + expect(err.code).assertEqual(0) + certStubCallback.uninstallUserTrustedCertificate(keyUriSec, (err) => { + expect(err.code).assertEqual(0) + done() + }) + }) + }) + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_UserCertificateInstall + * @tc.desc Installed user certificate exceeds certificate limit. + * @tc.number SEC_CertificateManagement_Interface_Js_UserCertificateInstall_0007 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_UserCertificateInstall_0007', 0, async function (done) { + loadInstallFile('rootca.cer') + let resultList = await certStubPromise.getUserTrustedCertificateList() + let count = CERTNUMLIMIT - resultList.certList.length + for (var i = 1;i < count + 1; i++) { + await certStubPromise.installUserTrustedCertificate({ + inData: certFileArray, + alias: 'userCer07' + i + }) + } + resultList = await certStubPromise.getUserTrustedCertificateList() + console.log('resultList is:' + JSON.stringify(resultList)) + expect(resultList.certList.length).assertEqual(CERTNUMLIMIT) + console.log('resultList length is:' + JSON.stringify(resultList.certList.length)) + try { + await certStubPromise.installUserTrustedCertificate({ + inData: certFileArray, + alias: 'overUserCerInstall' + }) + expect().assertFail() + } catch (err) { + console.log('err.code is:' + JSON.stringify(err.code)) + expect(err.code != 0).assertTrue() + } + await certStubPromise.uninstallAllUserTrustedCertificate() + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_UserCertificateInstall + * @tc.desc In the scenario where the installation of the user certificate fails, the parameter alias alias + * exceeds the length limit of 64 characters in the form of promise. + * @tc.number SEC_CertificateManagement_Interface_Js_UserCertificateInstall_0008 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_UserCertificateInstall_0008', 0, async function (done) { + loadInstallFile('rootca.cer') + let aliasOverLen = "CertificateAliasExceedingLengthLimitCertificateAliasExceedingLengthLimit" + try { + await certStubPromise.installUserTrustedCertificate({ + inData: certFileArray, + alias: aliasOverLen + }) + expect().assertFail() + } catch (err) { + console.log('Install_0008 err.code is:' + JSON.stringify(err.code)) + expect(err.code != 0).assertTrue() + } + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_UserCertificateInstall + * @tc.desc In the scenario where the installation of the user certificate fails, the parameter alias alias + * exceeds the length limit of 64 characters in the form of callback. + * @tc.number SEC_CertificateManagement_Interface_Js_UserCertificateInstall_0009 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_UserCertificateInstall_0009', 0, async function (done) { + loadInstallFile('rootca.cer') + let aliasOverLen = "CertificateAliasExceedingLengthLimitCertificateAliasExceedingLengthLimit" + certStubCallback.installUserTrustedCertificate({ + inData: certFileArray, + alias: aliasOverLen + }, (err) => { + expect(err.code != 0).assertTrue() + done() + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_PrivateCertificateInstall + * @tc.desc Install a private certificate, each parameter is valid in the form of promise. + * @tc.number SEC_CertificateManagement_Interface_Js_PrivateCertificateInstall_0001 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level2 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_PrivateCertificateInstall_0001', 0, async function (done) { + getGeneratePrivateCert() + let keyStorePwd = "123456" + let certAlias = "PrivateCert" + let privateCerInstall = false + let cmResult = await certStubPromise.installPrivateCertificate(keyStore, keyStorePwd, certAlias) + let keyUri = cmResult.authUri + let resultList = await certStubPromise.getPrivateCertificateList() + console.log('resultList is:' + JSON.stringify(resultList)) + for (var i = 0; i < resultList.credentialList.length; i++) { + if (resultList.credentialList[i].alias == certAlias) { + console.log('Find the installed private certificate alias') + privateCerInstall = true + break; + } + } + expect(privateCerInstall).assertTrue() + let type = 'CM_URI_TYPE_APP_KEY' + let certificate: CertBlob = { + inData: keyStore, + alias: 'PrivateCertAlias' + } + await certStubPromise.updatePrivateCertificate(type, keyUri, certificate) + resultList = await certStubPromise.getPrivateCertificateList() + console.log('resultList is:' + JSON.stringify(resultList)) + var privateCerUpdate = false + for (var i = 0; i < resultList.credentialList.length; i++) { + if (resultList.credentialList[i].alias == 'PrivateCertAlias') { + console.log('Find the update private certificate alias') + privateCerUpdate = true + break + } + } + expect(privateCerUpdate).assertTrue() + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_PrivateCertificateInstall + * @tc.desc Install a private certificate, each parameter is valid in the form of callback. + * @tc.number SEC_CertificateManagement_Interface_Js_PrivateCertificateInstall_0002 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level2 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_PrivateCertificateInstall_0002', 0, async function (done) { + getGeneratePrivateCert() + let keyStorePwd = "123456" + let certAlias = "PrivateCer02" + let privateCerInstall = false + certStubCallback.installPrivateCertificate(keyStore, keyStorePwd, certAlias, (err, data) => { + expect(err.code).assertEqual(0) + let keyUri = data.authUri + certStubCallback.getPrivateCertificateList((err, data) => { + for (var i = 0; i < data.credentialList.length; i++) { + if (data.credentialList[i].alias == certAlias) { + console.log('Find the installed private certificate alias') + privateCerInstall = true + break; + } + } + expect(privateCerInstall).assertTrue() + let type = 'CM_URI_TYPE_APP_KEY' + let certificate: CertBlob = { + inData: keyStore, + alias: 'PrivateCertAlias' + } + certStubCallback.updatePrivateCertificate(type, keyUri, certificate, (err) => { + certStubCallback.getPrivateCertificateList((err, resultList) => { + console.log('resultList is:' + JSON.stringify(resultList)) + var privateCerUpdateSign = false + for (var i = 0; i < resultList.credentialList.length; i++) { + if (resultList.credentialList[i].alias == 'PrivateCertAlias') { + console.log('Find the update private certificate alias') + privateCerUpdateSign = true + break + } + } + expect(privateCerUpdateSign).assertTrue() + done() + }) + }) + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_PrivateCertificateInstall + * @tc.desc Install a private certificate, each parameter is valid and the alias is the same, + * overwriting the installation promise form. + * @tc.number SEC_CertificateManagement_Interface_Js_PrivateCertificateInstall_0003 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_PrivateCertificateInstall_0003', 0, async function (done) { + getGeneratePrivateCert() + let keyStorePwd = "123456" + let certAlias = "PrivateCer03" + await certStubPromise.installPrivateCertificate(keyStore, keyStorePwd, certAlias) + await certStubPromise.installPrivateCertificate(keyStore, keyStorePwd, certAlias) + let privateCerInstall = false + let count = 0 + let keyUri = '' + let resultList = await certStubPromise.getPrivateCertificateList() + console.log('resultList is:' + JSON.stringify(resultList)) + for (var i = 0; i < resultList.credentialList.length; i++) { + if (resultList.credentialList[i].alias == certAlias) { + console.log('Find the installed private certificate alias') + privateCerInstall = true + keyUri = resultList.credentialList[i].keyUri + count++ + } + } + expect(privateCerInstall).assertTrue() + expect(count).assertEqual(1) + await certStubPromise.uninstallPrivateCertificate(keyUri) + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_PrivateCertificateInstall + * @tc.desc Install a private certificate, each parameter is valid and the alias is the same, + * overwriting the installation callback form. + * @tc.number SEC_CertificateManagement_Interface_Js_PrivateCertificateInstall_0004 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_PrivateCertificateInstall_0004', 0, async function (done) { + getGeneratePrivateCert() + let keyStorePwd = "123456" + let certAlias = "PrivateCer04" + let privateCerInstall = false + let keyUri = '' + certStubCallback.installPrivateCertificate(keyStore, keyStorePwd, certAlias, (err) => { + expect(err.code).assertEqual(0) + certStubCallback.installPrivateCertificate(keyStore, keyStorePwd, certAlias, (err) => { + expect(err.code).assertEqual(0) + let count = 0 + certStubCallback.getPrivateCertificateList((err, data) => { + for (var i = 0; i < data.credentialList.length; i++) { + if (data.credentialList[i].alias == certAlias) { + console.log('Find the installed private certificate alias') + privateCerInstall = true + keyUri = data.credentialList[i].keyUri + count++ + } + } + expect(privateCerInstall).assertTrue() + expect(count).assertEqual(1) + certStubCallback.uninstallPrivateCertificate(keyUri, (err) => { + expect(err.code).assertEqual(0) + done() + }) + }) + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_PrivateCertificateInstall + * @tc.desc Install the private certificate multiple times, each parameter is valid and the alias + * is different in promise form. + * @tc.number SEC_CertificateManagement_Interface_Js_PrivateCertificateInstall_0005 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_PrivateCertificateInstall_0005', 0, async function (done) { + getGeneratePrivateCert() + let keyStorePwd = "123456" + await certStubPromise.installPrivateCertificate(keyStore, keyStorePwd, "PrivateCer05-1") + await certStubPromise.installPrivateCertificate(keyStore, keyStorePwd, "PrivateCer05-2") + let privateCerInstall = false + let PrivateCerInstallSec = false + let keyUriFir = '' + let keyUriSec = '' + let resultList = await certStubPromise.getPrivateCertificateList() + console.log('resultList is:' + JSON.stringify(resultList)) + for (var i = 0; i < resultList.credentialList.length; i++) { + if (resultList.credentialList[i].alias == 'PrivateCer05-1') { + console.log('Find the first installed private certificate alias') + privateCerInstall = true + keyUriFir = resultList.credentialList[i].keyUri + } + if (resultList.credentialList[i].alias == 'PrivateCer05-2') { + console.log('Find the second installed private certificate alias') + PrivateCerInstallSec = true + keyUriSec = resultList.credentialList[i].keyUri + } + } + expect(privateCerInstall).assertTrue() + expect(PrivateCerInstallSec).assertTrue() + await certStubPromise.uninstallPrivateCertificate(keyUriFir) + await certStubPromise.uninstallPrivateCertificate(keyUriSec) + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_PrivateCertificateInstall + * @tc.desc Install the private certificate multiple times, each parameter is valid and the alias + * is different in callback form. + * @tc.number SEC_CertificateManagement_Interface_Js_PrivateCertificateInstall_0006 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_PrivateCertificateInstall_0006', 0, async function (done) { + getGeneratePrivateCert() + let privateCerInstall = false + let PrivateCerInstallSec = false + let keyStorePwd = "123456" + let keyUriFir = '' + let keyUriSec = '' + certStubCallback.installPrivateCertificate(keyStore, keyStorePwd, "PrivateCer06-1", (err) => { + expect(err.code).assertEqual(0) + certStubCallback.installPrivateCertificate(keyStore, keyStorePwd, "PrivateCer06-2", (err) => { + expect(err.code).assertEqual(0) + certStubCallback.getPrivateCertificateList((err, data) => { + for (var i = 0; i < data.credentialList.length; i++) { + if (data.credentialList[i].alias == "PrivateCer06-1") { + console.log('Find the first installed private certificate alias') + privateCerInstall = true + keyUriFir = data.credentialList[i].keyUri + } + if (data.credentialList[i].alias == "PrivateCer06-2") { + console.log('Find the second installed private certificate alias') + PrivateCerInstallSec = true + keyUriSec = data.credentialList[i].keyUri + } + } + expect(privateCerInstall).assertTrue() + expect(PrivateCerInstallSec).assertTrue() + certStubCallback.uninstallPrivateCertificate(keyUriFir, (err) => { + expect(err.code).assertEqual(0) + certStubCallback.uninstallPrivateCertificate(keyUriSec, (err) => { + expect(err.code).assertEqual(0) + done() + }) + }) + }) + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_PrivateCertificateInstall + * @tc.desc Install private business certificate promise form + The length of the parameter keystorePwd exceeds 64 bits, and the installation fails + The parameter certAlias exceeds the length limit of 64, and the installation fails. + * @tc.number SEC_CertificateManagement_Interface_Js_PrivateCertificateInstall_0007 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_PrivateCertificateInstall_0007', 0, async function (done) { + getGeneratePrivateCert() + let keyStorePwd = "123456" + let overKeystorePwd = "123456123456123456123456123456123456123456123456123456123456123456123456" + let certAlias = "PrivateCer07" + let overCertAlias = "PrivateCer07PrivateCer07PrivateCer07PrivateCer07PrivateCer07PrivateCer07" + try { + await certStubPromise.installPrivateCertificate(keyStore, overKeystorePwd, certAlias) + expect().assertFail() + } catch (err) { + expect(err.code != 0).assertTrue() + } + try { + await certStubPromise.installPrivateCertificate(keyStore, keyStorePwd, overCertAlias) + expect().assertFail() + } catch (err) { + console.log('Install private certificate err is:' + JSON.stringify(err)) + expect(err.code != 0).assertTrue() + } + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_PrivateCertificateInstall + * @tc.desc Install private business certificate callback form + The length of the parameter keystorePwd exceeds 64 bits, and the installation fails + The parameter certAlias exceeds the length limit of 64, and the installation fails.. + * @tc.number SEC_CertificateManagement_Interface_Js_PrivateCertificateInstall_0008 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_PrivateCertificateInstall_0008', 0, async function (done) { + getGeneratePrivateCert() + let keyStorePwd = "123456" + let overKeystorePwd = "123456123456123456123456123456123456123456123456123456123456123456123456" + let certAlias = "PrivateCer08" + let overCertAlias = "PrivateCer08PrivateCer08PrivateCer08PrivateCer08PrivateCer08PrivateCer08" + certStubCallback.installPrivateCertificate(keyStore, overKeystorePwd, certAlias, (err) => { + expect(err.code != 0).assertTrue() + certStubCallback.installPrivateCertificate(keyStore, keyStorePwd, overCertAlias, (err) => { + expect(err.code != 0).assertTrue() + done() + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_PrivateCertificateInstall + * @tc.desc Installing private certificates exceeds the certificate limit. + * @tc.number SEC_CertificateManagement_Interface_Js_PrivateCertificateInstall_0009 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_PrivateCertificateInstall_0009', 0, async function (done) { + getGeneratePrivateCert() + let keyStorePwd = "123456" + let resultList = await certStubPromise.getPrivateCertificateList() + let count = CERTNUMLIMIT - resultList.credentialList.length + for (let i = 1; i < count + 1; i++) { + await certStubPromise.installPrivateCertificate(keyStore, keyStorePwd, "PrivateCer09" + i) + } + resultList = await certStubPromise.getPrivateCertificateList() + expect(resultList.credentialList.length).assertEqual(CERTNUMLIMIT) + try { + await certStubPromise.installPrivateCertificate(keyStore, keyStorePwd, "overPrivateCerInstall") + expect().assertFail() + } catch (err) { + console.log('Install private certificate err is:' + JSON.stringify(err)) + expect(err.code != 0).assertTrue() + } + await certStubPromise.uninstallAllAppCertificate() + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_BusinessCertificateInstall + * @tc.desc Install the public business certificate, each parameter is valid in the form of promise. + * @tc.number SEC_CertificateManagement_Interface_Js_BusinessCertificateInstall_0001 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_BusinessCertificateInstall_0001', 0, async function (done) { + loadInstallFile('appca.p12') + let keystorePwd = "123456" + let certAlias = "AppCer01" + let appCerInstall = false + let keyUri = '' + await certStubPromise.installAppCertificate(certFileArray, keystorePwd, certAlias) + let resultList = await certStubPromise.getAppCertificateList() + console.log('resultList is:' + JSON.stringify(resultList)) + for (var i = 0; i < resultList.credentialList.length; i++) { + if (resultList.credentialList[i].alias == 'AppCer01') { + console.log('AppCer01 install SUCCESS') + appCerInstall = true + keyUri = resultList.credentialList[i].keyUri + break; + } + } + expect(appCerInstall).assertTrue() + await certStubPromise.uninstallAppCertificate(keyUri) + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_BusinessCertificateInstall + * @tc.desc Install the public business certificate, each parameter is valid in the form of callback. + * @tc.number SEC_CertificateManagement_Interface_Js_BusinessCertificateInstall_0002 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_BusinessCertificateInstall_0002', 0, async function (done) { + loadInstallFile('appca.p12') + let keystorePwd = "123456" + let certAlias = "AppCer02" + let appCerInstall = false + var keyUri = '' + certStubCallback.installAppCertificate(certFileArray, keystorePwd, certAlias, (err) => { + expect(err.code).assertEqual(0) + certStubCallback.getAppCertificateList((err, data) => { + for (var i = 0; i < data.credentialList.length; i++) { + if (data.credentialList[i].alias == certAlias) { + console.log('AppCer02 install success') + appCerInstall = true + keyUri = data.credentialList[i].keyUri + break; + } + } + expect(appCerInstall).assertTrue() + certStubCallback.uninstallAppCertificate(keyUri, (err) => { + expect(err.code).assertEqual(0) + done() + }) + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_BusinessCertificateInstall + * @tc.desc Install different public business certificates, each parameter is valid and the alias is + * the same, overwriting the installation promise form. + * @tc.number SEC_CertificateManagement_Interface_Js_BusinessCertificateInstall_0003 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_BusinessCertificateInstall_0003', 0, async function (done) { + loadInstallFile('appca.p12') + let keystorePwd = "123456" + let certAlias = "AppCer03" + await certStubPromise.installAppCertificate(certFileArray, keystorePwd, certAlias) + await certStubPromise.installAppCertificate(certFileArray, keystorePwd, certAlias) + let appCerInstall = false + let count = 0 + var keyUri = '' + let resultList = await certStubPromise.getAppCertificateList() + console.log('resultList is:' + JSON.stringify(resultList)) + for (var i = 0; i < resultList.credentialList.length; i++) { + if (resultList.credentialList[i].alias == certAlias) { + console.log('AppCer03 install SUCCESS') + appCerInstall = true + keyUri = resultList.credentialList[i].keyUri + count++ + } + } + expect(appCerInstall).assertTrue() + expect(count).assertEqual(1) + await certStubPromise.uninstallAppCertificate(keyUri) + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_BusinessCertificateInstall + * @tc.desc Install different public business certificates, each parameter is valid and the alias is + * the same, overwriting the installation callback form. + * @tc.number SEC_CertificateManagement_Interface_Js_BusinessCertificateInstall_0004 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_BusinessCertificateInstall_0004', 0, async function (done) { + loadInstallFile('appca.p12') + let keystorePwd = "123456" + let certAlias = "AppCer04" + let appCerInstall = false + var keyUri = '' + certStubCallback.installAppCertificate(certFileArray, keystorePwd, certAlias, (err) => { + expect(err.code).assertEqual(0) + certStubCallback.installAppCertificate(certFileArray, keystorePwd, certAlias, (err) => { + expect(err.code).assertEqual(0) + let count = 0 + certStubCallback.getAppCertificateList((err, data) => { + for (var i = 0; i < data.credentialList.length; i++) { + if (data.credentialList[i].alias == certAlias) { + console.log('AppCer02 install success') + appCerInstall = true + keyUri = data.credentialList[i].keyUri + count++ + } + } + expect(appCerInstall).assertTrue() + expect(count).assertEqual(1) + certStubCallback.uninstallAppCertificate(keyUri, (err) => { + expect(err.code).assertEqual(0) + done() + }) + }) + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_BusinessCertificateInstall + * @tc.desc Install the public business certificate multiple times, each parameter is valid and the alias + * is different in promise form. + * @tc.number SEC_CertificateManagement_Interface_Js_BusinessCertificateInstall_0005 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_BusinessCertificateInstall_0005', 0, async function (done) { + loadInstallFile('appca.p12') + let keystorePwd = "123456" + await certStubPromise.installAppCertificate(certFileArray, keystorePwd, "AppCer05-1") + await certStubPromise.installAppCertificate(certFileArray, keystorePwd, "AppCer05-2") + let appCerInstall = false + let appCerInstallSec = false + var keyUriFir = '' + var keyUriSec = '' + let resultList = await certStubPromise.getAppCertificateList() + console.log('resultList is:' + JSON.stringify(resultList)) + for (var i = 0; i < resultList.credentialList.length; i++) { + if (resultList.credentialList[i].alias == 'AppCer05-1') { + console.log('AppCer05 install SUCCESS') + appCerInstall = true + keyUriFir = resultList.credentialList[i].keyUri + } + if (resultList.credentialList[i].alias == 'AppCer05-2') { + console.log('AppCer05 install SUCCESS') + appCerInstallSec = true + keyUriSec = resultList.credentialList[i].keyUri + } + } + expect(appCerInstall).assertTrue() + expect(appCerInstallSec).assertTrue() + await certStubPromise.uninstallAppCertificate(keyUriFir) + await certStubPromise.uninstallAppCertificate(keyUriSec) + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_BusinessCertificateInstall + * @tc.desc Install the public business certificate multiple times, each parameter is valid and the alias + * is different in callback form. + * @tc.number SEC_CertificateManagement_Interface_Js_BusinessCertificateInstall_0006 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_BusinessCertificateInstall_0006', 0, async function (done) { + loadInstallFile('appca.p12') + let appCerInstall = false + let appCerInstallSec = false + let keystorePwd = "123456" + var keyUriFir = '' + var keyUriSec = '' + certStubCallback.installAppCertificate(certFileArray, keystorePwd, "AppCer06-1", (err) => { + expect(err.code).assertEqual(0) + certStubCallback.installAppCertificate(certFileArray, keystorePwd, "AppCer06-2", (err) => { + expect(err.code).assertEqual(0) + certStubCallback.getAppCertificateList((err, data) => { + for (let i = 0; i < data.credentialList.length; i++) { + if (data.credentialList[i].alias == "AppCer06-1") { + console.log('AppCer01 install success') + appCerInstall = true + keyUriFir = data.credentialList[i].keyUri + } + if (data.credentialList[i].alias == "AppCer06-2") { + console.log('AppCer02 install success') + appCerInstallSec = true + keyUriSec = data.credentialList[i].keyUri + } + } + expect(appCerInstall).assertTrue() + expect(appCerInstallSec).assertTrue() + certStubCallback.uninstallAppCertificate(keyUriFir, (err) => { + expect(err.code).assertEqual(0) + certStubCallback.uninstallAppCertificate(keyUriSec, (err) => { + expect(err.code).assertEqual(0) + done() + }) + }) + }) + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_BusinessCertificateInstall + * @tc.desc The installed business certificate exceeds the limit of the number of certificates. + * @tc.number SEC_CertificateManagement_Interface_Js_BusinessCertificateInstall_0007 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_BusinessCertificateInstall_0007', 0, async function (done) { + loadInstallFile('appca.p12') + let keystorePwd = "123456" + let resultList = await certStubPromise.getAppCertificateList() + let count = CERTNUMLIMIT - resultList.credentialList.length + for (let i = 1; i < count + 1; i++) { + await certStubPromise.installAppCertificate(certFileArray, keystorePwd, "AppCer07" + i) + } + resultList = await certStubPromise.getAppCertificateList() + expect(resultList.credentialList.length).assertEqual(CERTNUMLIMIT) + console.log('resultList length is:' + resultList.credentialList.length) + try { + await certStubPromise.installAppCertificate(certFileArray, keystorePwd, "overAppCerInstall") + expect().assertFail() + } catch (err) { + console.log('SEC_CertificateManagement_Interface_Js err is:' + JSON.stringify(err)) + expect(err.code != 0).assertTrue() + } + await certStubPromise.uninstallAllAppCertificate() + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_BusinessCertificateInstall + * @tc.desc Failed to install public business certificate Promise form + The length of the parameter keystorePwd exceeds 64 bits, and the installation fails + The parameter certAlias exceeds the length limit of 64, and the installation fails. + * @tc.number SEC_CertificateManagement_Interface_Js_BusinessCertificateInstall_0008 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_BusinessCertificateInstall_0008', 0, async function (done) { + loadInstallFile('appca.p12') + let keystorePwd = "123456" + let overKeystorePwd = "123456123456123456123456123456123456123456123456123456123456123456123456" + let certAlias = "AppCer08" + let overCertAlias = "AppCer09AppCer09AppCer09AppCer09AppCer09AppCer09AppCer09AppCer09AppCer09" + try { + await certStubPromise.installAppCertificate(certFileArray, overKeystorePwd, certAlias) + expect().assertFail() + } catch (err) { + console.log('SEC_CertificateManagement_Interface_Js err is:' + JSON.stringify(err)) + expect(err.code != 0).assertTrue() + } + try { + await certStubPromise.installAppCertificate(certFileArray, keystorePwd, overCertAlias) + expect().assertFail() + } catch (err) { + console.log('SEC_CertificateManagement_Interface_Js err is:' + JSON.stringify(err)) + expect(err.code != 0).assertTrue() + } + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_BusinessCertificateInstall + * @tc.desc Failed to install public business certificate callback form + The length of the parameter keystorePwd exceeds 64 bits, and the installation fails + The parameter certAlias exceeds the length limit of 64, and the installation fails.. + * @tc.number SEC_CertificateManagement_Interface_Js_BusinessCertificateInstall_0009 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_BusinessCertificateInstall_0009', 0, async function (done) { + loadInstallFile('appca.p12') + let keystorePwd = "123456" + let overKeystorePwd = "123456123456123456123456123456123456123456123456123456123456123456123456" + let certAlias = "AppCer09" + let overCertAlias = "AppCer09AppCer09AppCer09AppCer09AppCer09AppCer09AppCer09AppCer09AppCer09" + certStubCallback.installAppCertificate(certFileArray, overKeystorePwd, certAlias, (err) => { + expect(err.code != 0).assertTrue() + certStubCallback.installAppCertificate(certFileArray, keystorePwd, overCertAlias, (err) => { + expect(err.code != 0).assertTrue() + done() + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_CertificateDeleteAll + * @tc.desc Remove all user credentials promise form. + * @tc.number SEC_CertificateManagement_Interface_Js_CertificateDeleteAll_0001 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_CertificateDeleteAll_0001', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_CertificateDeleteAll_0001 start") + await certStubPromise.uninstallAllUserTrustedCertificate() + let cmResult = await certStubPromise.getUserTrustedCertificateList() + let certList = cmResult.certList + let certLen = certList.length + expect(certLen).assertEqual(0) + console.log("SEC_CertificateManagement_Interface_Js_CertificateDeleteAll_0001 end") + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_CertificateDeleteAll + * @tc.desc Remove all user credentials callback form . + * @tc.number SEC_CertificateManagement_Interface_Js_CertificateDeleteAll_0002 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_CertificateDeleteAll_0002', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_CertificateDeleteAll_0002 start") + certStubCallback.uninstallAllUserTrustedCertificate((err) => { + expect(err.code != CMErrorCode.CMR_ERROR_UNKNOWN_ERROR).assertTrue() + expect(err.code != CMErrorCode.CMR_ERROR_INTERNAL_ERROR).assertTrue() + expect(err.code != CMErrorCode.CMR_ERROR_INVALID_DIGEST).assertTrue() + expect(err.code != CMErrorCode.CMR_ERROR_CHECK_GET_PADDING_FAIL).assertTrue() + expect(err.code != CMErrorCode.CMR_ERROR_CHECK_GET_KEY_SIZE_FAIL).assertTrue() + expect(err.code != CMErrorCode.CMR_ERROR_CHECK_GET_ALG_FAIL).assertTrue() + expect(err.code != CMErrorCode.CMR_ERROR_EFUSE_READ_FAIL).assertTrue() + expect(err.code).assertEqual(0) + certStubCallback.getUserTrustedCertificateList((err, data) => { + expect(err.code).assertEqual(0) + let certList = data.certList + let certLen = certList.length + expect(certLen).assertEqual(0) + console.log("SEC_CertificateManagement_Interface_Js_CertificateDeleteAll_0002 end") + done() + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_CertificateDeleteAll + * @tc.desc Remove all business certificate promise forms. + * @tc.number SEC_CertificateManagement_Interface_Js_CertificateDeleteAll_0003 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_CertificateDeleteAll_0003', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_CertificateDeleteAll_0003 start") + await certStubPromise.uninstallAllAppCertificate() + let cmResult = await certStubPromise.getAppCertificateList() + let credentialList = cmResult.credentialList + let certLen = credentialList.length + expect(certLen).assertEqual(0) + cmResult = await certStubPromise.getPrivateCertificateList() + credentialList = cmResult.credentialList + certLen = credentialList.length + expect(certLen).assertEqual(0) + console.log("SEC_CertificateManagement_Interface_Js_CertificateDeleteAll_0003 end") + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_CertificateDeleteAll + * @tc.desc Remove all business certificate callback forms. + * @tc.number SEC_CertificateManagement_Interface_Js_CertificateDeleteAll_0004 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level4 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_CertificateDeleteAll_0004', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_CertificateDeleteAll_0004 start") + certStubCallback.uninstallAllAppCertificate((err) => { + expect(err.code).assertEqual(0) + certStubCallback.getAppCertificateList((err, data) => { + expect(err.code).assertEqual(0) + let credentialList = data.credentialList + let certLen = credentialList.length + expect(certLen).assertEqual(0) + certStubCallback.getPrivateCertificateList((err, data) => { + expect(err.code).assertEqual(0) + let credentialList = data.credentialList + let certLen = credentialList.length + expect(certLen).assertEqual(0) + console.log("SEC_CertificateManagement_Interface_Js_CertificateDeleteAll_0004 end") + done() + }) + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_CertificateDeleteAll + * @tc.desc Delete all user credentials promise form multiple times. + * @tc.number SEC_CertificateManagement_Interface_Js_CertificateDeleteAll_0005 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_CertificateDeleteAll_0005', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_CertificateDeleteAll_0005 start") + await certStubPromise.uninstallAllUserTrustedCertificate() + await certStubPromise.uninstallAllUserTrustedCertificate() + let cmResult = await certStubPromise.getUserTrustedCertificateList() + let certList = cmResult.certList + let certLen = certList.length + expect(certLen).assertEqual(0) + console.log("SEC_CertificateManagement_Interface_Js_CertificateDeleteAll_0005 end") + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_CertificateDeleteAll + * @tc.desc Delete all user credentials callback form multiple times. + * @tc.number SEC_CertificateManagement_Interface_Js_CertificateDeleteAll_0006 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_CertificateDeleteAll_0006', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_CertificateDeleteAll_0006 start") + certStubCallback.uninstallAllUserTrustedCertificate((err) => { + expect(err.code).assertEqual(0) + certStubCallback.uninstallAllUserTrustedCertificate((err) => { + expect(err.code).assertEqual(0) + certStubCallback.getUserTrustedCertificateList((err, data) => { + expect(err.code).assertEqual(0) + let certList = data.certList + let certLen = certList.length + expect(certLen).assertEqual(0) + console.log("SEC_CertificateManagement_Interface_Js_CertificateDeleteAll_0006 end") + done() + }) + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_CertificateDeleteAll + * @tc.desc Delete all business certificate promise forms multiple times. + * @tc.number SEC_CertificateManagement_Interface_Js_CertificateDeleteAll_0007 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_CertificateDeleteAll_0007', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_CertificateDeleteAll_0007 start") + await certStubPromise.uninstallAllAppCertificate() + await certStubPromise.uninstallAllAppCertificate() + let cmResult = await certStubPromise.getAppCertificateList() + let credentialList = cmResult.credentialList + let certLen = credentialList.length + expect(certLen).assertEqual(0) + cmResult = await certStubPromise.getPrivateCertificateList() + credentialList = cmResult.credentialList + certLen = credentialList.length + expect(certLen).assertEqual(0) + console.log("SEC_CertificateManagement_Interface_Js_CertificateDeleteAll_0007 end") + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_CertificateDeleteAll + * @tc.desc Delete all business certificate callback forms multiple times. + * @tc.number SEC_CertificateManagement_Interface_Js_CertificateDeleteAll_0008 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_CertificateDeleteAll_0008', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_CertificateDeleteAll_0008 start") + certStubCallback.uninstallAllAppCertificate((err) => { + expect(err.code).assertEqual(0) + certStubCallback.uninstallAllAppCertificate((err) => { + expect(err.code).assertEqual(0) + certStubCallback.getAppCertificateList((err, data) => { + expect(err.code).assertEqual(0) + let credentialList = data.credentialList + let certLen = credentialList.length + expect(certLen).assertEqual(0) + certStubCallback.getPrivateCertificateList((err, data) => { + expect(err.code).assertEqual(0) + let credentialList = data.credentialList + let certLen = credentialList.length + expect(certLen).assertEqual(0) + console.log("SEC_CertificateManagement_Interface_Js_CertificateDeleteAll_0008 end") + done() + }) + }) + }) + }) + }) + }) + } + \ No newline at end of file diff --git a/cer_xts/cer_xts_system/entry/src/main/ets/test/List.test.ets b/cer_xts/cer_xts_system/entry/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..9bd6cd3d1ddf069ed44017dc564879422208396a --- /dev/null +++ b/cer_xts/cer_xts_system/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import abilityTest from './Ability.test' + +export default function testsuite() { + console.log('in List.test') + abilityTest() +} \ No newline at end of file diff --git a/cer_xts/cer_xts_system/entry/src/main/module.json b/cer_xts/cer_xts_system/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..035cdc75464278063f3d80f9fc859ac37d6b8b61 --- /dev/null +++ b/cer_xts/cer_xts_system/entry/src/main/module.json @@ -0,0 +1,37 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:entry_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/cer_xts/cer_xts_system/entry/src/main/resources/base/element/string.json b/cer_xts/cer_xts_system/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..bb1ef26e3b6592242b9ab7ea5b9613dd896b372a --- /dev/null +++ b/cer_xts/cer_xts_system/entry/src/main/resources/base/element/string.json @@ -0,0 +1,40 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "MainAbility2_desc", + "value": "description" + }, + { + "name": "MainAbility2_label", + "value": "label" + }, + { + "name": "MainAbility3_desc", + "value": "description" + }, + { + "name": "MainAbility3_label", + "value": "label" + }, + { + "name": "app_name", + "value": "actsstartrunnertest" + }, + { + "name": "description_application", + "value": "demo for test" + } + ] +} \ No newline at end of file diff --git a/cer_xts/cer_xts_system/entry/src/main/resources/base/media/icon.png b/cer_xts/cer_xts_system/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/cer_xts/cer_xts_system/entry/src/main/resources/base/media/icon.png differ diff --git a/cer_xts/cer_xts_system/entry/src/main/resources/base/profile/main_pages.json b/cer_xts/cer_xts_system/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..e291133c8b3c329611da5af30c299ec10589c7c2 --- /dev/null +++ b/cer_xts/cer_xts_system/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/index" + ] +} \ No newline at end of file diff --git a/cer_xts/cer_xts_system/signature/openharmony_sx.p7b b/cer_xts/cer_xts_system/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/cer_xts/cer_xts_system/signature/openharmony_sx.p7b differ diff --git a/cer_xts/cer_xts_user/AppScope/app.json b/cer_xts/cer_xts_user/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..9495b5b994868bd70f497155e3d9a232a802de7c --- /dev/null +++ b/cer_xts/cer_xts_user/AppScope/app.json @@ -0,0 +1,19 @@ +{ + "app": { + "bundleName": "com.example.cer_xts_user", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "distributedNotificationEnabled": true, + "keepAlive" : true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} \ No newline at end of file diff --git a/cer_xts/cer_xts_user/AppScope/resources/base/element/string.json b/cer_xts/cer_xts_user/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..eddf099a370034aefb60aee9470ac7c598c5ac00 --- /dev/null +++ b/cer_xts/cer_xts_user/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "AppSelectorTest" + } + ] +} \ No newline at end of file diff --git a/cer_xts/cer_xts_user/AppScope/resources/base/media/app_icon.png b/cer_xts/cer_xts_user/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/cer_xts/cer_xts_user/AppScope/resources/base/media/app_icon.png differ diff --git a/cer_xts/cer_xts_user/BUILD.gn b/cer_xts/cer_xts_user/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..c8e90e38cf4726ca31fb99a71b49b1ea7b3c6037 --- /dev/null +++ b/cer_xts/cer_xts_user/BUILD.gn @@ -0,0 +1,41 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsCerTestUser") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":cer_xts_user_js_assets", + ":cer_xts_user_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsCerTestUser" +} + +ohos_app_scope("cer_xts_user_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("cer_xts_user_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("cer_xts_user_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":cer_xts_user_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/cer_xts/cer_xts_user/Test.json b/cer_xts/cer_xts_user/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..6ba684d8b669218a2823a7252ea3a5bd679b6240 --- /dev/null +++ b/cer_xts/cer_xts_user/Test.json @@ -0,0 +1,21 @@ +{ + "description": "Configuration for aceceshi Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "600000", + "bundle-name": "com.example.cer_xts_user", + "module-name": "entry", + "shell-timeout": "600000", + "testcase-timeout":"100000" + }, + "kits": [ + { + "test-file-name": [ + "ActsCerTestUser.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} + diff --git a/cer_xts/cer_xts_user/entry/src/main/ets/Application/AbilityStage.ts b/cer_xts/cer_xts_user/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..0190fb0606f5b60fafe51d094ef1b3c8d69d1da4 --- /dev/null +++ b/cer_xts/cer_xts_user/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/cer_xts/cer_xts_user/entry/src/main/ets/MainAbility/MainAbility.ts b/cer_xts/cer_xts_user/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..4f7032fc67a34d783772b9e2d2396a32ac9dd263 --- /dev/null +++ b/cer_xts/cer_xts_user/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,62 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import Ability from '@ohos.application.Ability' + import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + import { Hypium } from 'hypium/index' + import testsuite from '../test/List.test' + + export default class TestAbility extends Ability { + onCreate(want, launchParam) { + console.log('TestAbility onCreate') + // var abilityDelegator: any + // abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + // var abilityDelegatorArguments: any + // abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + // console.info('start run testcase!!!') + // Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + globalThis.abilityContext = this.context; + } + + onDestroy() { + console.log('TestAbility onDestroy') + } + + onWindowStageCreate(windowStage) { + console.log('TestAbility onWindowStageCreate') + windowStage.setUIContent(this.context, 'MainAbility/pages/index', null) + + } + + onWindowStageDestroy() { + console.log('TestAbility onWindowStageDestroy') + } + + onForeground() { + console.log('TestAbility onForeground') + setTimeout(()=>{ + console.info('in setTimeout') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + },2000) + } + + onBackground() { + console.log('TestAbility onBackground') + } + }; \ No newline at end of file diff --git a/cer_xts/cer_xts_user/entry/src/main/ets/MainAbility/pages/index.ets b/cer_xts/cer_xts_user/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..f166cb4984bdce1942383d40ac5f305fefdc595c --- /dev/null +++ b/cer_xts/cer_xts_user/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,48 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import router from '@ohos.router'; + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/cer_xts/cer_xts_user/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/cer_xts/cer_xts_user/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..1b4c5782a516e02419cea30fcbeb81283cb3f2cd --- /dev/null +++ b/cer_xts/cer_xts_user/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log("onAbilityCreateCallback"); +} + +async function addAbilityMonitorCallback(err: any) { + console.info("addAbilityMonitorCallback : " + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info("OpenHarmonyTestRunner OnPrepare ") + } + + async onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var MainAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility' + let lMonitor = { + abilityName: MainAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/cer_xts/cer_xts_user/entry/src/main/ets/pages/index.ets b/cer_xts/cer_xts_user/entry/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..f166cb4984bdce1942383d40ac5f305fefdc595c --- /dev/null +++ b/cer_xts/cer_xts_user/entry/src/main/ets/pages/index.ets @@ -0,0 +1,48 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import router from '@ohos.router'; + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/cer_xts/cer_xts_user/entry/src/main/ets/stub/certStubCallback.ts b/cer_xts/cer_xts_user/entry/src/main/ets/stub/certStubCallback.ts new file mode 100644 index 0000000000000000000000000000000000000000..7ea721f89136d0bb56226e309092d156a08ab037 --- /dev/null +++ b/cer_xts/cer_xts_user/entry/src/main/ets/stub/certStubCallback.ts @@ -0,0 +1,574 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + import { CMResult, BusinessError, CMErrorCode, CertBlob, CertManagerStore, CMKeyProperties } from './certStubStruct'; + import certStubUtil from './certStubUtil'; + import fileio from '@ohos.fileio'; + + var certUtil = new certStubUtil(); + const TAG = "CertManager Stub: "; + const certNum = 10 + const keyNum = 20 + const authorListA = ["121", "23123", "3123", "676"] + const authorListB = ["232", "878", "6756", "089"] + const authorListC = ["3434", "545", "7687", "023"] + + export class CertStubPromise { + exceptFlag = 0; + uriBase = "uri://stub/certFile/" + type = "CM_URI_TYPE_APP_KEY" + uriCount = 0; + systemCertMap = new Map(); + userCertMap = new Map(); + uriToAlias = new Map(); + appCredMap = new Map(); + privateCredMap = new Map(); + uriToAppList = new Map(); + + constructor() { + let newCert; + + console.log(TAG + "getSystemTrustedCertificateList stub constructor start"); + newCert = certUtil.parseCertInfo(this.uriBase + this.uriCount.toString(), + "SystemRoot_1", true, new Uint8Array([0, 1, 2, 42, 100, 101, 102, 255])); + this.systemCertMap.set(this.uriBase + this.uriCount.toString(), newCert); + this.uriCount++; + + newCert = certUtil.parseCertInfo(this.uriBase + this.uriCount.toString(), + "SystemRoot_2", false, new Uint8Array([64, 1, 2, 42, 100, 123, 321, 255])); + this.systemCertMap.set(this.uriBase + this.uriCount.toString(), newCert); + this.uriCount++; + + newCert = certUtil.parseCertInfo(this.uriBase + this.uriCount.toString(), + "SystemRoot_3", true, new Uint8Array([54, 1, 123, 42, 100, 101, 102, 23])); + this.systemCertMap.set(this.uriBase + this.uriCount.toString(), newCert); + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "TheEncryptionForCCMPV1", this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([25, 5, 34, 45, 64, 78, 7, 8])); + this.appCredMap.set("ApptemRoot_1", newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "ApptemRoot_1") + this.uriToAppList.set(this.uriBase + this.uriCount.toString(), authorListA) + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "TheEncryptionForCCMPV2", this.uriBase + this.uriCount.toString(), + certNum, keyNum, + new Uint8Array([23, 1, 43, 42, 78, 90, 56, 12])); + this.appCredMap.set("ApptemRoot_2", newCert); + this.uriToAppList.set(this.uriBase + this.uriCount.toString(), authorListB) + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "ApptemRoot_2") + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "TheEncryptionForCCMPV3", this.uriBase + this.uriCount.toString(), + certNum, keyNum, + new Uint8Array([21, 1, 32, 645, 100, 101, 102, 23])); + this.appCredMap.set("ApptemRoot_3", newCert); + this.uriToAppList.set(this.uriBase + this.uriCount.toString(), authorListC) + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "ApptemRoot_3") + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "Huawei-Employee_WPA_EAPIEA", + this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([32, 41, 54, 67, 77, 98, 91, 123])); + this.privateCredMap.set("PrivatetemRoot_1", newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "PrivatetemRoot_1") + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "Huawei-Employee_WPA_EAPIEB", + this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([34, 65, 67, 68, 33, 77, 14, 18])); + this.privateCredMap.set("PrivatetemRoot_2", newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "PrivatetemRoot_2") + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "Huawei-Employee_WPA_EAPIEC", + this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([12, 3, 54, 76, 8, 123, 43, 55])); + this.privateCredMap.set("PrivatetemRoot_3", newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "PrivatetemRoot_3") + this.uriCount++; + } + + getSystemTrustedCertificateList(callback) { + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + let data: CMResult; + let certList = new Array(); + + if (!this.exceptFlag) { + console.log(TAG + "getSystemTrustedCertificateList stub start"); + this.systemCertMap.forEach((data, keyUri) => { + certList.push(this.systemCertMap.get(keyUri)) + }) + data = { + certList: certList + }; + callback(error, data); + } else { + error = { + code: CMErrorCode.CMR_FAILURE, + }; + callback(error, null); + } + } + + getSystemTrustedCertificate(certUri: string, callback) { + let data: CMResult; + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + + if (this.systemCertMap.has(certUri)) { + data = { + certInfo: this.systemCertMap.get(certUri) + }; + callback(error, data); + } else { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + callback(error, null); + } + } + + setCertificateStatus(certUri: string, store: number, status: boolean, callback) { + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + let alias; + + if ((!this.systemCertMap.has(certUri)) && + (!this.uriToAlias.has(certUri))) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + callback(error, null); + } + console.log('store is:' + store) + if (store == CertManagerStore.CERT_MANAGER_SYSTEM_TRUSTED_STORE) { + this.systemCertMap.get(certUri).status = status; + console.log('status is:' + status) + callback(error, null); + } else if (store == CertManagerStore.CERT_MANAGER_USER_TRUSTED_STORE) { + alias = this.uriToAlias.get(certUri); + this.userCertMap.get(alias).status = status; + callback(error, null); + } else { + error = { + code: CMErrorCode.CMR_ERROR_NOT_SUPPORTED, + }; + callback(error, null); + } + } + + installUserTrustedCertificate(certificate: CertBlob, callback) { + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + if (certificate.alias.length > 64) { + error = { + code: CMErrorCode.CMR_ERROR_INVALID_ARGUMENT, + }; + callback(error, null); + } + + let newCert = certUtil.parseCertInfo(this.uriBase + this.uriCount.toString(), + certificate.alias, true, certificate.inData); + this.userCertMap.set(certificate.alias, newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), certificate.alias) + this.uriCount++; + + callback(error, null); + } + + uninstallAllUserTrustedCertificate(callback) { + console.log(TAG + "uninstallAllUserTrustedCertificate stub in"); + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + + this.userCertMap.clear(); + this.uriToAlias.clear(); + callback(error, null); + } + + uninstallUserTrustedCertificate(certUri: string, callback) { + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + let alias; + + if (!this.uriToAlias.has(certUri)) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + callback(error, null); + } + + alias = this.uriToAlias.get(certUri); + this.uriToAlias.delete(certUri); + this.userCertMap.delete(alias); + callback(error, null); + } + + getUserTrustedCertificateList(callback) { + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + let data: CMResult; + let certList = new Array(); + + + if (!this.exceptFlag) { + this.userCertMap.forEach((data, keyAlias) => { + certList.push(this.userCertMap.get(keyAlias)) + }) + + data = { + certList: certList + }; + callback(error, data); + } else { + error = { + code: CMErrorCode.CMR_FAILURE, + }; + callback(error, null); + } + } + + getUserTrustedCertificate(certUri: string, callback) { + let data: CMResult; + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + + if (this.uriToAlias.has(certUri)) { + let alias = this.uriToAlias.get(certUri); + data = { + certInfo: this.userCertMap.get(alias) + }; + callback(error, data); + } else { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + callback(error, null); + } + } + + installAppCertificate(keystore: Uint8Array, keystorePwd: string, certAlias: string, callback) { + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + if (keystorePwd.length > 64||certAlias.length > 64) { + error = { + code: CMErrorCode.CMR_ERROR_INVALID_ARGUMENT, + }; + callback(error) + } + let newCred = certUtil.parseCredential(this.type, certAlias, this.uriBase + this.uriCount.toString(), + certNum, keyNum, keystore); + this.appCredMap.set(certAlias, newCred); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), certAlias) + this.uriCount++; + + callback(error); + } + + installPrivateCertificate(keystore: Uint8Array, keystorePwd: string, certAlias: string, callback) { + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + let data: CMResult; + + if (keystorePwd.length > 64||certAlias.length > 64) { + error = { + code: CMErrorCode.CMR_ERROR_INVALID_ARGUMENT, + }; + callback(error) + } + let newCred = certUtil.parseCredential("privateCred", certAlias, this.uriBase + this.uriCount.toString(), + 1, 1, keystore); + this.privateCredMap.set(certAlias, newCred); + let authUriRet = this.uriBase + this.uriCount.toString() + this.uriToAlias.set(authUriRet, certAlias); + this.uriCount++; + data = { + authUri: authUriRet + } + callback(error, data); + } + + uninstallAllAppCertificate(callback) { + console.log(TAG + "uninstallAllAppCertificate stub in"); + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + + this.appCredMap.clear(); + this.privateCredMap.clear(); + + callback(error, null); + } + + uninstallAppCertificate(keyUri: string, callback) { + let alias; + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + + if (!this.uriToAlias.has(keyUri)) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + callback(error, null); + } + + alias = this.uriToAlias.get(keyUri); + this.uriToAlias.delete(keyUri); + this.appCredMap.delete(alias); + + callback(error, null); + } + + uninstallPrivateCertificate(keyUri, callback) { + let alias; + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + + if (!this.uriToAlias.has(keyUri)) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + callback(error, null); + } + + alias = this.uriToAlias.get(keyUri); + this.uriToAlias.delete(keyUri); + this.privateCredMap.delete(alias); + + callback(error, null); + } + + getAppCertificateList(callback) { + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + let data: CMResult; + let credList = new Array(); + + if (!this.exceptFlag) { + this.appCredMap.forEach((data, keyAlias) => { + credList.push(this.appCredMap.get(keyAlias)) + }) + + data = { + credentialList: credList + }; + callback(error, data); + } else { + error = { + code: CMErrorCode.CMR_FAILURE, + }; + callback(error, null); + } + } + + getPrivateCertificateList(callback) { + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + let data: CMResult; + let credList = new Array(); + + if (!this.exceptFlag) { + this.privateCredMap.forEach((data, keyAlias) => { + credList.push(this.privateCredMap.get(keyAlias)) + }) + + data = { + credentialList: credList + }; + callback(error, data); + } else { + error = { + code: CMErrorCode.CMR_FAILURE, + }; + callback(error, null); + } + } + + getAppCertificate(keyUri: string, callback) { + let data: CMResult; + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + + if (this.uriToAlias.has(keyUri)) { + let alias = this.uriToAlias.get(keyUri); + data = { + credential: this.appCredMap.get(alias) + }; + callback(error, data); + } else { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + callback(error, null); + } + } + + getPrivateCertificate(keyUri: string, callback) { + let data: CMResult; + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + + if (this.uriToAlias.has(keyUri)) { + let alias = this.uriToAlias.get(keyUri); + data = { + credential: this.privateCredMap.get(alias) + }; + callback(error, data); + } else { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + callback(error, null); + } + } + + grantAppCertificate(keyUri: string, clientAppUid: string, callback) { + let appList: Array; + let data: CMResult; + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + + console.log(TAG + "grantAppCertificate stub uri: " + keyUri + " clientAppUid: " + clientAppUid); + if (!this.uriToAlias.has(keyUri)) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + callback(error, null); + } + + if (this.uriToAppList.has(keyUri)) { + appList = this.uriToAppList.get(keyUri); + } else { + appList = new Array(); + } + + appList.push(clientAppUid); + this.uriToAppList.set(keyUri, appList) + data = { + authUri: "authUri-value" + }; + console.log(TAG + "grantAppCertificate stub uriToAppList: " + JSON.stringify(appList)); + + callback(error, data); + } + + isAuthorizedApp(keyUri: string, callback) { + let data: CMResult; + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + + data = { + isAuth: false + }; + callback(error, data); + } + + getAuthorizedAppList(keyUri: string, callback) { + let data: CMResult; + let appList: Array; + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + + if ((!this.uriToAlias.has(keyUri)) || (!this.uriToAppList.has(keyUri))) { + data = { + appUidList: appList, + }; + callback(error, data); + } + + appList = this.uriToAppList.get(keyUri); + + data = { + appUidList: appList + }; + callback(error, data); + } + + generatePrivateCertificate(keyAlias: string, keyProperties: CMKeyProperties, callback) { + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + if(keyAlias.length > 64){ + error = { + code: CMErrorCode.CMR_FAILURE + }; + callback(error, undefined) + } + console.log('SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate_0008' + keyProperties.type) + if(keyProperties.type != 'CM_URI_TYPE_APP_KEY' && keyProperties.type != 'CM_URI_TYPE_WLAN_KEY'){ + error = { + code: CMErrorCode.CMR_FAILURE + }; + callback(error, undefined) + } + let data: CMResult; + data = { + outData: new Uint8Array([0, 1, 2, 42, 100, 101, 102, 255]) + }; + callback(error, data); + } + + removeGrantedAppCertificate(keyUri: string, clientAppUid: string, callback) { + let appList: Array; + let error: BusinessError = { + code: CMErrorCode.CMR_SUCCESS + }; + + if ((!this.uriToAlias.has(keyUri)) || (!this.uriToAppList.has(keyUri))) { + let error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + callback(error, null); + } + + appList = this.uriToAppList.get(keyUri); + if (appList.indexOf(clientAppUid) != -1) { + appList = appList.filter(item => item != clientAppUid); + this.uriToAppList.set(keyUri, appList); + callback(error, null); + } else { + let error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + callback(error, null); + } + } + } + + let certStub = new CertStubPromise(); + + export default certStub as CertStubPromise; + \ No newline at end of file diff --git a/cer_xts/cer_xts_user/entry/src/main/ets/stub/certStubPromise.ts b/cer_xts/cer_xts_user/entry/src/main/ets/stub/certStubPromise.ts new file mode 100644 index 0000000000000000000000000000000000000000..3f1d431492f6919e809f5b7c936d581c6fa71dc3 --- /dev/null +++ b/cer_xts/cer_xts_user/entry/src/main/ets/stub/certStubPromise.ts @@ -0,0 +1,709 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + import { CMResult, BusinessError, CMErrorCode, CertBlob, CMSignatureSpec, CertManagerStore, CMKeyProperties } + from './certStubStruct'; + import certStubUtil from './certStubUtil'; + import fileio from '@ohos.fileio'; + + var certUtil = new certStubUtil(); + const TAG = "CertManager Stub: "; + const certNum = 10 + const keyNum = 20 + const authorListA = ["121", "23123", "3123", "676"] + const authorListB = ["232", "878", "6756", "089"] + const authorListC = ["3434", "545", "7687", "023"] + globalThis.exceptFlag = 0 + + export class CertStubPromise { + uriBase = "uri://stub/certFile/" + type = "CM_URI_TYPE_APP_KEY" + uriCount = 0; + systemCertMap = new Map(); + userCertMap = new Map(); + uriToAlias = new Map(); + appCredMap = new Map(); + privateCredMap = new Map(); + uriToAppList = new Map(); + + constructor() { + let newCert; + + console.log(TAG + "getSystemTrustedCertificateList stub constructor start"); + newCert = certUtil.parseCertInfo(this.uriBase + this.uriCount.toString(), + "SystemRoot_1", true, new Uint8Array([0, 1, 2, 42, 100, 101, 102, 255])); + this.systemCertMap.set(this.uriBase + this.uriCount.toString(), newCert); + this.uriCount++; + + newCert = certUtil.parseCertInfo(this.uriBase + this.uriCount.toString(), + "SystemRoot_2", false, new Uint8Array([64, 1, 2, 42, 100, 123, 321, 255])); + this.systemCertMap.set(this.uriBase + this.uriCount.toString(), newCert); + this.uriCount++; + + newCert = certUtil.parseCertInfo(this.uriBase + this.uriCount.toString(), + "SystemRoot_3", true, new Uint8Array([54, 1, 123, 42, 100, 101, 102, 23])); + this.systemCertMap.set(this.uriBase + this.uriCount.toString(), newCert); + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "TheEncryptionForCCMPV1", this.uriBase + this.uriCount.toString(), + certNum, keyNum, + new Uint8Array([25, 5, 34, 45, 64, 78, 7, 8])); + this.appCredMap.set("ApptemRoot_1", newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "ApptemRoot_1") + this.uriToAppList.set(this.uriBase + this.uriCount.toString(), authorListA) + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "TheEncryptionForCCMPV2", this.uriBase + this.uriCount.toString(), + certNum, keyNum, + new Uint8Array([23, 1, 43, 42, 78, 90, 56, 12])); + this.appCredMap.set("ApptemRoot_2", newCert); + this.uriToAppList.set(this.uriBase + this.uriCount.toString(), authorListB) + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "ApptemRoot_2") + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "TheEncryptionForCCMPV3", this.uriBase + this.uriCount.toString(), + certNum, keyNum, + new Uint8Array([21, 1, 32, 645, 100, 101, 102, 23])); + this.appCredMap.set("ApptemRoot_3", newCert); + this.uriToAppList.set(this.uriBase + this.uriCount.toString(), authorListC) + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "ApptemRoot_3") + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "Huawei-Employee_WPA_EAPIEA", + this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([32, 41, 54, 67, 77, 98, 91, 123])); + this.privateCredMap.set("PrivatetemRoot_1", newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "PrivatetemRoot_1") + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "Huawei-Employee_WPA_EAPIEB", + this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([34, 65, 67, 68, 33, 77, 14, 18])); + this.privateCredMap.set("PrivatetemRoot_2", newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "PrivatetemRoot_2") + this.uriCount++; + + newCert = certUtil.parseCredential(this.type, "Huawei-Employee_WPA_EAPIEC", + this.uriBase + this.uriCount.toString(), certNum, keyNum, + new Uint8Array([12, 3, 54, 76, 8, 123, 43, 55])); + this.privateCredMap.set("PrivatetemRoot_3", newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), "PrivatetemRoot_3") + this.uriCount++; + } + + getSystemTrustedCertificateList() { + return new Promise((resolve, reject) => { + let error: BusinessError; + let data: CMResult; + let certList = new Array(); + + if (!globalThis.exceptFlag) { + console.log(TAG + "getSystemTrustedCertificateList stub start"); + this.systemCertMap.forEach((data, keyUri) => { + certList.push(this.systemCertMap.get(keyUri)) + }) + data = { + certList: certList + }; + resolve(data); + } else { + error = { + code: CMErrorCode.CMR_FAILURE, + }; + reject(error); + } + }) + } + + getSystemTrustedCertificate(certUri: string) { + return new Promise((resolve, reject) => { + let data: CMResult; + let error: BusinessError; + + if (this.systemCertMap.has(certUri)) { + data = { + certInfo: this.systemCertMap.get(certUri) + }; + resolve(data); + } else { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + }) + } + + setCertificateStatus(certUri: string, store: number, status: boolean) { + return new Promise((resolve, reject) => { + let error: BusinessError; + let alias; + + if ((!this.systemCertMap.has(certUri)) && + (!this.uriToAlias.has(certUri))) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + + if (store == CertManagerStore.CERT_MANAGER_SYSTEM_TRUSTED_STORE) { + this.systemCertMap.get(certUri).status = status; + resolve(); + } else if (store == CertManagerStore.CERT_MANAGER_USER_TRUSTED_STORE) { + alias = this.uriToAlias.get(certUri); + this.userCertMap.get(alias).status = status; + resolve(); + } else { + error = { + code: CMErrorCode.CMR_ERROR_NOT_SUPPORTED, + }; + reject(error); + } + }) + } + + installUserTrustedCertificate(certificate: CertBlob) { + return new Promise((resolve, reject) => { + let error: BusinessError; + + if (this.userCertMap.size == 64) { + error = { + code: CMErrorCode.CMR_ERROR_STORAGE_FAILURE, + }; + reject(error) + } + + if (certificate.alias.length > 64) { + error = { + code: CMErrorCode.CMR_ERROR_INVALID_ARGUMENT, + }; + reject(error) + } + let newCert = certUtil.parseCertInfo(this.uriBase + this.uriCount.toString(), + certificate.alias, true, certificate.inData); + this.userCertMap.set(certificate.alias, newCert); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), certificate.alias) + this.uriCount++; + + resolve(); + }) + } + + uninstallAllUserTrustedCertificate() { + return new Promise((resolve, reject) => { + console.log(TAG + "uninstallAllUserTrustedCertificate stub in"); + this.userCertMap.clear(); + this.uriToAlias.clear(); + resolve(); + }) + } + + uninstallUserTrustedCertificate(certUri: string) { + return new Promise((resolve, reject) => { + let error: BusinessError; + let alias; + + if (!this.uriToAlias.has(certUri)) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + + alias = this.uriToAlias.get(certUri); + this.uriToAlias.delete(certUri); + this.userCertMap.delete(alias); + resolve(); + }) + } + + getUserTrustedCertificateList() { + return new Promise((resolve, reject) => { + let error: BusinessError; + let data: CMResult; + let certList = new Array(); + + if (!globalThis.exceptFlag) { + this.userCertMap.forEach((data, keyAlias) => { + certList.push(this.userCertMap.get(keyAlias)) + }) + + data = { + certList: certList + }; + resolve(data); + } else { + error = { + code: CMErrorCode.CMR_FAILURE, + }; + reject(error); + } + }) + } + + getUserTrustedCertificate(certUri: string) { + return new Promise((resolve, reject) => { + let data: CMResult; + let error: BusinessError; + + if (this.uriToAlias.has(certUri)) { + let alias = this.uriToAlias.get(certUri); + data = { + certInfo: this.userCertMap.get(alias) + }; + resolve(data); + } else { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + }) + } + + installAppCertificate(keystore: Uint8Array, keystorePwd: string, certAlias: string) { + return new Promise((resolve, reject) => { + let error: BusinessError; + let data: CMResult; + data = { + + } + if (this.appCredMap.size == 64) { + error = { + code: CMErrorCode.CMR_ERROR_STORAGE_FAILURE, + }; + reject(error) + } + if (keystorePwd.length > 64||certAlias.length > 64) { + error = { + code: CMErrorCode.CMR_ERROR_INVALID_ARGUMENT, + }; + reject(error) + } + let newCred = certUtil.parseCredential(this.type, certAlias, this.uriBase + this.uriCount.toString(), + certNum, keyNum, keystore); + this.appCredMap.set(certAlias, newCred); + this.uriToAlias.set(this.uriBase + this.uriCount.toString(), certAlias) + this.uriCount++; + + resolve(data); + }) + } + + installPrivateCertificate(keystore: Uint8Array, keystorePwd: string, certAlias: string) { + return new Promise((resolve, reject) => { + let error: BusinessError; + let data: CMResult; + + if (this.privateCredMap.size == 64) { + error = { + code: CMErrorCode.CMR_ERROR_STORAGE_FAILURE, + }; + reject(error) + } + if (keystorePwd.length > 64||certAlias.length > 64) { + error = { + code: CMErrorCode.CMR_ERROR_INVALID_ARGUMENT, + }; + reject(error) + } + let newCred = certUtil.parseCredential("privateCred", certAlias, this.uriBase + this.uriCount.toString(), + 1, 1, keystore); + this.privateCredMap.set(certAlias, newCred); + let authUriRet = this.uriBase + this.uriCount.toString() + this.uriToAlias.set(authUriRet, certAlias); + this.uriCount++; + data = { + authUri: authUriRet + } + resolve(data); + }) + } + + uninstallAllAppCertificate() { + return new Promise((resolve, reject) => { + console.log(TAG + "uninstallAllAppCertificate stub in"); + this.appCredMap.clear(); + this.privateCredMap.clear(); + + resolve(); + }) + } + + uninstallAppCertificate(keyUri: string) { + return new Promise((resolve, reject) => { + let alias; + let error: BusinessError; + + if (!this.uriToAlias.has(keyUri)) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + + alias = this.uriToAlias.get(keyUri); + this.uriToAlias.delete(keyUri); + this.appCredMap.delete(alias); + + resolve(); + }) + } + + uninstallPrivateCertificate(keyUri) { + return new Promise((resolve, reject) => { + let alias; + let error: BusinessError; + + if (!this.uriToAlias.has(keyUri)) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + + alias = this.uriToAlias.get(keyUri); + this.uriToAlias.delete(keyUri); + this.privateCredMap.delete(alias); + + resolve(); + }) + } + + getAppCertificateList() { + return new Promise((resolve, reject) => { + let error: BusinessError; + let data: CMResult; + let credList = new Array(); + + if (!globalThis.exceptFlag) { + this.appCredMap.forEach((data, keyAlias) => { + credList.push(this.appCredMap.get(keyAlias)) + }) + + data = { + credentialList: credList + }; + resolve(data); + } else { + error = { + code: CMErrorCode.CMR_FAILURE, + }; + reject(error); + } + }) + } + + getPrivateCertificateList() { + return new Promise((resolve, reject) => { + let error: BusinessError; + let data: CMResult; + let credList = new Array(); + + if (!globalThis.exceptFlag) { + this.privateCredMap.forEach((data, keyAlias) => { + credList.push(this.privateCredMap.get(keyAlias)) + }) + + data = { + credentialList: credList + }; + resolve(data); + } else { + error = { + code: CMErrorCode.CMR_FAILURE, + }; + reject(error); + } + }) + } + + getAppCertificate(keyUri: string) { + return new Promise((resolve, reject) => { + let data: CMResult; + let error: BusinessError; + + if (this.uriToAlias.has(keyUri)) { + let alias = this.uriToAlias.get(keyUri); + data = { + credential: this.appCredMap.get(alias) + }; + resolve(data); + } else { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + }) + } + + getPrivateCertificate(keyUri: string) { + return new Promise((resolve, reject) => { + let data: CMResult; + let error: BusinessError; + + if (this.uriToAlias.has(keyUri)) { + let alias = this.uriToAlias.get(keyUri); + data = { + credential: this.privateCredMap.get(alias) + }; + resolve(data); + } else { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + }) + } + + grantAppCertificate(keyUri: string, clientAppUid: string) { + return new Promise((resolve, reject) => { + let appList: Array; + let data: CMResult; + let error: BusinessError; + + console.log(TAG + "grantAppCertificate stub uri: " + keyUri + " clientAppUid: " + clientAppUid); + if (!this.uriToAlias.has(keyUri)) { + error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + + if (this.uriToAppList.has(keyUri)) { + appList = this.uriToAppList.get(keyUri); + } else { + appList = new Array(); + } + + appList.push(clientAppUid); + this.uriToAppList.set(keyUri, appList) + data = { + authUri: "authUri-value" + }; + console.log(TAG + "grantAppCertificate stub uriToAppList: " + JSON.stringify(appList)); + + resolve(data); + }) + } + + isAuthorizedApp(keyUri: string) { + return new Promise((resolve, reject) => { + let data: CMResult; + data = { + isAuth: false + }; + resolve(data); + }) + } + + getAuthorizedAppList(keyUri: string) { + return new Promise((resolve, reject) => { + let data: CMResult; + let appList: Array; + + if ((!this.uriToAlias.has(keyUri)) || (!this.uriToAppList.has(keyUri))) { + data = { + appUidList: appList, + }; + resolve(data); + } + + appList = this.uriToAppList.get(keyUri); + + data = { + appUidList: appList + }; + resolve(data); + }) + } + + removeGrantedAppCertificate(keyUri: string, clientAppUid: string) { + return new Promise((resolve, reject) => { + let appList: Array; + + if ((!this.uriToAlias.has(keyUri)) || (!this.uriToAppList.has(keyUri))) { + let error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + + appList = this.uriToAppList.get(keyUri); + if (appList.indexOf(clientAppUid) != -1) { + appList = appList.filter(item => item != clientAppUid); + this.uriToAppList.set(keyUri, appList); + resolve(); + } else { + let error = { + code: CMErrorCode.CMR_ERROR_NOT_EXIST, + }; + reject(error); + } + }) + } + + init(authUri: string, spec: CMSignatureSpec) { + return new Promise((resolve, reject) => { + let errorCode = CMErrorCode.CMR_SUCCESS; + let data: CMResult; + + resolve(); + }) + } + + update(handle: number, data: Uint8Array, token?: Uint8Array) { + return new Promise((resolve, reject) => { + let errorCode = CMErrorCode.CMR_SUCCESS; + let data: CMResult; + + resolve(); + }) + } + + finish(handle: number, signature?: Uint8Array) { + return new Promise((resolve, reject) => { + let errorCode = CMErrorCode.CMR_SUCCESS; + let data: CMResult; + + resolve(); + }) + } + + abort(handle: number) { + return new Promise((resolve, reject) => { + let errorCode = CMErrorCode.CMR_SUCCESS; + let data: CMResult; + + resolve(); + }) + } + + mapToJson(map) { + let obj = Object.create(null); + for (let [k, v] of map) { + obj[k] = v; + } + + return JSON.stringify(obj) + } + + jsonToMap(jsonString) { + console.log(TAG + "jsonToMap start"); + let map = new Map(); + let obj = JSON.parse(jsonString); + + for (let k of Object.keys(obj)) { + map.set(k, obj[k]) + } + return map; + } + + saveAllMaps() { + console.log(TAG + "saveAllMaps start"); + let dataList = [ + this.mapToJson(this.systemCertMap), + this.mapToJson(this.userCertMap), + this.mapToJson(this.uriToAlias), + this.mapToJson(this.appCredMap), + this.mapToJson(this.privateCredMap), + this.mapToJson(this.uriToAppList) + ]; + + let context = globalThis.certManagerAbilityContext; + let path = context.cacheDir; + path += '/certStubData' + try { + fileio.unlinkSync(path); + } catch (err) { + console.log(TAG + "saveAllMaps unlinkSync err: " + err); + } + let fd = fileio.openSync(path, 0o102, 0o666); + fileio.writeSync(fd, JSON.stringify(dataList)); + fileio.closeSync(fd); + console.log(TAG + "saveAllMaps end"); + } + + uint8ArrayToString(fileData) { + var dataString = ""; + for (var i = 0; i < fileData.length; i++) { + dataString += String.fromCharCode(fileData[i]); + } + return dataString + } + + generatePrivateCertificate(keyAlias: string, keyProperties: CMKeyProperties) { + return new Promise((resolve, reject) => { + if(keyProperties.type != 'CM_URI_TYPE_APP_KEY' && keyProperties.type != 'CM_URI_TYPE_WLAN_KEY' || + keyAlias.length > 64){ + let error: BusinessError = { + code: CMErrorCode.CMR_FAILURE + }; + reject(error) + } + let data: CMResult; + data = { + outData: new Uint8Array([0, 1, 2, 42, 100, 101, 102, 255]) + }; + resolve(data); + }) + } + + restoreMapsFromJson(json) { + console.log(TAG + "restoreMapsFromJson start Json: " + json); + let dataList = JSON.parse(json); + this.systemCertMap = this.jsonToMap(dataList[0]); + this.userCertMap = this.jsonToMap(dataList[1]); + this.uriToAlias = this.jsonToMap(dataList[2]); + this.appCredMap = this.jsonToMap(dataList[3]); + this.privateCredMap = this.jsonToMap(dataList[4]); + this.uriToAppList = this.jsonToMap(dataList[5]); + console.log(TAG + "restoreMapsFromJson end"); + } + + restoreAllMaps() { + console.log(TAG + "getAllMaps start"); + let context = globalThis.certManagerAbilityContext; + let path = context.cacheDir; + path += '/certStubData' + + try { + let fd = fileio.openSync(path, 0o002, 0o666); + console.log(TAG + "getAllMaps fd: " + fd); + let stat = fileio.fstatSync(fd); + let size = stat.size; + let buf = new ArrayBuffer(size); + + fileio.read(fd, buf, (err, data) => { + if (data) { + this.restoreMapsFromJson(this.uint8ArrayToString(new Uint8Array(data.buffer))); + } + fileio.closeSync(fd); + }); + } catch(err) { + console.log(TAG + "getAllMaps err: " + err); + } + + console.log(TAG + "getAllMaps end"); + } + } + + let certStub = new CertStubPromise(); + + export default certStub as CertStubPromise; + \ No newline at end of file diff --git a/cer_xts/cer_xts_user/entry/src/main/ets/stub/certStubStruct.ets b/cer_xts/cer_xts_user/entry/src/main/ets/stub/certStubStruct.ets new file mode 100644 index 0000000000000000000000000000000000000000..78c417c798e6145f591227aa9beace447e535f61 --- /dev/null +++ b/cer_xts/cer_xts_user/entry/src/main/ets/stub/certStubStruct.ets @@ -0,0 +1,161 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export interface CertInfo { + uri: string, + certAlias: string, + status: boolean, + issuerName: string, + subjectName: string, + serial: string, + notBefore: string, + notAfter: string, + fingerprintSha256: string, + cert: Uint8Array +} + +export interface certAbstract { + uri: string, + certAlias: string, + status: boolean, + subjectName: string, +} + +export interface CMResult { + certList?: Array, + certInfo?: CertInfo, + credentialList?:Array, + credential?: Credential, + appUidList?: Array + authUri?: string, + outData?: Uint8Array, + isAuth?: boolean +} + +export interface CMHandle { + errorCode: number, + handle: number; + token?: Uint8Array; +} + +export interface Credential { + type: string, + alias: string, + keyUri: string, + certNum: number, + keyNum: number, + credData: Uint8Array +} + +export interface CredentialAbstract { + type: string, + alias: string, + keyUri: string +} + +export interface CMContext { + userId: string, + uid: string, + packageName: string +}; + +export interface CertBlob { + readonly inData?: Uint8Array, + readonly alias?: string +}; + +export interface CMKeyProperties { + type: string; // Type of the key, must be CM_URI_TYPE_APP_KEY or CM_URI_TYPE_WLAN_KEY + alg: string; + size: number; + padding: string; + purpose: string; + digest: string; + authType: string; + authTimeout: string; +}; + +export interface CMSignatureSpec { + alg: string; + padding: string; + digest: string; + authToken: Uint8Array; // required only for user authentication +}; + +export enum CertManagerStore { + CERT_MANAGER_CREDENTIAL_STORE = 0, /* credential certificate store for end entity certificates. */ + CERT_MANAGER_SYSTEM_TRUSTED_STORE = 1, /* read only, updated by system only. */ + CERT_MANAGER_USER_TRUSTED_STORE = 2, /* modifiable by applications and user. */ + CERT_MANAGER_APPLICATION_TRUSTED_STORE = 3, /* application specific trusted certificate store; modifiable by the application only. */ +} + +export enum CMErrorCode { + CMR_SUCCESS = 0, + CMR_FAILURE = -1, + CMR_ERROR_INSTALL_CERTIFICATE = -2, + CMR_ERROR_SET_STATUS = -3, + CMR_ERROR_INVALID_ARGUMENT = -3, + CMR_ERROR_INVALID_STORE = -4, + CMR_ERROR_NOT_SUPPORTED = -5, + CMR_ERROR_UNINSTALL = -6, + CMR_ERROR_NO_PERMISSION = -7, + CMR_ERROR_INSUFFICIENT_DATA = -8, + CMR_ERROR_GET_CERTIRICATE = -9, + CMR_ERROR_STORAGE_FAILURE = -10, + CMR_ERROR_HARDWARE_FAILURE = -11, + CMR_ERROR_ALREADY_EXISTS = -12, + CMR_ERROR_NOT_EXIST = -13, + CMR_ERROR_NULL_POINTER = -14, + CMR_ERROR_FILE_SIZE_FAIL = -15, + CMR_ERROR_READ_FILE_FAIL = -16, + CMR_ERROR_INVALID_PUBLIC_KEY = -17, + CMR_ERROR_INVALID_PRIVATE_KEY = -18, + CMR_ERROR_INVALID_KEY_INFO = -19, + CMR_ERROR_REMOVE_CERTIFICATE_FAIL = -20, + CMR_ERROR_OPEN_FILE_FAIL = -21, + CMR_ERROR_INVALID_KEY_FILE = -22, + CMR_ERROR_IPC_MSG_FAIL = -23, + CMR_ERROR_REQUEST_OVERFLOWS = -24, + CMR_ERROR_PARAM_NOT_EXIST = -25, + CMR_ERROR_CRYPTO_ENGINE_ERROR = -26, + CMR_ERROR_COMMUNICATION_TIMEOUT = -27, + CMR_ERROR_IPC_INIT_FAIL = -28, + CMR_ERROR_IPC_DLOPEN_FAIL = -29, + CMR_ERROR_EFUSE_READ_FAIL = -30, + + CMR_ERROR_CHECK_GET_ALG_FAIL = -100, + CMR_ERROR_CHECK_GET_KEY_SIZE_FAIL = -101, + CMR_ERROR_CHECK_GET_PADDING_FAIL = -102, + CMR_ERROR_INVALID_DIGEST = -117, + + CMR_ERROR_INTERNAL_ERROR = -999, + CMR_ERROR_UNKNOWN_ERROR = -1000, +} + +export interface BusinessError { + /** + * Defines the basic error code. + * @since 6 + */ + code: number; +} + +export interface AsyncCallback { + /** + * Defines the callback data. + * @since 6 + */ + (err: BusinessError, data: T): void; +} diff --git a/cer_xts/cer_xts_user/entry/src/main/ets/stub/certStubUtil.ets b/cer_xts/cer_xts_user/entry/src/main/ets/stub/certStubUtil.ets new file mode 100644 index 0000000000000000000000000000000000000000..3c92db5ed961d6ea8ae391d391dbdad7a3a2cd67 --- /dev/null +++ b/cer_xts/cer_xts_user/entry/src/main/ets/stub/certStubUtil.ets @@ -0,0 +1,149 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { CertInfo, certAbstract, CMResult, CMContext, AsyncCallback, BusinessError, CMHandle, + Credential, CredentialAbstract, CMErrorCode, CertBlob, CMKeyProperties, CMSignatureSpec } from './certStubStruct' + +export default class certStubUtil { + constructor() { + } + +parseCertInfo(uri: string, certAlias: string, status: boolean, cert: Uint8Array): CertInfo { + let certInfo: CertInfo; + + certInfo = { + uri: uri, + certAlias: certAlias, + status: status, + issuerName: "CN = OpenHarmony Application Root CA,OU = OpenHarmony Team,O = OpenHarmony,C = CN", + subjectName: "CN = OpenHarmony Application Root CA,OU = OpenHarmony Team,O = OpenHarmony,C = CN", + serial: "0fe1388b", + notBefore: "2021/2/2", + notAfter: "2049/12/31", + fingerprintSha256: "23:b7:4d:a0:2f:00:a0:2a:16:c8:8d:bc:4c:71:ea:fd:7e:53:95:09", + cert: cert + } + + return certInfo; +} + +parseCertAbstract(uri: string, certAlias: string, status: boolean): certAbstract { + let result: certAbstract; + + result = { + uri: uri, + certAlias: certAlias, + status: status, + subjectName: "CN=SwissSign Gold CA - G2,OU=,O=SwissSign", + } + + return result; +} + + +parseCMHandle(errorCode: number, handle: number, token: Uint8Array): CMHandle { + let result: CMHandle; + + result = { + errorCode: errorCode, + handle: handle, + token: token, + } + + return result; +} + +parseCredential(type: string, alias: string, keyUri: string, certNum: number, + keyNum: number, credData: Uint8Array): Credential { + let result: Credential; + + result = { + type: type, + alias: alias, + keyUri: keyUri, + certNum: certNum, + keyNum: keyNum, + credData: credData + } + + return result; +} + +parseCredentialAbstract(type: string, alias: string, keyUri: string): CredentialAbstract { + let result: CredentialAbstract; + + result = { + type: type, + alias: alias, + keyUri: keyUri + } + + return result; +} + +parseCMContext(userId: string, uid: string, packageName: string): CMContext { + let result: CMContext; + + result = { + userId: userId, + uid: uid, + packageName: packageName + } + + return result; +} + +parseCMBlob(inData: Uint8Array, alias: string): CertBlob { + let result: CertBlob; + + result = { + inData: inData, + alias: alias + } + + return result; +} + +parseCMKeyProperties(): CMKeyProperties { + let result: CMKeyProperties; + + result = { + type: "CM_URI_TYPE_APP_KEY", // Type of the key, must be CM_URI_TYPE_APP_KEY or CM_URI_TYPE_WLAN_KEY + alg: "alg", + size: 375, + padding: "padding purpose", + purpose: "purpose property", + digest: "digest property", + authType: "Sha-256", + authTimeout: "30" + } + + return result; +} + +parseCMSignatureSpec(alg: string, padding: string, digest: string, authToken: Uint8Array): CMSignatureSpec { + let result: CMSignatureSpec; + + result = { + alg: alg, + padding: padding, + digest: digest, + authToken: authToken // required only for user authentication + } + + return result; +} + +} diff --git a/cer_xts/cer_xts_user/entry/src/main/ets/test/Ability.test.ets b/cer_xts/cer_xts_user/entry/src/main/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..5d4726da6b05af3a79a52f8e6307b6289c0e09f4 --- /dev/null +++ b/cer_xts/cer_xts_user/entry/src/main/ets/test/Ability.test.ets @@ -0,0 +1,858 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index' +import certStubPromise from './../stub/certStubPromise' +import certStubCallback from './../stub/certStubCallback' +import {CMSignatureSpec, CMErrorCode, CMKeyProperties, CertBlob} from './../stub/certStubStruct' +import fileio from '@ohos.fileio' + +var certFileArray : Uint8Array +function loadInstallFile(CertName: string) { + let path = globalThis.abilityContext.cacheDir + path = path + '/' + CertName + console.log('SEC_CertificateManagement_Interface_Js path is:' + path) + let fd = fileio.openSync(path, 0o102, 0o666); + console.log('SEC_CertificateManagement_Interface_Js fd is:' + fd) + let stat = fileio.fstatSync(fd); + let size = stat.size; + let buf = new ArrayBuffer(size); + fileio.read(fd, buf, (err, data) => { + if (data) { + certFileArray = new Uint8Array(data.buffer); + } + }); +} + + +async function installTestUserTrustedCAPromise(CertName: string){ + loadInstallFile(CertName) + await certStubPromise.installUserTrustedCertificate({ + inData: certFileArray, + alias: 'UserCert' + }) +} + +async function installTestUserTrustedCACallback(CertName: string){ + loadInstallFile(CertName) + certStubCallback.installUserTrustedCertificate({ + inData: certFileArray, + alias: 'UserCert' + }, (err, data)=>{ + console.log('in installUserTrustedCertificate callback') + }) +} + +export default function abilityTest() { + describe('CertificateUserXTSTest', function () { + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GetUserCAList + * @tc.desc Test for CmGetCertList js interface - user root certificate - get the certificate + * list normally (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_GetSystemCAList_0004 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetSystemCAList_0004', 0, async function (done) { + try { + let result = await certStubPromise.getSystemTrustedCertificateList() + expect(result.certList[0].uri).assertEqual('uri://stub/certFile/0') + expect(result.certList[0].certAlias).assertEqual('SystemRoot_1') + expect(result.certList[0].status).assertEqual(true) + expect(result.certList[0].subjectName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + expect(result.certList[1].uri).assertEqual('uri://stub/certFile/1') + expect(result.certList[1].certAlias).assertEqual('SystemRoot_2') + expect(result.certList[1].status).assertEqual(false) + expect(result.certList[1].subjectName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + expect(result.certList[2].uri).assertEqual('uri://stub/certFile/2') + expect(result.certList[2].certAlias).assertEqual('SystemRoot_3') + expect(result.certList[2].status).assertEqual(true) + expect(result.certList[2].subjectName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + done() + } catch (error) { + console.log('getSystemTrustedCertificateList failed' + JSON.stringify(error.code)) + expect().assertFail() + done() + } + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GetSystemCAList + * @tc.desc Test for CmGetCertList js interface - user root certificate - get the certificate + * list normally (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_GetSystemCAList_0008 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetSystemCAList_0008', 0, async function (done) { + certStubCallback.getSystemTrustedCertificateList((err, data) => { + expect(data.certList[0].uri).assertEqual('uri://stub/certFile/0') + expect(data.certList[0].certAlias).assertEqual('SystemRoot_1') + expect(data.certList[0].status).assertEqual(true) + expect(data.certList[0].subjectName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + expect(data.certList[1].uri).assertEqual('uri://stub/certFile/1') + expect(data.certList[1].certAlias).assertEqual('SystemRoot_2') + expect(data.certList[1].status).assertEqual(false) + expect(data.certList[1].subjectName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + expect(data.certList[2].uri).assertEqual('uri://stub/certFile/2') + expect(data.certList[2].certAlias).assertEqual('SystemRoot_3') + expect(data.certList[2].status).assertEqual(true) + expect(data.certList[2].subjectName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + expect(err.code).assertEqual(0) + done() + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GetSystemCAList + * @tc.desc Test for CmGetCertInfo js interface - system root certificate - get the certificate + * info normally (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_GetSystemCAInfo_0005 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetSystemCAInfo_0005', 0, async function (done) { + try { + let Listresult = await certStubPromise.getSystemTrustedCertificateList() + let Inforesult = await certStubPromise.getSystemTrustedCertificate(Listresult.certList[0].uri) + console.log('uri is:' + JSON.stringify(Inforesult.certInfo.uri)) + expect(Inforesult.certInfo.uri).assertEqual('uri://stub/certFile/0') + expect(Inforesult.certInfo.certAlias).assertEqual('SystemRoot_1') + expect(Inforesult.certInfo.status).assertEqual(true) + expect(Inforesult.certInfo.subjectName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + expect(Inforesult.certInfo.fingerprintSha256).assertEqual('23:b7:4d:a0:2f:00:a0:2a:16:c8:8d:' + + 'bc:4c:71:ea:fd:7e:53:95:09') + expect(Inforesult.certInfo.serial).assertEqual('0fe1388b') + expect(Inforesult.certInfo.issuerName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + expect(Inforesult.certInfo.notBefore).assertEqual('2021/2/2') + expect(Inforesult.certInfo.notAfter).assertEqual('2049/12/31') + done() + } catch (error) { + console.log('getSystemTrustedCertificate failed' + JSON.stringify(error.code)) + expect().assertFail() + done() + } + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GetSystemCAList + * @tc.desc Test for CmGetCertInfo js interface - system root certificate - get the certificate + * info normally (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_GetSystemCAInfo_0010 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetSystemCAInfo_0010', 0, async function (done) { + certStubCallback.getSystemTrustedCertificateList((err, Listresult) => { + certStubCallback.getSystemTrustedCertificate(Listresult.certList[0].uri, (err, data) => { + expect(data.certInfo.uri).assertEqual('uri://stub/certFile/0') + expect(data.certInfo.certAlias).assertEqual('SystemRoot_1') + expect(data.certInfo.status).assertEqual(true) + expect(data.certInfo.subjectName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + expect(data.certInfo.fingerprintSha256).assertEqual('23:b7:4d:a0:2f:00:a0:2a:16:c8:8d:' + + 'bc:4c:71:ea:fd:7e:53:95:09') + expect(data.certInfo.serial).assertEqual('0fe1388b') + expect(data.certInfo.issuerName).assertEqual('CN = OpenHarmony Application Root CA,OU = ' + + 'OpenHarmony Team,O = OpenHarmony,C = CN') + expect(data.certInfo.notBefore).assertEqual('2021/2/2') + expect(data.certInfo.notAfter).assertEqual('2049/12/31') + expect(err.code).assertEqual(CMErrorCode.CMR_SUCCESS) + done() + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GetUserCAList + * @tc.desc Test for CmGetCertList js interface - user root certificate - get the certificate + * list normally (promise). + * @tc.number SEC_CertificateManagement_Interface_Js_GetUserCAList_0004 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetUserCAList_0004', 0, async function (done) { + try { + let result = await certStubPromise.getUserTrustedCertificateList() + console.log('result is:' + JSON.stringify(result)) + done() + } catch (error) { + console.log('getUserTrustedCertificateList failed' + JSON.stringify(error.code)) + expect().assertFail() + done() + } + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GetUserCAList + * @tc.desc Test for CmGetCertList js interface - user root certificate - get the certificate + * list normally (callback). + * @tc.number SEC_CertificateManagement_Interface_Js_GetUserCAList_0008 + * @tc.spec SEC_CertificateManagement_Interface_JS + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GetUserCAList_0008', 0, async function (done) { + certStubCallback.getUserTrustedCertificateList((err, result) => { + expect(err.code).assertEqual(0) + done() + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate + * @tc.desc Generate a private certificate, each parameter is valid in the form of promise. + * @tc.number SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate_0001 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate_0001', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate_0001 start") + let keyAlias = 'generateKeyAlias' + let keyProperties: CMKeyProperties + keyProperties = { + type: 'CM_URI_TYPE_APP_KEY', + alg: 'string', + size: 1, + padding: 'string', + purpose: 'string', + digest: 'string', + authType: 'string', + authTimeout: 'string', + } + let cmResult = await certStubPromise.generatePrivateCertificate(keyAlias, keyProperties) + expect(cmResult.outData != undefined).assertTrue() + console.log("SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate_0001 end") + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate + * @tc.desc Generate a private certificate, each parameter is valid in the form of callback. + * @tc.number SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate_0002 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate_0002', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate_0002 start") + let keyAlias = 'generateKeyAlias' + let keyProperties: CMKeyProperties + keyProperties = { + type: 'CM_URI_TYPE_APP_KEY', + alg: 'string', + size: 1, + padding: 'string', + purpose: 'string', + digest: 'string', + authType: 'string', + authTimeout: 'string', + } + certStubCallback.generatePrivateCertificate(keyAlias, keyProperties, (err, data) => { + expect(err.code).assertEqual(0) + expect(data.outData != undefined).assertTrue() + console.log("SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate_0002 end") + done() + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate + * @tc.desc Generate private certificates multiple times, each parameter is valid in the form of promise. + * @tc.number SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate_0003 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate_0003', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate_0003 start") + let keyAlias = 'generateKeyAlias' + let keyProperties: CMKeyProperties + keyProperties = { + type: 'CM_URI_TYPE_WLAN_KEY', + alg: 'string', + size: 1, + padding: 'string', + purpose: 'string', + digest: 'string', + authType: 'string', + authTimeout: 'string', + } + let cmResult = await certStubPromise.generatePrivateCertificate(keyAlias, keyProperties) + expect(cmResult.outData != undefined).assertTrue() + cmResult = await certStubPromise.generatePrivateCertificate(keyAlias, keyProperties) + expect(cmResult.outData != undefined).assertTrue() + console.log("SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate_0003 end") + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate + * @tc.desc Generate private certificates multiple times, each parameter is valid in the form of callback. + * @tc.number SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate_0004 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate_0004', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate_0004 start") + let keyAlias = 'generateKeyAlias' + let keyProperties: CMKeyProperties + keyProperties = { + type: 'CM_URI_TYPE_WLAN_KEY', + alg: 'string', + size: 1, + padding: 'string', + purpose: 'string', + digest: 'string', + authType: 'string', + authTimeout: 'string', + } + certStubCallback.generatePrivateCertificate(keyAlias, keyProperties, (err, data) => { + expect(err.code).assertEqual(0) + expect(data.outData != undefined).assertTrue() + certStubCallback.generatePrivateCertificate(keyAlias, keyProperties, (err, data) => { + expect(err.code).assertEqual(0) + expect(data.outData != undefined).assertTrue() + console.log("SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate_0004 end") + done() + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate + * @tc.desc Generate a private certificate, the parameter alias exceeds the 64-bit limit promise form. + * @tc.number SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate_0005 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate_0005', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate_0005 start") + let keyAlias = 'generateKeyAliasgenerateKeyAliasgenerateKeyAliasgenerateKeyAlias' + let keyAliasExceed = 'generateKeyAliasgenerateKeyAliasgenerateKeyAliasgenerateKeyAliasg' + let keyProperties: CMKeyProperties + keyProperties = { + type: 'CM_URI_TYPE_APP_KEY', + alg: 'string', + size: 1, + padding: 'string', + purpose: 'string', + digest: 'string', + authType: 'string', + authTimeout: 'string', + } + try { + await certStubPromise.generatePrivateCertificate(keyAliasExceed, keyProperties) + } catch (err) { + expect(err.code != 0).assertTrue() + await certStubPromise.generatePrivateCertificate(keyAlias, keyProperties) + console.log("SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate_0005 end") + done() + } + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate + * @tc.desc Generate a private certificate, the parameter alias exceeds the 64-bit limit callback form. + * @tc.number SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate_0006 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate_0006', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate_0006 start") + let keyAlias = 'generateKeyAliasgenerateKeyAliasgenerateKeyAliasgenerateKeyAlias' + let keyAliasExceed = 'generateKeyAliasgenerateKeyAliasgenerateKeyAliasgenerateKeyAliasg' + let keyProperties: CMKeyProperties + keyProperties = { + type: 'CM_URI_TYPE_APP_KEY', + alg: 'string', + size: 1, + padding: 'string', + purpose: 'string', + digest: 'string', + authType: 'string', + authTimeout: 'string', + } + certStubCallback.generatePrivateCertificate(keyAliasExceed, keyProperties, (err) => { + expect(err.code != 0).assertTrue() + certStubCallback.generatePrivateCertificate(keyAlias, keyProperties, (err) => { + expect(err.code).assertEqual(0) + console.log("SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate_0006 end") + done() + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate + * @tc.desc Generate private certificate, wrong key attribute type (not CM_URI_TYPE_APP_KEY or + * CM_URI_TYPE_WLAN_KEY) promise form. + * @tc.number SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate_0007 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate_0007', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate_0007 start") + let keyAlias = 'generateKeyAlias' + let keyProperties: CMKeyProperties + keyProperties = { + type: 'error type', + alg: 'string', + size: 1, + padding: 'string', + purpose: 'string', + digest: 'string', + authType: 'string', + authTimeout: 'string', + } + try { + await certStubPromise.generatePrivateCertificate(keyAlias, keyProperties) + } catch (err) { + expect(err.code != 0).assertTrue() + console.log("SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate_0007 end") + done() + } + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate + * @tc.desc Generate private certificate, wrong key attribute type (not CM_URI_TYPE_APP_KEY or + * CM_URI_TYPE_WLAN_KEY) callback form. + * @tc.number SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate_0008 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate_0008', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate_0008 start") + let keyAlias = 'generateKeyAlias' + let keyProperties: CMKeyProperties + keyProperties = { + type: 'error type', + alg: 'string', + size: 1, + padding: 'string', + purpose: 'string', + digest: 'string', + authType: 'string', + authTimeout: 'string', + } + certStubCallback.generatePrivateCertificate(keyAlias, keyProperties, (err) => { + expect(err.code != 0).assertTrue() + console.log("SEC_CertificateManagement_Interface_Js_GeneratePrivateCertificate_0008 end") + done() + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_PrivateCertificateUninstall + * @tc.desc Delete the private business certificate, each parameter is valid in the form of promise. + * @tc.number SEC_CertificateManagement_Interface_Js_PrivateCertificateUninstall_0001 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_PrivateCertificateiUninstall_0001', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_PrivateCertificateiUninstall_0001 start") + let keyAlias = 'generateKeyAliasTest' + let keyProperties: CMKeyProperties + keyProperties = { + type: 'CM_URI_TYPE_APP_KEY', + alg: 'alg', + size: 1, + padding: 'padding', + purpose: 'purpose', + digest: 'digest', + authType: 'authType', + authTimeout: 'authTimeout', + } + let cmResult = await certStubPromise.generatePrivateCertificate(keyAlias, keyProperties) + let outData = cmResult.outData + let keystorePwd = "123456" + let certAlias = "PrivateCerTest" + cmResult = await certStubPromise.installPrivateCertificate(outData, keystorePwd, certAlias) + let keyUri = cmResult.authUri + try { + await certStubPromise.uninstallPrivateCertificate(keyUri) + } catch (err) { + expect().assertFail() + console.log("SEC_CertificateManagement_Interface_Js_PrivateCertificateiUninstall_0001 err " + err.code) + done() + } + console.log("SEC_CertificateManagement_Interface_Js_PrivateCertificateiUninstall_0001 end") + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_PrivateCertificateUninstall + * @tc.desc Delete the private business certificate, each parameter is valid in the form of callback. + * @tc.number SEC_CertificateManagement_Interface_Js_PrivateCertificateUninstall_0002 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_PrivateCertificateiUninstall_0002', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_PrivateCertificateiUninstall_0002 start") + let keyAlias = 'generateKeyAliasTest' + let keyProperties: CMKeyProperties + keyProperties = { + type: 'CM_URI_TYPE_APP_KEY', + alg: 'string', + size: 1, + padding: 'string', + purpose: 'string', + digest: 'string', + authType: 'string', + authTimeout: 'string', + } + certStubCallback.generatePrivateCertificate(keyAlias, keyProperties, (err, data) => { + expect(err.code).assertEqual(0) + let outData = data.outData + let keystorePwd = "123456" + let certAlias = "PrivateCerTest" + certStubCallback.installPrivateCertificate(outData, keystorePwd, certAlias, (err, data) => { + expect(err.code).assertEqual(0) + let keyUri = data.authUri + certStubCallback.uninstallPrivateCertificate(keyUri, (err) => { + expect(err.code).assertEqual(0) + console.log("SEC_CertificateManagement_Interface_Js_PrivateCertificateiUninstall_0002 end") + done() + }) + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_PrivateCertificateUninstall + * @tc.desc Delete multiple private business certificates multiple times, each parameter is valid + * in the form of promise. + * @tc.number SEC_CertificateManagement_Interface_Js_PrivateCertificateUninstall_0003 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_PrivateCertificateiUninstall_0003', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_PrivateCertificateiUninstall_0003 start") + let keyAlias = 'generateKeyAliasTest' + let keyProperties: CMKeyProperties + keyProperties = { + type: 'CM_URI_TYPE_APP_KEY', + alg: 'alg', + size: 1, + padding: 'padding', + purpose: 'purpose', + digest: 'digest', + authType: 'authType', + authTimeout: 'authTimeout', + } + let cmResult = await certStubPromise.generatePrivateCertificate(keyAlias, keyProperties) + let outData = cmResult.outData + let keystorePwd = "123456" + let installNumSign = 5 + for (let i = 0; i < installNumSign; i++) { + let certAlias = "PrivateCerTest" + i.toString() + cmResult = await certStubPromise.installPrivateCertificate(outData, keystorePwd, certAlias) + let keyUri = cmResult.authUri + try { + await certStubPromise.uninstallPrivateCertificate(keyUri) + } catch (err) { + expect().assertFail() + console.log("SEC_CertificateManagement_Interface_Js_PrivateCertificateiUninstall_0003 err " + err.code) + done() + } + } + console.log("SEC_CertificateManagement_Interface_Js_PrivateCertificateiUninstall_0003 end") + done() + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_PrivateCertificateUninstall + * @tc.desc Delete multiple private business certificates multiple times, each parameter is valid + * in the form of callback. + * @tc.number SEC_CertificateManagement_Interface_Js_PrivateCertificateUninstall_0004 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_PrivateCertificateiUninstall_0004', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_PrivateCertificateiUninstall_0004 start") + let keyAlias = 'generateKeyAliasTest' + let keyProperties: CMKeyProperties + keyProperties = { + type: 'CM_URI_TYPE_APP_KEY', + alg: 'string', + size: 1, + padding: 'string', + purpose: 'string', + digest: 'string', + authType: 'string', + authTimeout: 'string', + } + certStubCallback.generatePrivateCertificate(keyAlias, keyProperties, (err, data) => { + expect(err.code).assertEqual(0) + let outData = data.outData + let keystorePwd = "123456" + let certAlias = "PrivateCerTest" + certStubCallback.installPrivateCertificate(outData, keystorePwd, certAlias, (err, data) => { + expect(err.code).assertEqual(0) + let keyUri = data.authUri + certStubCallback.uninstallPrivateCertificate(keyUri, (err) => { + expect(err.code).assertEqual(0) + let certAlias = "PrivateCerTest" + "other" + certStubCallback.installPrivateCertificate(outData, keystorePwd, certAlias, (err, data) => { + expect(err.code).assertEqual(0) + let keyUri = data.authUri + certStubCallback.uninstallPrivateCertificate(keyUri, (err) => { + expect(err.code).assertEqual(0) + console.log("SEC_CertificateManagement_Interface_Js_PrivateCertificateiUninstall_0004 end") + done() + }) + }) + }) + }) + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_PrivateCertificateUninstall + * @tc.desc Delete the private business certificate, the parameter keyUri is wrong in the form of promise. + * @tc.number SEC_CertificateManagement_Interface_Js_PrivateCertificateUninstall_0005 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_PrivateCertificateiUninstall_0005', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_PrivateCertificateiUninstall_0005 start") + let keyUri = 'keyUriNotExistError' + try { + await certStubPromise.uninstallPrivateCertificate(keyUri) + } catch (err) { + expect(err.code != 0).assertTrue() + console.log("SEC_CertificateManagement_Interface_Js_PrivateCertificateiUninstall_0005 end") + done() + } + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_PrivateCertificateUninstall + * @tc.desc Delete the private business certificate, the parameter keyUri is wrong in the form of callback. + * @tc.number SEC_CertificateManagement_Interface_Js_PrivateCertificateUninstall_0006 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_PrivateCertificateiUninstall_0006', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_PrivateCertificateiUninstall_0006 start") + let keyUri = 'keyUriNotExistError' + certStubCallback.uninstallPrivateCertificate(keyUri, (err) => { + expect(err.code != 0).assertTrue() + console.log("SEC_CertificateManagement_Interface_Js_PrivateCertificateiUninstall_0006 end") + done() + }) + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_PrivateCertificateUninstall + * @tc.desc Delete the same private business certificate promise form multiple times. + * @tc.number SEC_CertificateManagement_Interface_Js_PrivateCertificateUninstall_0007 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_PrivateCertificateiUninstall_0007', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_PrivateCertificateiUninstall_0007 start") + let keyAlias = 'generateKeyAliasTest' + let keyProperties: CMKeyProperties + keyProperties = { + type: 'CM_URI_TYPE_APP_KEY', + alg: 'alg', + size: 1, + padding: 'padding', + purpose: 'purpose', + digest: 'digest', + authType: 'authType', + authTimeout: 'authTimeout', + } + let cmResult = await certStubPromise.generatePrivateCertificate(keyAlias, keyProperties) + let outData = cmResult.outData + let keystorePwd = "123456" + let certAlias = "PrivateCerTest" + cmResult = await certStubPromise.installPrivateCertificate(outData, keystorePwd, certAlias) + let keyUri = cmResult.authUri + try { + await certStubPromise.uninstallPrivateCertificate(keyUri) + } catch (err) { + expect().assertFail() + console.log("SEC_CertificateManagement_Interface_Js_PrivateCertificateiUninstall_0007 err " + err.code) + done() + } + try { + await certStubPromise.uninstallPrivateCertificate(keyUri) + } catch (err) { + expect(err.code != 0).assertTrue() + console.log("SEC_CertificateManagement_Interface_Js_PrivateCertificateiUninstall_0007 end") + done() + } + }) + + /** + * @tc.name SEC_CertificateManagement_Interface_Js_PrivateCertificateUninstall + * @tc.desc Delete the same private business certificate callback form multiple times. + * @tc.number SEC_CertificateManagement_Interface_Js_PrivateCertificateUninstall_0008 + * @tc.spec SEC_CertificateManagement_Interface_Js + * @tc.function SEC_CertificateManagement_Interface + * @tc.feature SEC_CertificateManagement + * @tc.size Medium + * @tc.level Level3 + * @tc.type FUNC + * @tc.author yanganli 00414042 + */ + it('SEC_CertificateManagement_Interface_Js_PrivateCertificateiUninstall_0008', 0, async function (done) { + console.log("SEC_CertificateManagement_Interface_Js_PrivateCertificateiUninstall_0008 start") + let keyAlias = 'generateKeyAliasTest' + let keyProperties: CMKeyProperties + keyProperties = { + type: 'CM_URI_TYPE_APP_KEY', + alg: 'string', + size: 1, + padding: 'string', + purpose: 'string', + digest: 'string', + authType: 'string', + authTimeout: 'string', + } + certStubCallback.generatePrivateCertificate(keyAlias, keyProperties, (err, data) => { + expect(err.code).assertEqual(0) + let outData = data.outData + let keystorePwd = "123456" + let certAlias = "PrivateCerTest" + certStubCallback.installPrivateCertificate(outData, keystorePwd, certAlias, (err, data) => { + expect(err.code).assertEqual(0) + let keyUri = data.authUri + certStubCallback.uninstallPrivateCertificate(keyUri, (err) => { + expect(err.code).assertEqual(0) + certStubCallback.uninstallPrivateCertificate(keyUri, (err) => { + expect(err.code != 0).assertTrue() + console.log("SEC_CertificateManagement_Interface_Js_PrivateCertificateiUninstall_0008 end") + done() + }) + }) + }) + }) + }) + + }) +} diff --git a/cer_xts/cer_xts_user/entry/src/main/ets/test/List.test.ets b/cer_xts/cer_xts_user/entry/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..8828f3c461f6224c1f8532e6e299c7b1facc2824 --- /dev/null +++ b/cer_xts/cer_xts_user/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import abilityTest from './Ability.test' + +export default function testsuite() { + abilityTest() +} \ No newline at end of file diff --git a/cer_xts/cer_xts_user/entry/src/main/module.json b/cer_xts/cer_xts_user/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..035cdc75464278063f3d80f9fc859ac37d6b8b61 --- /dev/null +++ b/cer_xts/cer_xts_user/entry/src/main/module.json @@ -0,0 +1,37 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:entry_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/cer_xts/cer_xts_user/entry/src/main/resources/base/element/string.json b/cer_xts/cer_xts_user/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..bb1ef26e3b6592242b9ab7ea5b9613dd896b372a --- /dev/null +++ b/cer_xts/cer_xts_user/entry/src/main/resources/base/element/string.json @@ -0,0 +1,40 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "MainAbility2_desc", + "value": "description" + }, + { + "name": "MainAbility2_label", + "value": "label" + }, + { + "name": "MainAbility3_desc", + "value": "description" + }, + { + "name": "MainAbility3_label", + "value": "label" + }, + { + "name": "app_name", + "value": "actsstartrunnertest" + }, + { + "name": "description_application", + "value": "demo for test" + } + ] +} \ No newline at end of file diff --git a/cer_xts/cer_xts_user/entry/src/main/resources/base/media/icon.png b/cer_xts/cer_xts_user/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/cer_xts/cer_xts_user/entry/src/main/resources/base/media/icon.png differ diff --git a/cer_xts/cer_xts_user/entry/src/main/resources/base/profile/main_pages.json b/cer_xts/cer_xts_user/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..e291133c8b3c329611da5af30c299ec10589c7c2 --- /dev/null +++ b/cer_xts/cer_xts_user/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/index" + ] +} \ No newline at end of file diff --git a/cer_xts/cer_xts_user/signature/openharmony_sx.p7b b/cer_xts/cer_xts_user/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/cer_xts/cer_xts_user/signature/openharmony_sx.p7b differ