@@ -1,3 +0,0 @@
|
||||
/node_modules
|
||||
/.preview
|
||||
/build
|
||||
@@ -1,70 +0,0 @@
|
||||
# 证书管理应用
|
||||
|
||||
## 简介<a name="section11660541593"></a>
|
||||
|
||||
证书管理应用是OpenHarmony中预置的系统应用,主要的功能包含系统根证书查看与启用禁用,用户根证书的安装、查看、启用禁用与卸载,公共业务证书的安装、查看、授权管理与卸载,私有业务证书的查看等功能。
|
||||
应用架构主要结合MVP和领域驱动设计思路,其架构如图1所示。
|
||||
|
||||
图1 证书管理应用架构图
|
||||
|
||||

|
||||
|
||||
|
||||
## 目录<a name="section161941989596"></a>
|
||||
|
||||
```
|
||||
/CertManagerFa/
|
||||
├── AppScope # 应用配置
|
||||
├── common # 公共工具类
|
||||
└── product
|
||||
└── phone
|
||||
└── src
|
||||
└── main
|
||||
├── ets # 代码目录
|
||||
│ ├── Application # AbilityStage类实现
|
||||
│ ├── MainAbility # Ability类实现
|
||||
│ ├── model # model层功能类实现
|
||||
│ ├── pages # 页面展示实现
|
||||
│ ├── presenter # 页面presenter层功能类实现
|
||||
│ └── stub # certManager打桩代码
|
||||
└── resources # 资源文件目录
|
||||
```
|
||||
|
||||
## 说明<a name="section1312121216216"></a>
|
||||
|
||||
### 使用说明<a name="section1551164914237"></a>
|
||||
|
||||
三方应用拉起证书管理FA并执行证书安装,使用方法如下:
|
||||
|
||||
```
|
||||
globalThis.context.startAbility(
|
||||
{
|
||||
bundleName: "com.ohos.certmanager",
|
||||
abilityName: "MainAbility",
|
||||
uri: "certInstall",
|
||||
})
|
||||
```
|
||||
|
||||
三方应用拉起证书管理应用并执行申请应用授权,使用方法如下:
|
||||
|
||||
```
|
||||
//拉起应用申请应用授权
|
||||
globalThis.context.startAbilityForResult(
|
||||
{
|
||||
bundleName: "com.ohos.certmanager",
|
||||
abilityName: "MainAbility",
|
||||
uri: "requestAuthorize",
|
||||
parameters: {
|
||||
appUid: appUid, //传入申请应用的appUid
|
||||
}
|
||||
})
|
||||
.then((data) => {
|
||||
if (!data.resultCode) {
|
||||
this.authUri = data.want.parameters.authUri; //授权成功后获取返回的authUri
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
## 相关仓<a name="section1371113476307"></a>
|
||||
|
||||
**security_certificate_manager**
|
||||
@@ -1,27 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
{
|
||||
"apiType": 'stageMode',
|
||||
"buildOption": {
|
||||
},
|
||||
"entryModules": [
|
||||
"entry"
|
||||
],
|
||||
"targets": [
|
||||
{
|
||||
"name": "default",
|
||||
}
|
||||
]
|
||||
}
|
||||
|
Before Width: | Height: | Size: 41 KiB |
@@ -1,17 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// 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;
|
||||
@@ -1,25 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
{
|
||||
"license": "",
|
||||
"devDependencies": {},
|
||||
"author": "",
|
||||
"name": "certmanager",
|
||||
"description": "certificate manager application",
|
||||
"main": "",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {}
|
||||
}
|
||||
@@ -1,203 +0,0 @@
|
||||
/*
|
||||
* 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 AsyncCallback<T, E = void> {
|
||||
(err: BusinessError<E>, data: T): void;
|
||||
}
|
||||
|
||||
export interface BusinessError<T = void> extends Error {
|
||||
code: number;
|
||||
data?: T;
|
||||
}
|
||||
|
||||
declare namespace CertManagerFunc {
|
||||
function getSystemTrustedCertificateList(callback: AsyncCallback<CMResult>) : void;
|
||||
function getSystemTrustedCertificateList() : Promise<CMResult>;
|
||||
|
||||
function getSystemTrustedCertificate(certUri: string, callback: AsyncCallback<CMResult>) : void;
|
||||
function getSystemTrustedCertificate(certUri: string) : Promise<CMResult>;
|
||||
|
||||
function setCertificateStatus(certUri: string, store: number, status: boolean, callback: AsyncCallback<boolean>) : void;
|
||||
function setCertificateStatus(certUri: string, store: number, status: boolean) : Promise<boolean>;
|
||||
|
||||
function installUserTrustedCertificate(certificate: CertBlob, callback: AsyncCallback<CMResult>) : void;
|
||||
function installUserTrustedCertificate(certificate: CertBlob,) : Promise<CMResult>;
|
||||
|
||||
function uninstallAllUserTrustedCertificate(callback: AsyncCallback<boolean>) : void;
|
||||
function uninstallAllUserTrustedCertificate() : Promise<boolean>;
|
||||
|
||||
function uninstallUserTrustedCertificate(certUri: string, callback: AsyncCallback<boolean>) : void;
|
||||
function uninstallUserTrustedCertificate(certUri: string) : Promise<boolean>;
|
||||
|
||||
function getAllUserTrustedCertificates(callback: AsyncCallback<CMResult>) : void;
|
||||
function getAllUserTrustedCertificates() : Promise<CMResult>;
|
||||
|
||||
function getUserTrustedCertificate(certUri: string, callback: AsyncCallback<CMResult>) : void;
|
||||
function getUserTrustedCertificate(certUri: string) : Promise<CMResult>;
|
||||
|
||||
function installPublicCertificate(keystore: Uint8Array, keystorePwd: string, certAlias: string, callback: AsyncCallback<CMResult>) : void;
|
||||
function installPublicCertificate(keystore: Uint8Array, keystorePwd: string, certAlias: string) : Promise<CMResult>;
|
||||
|
||||
function installPrivateCertificate(keystore: Uint8Array, keystorePwd: string, certAlias: string, callback: AsyncCallback<CMResult>) : void;
|
||||
function installPrivateCertificate(keystore: Uint8Array, keystorePwd: string, certAlias: string) : Promise<CMResult>;
|
||||
|
||||
function generatePrivateCertificate(keyAlias: string, keyProperties: CMKeyProperties, callback: AsyncCallback<CMResult>) : void;
|
||||
function generatePrivateCertificate(keyAlias: string, keyProperties: CMKeyProperties) : Promise<CMResult>;
|
||||
|
||||
function updatePrivateCertificate(type: string, keyUri: string, certificate: CertBlob, callback: AsyncCallback<boolean>) : void;
|
||||
function updatePrivateCertificate(type: string, keyUri: string, certificate: CertBlob) : Promise<boolean>;
|
||||
|
||||
function uninstallAllAppCertificate(callback: AsyncCallback<boolean>) : void;
|
||||
function uninstallAllAppCertificate() : Promise<boolean>;
|
||||
|
||||
function uninstallPublicCertificate(keyUri: string, callback: AsyncCallback<boolean>) : void;
|
||||
function uninstallPublicCertificate(keyUri: string) : Promise<boolean>;
|
||||
|
||||
function uninstallPrivateCertificate(keyUri: string, callback: AsyncCallback<boolean>) : void;
|
||||
function uninstallPrivateCertificate(keyUri: string) : Promise<boolean>;
|
||||
|
||||
function getAllPublicCertificates(callback: AsyncCallback<CMResult>) : void;
|
||||
function getAllPublicCertificates() : Promise<CMResult>;
|
||||
|
||||
function getAllAppPrivateCertificates(callback: AsyncCallback<CMResult>) : void;
|
||||
function getAllAppPrivateCertificates() : Promise<CMResult>;
|
||||
|
||||
function getPublicCertificate(keyUri: string, callback: AsyncCallback<CMResult>) : void;
|
||||
function getPublicCertificate(keyUri: string, ) : Promise<CMResult>;
|
||||
|
||||
function getPrivateCertificate(keyUri: string, callback: AsyncCallback<CMResult>) : void;
|
||||
function getPrivateCertificate(keyUri: string) : Promise<CMResult>;
|
||||
|
||||
function grantPublicCertificate(keyUri: string, clientAppUid: string, callback: AsyncCallback<CMResult>) : void;
|
||||
function grantPublicCertificate(keyUri: string, clientAppUid: string) : Promise<CMResult>;
|
||||
|
||||
function isAuthorizedApp(keyUri: string, callback: AsyncCallback<boolean>) : void;
|
||||
function isAuthorizedApp(keyUri: string) : Promise<boolean>;
|
||||
|
||||
function getAuthorizedAppList(keyUri: string, callback: AsyncCallback<CMResult>) : void;
|
||||
function getAuthorizedAppList(keyUri: string) : Promise<CMResult>;
|
||||
|
||||
function removeGrantedPublicCertificate(keyUri: string, clientAppUid: string, callback: AsyncCallback<boolean>) : void;
|
||||
function removeGrantedPublicCertificate(keyUri: string, clientAppUid: string) : Promise<boolean>;
|
||||
|
||||
function init(authUri: string, spec: CMSignatureSpec, callback: AsyncCallback<CMHandle>) : void;
|
||||
function init(authUri: string, spec: CMSignatureSpec) : Promise<CMHandle>;
|
||||
|
||||
function update(handle: Uint8Array, data: Uint8Array, callback: AsyncCallback<boolean>) : void;
|
||||
function update(handle: Uint8Array, data: Uint8Array) : Promise<boolean>;
|
||||
|
||||
function finish(handle: Uint8Array, callback: AsyncCallback<CMResult>) : void;
|
||||
function finish(handle: Uint8Array, signature: Uint8Array, callback: AsyncCallback<CMResult>) : void;
|
||||
function finish(handle: Uint8Array, signature?: Uint8Array) : Promise<CMResult>;
|
||||
|
||||
function abort(handle: Uint8Array, callback: AsyncCallback<boolean>) : void;
|
||||
function abort(handle: Uint8Array) : Promise<boolean>;
|
||||
|
||||
function installSystemAppCertificate(keystore: Uint8Array, keystorePwd: string, certAlias: string): Promise<CMResult>;
|
||||
|
||||
function getAllSystemAppCertificates(): Promise<CMResult>;
|
||||
|
||||
function getSystemAppCertificate(keyUri: string) : Promise<CMResult>;
|
||||
|
||||
function uninstallSystemAppCertificate(keyUri: string) : Promise<void>;
|
||||
|
||||
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 Credential {
|
||||
type: string;
|
||||
alias: string;
|
||||
keyUri: string;
|
||||
certNum: number;
|
||||
keyNum: number;
|
||||
credData:Uint8Array;
|
||||
}
|
||||
|
||||
export interface CredentialAbstract {
|
||||
type: string;
|
||||
alias: string;
|
||||
keyUri: string;
|
||||
}
|
||||
|
||||
export interface CertBlob {
|
||||
inData: Uint8Array;
|
||||
alias: string;
|
||||
}
|
||||
|
||||
export interface CMResult {
|
||||
certList?: Array<CertAbstract>;
|
||||
certInfo?: CertInfo;
|
||||
credentialList?: Array<CredentialAbstract>;
|
||||
credential?: Credential;
|
||||
appUidList?: Array<string>;
|
||||
uri?: string;
|
||||
outData?: Uint8Array;
|
||||
isAuth?: boolean;
|
||||
}
|
||||
|
||||
export interface CMKeyProperties {
|
||||
type: string;
|
||||
alg: string;
|
||||
size: number;
|
||||
padding: string;
|
||||
purpose: string;
|
||||
digest: string;
|
||||
authType: string;
|
||||
authTimeout: string;
|
||||
}
|
||||
|
||||
export enum CmKeyPurpose {
|
||||
CM_KEY_PURPOSE_SIGN = 4,
|
||||
CM_KEY_PURPOSE_VERIFY = 8,
|
||||
}
|
||||
|
||||
export interface CMSignatureSpec {
|
||||
purpose: CmKeyPurpose;
|
||||
}
|
||||
|
||||
export interface CMHandle {
|
||||
handle: Uint8Array;
|
||||
}
|
||||
|
||||
export enum CMErrorCode {
|
||||
CM_SUCCESS = 0,
|
||||
CM_ERROR_GENERIC = 17500001,
|
||||
CM_ERROR_NO_FOUND = 17500002,
|
||||
CM_ERROR_INCORRECT_FORMAT = 17500003,
|
||||
CM_ERROR_MAX_CERT_COUNT_REACHED = 17500004,
|
||||
CM_ERROR_NO_AUTHORIZATION = 17500005,
|
||||
CM_ERROR_ALIAS_LENGTH_REACHED_LIMIT = 17500006,
|
||||
CM_ERROR_PASSWORD_IS_ERR = 17500008
|
||||
}
|
||||
}
|
||||
|
||||
export default CertManagerFunc;
|
||||
@@ -1,22 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import AbilityStage from '@ohos.app.ability.AbilityStage';
|
||||
|
||||
export default class MyAbilityStage extends AbilityStage {
|
||||
onCreate(): void {
|
||||
console.info('[CertManager] MyAbilityStage onCreate');
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import Want from '@ohos.app.ability.Want';
|
||||
import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession';
|
||||
import { GlobalContext, PwdStore } from '../common/GlobalContext';
|
||||
import UIExtensionAbility from '@ohos.app.ability.UIExtensionAbility';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
|
||||
const PAGE_CA_INSTALL = 5;
|
||||
const TAG = 'CertPickerUiExtAbility';
|
||||
|
||||
export default class CertPickerUiExtAbility extends UIExtensionAbility {
|
||||
onCreate(): void {
|
||||
console.info('[CertManager] CertPickerUiExtAbility onCreate');
|
||||
}
|
||||
|
||||
onDestroy(): void {
|
||||
console.info('[CertManager] CertPickerUiExtAbility onDestroy');
|
||||
}
|
||||
|
||||
onSessionCreate(want: Want, session: UIExtensionContentSession): void {
|
||||
console.info('[CertManager] CertPickerUiExtAbility onSessionCreate');
|
||||
|
||||
if (want === null || want === undefined) {
|
||||
console.error('[CertManager] invalid want param');
|
||||
return;
|
||||
}
|
||||
let param: Record<string, Object> = {
|
||||
'session': session,
|
||||
'want': want
|
||||
}
|
||||
let storage: LocalStorage = new LocalStorage(param);
|
||||
try {
|
||||
if (this.isStartToInstall(want.parameters)) {
|
||||
session.loadContent('pages/CertificateInstallPage', storage);
|
||||
} else {
|
||||
session.loadContent('pages/picker/CertManagerSheetFa', storage);
|
||||
let pwdStore = new PwdStore();
|
||||
GlobalContext.getContext().setPwdStore(pwdStore);
|
||||
GlobalContext.getContext().setAbilityWant(want);
|
||||
}
|
||||
} catch (err) {
|
||||
let error = err as BusinessError;
|
||||
console.error(TAG, `onSessionCreat load content failed: ${error?.code}, msg:${error?.message}`);
|
||||
session.terminateSelf();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
session.setWindowBackgroundColor('#00000000');
|
||||
} catch (err) {
|
||||
console.error('[CertManager] CertPickerUiExtAbility setWindowBackgroundColor');
|
||||
}
|
||||
}
|
||||
|
||||
private isStartToInstall(parameters: Record<string, Object> | undefined): boolean {
|
||||
if(parameters === undefined) {
|
||||
return false;
|
||||
}
|
||||
return parameters['pageType'] === PAGE_CA_INSTALL;
|
||||
}
|
||||
onSessionDestroy(): void {
|
||||
// Main window is destroyed, release UI related resources
|
||||
GlobalContext.getContext().clearSession();
|
||||
console.info('[CertManager] CertPickerUiExtAbility onSessionDestroy');
|
||||
}
|
||||
|
||||
onForeground(): void {
|
||||
// Ability has brought to foreground
|
||||
console.info('[CertManager] CertPickerUiExtAbility onForeground');
|
||||
}
|
||||
|
||||
onBackground(): void {
|
||||
// Ability has back to background
|
||||
console.info('[CertManager] CertPickerUiExtAbility onBackground');
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import Ability from '@ohos.app.ability.UIAbility';
|
||||
import type Want from '@ohos.app.ability.Want';
|
||||
import type Window from '@ohos.window';
|
||||
import { GlobalContext, PwdStore } from '../common/GlobalContext';
|
||||
|
||||
export default class MainAbility extends Ability {
|
||||
onCreate(want: Want, launchParam): void {
|
||||
console.info('[CertManager] MainAbility onCreate');
|
||||
|
||||
if (want === null || want === undefined) {
|
||||
console.error('[CertManager] invalid want param');
|
||||
return;
|
||||
}
|
||||
let pwdStore = new PwdStore();
|
||||
GlobalContext.getContext().setCmContext(this.context);
|
||||
GlobalContext.getContext().setPwdStore(pwdStore);
|
||||
GlobalContext.getContext().setAbilityWant(want);
|
||||
GlobalContext.getContext().setFlag(false);
|
||||
}
|
||||
|
||||
onDestroy(): void {
|
||||
console.info('[CertManager] MainAbility onDestroy');
|
||||
}
|
||||
|
||||
onWindowStageCreate(windowStage: Window.WindowStage): void {
|
||||
// Main window is created, set main page for this ability
|
||||
console.info('[CertManager] MainAbility onWindowStageCreate');
|
||||
windowStage.loadContent('pages/certManagerFa', (err, data) => {
|
||||
if (err.code) {
|
||||
console.error('onWindowStageCreate failed, cause:' + JSON.stringify(err));
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onWindowStageDestroy(): void {
|
||||
// Main window is destroyed, release UI related resources
|
||||
console.info('[CertManager] MainAbility onWindowStageDestroy');
|
||||
}
|
||||
|
||||
onForeground(): void {
|
||||
// Ability has brought to foreground
|
||||
console.info('[CertManager] MainAbility onForeground');
|
||||
}
|
||||
|
||||
onBackground(): void {
|
||||
// Ability has back to background
|
||||
console.info('[CertManager] MainAbility onBackground');
|
||||
}
|
||||
|
||||
onNewWant(want: Want): void {
|
||||
console.info('[CertManager] MainAbility onNewWant');
|
||||
|
||||
if (want === null || want === undefined) {
|
||||
console.error('[CertManager] invalid want param');
|
||||
return;
|
||||
}
|
||||
GlobalContext.getContext().setAbilityWant(want);
|
||||
}
|
||||
};
|
||||
@@ -1,71 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import Want from '@ohos.app.ability.Want';
|
||||
import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession';
|
||||
import { GlobalContext, PwdStore } from '../common/GlobalContext';
|
||||
import UIExtensionAbility from '@ohos.app.ability.UIExtensionAbility';
|
||||
|
||||
export default class MainExtensionAbility extends UIExtensionAbility {
|
||||
onCreate(): void {
|
||||
console.info('[CertManager] MainExtensionAbility onCreate');
|
||||
}
|
||||
|
||||
onDestroy(): void {
|
||||
console.info('[CertManager] MainExtensionAbility onDestroy');
|
||||
}
|
||||
|
||||
onSessionCreate(want: Want, session: UIExtensionContentSession): void {
|
||||
console.info('[CertManager] MainExtensionAbility onSessionCreate');
|
||||
|
||||
if (want === null || want === undefined) {
|
||||
console.error('[CertManager] invalid want param');
|
||||
return;
|
||||
}
|
||||
let param: Record<string, Object> = {
|
||||
'session': session,
|
||||
'want': want
|
||||
}
|
||||
let storage: LocalStorage = new LocalStorage(param);
|
||||
let pullType: string = want.parameters.pullType as string;
|
||||
|
||||
if (pullType === 'systemCredInstall' || pullType === 'specifyInstall') {
|
||||
session.loadContent('pages/certInstallFromStorage', storage);
|
||||
} else {
|
||||
session.loadContent('pages/certManagerFa', storage);
|
||||
}
|
||||
GlobalContext.getContext().setAbilityWant(want);
|
||||
GlobalContext.getContext().setSession(session);
|
||||
let pwdStore = new PwdStore();
|
||||
GlobalContext.getContext().setPwdStore(pwdStore);
|
||||
GlobalContext.getContext().setFlag(true);
|
||||
}
|
||||
|
||||
onSessionDestroy(): void {
|
||||
// Main window is destroyed, release UI related resources
|
||||
GlobalContext.getContext().clearSession();
|
||||
console.info('[CertManager] MainExtensionAbility onSessionDestroy');
|
||||
}
|
||||
|
||||
onForeground(): void {
|
||||
// Ability has brought to foreground
|
||||
console.info('[CertManager] MainExtensionAbility onForeground');
|
||||
}
|
||||
|
||||
onBackground(): void {
|
||||
// Ability has back to background
|
||||
console.info('[CertManager] MainExtensionAbility onBackground');
|
||||
}
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type Want from '@ohos.app.ability.Want';
|
||||
import type UIAbilityContext from 'application/UIAbilityContext';
|
||||
import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession';
|
||||
|
||||
export class PwdStore {
|
||||
private certPwd: string = '';
|
||||
|
||||
setCertPwd(pwd: string): void {
|
||||
this.certPwd = pwd;
|
||||
}
|
||||
|
||||
getCertPwd(): string {
|
||||
return this.certPwd;
|
||||
}
|
||||
|
||||
clearCertPwd(): void {
|
||||
this.certPwd = '';
|
||||
}
|
||||
}
|
||||
|
||||
export class GlobalContext {
|
||||
private constructor() {
|
||||
};
|
||||
|
||||
private static instance: GlobalContext;
|
||||
private context: UIAbilityContext;
|
||||
private want: Want;
|
||||
private pwdStore: PwdStore;
|
||||
private session: UIExtensionContentSession;
|
||||
private flag: Boolean;
|
||||
|
||||
public static getContext(): GlobalContext {
|
||||
if (!GlobalContext.instance) {
|
||||
GlobalContext.instance = new GlobalContext();
|
||||
}
|
||||
return GlobalContext.instance;
|
||||
}
|
||||
|
||||
getCmContext(): UIAbilityContext {
|
||||
return this.context;
|
||||
}
|
||||
|
||||
getPwdStore(): PwdStore {
|
||||
return this.pwdStore;
|
||||
}
|
||||
|
||||
getAbilityWant(): Want {
|
||||
return this.want;
|
||||
}
|
||||
|
||||
getSession(): UIExtensionContentSession {
|
||||
return this.session;
|
||||
}
|
||||
|
||||
getFlag(): Boolean {
|
||||
return this.flag;
|
||||
}
|
||||
|
||||
setCmContext(context: UIAbilityContext): void {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
setPwdStore(pwdStore: PwdStore): void {
|
||||
this.pwdStore = pwdStore;
|
||||
}
|
||||
|
||||
setAbilityWant(want: Want): void {
|
||||
this.want = want;
|
||||
}
|
||||
|
||||
setSession(session: UIExtensionContentSession): void {
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
setFlag(flag: Boolean): void {
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
clearAbilityWantUri(): void {
|
||||
this.want.uri = '';
|
||||
}
|
||||
|
||||
clearSession(): void {
|
||||
this.session = undefined;
|
||||
}
|
||||
|
||||
clearAbilityWantParamsUri(): void {
|
||||
this.want.parameters.uri = '';
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export enum NavEntryKey {
|
||||
HOME_ENTRY = 'home_page',
|
||||
CA_CERTIFICATE_ENTRY = 'ca_cert',
|
||||
CREDENTIAL_LIST_ENTRY = 'cred_list',
|
||||
INSTALL_ENTRY = 'install_from_storage',
|
||||
CA_SYSTEM_DETAIL_ENTRY = 'ca_system_detail',
|
||||
CA_USER_DETAIL_ENTRY = 'ca_user_detail',
|
||||
CRED_SYSTEM_DETAIL_ENTRY = 'cred_system_detail',
|
||||
CRED_USER_DETAIL_ENTRY = 'cred_user_detail',
|
||||
AUTHORIZED_APP_ENTRY = 'authorized_app_management',
|
||||
CRED_PWD_INPUT_ENTRY = 'cred_pwd_input',
|
||||
|
||||
POP = 'pop'
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export class ComponentConfig {
|
||||
public WH_100_100 = '100%';
|
||||
public WH_30_100 = '30%';
|
||||
public WH_33_100 = '33%';
|
||||
public WH_35_100 = '35%';
|
||||
public WH_40_100 = '40%';
|
||||
public WH_45_100 = '45%';
|
||||
public WH_50_100 = '50%';
|
||||
public WH_55_100 = '55%';
|
||||
public WH_83_100 = '83%';
|
||||
public WH_90_100 = '90%';
|
||||
public value_20 = 20;
|
||||
public font_20 = 20;
|
||||
public MAX_LINES_1 = 1;
|
||||
public MAX_LINES_2 = 2;
|
||||
public MAX_LINES_3 = 3;
|
||||
public DURATION_TIME = 200;
|
||||
}
|
||||
|
||||
let componentConfig = new ComponentConfig();
|
||||
|
||||
export default componentConfig as ComponentConfig;
|
||||
@@ -1,85 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import ComponentConfig from './ComponentConfig';
|
||||
import Router from '@ohos.router';
|
||||
import { GlobalContext } from '../GlobalContext';
|
||||
|
||||
const TAG = 'CertManager HeadComponent: ';
|
||||
|
||||
/**
|
||||
* head custom component
|
||||
*/
|
||||
@Component
|
||||
export default struct HeadComponent {
|
||||
private icBackIsVisibility: boolean = true;
|
||||
private headName: string | Resource = '';
|
||||
@State isTouch: boolean = false;
|
||||
|
||||
isStartBySheet: boolean = false;
|
||||
onBackClicked?: () => void;
|
||||
|
||||
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('sys.color.ohos_id_color_click_effect')
|
||||
: $r('sys.color.ohos_id_color_sub_background'))
|
||||
.visibility(this.icBackIsVisibility ? Visibility.Visible : Visibility.None)
|
||||
.onClick(() => {
|
||||
if (this.isStartBySheet) {
|
||||
this.onBackClicked?.();
|
||||
return;
|
||||
}
|
||||
let length = Router.getLength();
|
||||
console.info(TAG + 'router length: ' + Number(length));
|
||||
if (GlobalContext.getContext().getFlag()) {
|
||||
Number(length) == 1 ? GlobalContext.getContext().getSession().sendData({'action': 'exit'}) : Router.back();
|
||||
} else {
|
||||
Number(length) == 1 ? GlobalContext.getContext().getCmContext().terminateSelf() : 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)
|
||||
.maxFontScale(1)
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary'))
|
||||
.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_12') })
|
||||
.height($r('app.float.wh_value_56'))
|
||||
.alignItems(VerticalAlign.Center)
|
||||
.align(Alignment.Start)
|
||||
}
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import ComponentConfig from './ComponentConfig';
|
||||
|
||||
/**
|
||||
* Sub-Page Entry Component
|
||||
*/
|
||||
@Component
|
||||
export struct SubEntryComponent {
|
||||
private targetPage: string = '';
|
||||
private title: string | Resource = '';
|
||||
|
||||
onItemClicked?: (targetRouter: string) => void;
|
||||
|
||||
@Styles normalStyle() {
|
||||
.backgroundColor($r('sys.color.ohos_id_color_card_bg'))
|
||||
};
|
||||
|
||||
@Styles pressedStyle() {
|
||||
.backgroundColor($r('sys.color.ohos_id_color_click_effect'))
|
||||
};
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
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('sys.color.ohos_id_color_text_primary'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.margin({ left: $r('app.float.wh_value_8') })
|
||||
.textAlign(TextAlign.Start);
|
||||
}
|
||||
|
||||
Image($r('app.media.ic_settings_arrow'))
|
||||
.width($r('app.float.wh_value_12'))
|
||||
.height($r('app.float.wh_value_24'))
|
||||
.fillColor($r('sys.color.ohos_id_color_primary'))
|
||||
.opacity($r('app.float.opacity_0_2'))
|
||||
.margin({ right: $r('app.float.wh_value_8') });
|
||||
}
|
||||
.borderRadius($r('app.float.radius_20'))
|
||||
.height(ComponentConfig.WH_100_100)
|
||||
.width(ComponentConfig.WH_100_100)
|
||||
.stateStyles({
|
||||
normal: this.normalStyle,
|
||||
pressed: this.pressedStyle
|
||||
})
|
||||
}
|
||||
.onClick(event => {
|
||||
this.onItemClicked?.(this.targetPage);
|
||||
})
|
||||
.height($r('app.float.wh_value_48'))
|
||||
.backgroundColor($r('sys.color.ohos_id_color_foreground_contrary'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sub-Page Entry Component with EndText
|
||||
*/
|
||||
@Component
|
||||
export struct SubEntryComponentWithEndText {
|
||||
@Prop endText: string = '';
|
||||
private targetPage: string = '';
|
||||
private title: string | Resource = '';
|
||||
|
||||
@Styles normalStyle() {
|
||||
.backgroundColor($r('sys.color.ohos_id_color_card_bg'))
|
||||
};
|
||||
|
||||
@Styles pressedStyle() {
|
||||
.backgroundColor($r('sys.color.ohos_id_color_click_effect'))
|
||||
};
|
||||
|
||||
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('sys.color.ohos_id_color_text_primary'))
|
||||
.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'))
|
||||
.stateStyles({
|
||||
normal: this.normalStyle,
|
||||
pressed: this.pressedStyle
|
||||
})
|
||||
}
|
||||
.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'));
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export default class FilterParams {
|
||||
public static readonly MAX_SELECT_FILE_NUM = 1;
|
||||
public static readonly CERT_FILE_SUFFIX = ['.pem,.cer,.crt,.der'];
|
||||
public static readonly CREDENTIAL_FILE_SUFFIX = ['.pfx,.p12'];
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export enum WidthPercent {
|
||||
WH_AUTO = 'auto',
|
||||
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%'
|
||||
};
|
||||
|
||||
export enum LocationChoice {
|
||||
SWITCH_BUTTON_X_OFFSET = '-4vp',
|
||||
DIALOG_DY_OFFSET = '-16vp'
|
||||
};
|
||||
|
||||
export enum ConfigValue {
|
||||
PWD_MAX_LENGTH = 64,
|
||||
ALIAS_MAX_LENGTH = 16,
|
||||
APP_AUTH_MAX_LENGTH = 4,
|
||||
REQUEST_AUTH_MAX_LENGTH = 5
|
||||
};
|
||||
@@ -1,24 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@Observed
|
||||
export class SheetParam {
|
||||
public sheetType: number = -1;
|
||||
public sheetMinHeight: number = 0;
|
||||
public lastSheetPage: string = '';
|
||||
|
||||
constructor() {
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2022-2023 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 bundleManager from '@ohos.bundle.bundleManager';
|
||||
import bundleResManager from '@ohos.bundle.bundleResourceManager';
|
||||
import { CMModelErrorCode } from '../model/CertMangerModel';
|
||||
import { AppInfoVo } from './CertManagerVo/AppInfoVo';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
|
||||
const TAG = 'certManager BUNDLE:';
|
||||
|
||||
export class BundleNameModel {
|
||||
async getAppInfoList(appUid: number, callback: Function): Promise<void> {
|
||||
console.info(TAG + 'getAppInfoList enter uid: ' + appUid);
|
||||
try {
|
||||
let appInfo: AppInfoVo = {
|
||||
appImage: '',
|
||||
appName: '',
|
||||
};
|
||||
|
||||
let appCloneIdentity = await bundleManager.getAppCloneIdentity(appUid);
|
||||
console.info(TAG + 'appBundleName: ' + appCloneIdentity.bundleName + ', appIndex: ' + appCloneIdentity.appIndex);
|
||||
|
||||
let bundleFlags = bundleResManager.ResourceFlag.GET_RESOURCE_INFO_ALL;
|
||||
let resourceInfo = bundleResManager.getBundleResourceInfo(appCloneIdentity.bundleName, bundleFlags,
|
||||
appCloneIdentity.appIndex);
|
||||
appInfo.appName = resourceInfo.label;
|
||||
appInfo.appImage = resourceInfo.icon;
|
||||
console.info(TAG + 'get bundle info success');
|
||||
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS, appInfo);
|
||||
} catch (err) {
|
||||
let e: BusinessError = err as BusinessError;
|
||||
console.error(TAG + 'getAppInfoList failed, message: ' + e.message + ', code: ' + e.code);
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION, undefined);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let bundleNameModel = new BundleNameModel();
|
||||
|
||||
export default bundleNameModel as BundleNameModel;
|
||||
@@ -1,28 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export class AppAuthorVo {
|
||||
public appImage: string;
|
||||
public uid: string;
|
||||
public appName: string;
|
||||
public status: boolean;
|
||||
|
||||
constructor(appImage: string, uid: string, appName: string, status: boolean) {
|
||||
this.appImage = appImage;
|
||||
this.uid = uid;
|
||||
this.appName = appName;
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export class AppInfoVo {
|
||||
public appImage: string = '';
|
||||
public appName: string = '';
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export class CertAbstractVo {
|
||||
public uri: string;
|
||||
public certAlias: string;
|
||||
public status: boolean;
|
||||
public subjectName: string;
|
||||
public 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;
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export class CertInfoVo {
|
||||
public uri: string;
|
||||
public certAlias: string;
|
||||
public status: boolean;
|
||||
public issuerName: string;
|
||||
public subjectName: string;
|
||||
public serial: string;
|
||||
public notBefore: string;
|
||||
public notAfter: string;
|
||||
public fingerprintSha256: string;
|
||||
public cert: Uint8Array;
|
||||
public subjectNameMap: Map<string, string>;
|
||||
public issuerNameMap: Map<string, string>;
|
||||
public dateMap: Map<string, string>;
|
||||
|
||||
constructor(
|
||||
uri: string,
|
||||
certAlias: string,
|
||||
status: boolean,
|
||||
issuerName: string,
|
||||
subjectName: string,
|
||||
serial: string,
|
||||
notBefore: string,
|
||||
notAfter: string,
|
||||
fingerprintSha256: string,
|
||||
cert: Uint8Array,
|
||||
subjectNameMap: Map<string, string>,
|
||||
issuerNameMap: Map<string, string>,
|
||||
dateMap: Map<string, string>) {
|
||||
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;
|
||||
}
|
||||
|
||||
clearCertInfoVo(): void {
|
||||
this.uri = '';
|
||||
this.certAlias = '';
|
||||
this.status = false;
|
||||
this.issuerName = '';
|
||||
this.subjectName = '';
|
||||
this.serial = '';
|
||||
this.notBefore = '';
|
||||
this.notAfter = '';
|
||||
this.fingerprintSha256 = '';
|
||||
this.cert = new Uint8Array();
|
||||
this.subjectNameMap.clear();
|
||||
this.issuerNameMap.clear();
|
||||
this.dateMap.clear();
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export class CredentialAbstractVo {
|
||||
public credType: string;
|
||||
public alias: string;
|
||||
public keyUri: string;
|
||||
|
||||
constructor(credType: string, alias: string, keyUri: string) {
|
||||
this.credType = credType;
|
||||
this.alias = alias;
|
||||
this.keyUri = keyUri;
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export class CredentialVo {
|
||||
public credType: string;
|
||||
public alias: string;
|
||||
public keyUri: string;
|
||||
public certNum: number;
|
||||
public keyNum: number;
|
||||
public 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;
|
||||
}
|
||||
|
||||
clearCredentialVo(): void {
|
||||
this.credType = '';
|
||||
this.alias = '';
|
||||
this.keyUri = '';
|
||||
this.certNum = 0;
|
||||
this.keyNum = 0;
|
||||
this.credData = new Uint8Array();
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export class RouterAppUidVo {
|
||||
public appUid: string;
|
||||
|
||||
constructor(appUid: string) {
|
||||
this.appUid = appUid;
|
||||
}
|
||||
}
|
||||
|
||||
export class RouterFileVo {
|
||||
public uri: string;
|
||||
public suffix: string;
|
||||
|
||||
constructor(uri: string, suffix: string) {
|
||||
this.uri = uri;
|
||||
this.suffix = suffix;
|
||||
}
|
||||
}
|
||||
|
||||
export class RouterParams {
|
||||
public fileInfo: RouterFileVo;
|
||||
public pwd: string
|
||||
|
||||
constructor(fileInfo: RouterFileVo, pwd: string) {
|
||||
this.fileInfo = fileInfo;
|
||||
this.pwd = pwd
|
||||
}
|
||||
}
|
||||
@@ -1,755 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { CertAbstractVo } from './CertManagerVo/CertAbstractVo';
|
||||
import { CertInfoVo } from './CertManagerVo/CertInfoVo';
|
||||
import { CredentialAbstractVo } from './CertManagerVo/CredentialAbstractVo';
|
||||
import { CredentialVo } from './CertManagerVo/CredentialVo';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
import CertManager from '@ohos.security.certManager';
|
||||
import cert from '@ohos.security.cert';
|
||||
|
||||
const TAG = 'CertManager Model: ';
|
||||
|
||||
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,
|
||||
CM_MODEL_ERROR_NOT_FOUND = -5,
|
||||
CM_MODEL_ERROR_INCORRECT_FORMAT = -6,
|
||||
CM_MODEL_ERROR_MAX_QUANTITY_REACHED = -7,
|
||||
CM_MODEL_ERROR_ALIAS_LENGTH_REACHED_LIMIT = -8,
|
||||
CM_MODEL_ERROR_PASSWORD_ERR = -9,
|
||||
CM_MODEL_ERROR_ADVANCED_SECURITY = -10
|
||||
}
|
||||
|
||||
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,
|
||||
CM_MODEL_OPT_SYSTEM_CRED = 5,
|
||||
}
|
||||
|
||||
export enum CertManagerStore {
|
||||
/* credential certificate store for end entity certificates. */
|
||||
CERT_MANAGER_CREDENTIAL_STORE = 0,
|
||||
/* read only, updated by system only. */
|
||||
CERT_MANAGER_SYSTEM_TRUSTED_STORE = 1,
|
||||
/* modifiable by applications and user. */
|
||||
CERT_MANAGER_USER_TRUSTED_STORE = 2,
|
||||
/* application specific trusted certificate store; modifiable by the application only. */
|
||||
CERT_MANAGER_APPLICATION_TRUSTED_STORE = 3,
|
||||
}
|
||||
|
||||
export class CertMangerModel {
|
||||
getCertOrCredList(optType: CMModelOptType, callback: Function): void {
|
||||
console.info(TAG + 'getCertOrCredList start');
|
||||
|
||||
switch (optType) {
|
||||
case CMModelOptType.CM_MODEL_OPT_SYSTEM_CA:
|
||||
this.getSystemTrustedCertificateList((errCode: CMModelErrorCode, certList: Array<CertAbstractVo>) => {
|
||||
callback(errCode, certList);
|
||||
});
|
||||
break;
|
||||
case CMModelOptType.CM_MODEL_OPT_USER_CA:
|
||||
this.getAllUserTrustedCertificates((errCode: CMModelErrorCode, certList: Array<CertAbstractVo>) => {
|
||||
callback(errCode, certList);
|
||||
});
|
||||
break;
|
||||
case CMModelOptType.CM_MODEL_OPT_APP_CRED:
|
||||
this.getAppCredList((errCode: CMModelErrorCode, credList: Array<CredentialAbstractVo>) => {
|
||||
callback(errCode, credList);
|
||||
});
|
||||
break;
|
||||
case CMModelOptType.CM_MODEL_OPT_SYSTEM_CRED:
|
||||
this.getSystemCredList((errCode: CMModelErrorCode, credList: Array<CredentialAbstractVo>) => {
|
||||
callback(errCode, credList)
|
||||
})
|
||||
break;
|
||||
default:
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_UNKNOWN_OPT, undefined);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
getCertOrCred(optType: CMModelOptType, uri: string, callback: Function): void {
|
||||
console.info(TAG + 'getCertOrCred start');
|
||||
|
||||
switch (optType) {
|
||||
case CMModelOptType.CM_MODEL_OPT_SYSTEM_CA:
|
||||
this.getSystemTrustedCertificate(uri, (errCode: CMModelErrorCode, certInfo: CertInfoVo) => {
|
||||
callback(errCode, certInfo);
|
||||
});
|
||||
break;
|
||||
case CMModelOptType.CM_MODEL_OPT_USER_CA:
|
||||
this.getUserTrustedCertificate(uri, (errCode: CMModelErrorCode, certInfo: CertInfoVo) => {
|
||||
callback(errCode, certInfo);
|
||||
});
|
||||
break;
|
||||
case CMModelOptType.CM_MODEL_OPT_APP_CRED:
|
||||
this.getAppCredential(uri, (errCode: CMModelErrorCode, credInfo: CredentialVo) => {
|
||||
callback(errCode, credInfo);
|
||||
});
|
||||
break;
|
||||
case CMModelOptType.CM_MODEL_OPT_SYSTEM_CRED:
|
||||
this.getSystemCredential(uri, (errCode: CMModelErrorCode, credInfo: CredentialVo) => {
|
||||
callback(errCode, credInfo)
|
||||
})
|
||||
break;
|
||||
default:
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_UNKNOWN_OPT, undefined);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
deleteCertOrCred(optType: CMModelOptType, uri: string, callback: Function): void {
|
||||
console.info(TAG + 'deleteCertOrCred start');
|
||||
|
||||
switch (optType) {
|
||||
case CMModelOptType.CM_MODEL_OPT_USER_CA:
|
||||
this.deleteUserTrustedCertificate(uri, (errCode: CMModelErrorCode) => {
|
||||
callback(errCode);
|
||||
});
|
||||
break;
|
||||
case CMModelOptType.CM_MODEL_OPT_APP_CRED:
|
||||
this.deleteAppCredential(uri, (errCode: CMModelErrorCode) => {
|
||||
callback(errCode);
|
||||
});
|
||||
break;
|
||||
case CMModelOptType.CM_MODEL_OPT_SYSTEM_CA:
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_NOT_SUPPORT);
|
||||
case CMModelOptType.CM_MODEL_OPT_SYSTEM_CRED:
|
||||
this.deleteSystemCredential(uri, (errCode: CMModelErrorCode) => {
|
||||
callback(errCode)
|
||||
})
|
||||
break;
|
||||
default:
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_UNKNOWN_OPT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
setCertStatus(optType: CMModelOptType, uri: string, status: boolean, callback: Function): void {
|
||||
console.info(TAG + 'setCertStatus start');
|
||||
|
||||
switch (optType) {
|
||||
case CMModelOptType.CM_MODEL_OPT_USER_CA:
|
||||
this.setCertificateStatus(uri, CertManagerStore.CERT_MANAGER_USER_TRUSTED_STORE, status,
|
||||
(errCode: CMModelErrorCode) => {
|
||||
callback(errCode);
|
||||
});
|
||||
break;
|
||||
case CMModelOptType.CM_MODEL_OPT_SYSTEM_CA:
|
||||
this.setCertificateStatus(uri, CertManagerStore.CERT_MANAGER_SYSTEM_TRUSTED_STORE, status,
|
||||
(errCode: CMModelErrorCode) => {
|
||||
callback(errCode);
|
||||
});
|
||||
break;
|
||||
case CMModelOptType.CM_MODEL_OPT_APP_CRED:
|
||||
case CMModelOptType.CM_MODEL_OPT_SYSTEM_CRED:
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_NOT_SUPPORT);
|
||||
break;
|
||||
default:
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_UNKNOWN_OPT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
delAllCertOrCred(optType: CMModelOptType, callback: Function): void {
|
||||
console.info(TAG + 'delAllCertOrCred start');
|
||||
|
||||
switch (optType) {
|
||||
case CMModelOptType.CM_MODEL_OPT_USER_CA:
|
||||
this.delAllUserCertificate((errCode: CMModelErrorCode) => {
|
||||
callback(errCode);
|
||||
});
|
||||
break;
|
||||
case CMModelOptType.CM_MODEL_OPT_APP_CRED:
|
||||
this.delAllAppCredential((errCode: CMModelErrorCode) => {
|
||||
callback(errCode);
|
||||
});
|
||||
break;
|
||||
case CMModelOptType.CM_MODEL_OPT_SYSTEM_CA:
|
||||
case CMModelOptType.CM_MODEL_OPT_SYSTEM_CRED:
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_NOT_SUPPORT);
|
||||
break;
|
||||
default:
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_UNKNOWN_OPT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
getAuthAppList(optType: CMModelOptType, uri: string, callback: Function): void {
|
||||
console.info(TAG + 'getAuthAppList start');
|
||||
|
||||
switch (optType) {
|
||||
case CMModelOptType.CM_MODEL_OPT_APP_CRED:
|
||||
this.getAuthorizedAppList(uri, (errCode: CMModelErrorCode, appUidList: Array<string>) => {
|
||||
callback(errCode, appUidList);
|
||||
});
|
||||
break;
|
||||
case CMModelOptType.CM_MODEL_OPT_USER_CA:
|
||||
case CMModelOptType.CM_MODEL_OPT_SYSTEM_CA:
|
||||
case CMModelOptType.CM_MODEL_OPT_SYSTEM_CRED:
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_NOT_SUPPORT);
|
||||
break;
|
||||
default:
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_UNKNOWN_OPT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
setAppAuthPromise(optType: CMModelOptType, uri: string, appUid: string, status: boolean): Promise<void> {
|
||||
console.info(TAG + 'setAppAuth start');
|
||||
switch (optType) {
|
||||
case CMModelOptType.CM_MODEL_OPT_APP_CRED:
|
||||
return new Promise((resolve, reject) => {
|
||||
this.setAuthorizedAppStatus(uri, appUid, status, (errCode: CMModelErrorCode, data: string) => {
|
||||
if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) {
|
||||
resolve(void(data));
|
||||
} else {
|
||||
reject(errCode);
|
||||
}
|
||||
});
|
||||
});
|
||||
default:
|
||||
return new Promise((resolve, reject) => {
|
||||
reject(CMModelErrorCode.CM_MODEL_ERROR_UNKNOWN_OPT);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
setAppAuth(optType: CMModelOptType, uri: string, appUid: string, status: boolean, callback: Function): void {
|
||||
console.info(TAG + 'setAppAuth start');
|
||||
|
||||
switch (optType) {
|
||||
case CMModelOptType.CM_MODEL_OPT_APP_CRED:
|
||||
this.setAuthorizedAppStatus(uri, appUid, status, (errCode: CMModelErrorCode, data: string) => {
|
||||
callback(errCode, data);
|
||||
});
|
||||
break;
|
||||
case CMModelOptType.CM_MODEL_OPT_USER_CA:
|
||||
case CMModelOptType.CM_MODEL_OPT_SYSTEM_CA:
|
||||
case CMModelOptType.CM_MODEL_OPT_SYSTEM_CRED:
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_NOT_SUPPORT);
|
||||
break;
|
||||
default:
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_UNKNOWN_OPT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
installCertOrCred(optType: CMModelOptType, alias: string, data: Uint8Array, pwd: string, callback: Function): void {
|
||||
console.info(TAG + 'installCertOrCred start');
|
||||
switch (optType) {
|
||||
case CMModelOptType.CM_MODEL_OPT_USER_CA:
|
||||
this.installUserCertificate(data, alias, (errCode: CMModelErrorCode, uri: string) => {
|
||||
callback(errCode, uri);
|
||||
});
|
||||
break;
|
||||
case CMModelOptType.CM_MODEL_OPT_APP_CRED:
|
||||
this.installPublicCertificate(data, alias, pwd, (errCode: CMModelErrorCode) => {
|
||||
callback(errCode);
|
||||
});
|
||||
break;
|
||||
case CMModelOptType.CM_MODEL_OPT_SYSTEM_CRED:
|
||||
this.installSystemAppCertificate(data, alias, pwd, (errCode: CMModelErrorCode) => {
|
||||
callback(errCode);
|
||||
});
|
||||
break;
|
||||
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: Function): Promise<void> {
|
||||
console.info(TAG + 'getSystemTrustedCertificateList start');
|
||||
try {
|
||||
let subjectNameCN: string = '';
|
||||
let result = await CertManager.getSystemTrustedCertificateList();
|
||||
let certList: CertAbstractVo[] = [];
|
||||
let regex: RegExp = new RegExp('(?<=CN=).*?(?=,)', 'g');
|
||||
if (result.certList !== undefined) {
|
||||
for (let i = 0; i < result.certList.length; i++) {
|
||||
if (result.certList[i].subjectName.length !== 0) {
|
||||
let temp = result.certList[i].subjectName.match(regex);
|
||||
subjectNameCN = (temp !== undefined) ? String(temp) : '';
|
||||
console.info('subjectNameCN is:' + subjectNameCN);
|
||||
}
|
||||
certList.push(new CertAbstractVo(String(result.certList[i].uri), String(result.certList[i].certAlias),
|
||||
Boolean(result.certList[i].status), String(result.certList[i].subjectName), String(subjectNameCN)));
|
||||
}
|
||||
console.info(TAG + 'getSystemTrustedCertificateList end');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS, certList);
|
||||
} else {
|
||||
console.error(TAG + 'getSystemTrustedCertificateList failed, undefined');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_FAILED, undefined);
|
||||
}
|
||||
} catch (err) {
|
||||
let e: BusinessError = err as BusinessError;
|
||||
console.error(TAG + 'getSystemTrustedCertificateList err, message: ' + e.message + ', code: ' + e.code);
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION, undefined);
|
||||
}
|
||||
}
|
||||
|
||||
private async getSystemTrustedCertificate(certUri: string, callback: Function): Promise<void> {
|
||||
console.info(TAG + 'getSystemTrustedCertificate start');
|
||||
try {
|
||||
let result = await CertManager.getSystemTrustedCertificate(certUri);
|
||||
let subjectNameMap: Map<string, string> = new Map();
|
||||
let issuerNameMap: Map<string, string> = new Map();
|
||||
let dateMap: Map<string, string> = new Map();
|
||||
let regex1: RegExp = new RegExp('(?<=CN=).*?(?=,)', 'g');
|
||||
let regex2: RegExp = new RegExp('(?<=OU=).*?(?=,)', 'g');
|
||||
let regex3: RegExp = new RegExp('(?<=O=).*', 'g');
|
||||
|
||||
if (result.certInfo !== undefined) {
|
||||
if (result.certInfo.subjectName.length !== 0) {
|
||||
let subjectNameCN = result.certInfo.subjectName.match(regex1);
|
||||
console.info('subjectNameCN is:' + subjectNameCN);
|
||||
let subjectNameOU = result.certInfo.subjectName.match(regex2);
|
||||
console.info('subjectNameOU is:' + subjectNameOU);
|
||||
let subjectNameO = result.certInfo.subjectName.match(regex3);
|
||||
console.info('subjectNameO is:' + subjectNameO);
|
||||
subjectNameMap.set('常用名称:', String(subjectNameCN));
|
||||
subjectNameMap.set('组织:', String(subjectNameO));
|
||||
subjectNameMap.set('组织单位:', String(subjectNameOU));
|
||||
subjectNameMap.set('序列号:', String(result.certInfo.serial));
|
||||
}
|
||||
if (result.certInfo.issuerName.length !== 0) {
|
||||
let issuerNameCN = result.certInfo.issuerName.match(regex1);
|
||||
console.info('issuerNameCN is:' + issuerNameCN);
|
||||
let issuerNameOU = result.certInfo.issuerName.match(regex2);
|
||||
console.info('issuerNameOU is:' + issuerNameOU);
|
||||
let issuerNameO = result.certInfo.issuerName.match(regex3);
|
||||
console.info('issuerNameO is:' + issuerNameO);
|
||||
issuerNameMap.set('常用名称:', String(issuerNameCN));
|
||||
issuerNameMap.set('组织:', String(issuerNameO));
|
||||
issuerNameMap.set('组织单位:', String(issuerNameOU));
|
||||
}
|
||||
dateMap.set('颁发时间:', String(result.certInfo.notBefore));
|
||||
dateMap.set('有效期至:', String(result.certInfo.notAfter));
|
||||
|
||||
let certData: Uint8Array = result.certInfo.cert;
|
||||
let certInfo = new CertInfoVo(String(result.certInfo.uri), String(result.certInfo.certAlias),
|
||||
Boolean(result.certInfo.status), String(result.certInfo.issuerName), String(result.certInfo.subjectName),
|
||||
String(result.certInfo.serial), String(result.certInfo.notBefore),
|
||||
String(result.certInfo.notAfter), String(result.certInfo.fingerprintSha256),
|
||||
certData, subjectNameMap, issuerNameMap, dateMap);
|
||||
console.info(TAG + 'getSystemTrustedCertificate end');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS, certInfo);
|
||||
} else {
|
||||
console.error(TAG + 'getSystemTrustedCertificate failed, undefined');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_FAILED, undefined);
|
||||
}
|
||||
} catch (err) {
|
||||
let e: BusinessError = err as BusinessError;
|
||||
console.error(TAG + 'getSystemTrustedCertificate err, message: ' + e.message + ', code: ' + e.code);
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION, undefined);
|
||||
}
|
||||
}
|
||||
|
||||
private async getAllUserTrustedCertificates(callback: Function): Promise<void> {
|
||||
console.info(TAG + 'getAllUserTrustedCertificates start');
|
||||
try {
|
||||
let subjectNameCN: string = '';
|
||||
let result = await CertManager.getAllUserTrustedCertificates();
|
||||
let certList: CertAbstractVo[] = [];
|
||||
let regex: RegExp = new RegExp('(?<=CN=).*?(?=,)', 'g');
|
||||
if (result.certList !== undefined) {
|
||||
for (let i = 0; i < result.certList.length; i++) {
|
||||
if (result.certList[i].subjectName.length !== 0) {
|
||||
let temp = result.certList[i].subjectName.match(regex);
|
||||
subjectNameCN = (temp !== undefined) ? String(temp) : '';
|
||||
console.info('subjectNameCN is:' + subjectNameCN);
|
||||
}
|
||||
if (String(result.certList[i].uri).indexOf('u=0;') === -1) {
|
||||
certList.push(new CertAbstractVo(String(result.certList[i].uri), String(result.certList[i].certAlias),
|
||||
Boolean(result.certList[i].status), String(result.certList[i].subjectName), String(subjectNameCN)));
|
||||
}
|
||||
}
|
||||
console.info(TAG + 'getAllUserTrustedCertificates end');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS, certList);
|
||||
} else {
|
||||
console.error(TAG + 'getAllUserTrustedCertificates failed, undefined');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_FAILED, undefined);
|
||||
}
|
||||
} catch (err) {
|
||||
let e: BusinessError = err as BusinessError;
|
||||
console.error(TAG + 'getAllUserTrustedCertificates err, message: ' + e.message + ', code: ' + e.code);
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
private async getUserTrustedCertificate(certUri: string, callback: Function): Promise<void> {
|
||||
console.info(TAG + 'getUserTrustedCertificate start');
|
||||
try {
|
||||
let result = await CertManager.getUserTrustedCertificate(certUri);
|
||||
let subjectNameMap: Map<string, string> = new Map();
|
||||
let issuerNameMap: Map<string, string> = new Map();
|
||||
let dateMap: Map<string, string> = new Map();
|
||||
let regex1: RegExp = new RegExp('(?<=CN=).*?(?=,)', 'g');
|
||||
let regex2: RegExp = new RegExp('(?<=OU=).*?(?=,)', 'g');
|
||||
let regex3: RegExp = new RegExp('(?<=O=).*', 'g');
|
||||
|
||||
if (result.certInfo !== undefined) {
|
||||
if (result.certInfo.subjectName.length !== 0) {
|
||||
let subjectNameCN = result.certInfo.subjectName.match(regex1);
|
||||
console.info('subjectNameCN is:' + subjectNameCN);
|
||||
let subjectNameOU = result.certInfo.subjectName.match(regex2);
|
||||
console.info('subjectNameOU is:' + subjectNameOU);
|
||||
let subjectNameO = result.certInfo.subjectName.match(regex3);
|
||||
console.info('SubjectNameO is:' + subjectNameO);
|
||||
subjectNameMap.set('常用名称:', String(subjectNameCN));
|
||||
subjectNameMap.set('组织:', String(subjectNameO));
|
||||
subjectNameMap.set('组织单位:', String(subjectNameOU));
|
||||
subjectNameMap.set('序列号:', String(result.certInfo.serial));
|
||||
}
|
||||
if (result.certInfo.issuerName.length !== 0) {
|
||||
let issuerNameCN = result.certInfo.issuerName.match(regex1);
|
||||
console.info('issuerNameCN is:' + issuerNameCN);
|
||||
let issuerNameOU = result.certInfo.issuerName.match(regex2);
|
||||
console.info('issuerNameOU is:' + issuerNameOU);
|
||||
let issuerNameO = result.certInfo.issuerName.match(regex3);
|
||||
console.info('issuerNameO is:' + issuerNameO);
|
||||
issuerNameMap.set('常用名称:', String(issuerNameCN));
|
||||
issuerNameMap.set('组织:', String(issuerNameO));
|
||||
issuerNameMap.set('组织单位:', String(issuerNameOU));
|
||||
}
|
||||
dateMap.set('颁发时间:', String(result.certInfo.notBefore));
|
||||
dateMap.set('有效期至:', String(result.certInfo.notAfter));
|
||||
let certData: Uint8Array = result.certInfo.cert;
|
||||
let certInfo = new CertInfoVo(String(result.certInfo.uri), String(result.certInfo.certAlias),
|
||||
Boolean(result.certInfo.status), String(result.certInfo.issuerName), String(result.certInfo.subjectName),
|
||||
String(result.certInfo.serial), String(result.certInfo.notBefore),
|
||||
String(result.certInfo.notAfter), String(result.certInfo.fingerprintSha256),
|
||||
certData, subjectNameMap, issuerNameMap, dateMap);
|
||||
console.info(TAG + 'getUserTrustedCertificate end');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS, certInfo);
|
||||
} else {
|
||||
console.error(TAG + 'getUserTrustedCertificate failed, undefined');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_FAILED, undefined);
|
||||
}
|
||||
} catch (err) {
|
||||
let e: BusinessError = err as BusinessError;
|
||||
console.error(TAG + 'getUserTrustedCertificate err, message: ' + e.message + ', code: ' + e.code);
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION, undefined);
|
||||
}
|
||||
}
|
||||
|
||||
private async deleteUserTrustedCertificate(certUri: string, callback: Function): Promise<void> {
|
||||
console.info(TAG + 'deleteUserTrustedCertificate start');
|
||||
try {
|
||||
await CertManager.uninstallUserTrustedCertificate(certUri);
|
||||
console.info(TAG + 'deleteUserTrustedCertificate end');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS);
|
||||
} catch (err) {
|
||||
let e: BusinessError = err as BusinessError;
|
||||
console.error(TAG + 'deleteUserTrustedCertificate err, message: ' + e.message + ', code: ' + e.code);
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
private async setCertificateStatus(certUri: string, store: number,
|
||||
status: boolean, callback: Function): Promise<void> {
|
||||
console.info(TAG + 'setCertificateStatus start');
|
||||
try {
|
||||
await CertManager.setCertificateStatus(certUri, store, status);
|
||||
console.info(TAG + 'setCertificateStatus end');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS);
|
||||
} catch (err) {
|
||||
let e: BusinessError = err as BusinessError;
|
||||
console.error(TAG + 'setCertificateStatus failed with err, message: ' + e.message + ', code: ' + e.code);
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
private async getAppCredList(callback: Function): Promise<void> {
|
||||
console.info(TAG + 'getAppCredList start');
|
||||
try {
|
||||
let result = await CertManager.getAllPublicCertificates();
|
||||
let credList: CredentialAbstractVo[] = [];
|
||||
if (result.credentialList !== undefined) {
|
||||
for (let i = 0; i < result.credentialList.length; i++) {
|
||||
credList.push(new CredentialAbstractVo(String(result.credentialList[i].type),
|
||||
String(result.credentialList[i].alias), String(result.credentialList[i].keyUri)));
|
||||
}
|
||||
console.info(TAG + 'getAppCredList end');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS, credList);
|
||||
} else {
|
||||
console.error(TAG + 'getAppCredList failed, undefined.');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_FAILED, undefined);
|
||||
}
|
||||
} catch (err) {
|
||||
let e: BusinessError = err as BusinessError;
|
||||
console.error(TAG + 'getAppCredList failed with err, message: ' + e.message + ', code: ' + e.code);
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
private async getSystemCredList(callback: Function): Promise<void> {
|
||||
console.info(TAG + 'getSystemList start');
|
||||
try {
|
||||
let result = await CertManager.getAllSystemAppCertificates();
|
||||
let credList: CredentialAbstractVo[] = [];
|
||||
if (result.credentialList !== undefined) {
|
||||
for (let i = 0; i < result.credentialList.length; i++) {
|
||||
credList.push(new CredentialAbstractVo(String(result.credentialList[i].type),
|
||||
String(result.credentialList[i].alias), String(result.credentialList[i].keyUri)));
|
||||
}
|
||||
console.info(TAG + 'getSystemCredList end');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS, credList);
|
||||
} else {
|
||||
console.error(TAG + 'getSystemCredList failed, undefined.');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_FAILED, undefined)
|
||||
}
|
||||
} catch (err) {
|
||||
let e: BusinessError = err as BusinessError;
|
||||
console.error(TAG, 'getSystemCredList failed with err, message: ' + e.message + ', code: ' + e.code)
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION)
|
||||
}
|
||||
}
|
||||
|
||||
private async getAppCredential(certUri: string, callback: Function): Promise<void> {
|
||||
console.info(TAG + 'getAppCredential start');
|
||||
try {
|
||||
let result = await CertManager.getPublicCertificate(certUri);
|
||||
if (result.credential !== undefined) {
|
||||
let certData: Uint8Array = result.credential.credData;
|
||||
let credInfo = new CredentialVo(String(result.credential.type), String(result.credential.alias),
|
||||
String(result.credential.keyUri), Number(result.credential.certNum),
|
||||
Number(result.credential.keyNum), certData);
|
||||
console.info(TAG + 'getAppCredential end');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS, credInfo);
|
||||
} else {
|
||||
console.error(TAG + 'getAppCredential failed, undefined');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_FAILED, undefined);
|
||||
}
|
||||
} catch (err) {
|
||||
let e: BusinessError = err as BusinessError;
|
||||
console.error(TAG + 'getAppCredential failed with err, message: ' + e.message + ', code: ' + e.code);
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION, undefined);
|
||||
}
|
||||
}
|
||||
|
||||
private async getSystemCredential(certUri: string, callback: Function): Promise<void> {
|
||||
console.info(TAG + 'getSystemCredential start');
|
||||
try {
|
||||
let result = await CertManager.getSystemAppCertificate(certUri);
|
||||
if (result.credential !== undefined) {
|
||||
let certData: Uint8Array = result.credential.credData;
|
||||
let credInfo = new CredentialVo(String(result.credential.type), String(result.credential.alias),
|
||||
String(result.credential.keyUri), Number(result.credential.certNum),
|
||||
Number(result.credential.keyNum), certData);
|
||||
console.info(TAG + 'getSystemCredential end');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS, credInfo);
|
||||
} else {
|
||||
console.error(TAG + 'getSystemCredential failed, undefined');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_FAILED, undefined);
|
||||
}
|
||||
} catch (err) {
|
||||
let e: BusinessError = err as BusinessError;
|
||||
console.error(TAG + 'getSystemCredential failed with err, message: ' + e.message + ', code: ' + e.code);
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION, undefined);
|
||||
}
|
||||
}
|
||||
|
||||
private async deleteAppCredential(certUri: string, callback: Function): Promise<void> {
|
||||
console.info(TAG + 'deleteAppCredential start');
|
||||
try {
|
||||
await CertManager.uninstallPublicCertificate(certUri);
|
||||
console.info(TAG + 'deleteAppCredential end');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS);
|
||||
} catch (err) {
|
||||
let e: BusinessError = err as BusinessError;
|
||||
console.error(TAG + 'deleteAppCredential failed with err, message: ' + e.message + ', code: ' + e.code);
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
private async deleteSystemCredential(certUri: string, callback: Function): Promise<void> {
|
||||
console.info(TAG, 'deleteSystemCredential start');
|
||||
try {
|
||||
await CertManager.uninstallSystemAppCertificate(certUri);
|
||||
console.info(TAG, 'deleteSystemCredential end');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS);
|
||||
} catch (err) {
|
||||
let e: BusinessError = err as BusinessError;
|
||||
console.error(TAG + 'deleteSystemCredential failed with err, message: ' + e.message + ', code: ' + e.code);
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
private async delAllUserCertificate(callback: Function): Promise<void> {
|
||||
console.info(TAG + 'delAllUserCertificate start');
|
||||
try {
|
||||
await CertManager.uninstallAllUserTrustedCertificate();
|
||||
console.info(TAG + 'delAllUserCertificate end');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS);
|
||||
} catch (err) {
|
||||
let e: BusinessError = err as BusinessError;
|
||||
console.error(TAG + 'delAllUserCertificate failed with err, message: ' + e.message + ', code: ' + e.code);
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
private async delAllAppCredential(callback: Function): Promise<void> {
|
||||
console.info(TAG + 'delAllAppCredential start');
|
||||
try {
|
||||
await CertManager.uninstallAllAppCertificate();
|
||||
console.info(TAG + 'delAllAppCredential end');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS);
|
||||
} catch (err) {
|
||||
let e: BusinessError = err as BusinessError;
|
||||
console.error(TAG + 'delAllAppCredential failed with err, message: ' + e.message + ', code: ' + e.code);
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
private async getAuthorizedAppList(uri: string, callback: Function): Promise<void> {
|
||||
console.info(TAG + 'getAuthorizedAppList start');
|
||||
try {
|
||||
let result = await CertManager.getAuthorizedAppList(uri);
|
||||
console.info(TAG + 'getAuthorizedAppList end');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS, result.appUidList);
|
||||
} catch (err) {
|
||||
let e: BusinessError = err as BusinessError;
|
||||
console.error(TAG + 'getAuthorizedAppList failed with err, message: ' + e.message + ', code: ' + e.code);
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION, undefined);
|
||||
}
|
||||
}
|
||||
|
||||
private async setAuthorizedAppStatus(
|
||||
uri: string,
|
||||
appUid: string,
|
||||
status: boolean,
|
||||
callback: Function
|
||||
): Promise<void> {
|
||||
console.info(TAG + 'setAuthorizedAppStatus start');
|
||||
try {
|
||||
if (status) {
|
||||
let result = await CertManager.grantPublicCertificate(uri, appUid);
|
||||
console.info(TAG + 'setAuthorizedAppStatus true end');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS, result.uri);
|
||||
} else {
|
||||
console.info(TAG + 'appId:' + appUid + 'uri:' + uri);
|
||||
await CertManager.removeGrantedPublicCertificate(uri, appUid);
|
||||
console.info(TAG + 'setAuthorizedAppStatus false end');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS);
|
||||
}
|
||||
} catch (err) {
|
||||
let e: BusinessError = err as BusinessError;
|
||||
console.error(TAG + 'setAuthorizedAppStatus failed with err, message: ' + e.message + ', code: ' + e.code);
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
private async installUserCertificate(data: Uint8Array, alias: string, callback: Function): Promise<void> {
|
||||
console.info(TAG + 'installUserCertificate start');
|
||||
if ((data === undefined) || (data.length === 0)) {
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_INCORRECT_FORMAT);
|
||||
console.error(TAG + 'installUserCertificate data is empty.');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
let result = await CertManager.installUserTrustedCertificate({
|
||||
inData: data,
|
||||
alias: alias
|
||||
});
|
||||
console.info(TAG + 'installUserCertificate end');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS, result.uri);
|
||||
} catch (err) {
|
||||
let e: BusinessError = err as BusinessError;
|
||||
if (e.code === CertManager.CMErrorCode.CM_ERROR_INCORRECT_FORMAT) {
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_INCORRECT_FORMAT)
|
||||
} else if (e.code === CertManager.CMErrorCode.CM_ERROR_MAX_CERT_COUNT_REACHED) {
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_MAX_QUANTITY_REACHED)
|
||||
} else if (e.code === CertManager.CMErrorCode.CM_ERROR_ALIAS_LENGTH_REACHED_LIMIT) {
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_ALIAS_LENGTH_REACHED_LIMIT)
|
||||
} else {
|
||||
console.error(TAG + 'installUserCertificate failed with err, message: ' + e.message + ', code: ' + e.code);
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async installPublicCertificate(
|
||||
data: Uint8Array,
|
||||
alias: string,
|
||||
pwd: string,
|
||||
callback: Function
|
||||
): Promise<void> {
|
||||
console.info(TAG + 'installPublicCertificate start');
|
||||
try {
|
||||
await CertManager.installPublicCertificate(data, pwd, alias);
|
||||
console.info(TAG + 'installPublicCertificate end');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS);
|
||||
} catch (err) {
|
||||
let e: BusinessError = err as BusinessError;
|
||||
if (e.code === CertManager.CMErrorCode.CM_ERROR_INCORRECT_FORMAT) {
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_INCORRECT_FORMAT)
|
||||
} else if (e.code === CertManager.CMErrorCode.CM_ERROR_MAX_CERT_COUNT_REACHED) {
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_MAX_QUANTITY_REACHED)
|
||||
} else if (e.code === CertManager.CMErrorCode.CM_ERROR_ALIAS_LENGTH_REACHED_LIMIT) {
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_ALIAS_LENGTH_REACHED_LIMIT)
|
||||
} else if (e.code === CertManager.CMErrorCode.CM_ERROR_PASSWORD_IS_ERR) {
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_PASSWORD_ERR);
|
||||
} else {
|
||||
console.error(TAG + 'installPublicCertificate failed with err, message: ' + e.message + ', code: ' + e.code);
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async installSystemAppCertificate(
|
||||
data: Uint8Array,
|
||||
alias: string,
|
||||
pwd: string,
|
||||
callback: Function
|
||||
): Promise<void> {
|
||||
console.info(TAG, 'installSystemAppCertificate start');
|
||||
try {
|
||||
await CertManager.installSystemAppCertificate(data, pwd, alias);
|
||||
console.info(TAG + 'installSystemAppCertificate end');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS);
|
||||
} catch (err) {
|
||||
let e: BusinessError = err as BusinessError;
|
||||
if (e.code === CertManager.CMErrorCode.CM_ERROR_INCORRECT_FORMAT) {
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_INCORRECT_FORMAT);
|
||||
} else if (e.code === CertManager.CMErrorCode.CM_ERROR_MAX_CERT_COUNT_REACHED) {
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_MAX_QUANTITY_REACHED);
|
||||
} else if (e.code === CertManager.CMErrorCode.CM_ERROR_ALIAS_LENGTH_REACHED_LIMIT) {
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_ALIAS_LENGTH_REACHED_LIMIT);
|
||||
} else if (e.code === CertManager.CMErrorCode.CM_ERROR_PASSWORD_IS_ERR) {
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_PASSWORD_ERR);
|
||||
} else {
|
||||
console.error(TAG + 'installSystemAppCertificate failed with err, message: ' + e.message + ', code: ' + e.code);
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let certMangerModel = new CertMangerModel();
|
||||
|
||||
export default certMangerModel as CertMangerModel;
|
||||
@@ -1,85 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import userAuth from '@ohos.userIAM.userAuth';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
|
||||
export class CheckUserAuthModel {
|
||||
public isAuthTypeSupported(authType: userAuth.UserAuthType): boolean {
|
||||
try {
|
||||
userAuth.getAvailableStatus(authType, userAuth.AuthTrustLevel.ATL1);
|
||||
console.info('[CM&CheckUserAuthModel]: ' + 'userAuthType' + authType + 'is supported');
|
||||
return true;
|
||||
} catch (error) {
|
||||
let err: BusinessError = error as BusinessError;
|
||||
console.error(`[CM&CheckUserAuthModel]: userAuthType ${authType} is not supported, message is ${err?.message}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public auth(titleStr: string, callback: (authResult: boolean) => void): void {
|
||||
let fingerPrint: boolean = this.isAuthTypeSupported(userAuth.UserAuthType.FINGERPRINT);
|
||||
let pin: boolean = this.isAuthTypeSupported(userAuth.UserAuthType.PIN);
|
||||
let authTypeArray = [userAuth.UserAuthType.FINGERPRINT];
|
||||
if (fingerPrint) {
|
||||
authTypeArray = [userAuth.UserAuthType.FINGERPRINT];
|
||||
if (pin) {
|
||||
authTypeArray = [userAuth.UserAuthType.FINGERPRINT, userAuth.UserAuthType.PIN];
|
||||
}
|
||||
} else if (pin) {
|
||||
authTypeArray = [userAuth.UserAuthType.PIN];
|
||||
} else {
|
||||
/* The user does not set identity authentication. */
|
||||
callback(true);
|
||||
return;
|
||||
}
|
||||
|
||||
const authParam: userAuth.AuthParam = {
|
||||
challenge: new Uint8Array([49, 49, 49, 49, 49, 49]),
|
||||
authType: authTypeArray,
|
||||
authTrustLevel: userAuth.AuthTrustLevel.ATL1
|
||||
}
|
||||
const widgetParam: userAuth.WidgetParam = {
|
||||
title: titleStr
|
||||
};
|
||||
|
||||
try {
|
||||
let userAuthInstance = userAuth.getUserAuthInstance(authParam, widgetParam);
|
||||
console.info('[CM&CheckUserAuthModel]: get userAuth instance success');
|
||||
userAuthInstance.start();
|
||||
|
||||
userAuthInstance.on('result', {
|
||||
onResult(result) {
|
||||
if (result.result === userAuth.UserAuthResultCode.SUCCESS) {
|
||||
callback(true);
|
||||
} else if (result.result === userAuth.UserAuthResultCode.CANCELED) {
|
||||
/* User cancels authentication. */
|
||||
callback(false);
|
||||
} else {
|
||||
/* User authentication failed. */
|
||||
callback(false);
|
||||
}
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
let err: BusinessError = error as BusinessError;
|
||||
console.error(`[CM&CheckUserAuthModel]: auth catch error. code is ${err?.code}, message is ${err?.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let checkUserAuthModel = new CheckUserAuthModel();
|
||||
|
||||
export default checkUserAuthModel as CheckUserAuthModel;
|
||||
@@ -1,64 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import fileUri from '@ohos.file.fileuri';
|
||||
import fs from '@ohos.file.fs';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
|
||||
export class FileIoModel {
|
||||
getMediaFileData(mediaUri: string, callback: Function): void {
|
||||
console.info('CertManager FA getMediaFile start');
|
||||
let file: fs.File | undefined = undefined;
|
||||
try {
|
||||
file = fs.openSync(mediaUri, fs.OpenMode.READ_ONLY);
|
||||
let stat = fs.statSync(file.fd);
|
||||
let buf = new ArrayBuffer(Number(stat.size));
|
||||
let num = fs.readSync(file.fd, buf);
|
||||
console.info('CertManager FA getMediaFile success');
|
||||
callback(new Uint8Array(buf));
|
||||
} catch (err) {
|
||||
let e: BusinessError = err as BusinessError;
|
||||
console.error('CertManager FA getMediaFileData failed with err, message: ' + e.message + ', code: ' + e.code);
|
||||
callback(undefined);
|
||||
} finally {
|
||||
try {
|
||||
if (file !== undefined && file !== null) {
|
||||
fs.closeSync(file.fd);
|
||||
}
|
||||
} catch (err) {
|
||||
let e: BusinessError = err as BusinessError;
|
||||
console.error('CertManager FA close io stream failed with err, message: ' + e.message + ', code: ' + e.code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getMediaFileSuffix(mediaUri: string, callback: Function): void {
|
||||
try {
|
||||
console.info('CertManager FA getMediaFileSuffix start');
|
||||
let uri = new fileUri.FileUri(mediaUri);
|
||||
let suffix = uri.name.substring(uri.name.lastIndexOf('.') + 1);
|
||||
let suffixLowerCase = suffix.toLowerCase();
|
||||
callback(suffixLowerCase);
|
||||
} catch (err) {
|
||||
let e: BusinessError = err as BusinessError;
|
||||
console.error('CertManager FA getMediaFileSuffix failed with err, message: ' + e.message + ', code: ' + e.code);
|
||||
callback(undefined);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let fileIoModel = new FileIoModel();
|
||||
|
||||
export default fileIoModel as FileIoModel;
|
||||
@@ -1,58 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import window from '@ohos.window';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
import { GlobalContext } from '../common/GlobalContext';
|
||||
import type UIAbilityContext from 'application/UIAbilityContext';
|
||||
import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession';
|
||||
|
||||
const TAG: string = 'PreventScreenshotsModel';
|
||||
|
||||
export default class PreventScreenshotsModel {
|
||||
private static sInstance: PreventScreenshotsModel;
|
||||
|
||||
public static getInstance(): PreventScreenshotsModel {
|
||||
if (PreventScreenshotsModel.sInstance == null) {
|
||||
PreventScreenshotsModel.sInstance = new PreventScreenshotsModel();
|
||||
}
|
||||
return PreventScreenshotsModel.sInstance;
|
||||
}
|
||||
|
||||
PreventScreenshots(flag: boolean, session: UIExtensionContentSession | undefined) {
|
||||
let isPrivacyMode: boolean = flag;
|
||||
if (session !== undefined) {
|
||||
session.setWindowPrivacyMode(isPrivacyMode);
|
||||
return;
|
||||
}
|
||||
|
||||
let windowClass: window.Window | undefined = undefined;
|
||||
let context: UIAbilityContext = GlobalContext.getContext().getCmContext();
|
||||
if (context === undefined) {
|
||||
console.error(TAG, 'context is undefined!');
|
||||
return;
|
||||
}
|
||||
|
||||
window.getLastWindow(context).then((window) => {
|
||||
windowClass = window;
|
||||
console.info(TAG,'Success in obtaining the top window data');
|
||||
windowClass.setWindowPrivacyMode(isPrivacyMode).catch((err: BusinessError) => {
|
||||
console.error(TAG, 'setWindowPrivacyMode failed: ' + JSON.stringify(err));
|
||||
})
|
||||
}).catch((err: BusinessError) => {
|
||||
console.info(TAG + 'getLastWindow failed: ' + JSON.stringify(err));
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,212 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { CustomContentDialog, AlertDialog } from '@ohos.arkui.advanced.Dialog';
|
||||
import { CMModelErrorCode, CMModelOptType } from '../model/CertMangerModel';
|
||||
import checkUserAuthModel from '../model/CheckUserAuthModel';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession';
|
||||
import certManagerModel from '../model/CertMangerModel';
|
||||
import util from '@ohos.util';
|
||||
|
||||
/* instrument ignore file */
|
||||
|
||||
const TAG = 'CertificateInstallPage';
|
||||
let storage = LocalStorage.getShared();
|
||||
|
||||
@Entry(storage)
|
||||
@Component
|
||||
struct CertificateInstallPage {
|
||||
@State installFailedDialogMessage: ResourceStr = '';
|
||||
@State callerName: string = '';
|
||||
@State resultCode: number = CMModelErrorCode.CM_MODEL_ERROR_FAILED;
|
||||
@State successUri: string = '';
|
||||
;
|
||||
private session: UIExtensionContentSession =
|
||||
storage?.get<UIExtensionContentSession>('session') as UIExtensionContentSession;
|
||||
private want: Want = storage?.get<Want>('want') as Want;
|
||||
|
||||
private context: Context = getContext(this);
|
||||
|
||||
installFailedDialog: CustomDialogController = new CustomDialogController({
|
||||
alignment: DialogAlignment.Center,
|
||||
showInSubWindow: true,
|
||||
cancel: () => {
|
||||
this.session?.terminateSelfWithResult({
|
||||
resultCode: this.resultCode
|
||||
});
|
||||
},
|
||||
builder: AlertDialog({
|
||||
primaryTitle: $r('app.string.cert_install_failed'),
|
||||
content: this.installFailedDialogMessage,
|
||||
primaryButton: {
|
||||
value: $r('app.string.OK'),
|
||||
action: () => {
|
||||
this.session?.terminateSelfWithResult({
|
||||
resultCode: this.resultCode
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
installSuccessDialog: CustomDialogController = new CustomDialogController({
|
||||
alignment: DialogAlignment.Center,
|
||||
showInSubWindow: true,
|
||||
cancel: () => {
|
||||
this.session?.sendData({'uri': this.successUri});
|
||||
},
|
||||
builder: AlertDialog({
|
||||
primaryTitle: $r('app.string.cert_install_success'),
|
||||
content: $r('app.string.cert_install_success_tip'),
|
||||
primaryButton: {
|
||||
value: $r('app.string.OK'),
|
||||
action: () => {
|
||||
this.session?.sendData({'uri': this.successUri});
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
rootCertificateDialog: CustomDialogController = new CustomDialogController({
|
||||
alignment: DialogAlignment.Center,
|
||||
showInSubWindow: false,
|
||||
cancel: () => {
|
||||
this.session?.terminateSelf();
|
||||
},
|
||||
builder: AlertDialog({
|
||||
primaryTitle: $r('app.string.cert_install_tip', this.callerName),
|
||||
content: $r('app.string.cert_install_warning'),
|
||||
primaryButton: {
|
||||
value: $r('app.string.root_certificate_cancel'),
|
||||
action: () => {
|
||||
console.info(TAG, 'USER_CA_STATUS_CONFIRM cancel');
|
||||
this.session?.terminateSelf();
|
||||
}
|
||||
},
|
||||
secondaryButton: {
|
||||
value: $r('app.string.root_certificate_continue'),
|
||||
action: () => {
|
||||
console.info(TAG, 'USER_CA_STATUS_CONFIRM confirm');
|
||||
this.checkUserAuth();
|
||||
}
|
||||
}
|
||||
}),
|
||||
})
|
||||
|
||||
aboutToAppear(): void {
|
||||
let isGranted = this.getCallerName();
|
||||
if (!isGranted) {
|
||||
this.session?.terminateSelf();
|
||||
return;
|
||||
}
|
||||
this.rootCertificateDialog.open();
|
||||
}
|
||||
|
||||
build() {
|
||||
}
|
||||
|
||||
private getCallerName(): boolean {
|
||||
if (this.want === undefined || this.want === null) {
|
||||
console.error(TAG, 'initData, want is undefined');
|
||||
return false;
|
||||
}
|
||||
let parameters = this.want.parameters;
|
||||
if (parameters === undefined || parameters === null) {
|
||||
console.error(TAG, 'initData, parameters is undefined');
|
||||
return false;
|
||||
}
|
||||
let callerName = parameters['bundleName'];
|
||||
if (callerName === undefined || callerName === null) {
|
||||
console.error(TAG, 'getCallerName, callerName is undefined');
|
||||
return false;
|
||||
}
|
||||
this.callerName = 'callerName as string';
|
||||
return true;
|
||||
}
|
||||
|
||||
private handleInstallResult(resultCode: CMModelErrorCode, uri: string) {
|
||||
if (resultCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) {
|
||||
this.successUri = uri;
|
||||
this.installSuccessDialog.open();
|
||||
} else if (resultCode === CMModelErrorCode.CM_MODEL_ERROR_INCORRECT_FORMAT) {
|
||||
this.resultCode = CMModelErrorCode.CM_MODEL_ERROR_INCORRECT_FORMAT;
|
||||
this.installFailedDialogMessage = $r('app.string.Install_ERROR_INCORRECT_FORMAT');
|
||||
this.installFailedDialog.open();
|
||||
} else if (resultCode === CMModelErrorCode.CM_MODEL_ERROR_MAX_QUANTITY_REACHED) {
|
||||
this.resultCode = CMModelErrorCode.CM_MODEL_ERROR_MAX_QUANTITY_REACHED;
|
||||
this.installFailedDialogMessage = $r('app.string.Install_Error_MAX_QUANTITY_REACHED');
|
||||
this.installFailedDialog.open();
|
||||
} else {
|
||||
console.debug(TAG, `result code ${resultCode}, need not show result`);
|
||||
this.session?.terminateSelfWithResult({
|
||||
resultCode: resultCode
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
checkUserAuth() {
|
||||
let titleStr = this.context?.resourceManager.getStringSync($r('app.string.Identity_Authentication'));
|
||||
checkUserAuthModel.auth(titleStr, (authResult: boolean) => {
|
||||
if (!authResult) {
|
||||
console.warn(TAG, 'userAuth cancel!');
|
||||
this.session?.terminateSelf();
|
||||
return;
|
||||
}
|
||||
console.info(TAG, 'userAuth success!');
|
||||
this.installCaCertificate();
|
||||
})
|
||||
}
|
||||
|
||||
private async getCertificateData(parameters: Record<string, Object>): Promise<Uint8Array | undefined> {
|
||||
return new Promise<Uint8Array | undefined>(resolve => {
|
||||
let certificateDataObj = parameters['cert'];
|
||||
if (certificateDataObj === undefined || certificateDataObj === null) {
|
||||
console.error(TAG, 'getCertificateData, certificate data is undefined');
|
||||
return resolve(undefined);
|
||||
}
|
||||
new util.Base64Helper().decode(certificateDataObj as string).then((value) => {
|
||||
return resolve(value);
|
||||
}).catch((error: BusinessError) => {
|
||||
console.error(TAG, `decode certificate data err: ${error?.code}, msg: ${error?.message}`);
|
||||
return resolve(undefined);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private installCaCertificate(): void {
|
||||
if (this.want === undefined || this.want === null) {
|
||||
console.error(TAG, 'initData, want is undefined');
|
||||
return;
|
||||
}
|
||||
let parameters = this.want.parameters;
|
||||
if (parameters === undefined || parameters === null) {
|
||||
console.error(TAG, 'initData, parameters is undefined');
|
||||
return;
|
||||
}
|
||||
this.getCertificateData(parameters).then(data => {
|
||||
if (data === undefined) {
|
||||
console.error(TAG, 'installCaCertificate, certificate data is undefined');
|
||||
this.session?.terminateSelf();
|
||||
return;
|
||||
}
|
||||
certManagerModel.installCertOrCred(CMModelOptType.CM_MODEL_OPT_USER_CA, '', data,
|
||||
'', (resultCode: CMModelErrorCode, uri: string) => {
|
||||
console.info(TAG, `installCertOrCred result: ${resultCode}`);
|
||||
this.handleInstallResult(resultCode, uri);
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,861 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { WidthPercent, ConfigValue } from '../common/util/ConfigData';
|
||||
import HeadComponent from '../common/component/headComponent';
|
||||
import CmShowAppCredPresenter from '../presenter/CmShowAppCredPresenter';
|
||||
import CMFaPresenter from '../presenter/CmFaPresenter';
|
||||
import { GlobalContext } from '../common/GlobalContext';
|
||||
import { CredentialAbstractVo } from '../model/CertManagerVo/CredentialAbstractVo';
|
||||
import { AppAuthorVo } from '../model/CertManagerVo/AppAuthorVo';
|
||||
import router from '@ohos.router';
|
||||
import { CustomContentDialog } from '@ohos.arkui.advanced.Dialog';
|
||||
import CmShowSysCredPresenter from '../presenter/CmShowSysCredPresenter';
|
||||
import { NavEntryKey } from '../common/NavEntryKey';
|
||||
import { CredSystemDetailParam } from './detail/CredSystemDetailPage';
|
||||
import { CredUserDetailParam } from './detail/CredUserDetailPage';
|
||||
import { SheetParam } from '../common/util/SheetParam';
|
||||
import { DialogComponent } from './detail/AuthorizedAppManagementPage';
|
||||
|
||||
const COPIES_NUM: number = 12;
|
||||
|
||||
@Component
|
||||
export struct componentPublic {
|
||||
private alias: string = '';
|
||||
private keyUri: string = '';
|
||||
@Link mShowAppCaPresenter: CmShowAppCredPresenter;
|
||||
@State authorInfo: CmShowAppCredPresenter = CmShowAppCredPresenter.getInstance();
|
||||
private authorScroller: Scroller = new Scroller();
|
||||
@State isHoverBackgroundColor: ResourceColor = '';
|
||||
@Styles pressedStyles(): void {
|
||||
.backgroundColor($r('sys.color.ohos_id_color_click_effect'))
|
||||
}
|
||||
@Styles normalStyles(): void {
|
||||
.backgroundColor(this.isHoverBackgroundColor)
|
||||
}
|
||||
|
||||
onItemClicked?: () => void;
|
||||
|
||||
getAuthorizedAppList(): void {
|
||||
this.authorInfo.getAuthorizedAppList(this.mShowAppCaPresenter.credInfo.keyUri);
|
||||
}
|
||||
|
||||
deleteWarnDialog: CustomDialogController = new CustomDialogController({
|
||||
builder: CustomContentDialog({
|
||||
contentBuilder: () => {
|
||||
this.deleteWarnContent();
|
||||
},
|
||||
contentAreaPadding: { right: $r('app.float.wh_value_0') },
|
||||
buttons: [
|
||||
{
|
||||
value: $r('app.string.cancelAuthApp'),
|
||||
buttonStyle: ButtonStyleMode.TEXTUAL,
|
||||
action: () => {
|
||||
this.appDialogController?.close();
|
||||
}
|
||||
},
|
||||
{
|
||||
value: $r('app.string.deleteAllCredDelete'),
|
||||
buttonStyle: ButtonStyleMode.TEXTUAL,
|
||||
action: () => {
|
||||
this.mShowAppCaPresenter.deleteAppCred(this.mShowAppCaPresenter.credInfo.keyUri);
|
||||
this.deleteWarnDialog?.close();
|
||||
},
|
||||
role: ButtonRole.ERROR
|
||||
}
|
||||
]
|
||||
}),
|
||||
})
|
||||
|
||||
appDialogController: CustomDialogController = new CustomDialogController({
|
||||
builder: CustomContentDialog({
|
||||
contentBuilder: () => {
|
||||
this.appControllerContent();
|
||||
},
|
||||
contentAreaPadding: { right: $r('app.float.wh_value_0') },
|
||||
buttons: [
|
||||
{
|
||||
value: $r('app.string.cancelAuthApp'),
|
||||
buttonStyle: ButtonStyleMode.TEXTUAL,
|
||||
action: () => {
|
||||
this.appDialogController?.close();
|
||||
}
|
||||
},
|
||||
{
|
||||
value: $r('app.string.finishAuthApp'),
|
||||
buttonStyle: ButtonStyleMode.TEXTUAL,
|
||||
action: () => {
|
||||
this.authorInfo.removeGrantedAppList(this.authorInfo.credInfo.keyUri).then(() => {
|
||||
this.appDialogController?.close();
|
||||
})
|
||||
}
|
||||
}
|
||||
]
|
||||
}),
|
||||
})
|
||||
|
||||
credDetailsDialog: CustomDialogController = new CustomDialogController({
|
||||
builder: CustomContentDialog({
|
||||
contentBuilder: () => {
|
||||
this.credDetailContent();
|
||||
},
|
||||
contentAreaPadding: { right: $r('app.float.wh_value_0') },
|
||||
buttons: [
|
||||
{
|
||||
value: $r('app.string.publicDetailsCancel'),
|
||||
buttonStyle: ButtonStyleMode.TEXTUAL,
|
||||
action: () => {
|
||||
this.credDetailsDialog?.close();
|
||||
}
|
||||
},
|
||||
{
|
||||
value: $r('app.string.publicDetailsDelete'),
|
||||
buttonStyle: ButtonStyleMode.TEXTUAL,
|
||||
action: () => {
|
||||
this.onShowDeleteWarnDialog();
|
||||
},
|
||||
role: ButtonRole.ERROR
|
||||
}
|
||||
]
|
||||
}),
|
||||
})
|
||||
|
||||
@Builder
|
||||
appControllerContent(): void {
|
||||
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 > ConfigValue.APP_AUTH_MAX_LENGTH) {
|
||||
Stack({ alignContent: Alignment.TopEnd }) {
|
||||
Scroll(this.authorScroller) {
|
||||
List() {
|
||||
ForEach(this.authorInfo.appInfoList, (item: AppAuthorVo, index) => {
|
||||
ListItem() {
|
||||
DialogComponent({ appImage: item.appImage, appName: item.appName,
|
||||
indexNum: index, uidItem: $authorInfo })
|
||||
}
|
||||
})
|
||||
}
|
||||
.scrollBar(BarState.Off)
|
||||
.divider({
|
||||
strokeWidth: $r('app.float.Evidence_strokeWidth'),
|
||||
color: $r('sys.color.ohos_id_color_list_separator')
|
||||
})
|
||||
.visibility(this.authorInfo.appInfoList.length > 0 ? Visibility.Visible : Visibility.None)
|
||||
}
|
||||
.scrollBar(BarState.Off)
|
||||
.margin({
|
||||
left: $r('app.float.wh_value_24'),
|
||||
right: $r('app.float.wh_value_24')
|
||||
})
|
||||
|
||||
ScrollBar({ scroller: this.authorScroller, direction: ScrollBarDirection.Vertical,
|
||||
state: BarState.Auto }) {
|
||||
Text()
|
||||
.width($r('app.float.wh_value_3'))
|
||||
.height($r('app.float.wh_value_50'))
|
||||
.borderRadius($r('app.float.wh_value_10'))
|
||||
.backgroundColor($r('sys.color.ohos_id_color_foreground'))
|
||||
.opacity($r('app.float.text_opacity_0_4'))
|
||||
}
|
||||
.width($r('app.float.wh_value_3'))
|
||||
.margin({
|
||||
right: $r('app.float.wh_value_3')
|
||||
})
|
||||
}
|
||||
.height(WidthPercent.WH_50_100)
|
||||
} else {
|
||||
List() {
|
||||
ForEach(this.mShowAppCaPresenter.appInfoList, (item: AppAuthorVo, index) => {
|
||||
ListItem() {
|
||||
DialogComponent({ appImage: item.appImage, appName: item.appName,
|
||||
indexNum: index, uidItem: $authorInfo })
|
||||
}
|
||||
})
|
||||
}
|
||||
.scrollBar(BarState.Off)
|
||||
.margin({
|
||||
left: $r('app.float.wh_value_24'),
|
||||
right: $r('app.float.wh_value_24')
|
||||
})
|
||||
.divider({
|
||||
strokeWidth: $r('app.float.Evidence_strokeWidth'),
|
||||
color: $r('sys.color.ohos_id_color_list_separator')
|
||||
})
|
||||
.visibility(this.authorInfo.appInfoList.length > 0 ? Visibility.Visible : Visibility.None)
|
||||
}
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.borderRadius($r('app.float.user_list_divider_borderRadius_value'))
|
||||
.backgroundColor($r('sys.color.ohos_id_color_dialog_bg'))
|
||||
}
|
||||
|
||||
@Builder
|
||||
credDetailContent(): void {
|
||||
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_10'),
|
||||
right: $r('app.float.wh_value_10')
|
||||
})
|
||||
.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_10'),
|
||||
right: $r('app.float.wh_value_10')
|
||||
})
|
||||
.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.onShowAuthMngChange();
|
||||
})
|
||||
.margin({
|
||||
top: $r('app.float.wh_value_12'),
|
||||
left: $r('app.float.wh_value_24'),
|
||||
right: $r('app.float.wh_value_24')
|
||||
})
|
||||
.height('48vp')
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.borderRadius($r('app.float.user_list_divider_borderRadius_value'))
|
||||
.backgroundColor($r('sys.color.ohos_id_color_dialog_bg'))
|
||||
}
|
||||
|
||||
@Builder
|
||||
deleteWarnContent(): void {
|
||||
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)
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.borderRadius($r('app.float.user_list_divider_borderRadius_value'))
|
||||
.backgroundColor($r('sys.color.ohos_id_color_dialog_bg'))
|
||||
}
|
||||
|
||||
onShowAuthMngChange() {
|
||||
this.credDetailsDialog?.close();
|
||||
this.appDialogController.open();
|
||||
}
|
||||
|
||||
onShowDeleteWarnDialog() {
|
||||
this.credDetailsDialog?.close();
|
||||
this.deleteWarnDialog.open();
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
Row() {
|
||||
Image($r('app.media.ic_settings_arrow'))
|
||||
.width($r('app.float.publicList_image_wh'))
|
||||
.height($r('app.float.publicList_image_hg'))
|
||||
}
|
||||
}
|
||||
.height($r('app.float.wh_value_48'))
|
||||
.hoverEffect(HoverEffect.Highlight)
|
||||
.onHover((isHover?: boolean) => {
|
||||
this.isHoverBackgroundColor = isHover ? $r('sys.color.ohos_id_color_hover') : ''
|
||||
})
|
||||
.backgroundColor(this.isHoverBackgroundColor)
|
||||
.stateStyles({
|
||||
pressed: this.pressedStyles,
|
||||
normal: this.normalStyles
|
||||
})
|
||||
.padding({
|
||||
left: $r('app.float.wh_value_8'),
|
||||
right: $r('app.float.wh_value_8')
|
||||
})
|
||||
.borderRadius($r('app.float.wh_value_20'))
|
||||
.onClick(() => {
|
||||
this.mShowAppCaPresenter.getAppCred(this.keyUri, () => {
|
||||
this.getAuthorizedAppList();
|
||||
if (this.onItemClicked !== undefined) {
|
||||
this.onItemClicked();
|
||||
} else {
|
||||
this.credDetailsDialog.open();
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
export struct componentSystem {
|
||||
private alias: string = '';
|
||||
private keyUri: string = '';
|
||||
@State mSystemCredPresenter: CmShowSysCredPresenter = CmShowSysCredPresenter.getInstance();
|
||||
@State isHoverBackgroundColor: ResourceColor = '';
|
||||
@Link systemCredPresenter: CmShowSysCredPresenter;
|
||||
@Styles pressedStyles(): void {
|
||||
.backgroundColor($r('sys.color.ohos_id_color_click_effect'))
|
||||
}
|
||||
@Styles normalStyles(): void {
|
||||
.backgroundColor(this.isHoverBackgroundColor)
|
||||
}
|
||||
|
||||
onItemClicked?: () => void;
|
||||
|
||||
sysCredDetailsDialog: CustomDialogController = new CustomDialogController({
|
||||
builder: CustomContentDialog({
|
||||
contentBuilder: () => {
|
||||
this.sysCredDetailContent();
|
||||
},
|
||||
contentAreaPadding: { right: $r('app.float.wh_value_0') },
|
||||
buttons: [
|
||||
{
|
||||
value: $r('app.string.publicDetailsCancel'),
|
||||
buttonStyle: ButtonStyleMode.TEXTUAL,
|
||||
action: () => {
|
||||
this.sysCredDetailsDialog?.close();
|
||||
}
|
||||
},
|
||||
{
|
||||
value: $r('app.string.publicDetailsDelete'),
|
||||
buttonStyle: ButtonStyleMode.TEXTUAL,
|
||||
action: () => {
|
||||
this.sysCredDetailsDialog?.close();
|
||||
this.deleteWarnDialog.open();
|
||||
},
|
||||
role: ButtonRole.ERROR
|
||||
}
|
||||
]
|
||||
}),
|
||||
})
|
||||
|
||||
deleteWarnDialog: CustomDialogController = new CustomDialogController({
|
||||
builder: CustomContentDialog({
|
||||
contentBuilder: () => {
|
||||
this.deleteWarnContent();
|
||||
},
|
||||
contentAreaPadding: { right: $r('app.float.wh_value_0') },
|
||||
buttons: [
|
||||
{
|
||||
value: $r('app.string.cancelAuthApp'),
|
||||
buttonStyle: ButtonStyleMode.TEXTUAL,
|
||||
action: () => {
|
||||
this.sysCredDetailsDialog?.close();
|
||||
}
|
||||
},
|
||||
{
|
||||
value: $r('app.string.deleteAllCredDelete'),
|
||||
buttonStyle: ButtonStyleMode.TEXTUAL,
|
||||
action: () => {
|
||||
this.mSystemCredPresenter.deleteSystemCred(this.mSystemCredPresenter.credInfo.keyUri);
|
||||
this.deleteWarnDialog?.close();
|
||||
this.systemCredPresenter.updateSystemCredList();
|
||||
},
|
||||
role: ButtonRole.ERROR
|
||||
}
|
||||
]
|
||||
}),
|
||||
})
|
||||
|
||||
@Builder
|
||||
sysCredDetailContent(): void {
|
||||
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.systemCredPresenter.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.systemCredPresenter.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_10'),
|
||||
right: $r('app.float.wh_value_10')
|
||||
})
|
||||
.opacity($r('app.float.opacity_100_60'))
|
||||
.alignSelf(ItemAlign.Start)
|
||||
|
||||
Text($r('app.string.userCerNum', String(this.systemCredPresenter.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_10'),
|
||||
right: $r('app.float.wh_value_10')
|
||||
})
|
||||
.opacity($r('app.float.opacity_100_60'))
|
||||
.alignSelf(ItemAlign.Start)
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.borderRadius($r('app.float.user_list_divider_borderRadius_value'))
|
||||
.backgroundColor($r('sys.color.ohos_id_color_dialog_bg'))
|
||||
}
|
||||
|
||||
@Builder
|
||||
deleteWarnContent(): void {
|
||||
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)
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.borderRadius($r('app.float.user_list_divider_borderRadius_value'))
|
||||
.backgroundColor($r('sys.color.ohos_id_color_dialog_bg'))
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
Row() {
|
||||
Image($r('app.media.ic_settings_arrow'))
|
||||
.width($r('app.float.publicList_image_wh'))
|
||||
.height($r('app.float.publicList_image_hg'))
|
||||
}
|
||||
}
|
||||
.height($r('app.float.wh_value_48'))
|
||||
.hoverEffect(HoverEffect.Highlight)
|
||||
.onHover((isHover?: boolean) => {
|
||||
this.isHoverBackgroundColor = isHover ? $r('sys.color.ohos_id_color_hover') : ''
|
||||
})
|
||||
.backgroundColor(this.isHoverBackgroundColor)
|
||||
.stateStyles({
|
||||
pressed: this.pressedStyles,
|
||||
normal: this.normalStyles
|
||||
})
|
||||
.padding({
|
||||
left: $r('app.float.wh_value_8'),
|
||||
right: $r('app.float.wh_value_8')
|
||||
})
|
||||
.borderRadius($r('app.float.wh_value_20'))
|
||||
.onClick(() => {
|
||||
this.mSystemCredPresenter.getSystemCred(this.keyUri, () => {
|
||||
if (this.onItemClicked !== undefined) {
|
||||
this.onItemClicked();
|
||||
} else {
|
||||
this.sysCredDetailsDialog.open();
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
export struct evidenceList {
|
||||
@State mShowAppCaPresenter: CmShowAppCredPresenter = CmShowAppCredPresenter.getInstance();
|
||||
@State mShowSysCredPresenter: CmShowSysCredPresenter = CmShowSysCredPresenter.getInstance();
|
||||
@State mFaPresenter: CMFaPresenter = CMFaPresenter.getInstance();
|
||||
private publicScroller: Scroller = new Scroller();
|
||||
private systemScroller: Scroller = new Scroller();
|
||||
@State currentIndex: number = 0;
|
||||
@State fontColor: Resource = $r('app.color.evidenceList_TabBuilder_fontColor_182431');
|
||||
@State selectedFontColor: Resource = $r('app.color.font_color_007DFF');
|
||||
private controller: TabsController = new TabsController();
|
||||
@State animationDurationNum: number = 400;
|
||||
|
||||
isStartBySheetFirst: boolean = false;
|
||||
isStartBySheet: boolean = false;
|
||||
selected?: (path: string, param?: Object) => void;
|
||||
@Prop sheetParam: SheetParam;
|
||||
@State headRectHeight: number = 64;
|
||||
@State headRectHeightReal: number = 0;
|
||||
@State systemScrollerHeight: number = 0;
|
||||
@State publicScrollerHeight: number = 0;
|
||||
|
||||
@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') })
|
||||
.color(this.selectedFontColor)
|
||||
.alignSelf(ItemAlign.Center)
|
||||
}
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
}
|
||||
|
||||
aboutToAppear() {
|
||||
this.mShowAppCaPresenter.updateAppCredListCallback(() => {
|
||||
console.info('get AppCredList first');
|
||||
})
|
||||
this.mShowSysCredPresenter.updateSystemCredListCallback(() => {
|
||||
console.info('get systemCredList start');
|
||||
})
|
||||
}
|
||||
|
||||
onPageShow() {
|
||||
let uri = GlobalContext.getContext().getAbilityWant().uri;
|
||||
GlobalContext.getContext().clearAbilityWantUri();
|
||||
|
||||
if (uri === 'certInstall') {
|
||||
router.pushUrl({
|
||||
url: 'pages/certInstallFromStorage'
|
||||
})
|
||||
} else if (uri === 'requestAuthorize') {
|
||||
this.mFaPresenter.startRequestAuth(GlobalContext.getContext().getAbilityWant().parameters?.appUid as string);
|
||||
} else {
|
||||
console.error('The want type is not supported.');
|
||||
}
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
GridRow({
|
||||
columns: COPIES_NUM,
|
||||
gutter: vp2px(1) === 2 ? $r('app.float.wh_value_12') : $r('app.float.wh_value_0')
|
||||
}) {
|
||||
GridCol({ span: { xs: COPIES_NUM, sm: COPIES_NUM, md: COPIES_NUM, lg: COPIES_NUM },
|
||||
offset: { xs: 0, sm: 0, md: 0, lg: 0 } }) {
|
||||
Row() {
|
||||
Stack({ alignContent: Alignment.Top }) {
|
||||
Column() {
|
||||
HeadComponent({ headName: $r('app.string.userEvidence'), isStartBySheet: this.isStartBySheet,
|
||||
icBackIsVisibility: !this.isStartBySheetFirst,
|
||||
onBackClicked: () => {
|
||||
this.selected?.(NavEntryKey.POP);
|
||||
}})
|
||||
.margin({
|
||||
left: $r('app.float.wh_value_16'),
|
||||
top: this.isStartBySheet ? 8 : 0
|
||||
})
|
||||
}.zIndex(1)
|
||||
.onAreaChange((oldArea, newArea) => {
|
||||
this.headRectHeight = newArea.height as number;
|
||||
this.headRectHeightReal = newArea.height as number;
|
||||
})
|
||||
|
||||
Column() {
|
||||
Tabs({barPosition: BarPosition.Start, index: 0, controller: this.controller}) {
|
||||
TabContent() {
|
||||
Stack({alignContent: Alignment.TopEnd}) {
|
||||
Scroll(this.systemScroller) {
|
||||
List() {
|
||||
ForEach(this.mShowSysCredPresenter.credList, (item: CredentialAbstractVo) => {
|
||||
ListItem() {
|
||||
componentSystem({
|
||||
alias: item.alias,
|
||||
keyUri: item.keyUri,
|
||||
systemCredPresenter: $mShowSysCredPresenter,
|
||||
onItemClicked: this.isStartBySheet ? () => {
|
||||
this.selected?.(NavEntryKey.CRED_SYSTEM_DETAIL_ENTRY,
|
||||
new CredSystemDetailParam(this.mShowSysCredPresenter));
|
||||
} : undefined
|
||||
})
|
||||
}
|
||||
}, (item:CredentialAbstractVo) => JSON.stringify(item))
|
||||
}
|
||||
.backgroundColor($r('sys.color.ohos_id_color_list_card_bg'))
|
||||
.borderRadius($r('sys.float.padding_level10'))
|
||||
.scrollBar(BarState.Off)
|
||||
.padding({
|
||||
right: $r('app.float.wh_value_4'),
|
||||
left: $r('app.float.wh_value_4'),
|
||||
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('sys.color.ohos_id_color_list_separator'),
|
||||
endMargin: $r('app.float.wh_value_3')
|
||||
})
|
||||
.visibility(this.mShowSysCredPresenter.credList.length > 0
|
||||
? Visibility.Visible : Visibility.None)
|
||||
}
|
||||
.position({ y: $r('app.float.wh_value_0') })
|
||||
.scrollable(ScrollDirection.Vertical)
|
||||
.scrollBar(BarState.Off)
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(this.isStartBySheet ? WidthPercent.WH_AUTO : WidthPercent.WH_100_100)
|
||||
.align(Alignment.Top)
|
||||
.edgeEffect(EdgeEffect.Spring)
|
||||
.padding({
|
||||
left: $r('app.float.wh_value_16'),
|
||||
right: $r('app.float.wh_value_16'),
|
||||
bottom: this.isStartBySheet ? $r('app.float.wh_value_80') : $r('app.float.wh_value_24')
|
||||
})
|
||||
.constraintSize({
|
||||
minHeight: this.getScrollMinHeight()
|
||||
}).onAreaChange((oldArea, newArea) => {
|
||||
this.systemScrollerHeight = newArea.height as number;
|
||||
})
|
||||
|
||||
Column() {
|
||||
ScrollBar({
|
||||
scroller: this.systemScroller,
|
||||
direction: ScrollBarDirection.Vertical,
|
||||
state: BarState.Auto
|
||||
}).margin({
|
||||
bottom: this.isStartBySheet ? $r('app.float.wh_value_80') : $r('app.float.wh_value_24')
|
||||
})
|
||||
}.height(this.systemScrollerHeight)
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
}
|
||||
.tabBar(this.TabBuilder(0))
|
||||
|
||||
TabContent() {
|
||||
Stack({ alignContent: Alignment.TopEnd }) {
|
||||
Scroll(this.publicScroller) {
|
||||
List() {
|
||||
ForEach(this.mShowAppCaPresenter.credList, (item: CredentialAbstractVo) => {
|
||||
ListItem() {
|
||||
componentPublic({
|
||||
alias: item.alias,
|
||||
keyUri: item.keyUri,
|
||||
mShowAppCaPresenter: $mShowAppCaPresenter,
|
||||
onItemClicked: this.isStartBySheet ? () => {
|
||||
this.selected?.(NavEntryKey.CRED_USER_DETAIL_ENTRY,
|
||||
new CredUserDetailParam(this.mShowAppCaPresenter));
|
||||
} : undefined
|
||||
})
|
||||
}
|
||||
}, (item: CredentialAbstractVo) => JSON.stringify(item))
|
||||
}
|
||||
.backgroundColor($r('sys.color.ohos_id_color_list_card_bg'))
|
||||
.borderRadius($r('sys.float.padding_level10'))
|
||||
.scrollBar(BarState.Off)
|
||||
.padding({
|
||||
right: $r('app.float.wh_value_4'),
|
||||
left: $r('app.float.wh_value_4'),
|
||||
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('sys.color.ohos_id_color_list_separator'),
|
||||
endMargin: $r('app.float.wh_value_3')
|
||||
})
|
||||
.visibility(this.mShowAppCaPresenter.credList.length > 0 ? Visibility.Visible : Visibility.None)
|
||||
}
|
||||
.position({ y: $r('app.float.wh_value_0') })
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(this.isStartBySheet ? WidthPercent.WH_AUTO : WidthPercent.WH_100_100)
|
||||
.align(Alignment.Top)
|
||||
.edgeEffect(EdgeEffect.Spring)
|
||||
.scrollable(ScrollDirection.Vertical)
|
||||
.scrollBar(BarState.Off)
|
||||
.padding({
|
||||
left: $r('app.float.wh_value_16'),
|
||||
right: $r('app.float.wh_value_16'),
|
||||
bottom: this.isStartBySheet ? $r('app.float.wh_value_80') : $r('app.float.wh_value_24')
|
||||
})
|
||||
.constraintSize({
|
||||
minHeight: this.getScrollMinHeight()
|
||||
}).onAreaChange((oldArea, newArea) => {
|
||||
this.publicScrollerHeight = newArea.height as number;
|
||||
})
|
||||
|
||||
Column() {
|
||||
ScrollBar({
|
||||
scroller: this.publicScroller,
|
||||
direction: ScrollBarDirection.Vertical,
|
||||
state: BarState.Auto
|
||||
}).margin({
|
||||
bottom: this.isStartBySheet ? $r('app.float.wh_value_80') : $r('app.float.wh_value_24')
|
||||
})
|
||||
}.height(this.publicScrollerHeight)
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
}
|
||||
.tabBar(this.TabBuilder(1))
|
||||
}
|
||||
.vertical(false)
|
||||
.scrollable(true)
|
||||
.barMode(BarMode.Fixed)
|
||||
.barWidth($r('app.float.tabs_barWidth_value'))
|
||||
.barHeight($r('app.float.tabs_barHeight_value'))
|
||||
.animationDuration(this.animationDurationNum)
|
||||
.height(this.isStartBySheet ? WidthPercent.WH_AUTO : WidthPercent.WH_100_100)
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.onChange((index: number) => {
|
||||
this.currentIndex = index;
|
||||
})
|
||||
}
|
||||
.height(this.isStartBySheet ? WidthPercent.WH_AUTO : WidthPercent.WH_100_100)
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.padding({
|
||||
top: this.headRectHeight
|
||||
})
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(this.isStartBySheet ? WidthPercent.WH_AUTO : WidthPercent.WH_100_100)
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(this.isStartBySheet ? WidthPercent.WH_AUTO : WidthPercent.WH_100_100)
|
||||
}
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(this.isStartBySheet ? WidthPercent.WH_AUTO : WidthPercent.WH_100_100)
|
||||
}
|
||||
.backgroundColor($r('sys.color.ohos_id_color_sub_background'))
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(this.isStartBySheet ? WidthPercent.WH_AUTO : WidthPercent.WH_100_100)
|
||||
}
|
||||
|
||||
getScrollMinHeight() {
|
||||
if (this.sheetParam === undefined || this.headRectHeightReal === 0 ||
|
||||
this.sheetParam.sheetMinHeight < this.headRectHeightReal) {
|
||||
return 0;
|
||||
}
|
||||
return this.sheetParam.sheetMinHeight - this.headRectHeightReal - 56;
|
||||
}
|
||||
}
|
||||
@@ -1,413 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { WidthPercent } from '../common/util/ConfigData';
|
||||
import HeadComponent from '../common/component/headComponent';
|
||||
import CmFaPresenter from '../presenter/CmFaPresenter';
|
||||
import { GlobalContext } from '../common/GlobalContext';
|
||||
import ComponentConfig from '../common/component/ComponentConfig';
|
||||
import router from '@ohos.router';
|
||||
import { CustomContentDialog } from '@ohos.arkui.advanced.Dialog';
|
||||
import checkUserAuthModel from '../model/CheckUserAuthModel';
|
||||
import { NavEntryKey } from '../common/NavEntryKey';
|
||||
import picker from '@ohos.file.picker';
|
||||
import FileIoModel from '../model/FileIoModel';
|
||||
import CmInstallPresenter from '../presenter/CmInstallPresenter';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
import { RouterFileVo } from '../model/CertManagerVo/RouterInfoVo';
|
||||
import { CredPwdInputParam } from './detail/CredPwdInputPage';
|
||||
import { SheetParam } from '../common/util/SheetParam';
|
||||
import FilterParams from '../common/constants/FileFilterParams';
|
||||
|
||||
const COPIES_NUM: number = 12;
|
||||
|
||||
const TAG: string = 'CertInstallFromStorage: ';
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
export struct CertInstallFromStorage {
|
||||
@State columnMargin: string = '12vp';
|
||||
@State mFaPresenter: CmFaPresenter = CmFaPresenter.getInstance();
|
||||
@State installCertFlag: boolean = false;
|
||||
private context: Context = getContext(this);
|
||||
|
||||
isStartBySheetFirst: boolean = false;
|
||||
isStartBySheet: boolean = false;
|
||||
selected?: (path: string, param?: Object) => void;
|
||||
@Prop sheetParam: SheetParam;
|
||||
@State private headRectHeight: number = 64;
|
||||
@State private headRectHeightReal: number = 0;
|
||||
private scroller: Scroller = new Scroller();
|
||||
@State private scrollerHeight: number = 0;
|
||||
|
||||
@Styles normalStyle() {
|
||||
.backgroundColor($r('sys.color.ohos_id_color_card_bg'))
|
||||
.borderRadius($r('app.float.user_list_divider_borderRadius_value'))
|
||||
};
|
||||
@Styles pressedStyle() {
|
||||
.backgroundColor($r('sys.color.ohos_id_color_click_effect'))
|
||||
.borderRadius($r('app.float.user_list_divider_borderRadius_value'))
|
||||
};
|
||||
|
||||
rootCertificateDialog: CustomDialogController = new CustomDialogController({
|
||||
alignment: DialogAlignment.Center,
|
||||
builder: CustomContentDialog({
|
||||
contentBuilder: () => {
|
||||
this.rootCertificateContent();
|
||||
},
|
||||
contentAreaPadding: { right: $r('app.float.wh_value_0') },
|
||||
buttons: [
|
||||
{
|
||||
value: $r('app.string.root_certificate_cancel'),
|
||||
buttonStyle: ButtonStyleMode.TEXTUAL,
|
||||
action: () => {
|
||||
}
|
||||
},
|
||||
{
|
||||
value: $r('app.string.root_certificate_continue'),
|
||||
buttonStyle: ButtonStyleMode.TEXTUAL,
|
||||
action: () => {
|
||||
this.installCertFlag = true;
|
||||
this.checkUserAuth();
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
})
|
||||
|
||||
@Builder
|
||||
rootCertificateContent(): void {
|
||||
Column() {
|
||||
Text($r('app.string.root_certificate'))
|
||||
.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.root_certificate_message'))
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body1'))
|
||||
.fontWeight(FontWeight.Regular)
|
||||
.fontColor($r('sys.color.ohos_id_color_primary'))
|
||||
.margin({
|
||||
left: $r('app.float.wh_value_24'),
|
||||
right: $r('app.float.wh_value_24')
|
||||
})
|
||||
.alignSelf(ItemAlign.Start)
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.borderRadius($r('app.float.user_list_divider_borderRadius_value'))
|
||||
.backgroundColor($r('sys.color.ohos_id_color_dialog_bg'))
|
||||
}
|
||||
|
||||
checkUserAuth() {
|
||||
let titleStr = getContext().resourceManager.getStringSync($r('app.string.Identity_Authentication'));
|
||||
checkUserAuthModel.auth(titleStr, (authResult: boolean) => {
|
||||
if (authResult) {
|
||||
console.info('checkUserAuth success');
|
||||
if (this.installCertFlag) {
|
||||
if (this.isStartBySheet) {
|
||||
this.startInstallCertBySheet();
|
||||
} else {
|
||||
this.mFaPresenter.startInstallCert(this.context);
|
||||
}
|
||||
} else {
|
||||
if (this.isStartBySheet) {
|
||||
this.startInstallEvidenceBySheet();
|
||||
} else {
|
||||
this.mFaPresenter.startInstallEvidence(this.context);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
startInstallCertBySheet(): void {
|
||||
try {
|
||||
let documentSelectOptions = new picker.DocumentSelectOptions();
|
||||
documentSelectOptions.maxSelectNumber = FilterParams.MAX_SELECT_FILE_NUM;
|
||||
documentSelectOptions.fileSuffixFilters = FilterParams.CERT_FILE_SUFFIX;
|
||||
let documentPicker = new picker.DocumentViewPicker(this.context);
|
||||
console.info(TAG + 'start documentPicker.select');
|
||||
documentPicker.select(documentSelectOptions).then((documentSelectResult) => {
|
||||
if (documentSelectResult.length >= 1) {
|
||||
this.routeToNextInstallCert(String(documentSelectResult[0]))
|
||||
} else {
|
||||
console.error(TAG + 'documentPicker.select length invalid:' + documentSelectResult.length);
|
||||
}
|
||||
}).catch((err: BusinessError) => {
|
||||
console.error(TAG + 'documentPicker.select failed with err, message: ' + err.message + ', code: ' + err.code);
|
||||
});
|
||||
} catch (err) {
|
||||
let e: BusinessError = err as BusinessError;
|
||||
console.error(TAG + 'DocumentViewPicker failed with err, message: ' + e.message + ', code: ' + e.code);
|
||||
}
|
||||
}
|
||||
|
||||
routeToNextInstallCert(fileUri: string): void {
|
||||
FileIoModel.getMediaFileSuffix(fileUri, (suffix: string | undefined) => {
|
||||
if (suffix !== undefined) {
|
||||
console.debug(TAG, 'suffix = ', suffix);
|
||||
if ((suffix === 'cer') || (suffix === 'pem') || (suffix === 'crt') || (suffix === 'der')) {
|
||||
CmInstallPresenter.getInstance().installCert(fileUri, '', suffix, false);
|
||||
} else {
|
||||
this.mFaPresenter.unrecognizedFileTips();
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
startInstallEvidenceBySheet(): void {
|
||||
try {
|
||||
let documentSelectOptions = new picker.DocumentSelectOptions();
|
||||
documentSelectOptions.maxSelectNumber = FilterParams.MAX_SELECT_FILE_NUM;
|
||||
documentSelectOptions.fileSuffixFilters = FilterParams.CREDENTIAL_FILE_SUFFIX;
|
||||
let documentPicker = new picker.DocumentViewPicker(this.context);
|
||||
console.info(TAG + 'start documentPicker.select');
|
||||
documentPicker.select(documentSelectOptions).then((documentSelectResult) => {
|
||||
if (documentSelectResult.length >= 1) {
|
||||
this.routeToNextInstallEvidence(String(documentSelectResult[0]))
|
||||
} else {
|
||||
console.error(TAG + 'documentPicker.select length invalid:' + documentSelectResult.length);
|
||||
}
|
||||
}).catch((err: BusinessError) => {
|
||||
console.error(TAG + 'documentPicker.select failed with err, message: ' + err.message + ', code: ' + err.code);
|
||||
});
|
||||
} catch (err) {
|
||||
let e: BusinessError = err as BusinessError;
|
||||
console.error(TAG + 'DocumentViewPicker failed with err, message: ' + e.message + ', code: ' + e.code);
|
||||
}
|
||||
}
|
||||
|
||||
routeToNextInstallEvidence(fileUri: string): void {
|
||||
FileIoModel.getMediaFileSuffix(fileUri, (suffix: string | undefined) => {
|
||||
if (suffix !== undefined) {
|
||||
console.debug(TAG, 'suffix = ', suffix);
|
||||
if ((suffix === 'p12') || (suffix === 'pfx')) {
|
||||
this.selected?.(NavEntryKey.CRED_PWD_INPUT_ENTRY, new CredPwdInputParam(new RouterFileVo(fileUri, suffix)));
|
||||
} else {
|
||||
this.mFaPresenter.unrecognizedFileTips();
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
GridRow({
|
||||
columns: COPIES_NUM,
|
||||
gutter: vp2px(1) === 2 ? $r('app.float.wh_value_12') : $r('app.float.wh_value_0')
|
||||
}) {
|
||||
GridCol({ span: COPIES_NUM }) {
|
||||
Row({}) {
|
||||
Stack({ alignContent: Alignment.Top }) {
|
||||
Column() {
|
||||
HeadComponent({ headName: $r('app.string.installInStorageDevice'), isStartBySheet: this.isStartBySheet,
|
||||
icBackIsVisibility: !this.isStartBySheetFirst,
|
||||
onBackClicked: () => {
|
||||
this.selected?.(NavEntryKey.POP);
|
||||
}})
|
||||
.margin({
|
||||
top: this.isStartBySheet ? 8 : 0,
|
||||
left: 12,
|
||||
right: 12
|
||||
})
|
||||
}.zIndex(1)
|
||||
.onAreaChange((oldArea, newArea) => {
|
||||
this.headRectHeight = newArea.height as number;
|
||||
this.headRectHeightReal = newArea.height as number;
|
||||
})
|
||||
|
||||
Stack({ alignContent: Alignment.TopEnd }) {
|
||||
Scroll(this.scroller) {
|
||||
Column() {
|
||||
Row() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
|
||||
Text($r('app.string.CA_cert'))
|
||||
.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_12') })
|
||||
.textAlign(TextAlign.Start)
|
||||
}
|
||||
}
|
||||
.stateStyles({
|
||||
normal: this.normalStyle,
|
||||
pressed: this.pressedStyle
|
||||
})
|
||||
.constraintSize({
|
||||
minHeight: $r('app.float.wh_value_48')
|
||||
})
|
||||
.onClick(() => {
|
||||
this.rootCertificateDialog.open();
|
||||
})
|
||||
|
||||
Divider()
|
||||
.color($r('sys.color.ohos_id_color_list_separator'))
|
||||
.margin({
|
||||
left: $r('app.float.wh_value_12'),
|
||||
right: $r('app.float.wh_value_12')
|
||||
})
|
||||
|
||||
Row() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
|
||||
Text($r('app.string.system_credentials'))
|
||||
.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_12') })
|
||||
.textAlign(TextAlign.Start)
|
||||
}
|
||||
.onClick(() => {
|
||||
this.installCertFlag = false;
|
||||
AppStorage.setOrCreate('installSystemCred', true);
|
||||
AppStorage.setOrCreate('installUserCred',false);
|
||||
if (this.isStartBySheet) {
|
||||
this.startInstallEvidenceBySheet();
|
||||
} else {
|
||||
this.mFaPresenter.startInstallEvidence(this.context);
|
||||
}
|
||||
})
|
||||
}
|
||||
.stateStyles({
|
||||
normal: this.normalStyle,
|
||||
pressed: this.pressedStyle
|
||||
})
|
||||
.constraintSize({
|
||||
minHeight: $r('app.float.wh_value_48')
|
||||
})
|
||||
|
||||
Divider()
|
||||
.color($r('sys.color.ohos_id_color_list_separator'))
|
||||
.margin({
|
||||
left: $r('app.float.wh_value_12'),
|
||||
right: $r('app.float.wh_value_12')
|
||||
})
|
||||
|
||||
Row() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
|
||||
Text($r('app.string.user_certificate_credentials'))
|
||||
.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_12') })
|
||||
.textAlign(TextAlign.Start)
|
||||
}
|
||||
.onClick(() => {
|
||||
this.installCertFlag = false;
|
||||
AppStorage.setOrCreate('installUserCred', true);
|
||||
AppStorage.setOrCreate('installSystemCred',false);
|
||||
if (this.isStartBySheet) {
|
||||
this.startInstallEvidenceBySheet();
|
||||
} else {
|
||||
this.mFaPresenter.startInstallEvidence(this.context);
|
||||
}
|
||||
})
|
||||
}
|
||||
.stateStyles({
|
||||
normal: this.normalStyle,
|
||||
pressed: this.pressedStyle
|
||||
})
|
||||
.constraintSize({
|
||||
minHeight: $r('app.float.wh_value_48')
|
||||
})
|
||||
}
|
||||
.padding($r('app.float.wh_value_4'))
|
||||
.backgroundColor($r('sys.color.ohos_id_color_card_bg'))
|
||||
.borderRadius($r('app.float.radius_20'))
|
||||
.width(ComponentConfig.WH_100_100)
|
||||
}
|
||||
.align(Alignment.Top)
|
||||
.scrollable(ScrollDirection.Vertical)
|
||||
.scrollBar(BarState.Off)
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.edgeEffect(EdgeEffect.Spring)
|
||||
.height(this.isStartBySheet ? WidthPercent.WH_AUTO : WidthPercent.WH_100_100)
|
||||
.padding({
|
||||
left: 16,
|
||||
right: 16,
|
||||
bottom: $r('app.float.wh_value_24')
|
||||
}).constraintSize({
|
||||
minHeight: this.getScrollMinHeight()
|
||||
}).onAreaChange((oldArea, newArea) => {
|
||||
this.scrollerHeight = newArea.height as number;
|
||||
})
|
||||
|
||||
Column() {
|
||||
ScrollBar({
|
||||
scroller: this.scroller,
|
||||
direction: ScrollBarDirection.Vertical,
|
||||
state: BarState.Auto
|
||||
}).margin({
|
||||
bottom: $r('app.float.wh_value_24')
|
||||
})
|
||||
}.height(this.scrollerHeight)
|
||||
}.padding({
|
||||
top: this.headRectHeight
|
||||
})
|
||||
}
|
||||
.backgroundColor($r('sys.color.ohos_id_color_sub_background'))
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(this.isStartBySheet ? WidthPercent.WH_AUTO : WidthPercent.WH_100_100)
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(this.isStartBySheet ? WidthPercent.WH_AUTO : WidthPercent.WH_100_100);
|
||||
}
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(this.isStartBySheet ? WidthPercent.WH_AUTO : WidthPercent.WH_100_100);
|
||||
}
|
||||
.backgroundColor($r('sys.color.ohos_id_color_sub_background'))
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(this.isStartBySheet ? WidthPercent.WH_AUTO : WidthPercent.WH_100_100);
|
||||
}
|
||||
|
||||
getScrollMinHeight() {
|
||||
if (this.sheetParam === undefined || this.headRectHeightReal === 0 ||
|
||||
this.sheetParam.sheetMinHeight < this.headRectHeightReal) {
|
||||
return 0;
|
||||
}
|
||||
return this.sheetParam.sheetMinHeight - this.headRectHeightReal;
|
||||
}
|
||||
|
||||
onPageShow() {
|
||||
let uiExtensionFlag = GlobalContext.getContext().getFlag();
|
||||
let installType: string = GlobalContext.getContext().getAbilityWant().parameters?.installType as string;
|
||||
let uri = GlobalContext.getContext().getAbilityWant().uri ||
|
||||
GlobalContext.getContext().getAbilityWant().parameters?.uri;
|
||||
GlobalContext.getContext().clearAbilityWantUri();
|
||||
GlobalContext.getContext().clearAbilityWantParamsUri();
|
||||
if (uri === 'certInstall') {
|
||||
router.pushUrl({
|
||||
url: 'pages/certInstallFromStorage'
|
||||
})
|
||||
} else if (uri === 'requestAuthorize') {
|
||||
this.mFaPresenter.startRequestAuth(GlobalContext.getContext().getAbilityWant().parameters?.appUid as string);
|
||||
} else if (uiExtensionFlag && uri === 'systemCredInstall' && installType === 'systemCred') {
|
||||
AppStorage.setOrCreate('installSystemCred', true);
|
||||
AppStorage.setOrCreate('installUserCred', false);
|
||||
this.mFaPresenter.startInstallEvidence(this.context);
|
||||
} else if (uiExtensionFlag && uri === 'specifyInstall') {
|
||||
let fileUri = GlobalContext.getContext().getAbilityWant().parameters?.fileUri as string;
|
||||
this.mFaPresenter.startInstall(installType, fileUri);
|
||||
} else {
|
||||
console.error('The want type is not supported');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,349 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { WidthPercent } from '../common/util/ConfigData';
|
||||
import HeadComponent from '../common/component/headComponent';
|
||||
import { SubEntryComponent } from '../common/component/subEntryComponent';
|
||||
import CmFaPresenter from '../presenter/CmFaPresenter';
|
||||
import { GlobalContext } from '../common/GlobalContext';
|
||||
import router from '@ohos.router';
|
||||
import promptAction from '@ohos.promptAction';
|
||||
import { CustomContentDialog } from '@ohos.arkui.advanced.Dialog';
|
||||
import { NavEntryKey } from '../common/NavEntryKey';
|
||||
import { SheetParam } from '../common/util/SheetParam';
|
||||
|
||||
const DISPLAY_DURATION: number = 2000;
|
||||
const COPIES_NUM: number = 12;
|
||||
|
||||
class CertListItem {
|
||||
public targetPage: string = '';
|
||||
public title: Resource = $r('app.string.CA_cert');
|
||||
};
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
export struct CertificateComponent {
|
||||
@State columnMargin: string = '12vp';
|
||||
@State mFaPresenter: CmFaPresenter = CmFaPresenter.getInstance();
|
||||
private listItems: Array<CertListItem> = [
|
||||
{ targetPage: 'pages/trustedCa', title: $r('app.string.CA_cert') },
|
||||
{ targetPage: 'pages/cerEvidenceFa', title: $r('app.string.userEvidence') }
|
||||
];
|
||||
@Styles normalStyle() {
|
||||
.backgroundColor($r('sys.color.ohos_id_color_card_bg'))
|
||||
};
|
||||
@Styles pressedStyle() {
|
||||
.backgroundColor($r('sys.color.ohos_id_color_click_effect'))
|
||||
};
|
||||
|
||||
isStartBySheet: boolean = false;
|
||||
selected?: (path: string) => void;
|
||||
@State private headRectHeight: number = 64;
|
||||
@State private headRectHeightReal: number = 0;
|
||||
@Prop sheetParam: SheetParam;
|
||||
private scroller: Scroller = new Scroller();
|
||||
@State private scrollerHeight: number = 0;
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
GridRow({
|
||||
columns: COPIES_NUM,
|
||||
gutter: vp2px(1) === 2 ? $r('app.float.wh_value_12') : $r('app.float.wh_value_0')
|
||||
}) {
|
||||
GridCol({ span: COPIES_NUM }) {
|
||||
Stack({ alignContent: Alignment.Top }) {
|
||||
Column() {
|
||||
HeadComponent({ headName: $r('app.string.certificateTab'), icBackIsVisibility: !this.isStartBySheet })
|
||||
.margin({
|
||||
top: this.isStartBySheet ? 8 : 0,
|
||||
left: 12,
|
||||
right: 12
|
||||
})
|
||||
}.onAreaChange((oldArea, newArea) => {
|
||||
this.headRectHeight = newArea.height as number;
|
||||
this.headRectHeightReal = newArea.height as number;
|
||||
}).zIndex(1)
|
||||
|
||||
Stack({ alignContent: Alignment.TopEnd }) {
|
||||
Scroll(this.scroller) {
|
||||
Column({ space: this.columnMargin }) {
|
||||
List() {
|
||||
ForEach(this.listItems, (item: CertListItem) => {
|
||||
ListItem() {
|
||||
SubEntryComponent({ targetPage: item.targetPage, title: item.title,
|
||||
onItemClicked: targetRouter => {
|
||||
if (this.isStartBySheet) {
|
||||
if (targetRouter === 'pages/trustedCa') {
|
||||
this.selected?.(NavEntryKey.CA_CERTIFICATE_ENTRY);
|
||||
} else {
|
||||
this.selected?.(NavEntryKey.CREDENTIAL_LIST_ENTRY);
|
||||
}
|
||||
} else {
|
||||
router.pushUrl({
|
||||
url: targetRouter
|
||||
});
|
||||
}
|
||||
} })
|
||||
}
|
||||
.stateStyles({
|
||||
normal: this.normalStyle,
|
||||
pressed: this.pressedStyle
|
||||
});
|
||||
}, (item: CertListItem) => JSON.stringify(item))
|
||||
}
|
||||
.padding($r('app.float.wh_value_4'))
|
||||
.divider({
|
||||
strokeWidth: $r('app.float.sys_list_divider_strokeWidth_value'),
|
||||
color: $r('sys.color.ohos_id_color_list_separator'),
|
||||
startMargin: $r('app.float.wh_value_8'),
|
||||
endMargin: $r('app.float.wh_value_8')
|
||||
})
|
||||
.borderRadius($r('app.float.user_list_divider_borderRadius_value'))
|
||||
.backgroundColor($r('sys.color.ohos_id_color_list_card_bg'))
|
||||
|
||||
CertInstallComponent({ mFaPresenter: $mFaPresenter, onItemClicked: () => {
|
||||
if (this.isStartBySheet) {
|
||||
this.selected?.(NavEntryKey.INSTALL_ENTRY);
|
||||
} else {
|
||||
router.pushUrl({
|
||||
url: 'pages/certInstallFromStorage'
|
||||
}, router.RouterMode.Standard)
|
||||
}
|
||||
} })
|
||||
|
||||
DeleteAll({ mFaPresenter: $mFaPresenter })
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
}
|
||||
.align(Alignment.Top)
|
||||
.scrollable(ScrollDirection.Vertical)
|
||||
.scrollBar(BarState.Off)
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(this.isStartBySheet ? WidthPercent.WH_AUTO : WidthPercent.WH_100_100)
|
||||
.edgeEffect(EdgeEffect.Spring)
|
||||
.padding({
|
||||
left: 16,
|
||||
right: 16,
|
||||
bottom: $r('app.float.wh_value_24')
|
||||
})
|
||||
.constraintSize({
|
||||
minHeight: this.getScrollMinHeight()
|
||||
}).onAreaChange((oldArea, newArea) => {
|
||||
this.scrollerHeight = newArea.height as number;
|
||||
})
|
||||
|
||||
Column() {
|
||||
ScrollBar({
|
||||
scroller: this.scroller,
|
||||
direction: ScrollBarDirection.Vertical,
|
||||
state: BarState.Auto
|
||||
}).margin({
|
||||
bottom: $r('app.float.wh_value_24')
|
||||
})
|
||||
}.height(this.scrollerHeight)
|
||||
}
|
||||
.padding({
|
||||
top: this.headRectHeight
|
||||
})
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(this.isStartBySheet ? WidthPercent.WH_AUTO : WidthPercent.WH_100_100)
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(this.isStartBySheet ? WidthPercent.WH_AUTO : WidthPercent.WH_100_100)
|
||||
}
|
||||
}
|
||||
.margin(vp2px(1) === 2 ? $r('app.float.item_common_horizontal_margin') : $r('app.float.wh_value_0'))
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(this.isStartBySheet ? WidthPercent.WH_AUTO : WidthPercent.WH_100_100);
|
||||
}
|
||||
.backgroundColor($r('sys.color.ohos_id_color_sub_background'))
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(this.isStartBySheet ? WidthPercent.WH_AUTO : WidthPercent.WH_100_100)
|
||||
}
|
||||
|
||||
getScrollMinHeight() {
|
||||
if (this.sheetParam === undefined || this.headRectHeightReal === 0 ||
|
||||
this.sheetParam.sheetMinHeight < this.headRectHeightReal) {
|
||||
return 0;
|
||||
}
|
||||
return this.sheetParam.sheetMinHeight - this.headRectHeightReal;
|
||||
}
|
||||
|
||||
onPageShow() {
|
||||
let uri = GlobalContext.getContext().getAbilityWant().uri;
|
||||
GlobalContext.getContext().clearAbilityWantUri();
|
||||
|
||||
if (uri === 'certInstall') {
|
||||
router.pushUrl({
|
||||
url: 'pages/certInstallFromStorage'
|
||||
})
|
||||
} else if (uri === 'requestAuthorize') {
|
||||
this.mFaPresenter.startRequestAuth(GlobalContext.getContext().getAbilityWant().parameters?.appUid as string);
|
||||
} else {
|
||||
console.error('The want type is not supported');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
struct DeleteAll {
|
||||
@Link mFaPresenter: CmFaPresenter;
|
||||
@Styles normalStyle() {
|
||||
.backgroundColor($r('sys.color.ohos_id_color_card_bg'))
|
||||
.borderRadius($r('app.float.user_list_divider_borderRadius_value'))
|
||||
};
|
||||
@Styles pressedStyle() {
|
||||
.backgroundColor($r('sys.color.ohos_id_color_click_effect'))
|
||||
.borderRadius($r('app.float.user_list_divider_borderRadius_value'))
|
||||
};
|
||||
|
||||
deleteWarnDialog: CustomDialogController = new CustomDialogController({
|
||||
builder: CustomContentDialog({
|
||||
contentBuilder: () => {
|
||||
this.deleteWarnContent();
|
||||
},
|
||||
contentAreaPadding: {right: $r('app.float.wh_value_0')},
|
||||
buttons: [
|
||||
{
|
||||
value: $r('app.string.deleteAllCredCancel'),
|
||||
buttonStyle: ButtonStyleMode.TEXTUAL,
|
||||
action: () => {
|
||||
this.deleteWarnDialog?.close();
|
||||
}
|
||||
},
|
||||
{
|
||||
value: $r('app.string.deleteAllCredDelete'),
|
||||
buttonStyle: ButtonStyleMode.TEXTUAL,
|
||||
action: () => {
|
||||
this.mFaPresenter.uninstallAllCert();
|
||||
this.deleteWarnDialog?.close();
|
||||
promptAction.showToast({
|
||||
message: $r('app.string.delete_success'),
|
||||
duration: DISPLAY_DURATION,
|
||||
})
|
||||
},
|
||||
role: ButtonRole.ERROR
|
||||
}
|
||||
]
|
||||
}),
|
||||
})
|
||||
|
||||
@Builder
|
||||
deleteWarnContent(): void {
|
||||
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)
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.borderRadius($r('app.float.user_list_divider_borderRadius_value'))
|
||||
}
|
||||
|
||||
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('sys.color.ohos_id_color_text_hyperlink'))
|
||||
.padding({ left: $r('app.float.distance_8') })
|
||||
.stateStyles({
|
||||
normal: this.normalStyle,
|
||||
pressed: this.pressedStyle
|
||||
})
|
||||
.height(WidthPercent.WH_100_100)
|
||||
.borderRadius($r('app.float.radius_20'))
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.textAlign(TextAlign.Start);
|
||||
}
|
||||
.padding($r('app.float.distance_4'))
|
||||
.height($r('app.float.wh_value_56'))
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.borderRadius($r('app.float.radius_24'))
|
||||
.backgroundColor($r('sys.color.ohos_id_color_foreground_contrary'))
|
||||
.onClick(() => {
|
||||
this.deleteWarnDialog.open();
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
export struct CertInstallComponent {
|
||||
@Link mFaPresenter: CmFaPresenter;
|
||||
@Styles normalStyle() {
|
||||
.backgroundColor($r('sys.color.ohos_id_color_card_bg'))
|
||||
.borderRadius($r('app.float.user_list_divider_borderRadius_value'))
|
||||
};
|
||||
@Styles pressedStyle() {
|
||||
.backgroundColor($r('sys.color.ohos_id_color_click_effect'))
|
||||
.borderRadius($r('app.float.user_list_divider_borderRadius_value'))
|
||||
};
|
||||
|
||||
onItemClicked?: () => void;
|
||||
|
||||
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('sys.color.ohos_id_color_text_primary'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.margin({ left: $r('app.float.wh_value_8') });
|
||||
}
|
||||
|
||||
Image($r('app.media.ic_settings_arrow'))
|
||||
.width($r('app.float.wh_value_12'))
|
||||
.height($r('app.float.wh_value_24'))
|
||||
.fillColor($r('sys.color.ohos_id_color_primary'))
|
||||
.opacity($r('app.float.opacity_0_2'))
|
||||
.margin({ right: $r('app.float.wh_value_8') });
|
||||
}
|
||||
.borderRadius($r('app.float.radius_20'))
|
||||
.height(WidthPercent.WH_100_100)
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.stateStyles({
|
||||
normal: this.normalStyle,
|
||||
pressed: this.pressedStyle
|
||||
})
|
||||
}
|
||||
.backgroundColor($r('sys.color.ohos_id_color_foreground_contrary'))
|
||||
.padding($r('app.float.distance_4'))
|
||||
.height($r('app.float.wh_value_56'))
|
||||
.borderRadius($r('app.float.radius_24'))
|
||||
.onClick(() => {
|
||||
this.onItemClicked?.();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,160 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import HeadComponent from '../common/component/headComponent';
|
||||
import { WidthPercent, ConfigValue } from '../common/util/ConfigData';
|
||||
import router from '@ohos.router';
|
||||
import CmFaPresenter from '../presenter/CmFaPresenter';
|
||||
import { GlobalContext } from '../common/GlobalContext';
|
||||
import { RouterFileVo } from '../model/CertManagerVo/RouterInfoVo';
|
||||
import CmInstallPresenter from '../presenter/CmInstallPresenter';
|
||||
import { CMModelErrorCode } from '../model/CertMangerModel';
|
||||
import ComponentConfig from '../common/component/ComponentConfig';
|
||||
import PreventScreenshotsPresenter from '../model/PreventScreenshotsModel';
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct CertPwdInput {
|
||||
@State certPwd: string = '';
|
||||
@State mFaPresenter: CmFaPresenter = CmFaPresenter.getInstance();
|
||||
@State isPasswordError: boolean = false;
|
||||
@State passWordWarn: number = 0;
|
||||
@State mAppCredAuthPresenter: CmInstallPresenter = CmInstallPresenter.getInstance();
|
||||
@State mPreventScreenshotsPresenter: PreventScreenshotsPresenter = PreventScreenshotsPresenter.getInstance();
|
||||
|
||||
onPageShow() {
|
||||
this.mPreventScreenshotsPresenter.PreventScreenshots(true, GlobalContext.getContext().getSession());
|
||||
let uri = GlobalContext.getContext().getAbilityWant().uri;
|
||||
GlobalContext.getContext().clearAbilityWantUri();
|
||||
|
||||
if (uri === 'certInstall') {
|
||||
router.pushUrl({
|
||||
url: 'pages/certInstallFromStorage'
|
||||
})
|
||||
} else if (uri === 'requestAuthorize') {
|
||||
this.mFaPresenter.startRequestAuth(GlobalContext.getContext().getAbilityWant().parameters?.appUid as string);
|
||||
} else {
|
||||
console.error('The want type is not supported');
|
||||
}
|
||||
}
|
||||
|
||||
onPageHide() {
|
||||
this.mPreventScreenshotsPresenter.PreventScreenshots(false, GlobalContext.getContext().getSession());
|
||||
}
|
||||
|
||||
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({ text: this.certPwd })
|
||||
.type(InputType.Password)
|
||||
.focusable(true)
|
||||
.border(this.isPasswordError ? {
|
||||
width: $r('app.float.wh_value_1'),
|
||||
color: $r('sys.color.ohos_id_color_warning')
|
||||
} : { width: $r('app.float.wh_value_0') })
|
||||
.maxLength(ConfigValue.PWD_MAX_LENGTH)
|
||||
.margin({
|
||||
top: $r('app.float.distance_16'),
|
||||
left: $r('app.float.distance_24'),
|
||||
right: $r('app.float.distance_24')
|
||||
})
|
||||
.height($r('app.float.wh_value_40'))
|
||||
.onChange((value: string) => {
|
||||
this.certPwd = value;
|
||||
})
|
||||
|
||||
Row() {
|
||||
Text($r('app.string.Password_Message'))
|
||||
.fontFamily('HarmonyHeiTi')
|
||||
.fontSize($r('app.float.distance_14'))
|
||||
.fontWeight(FontWeight.Regular)
|
||||
.lineHeight($r('app.float.distance_19'))
|
||||
.width(ComponentConfig.WH_100_100)
|
||||
.textAlign(TextAlign.Center)
|
||||
.fontColor($r('sys.color.ohos_id_color_warning'))
|
||||
.visibility(this.passWordWarn === CMModelErrorCode.CM_MODEL_ERROR_PASSWORD_ERR
|
||||
? Visibility.Visible : Visibility.None)
|
||||
}
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(WidthPercent.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'),
|
||||
})
|
||||
.enabled(this.certPwd !== undefined && this.certPwd.length > 0)
|
||||
.onClick(() => {
|
||||
let fileInfo: RouterFileVo = router.getParams() as RouterFileVo;
|
||||
this.isPasswordError = false;
|
||||
GlobalContext.getContext().getPwdStore().setCertPwd(this.certPwd);
|
||||
CmInstallPresenter.getInstance().installCert(fileInfo.uri, '', fileInfo.suffix, true).then((resultCode) => {
|
||||
this.passWordWarn = resultCode;
|
||||
if (resultCode === CMModelErrorCode.CM_MODEL_ERROR_PASSWORD_ERR) {
|
||||
this.isPasswordError = true;
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
.margin({ bottom: $r('app.float.wh_value_24') })
|
||||
}
|
||||
.justifyContent(FlexAlign.End)
|
||||
.height(WidthPercent.WH_25_100);
|
||||
}
|
||||
.backgroundColor($r('sys.color.ohos_id_color_sub_background'))
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(WidthPercent.WH_100_100);
|
||||
}
|
||||
}
|
||||
@@ -1,173 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import HeadComponent from '../../common/component/headComponent';
|
||||
import { WidthPercent } from '../../common/util/ConfigData';
|
||||
import { AppAuthorVo } from '../../model/CertManagerVo/AppAuthorVo';
|
||||
import CmShowAppCredPresenter from '../../presenter/CmShowAppCredPresenter';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
import { SheetParam } from '../../common/util/SheetParam';
|
||||
import { NavEntryKey } from '../../common/NavEntryKey';
|
||||
|
||||
const TAG: string = 'AuthorizedAppManagementPage: ';
|
||||
|
||||
export class AuthorizedAppManagementParam {
|
||||
public presenter: CmShowAppCredPresenter;
|
||||
|
||||
constructor(presenter: CmShowAppCredPresenter) {
|
||||
this.presenter = presenter;
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
export struct DialogComponent {
|
||||
@Link uidItem: CmShowAppCredPresenter;
|
||||
private appName: string = '';
|
||||
private appImage: string = '';
|
||||
private indexNum: number = 0;
|
||||
|
||||
onChanged?: () => void;
|
||||
|
||||
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.indexNum].status = isOn;
|
||||
if (!isOn) {
|
||||
this.onChanged?.();
|
||||
}
|
||||
})
|
||||
.margin({ right: $r('app.float.wh_value_16') })
|
||||
|
||||
}.height($r('app.float.wh_value_72'))
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
export struct AuthorizedAppManagementPage {
|
||||
private stack?: NavPathStack;
|
||||
|
||||
@State presenter: CmShowAppCredPresenter = CmShowAppCredPresenter.getInstance();
|
||||
@Prop sheetParam: SheetParam;
|
||||
@State private headRectHeight: number = 64;
|
||||
@State private headRectHeightReal: number = 0;
|
||||
private scroller: Scroller = new Scroller();
|
||||
@State private scrollerHeight: number = 0;
|
||||
|
||||
build() {
|
||||
NavDestination() {
|
||||
Stack({ alignContent: Alignment.Top }) {
|
||||
Column() {
|
||||
HeadComponent({ headName: $r('app.string.managerAuthApp'), isStartBySheet: true, onBackClicked: () => {
|
||||
this.stack?.pop();
|
||||
} })
|
||||
.margin({
|
||||
left: $r('app.float.wh_value_12'),
|
||||
top: 8
|
||||
})
|
||||
}.zIndex(1)
|
||||
.onAreaChange((oldArea, newArea) => {
|
||||
this.headRectHeight = newArea.height as number;
|
||||
this.headRectHeightReal = newArea.height as number;
|
||||
})
|
||||
|
||||
Stack({ alignContent: Alignment.TopEnd }) {
|
||||
Scroll(this.scroller) {
|
||||
List() {
|
||||
ForEach(this.presenter.appInfoList, (item: AppAuthorVo, index) => {
|
||||
ListItem() {
|
||||
DialogComponent({ appImage: item.appImage, appName: item.appName,
|
||||
indexNum: index, uidItem: $presenter,
|
||||
onChanged: async () => {
|
||||
await this.presenter.removeGrantedAppList(this.presenter.credInfo.keyUri);
|
||||
this.presenter.getAuthorizedAppList(this.presenter.credInfo.keyUri);
|
||||
} })
|
||||
}
|
||||
})
|
||||
}
|
||||
.scrollBar(BarState.Off)
|
||||
.divider({
|
||||
strokeWidth: $r('app.float.Evidence_strokeWidth'),
|
||||
color: $r('sys.color.ohos_id_color_list_separator'),
|
||||
startMargin: 64
|
||||
})
|
||||
}
|
||||
.align(Alignment.Top)
|
||||
.edgeEffect(EdgeEffect.Spring)
|
||||
.constraintSize({
|
||||
minHeight: this.getScrollMinHeight()
|
||||
})
|
||||
.scrollBar(BarState.Off)
|
||||
.padding({
|
||||
left: $r('app.float.wh_value_24'),
|
||||
bottom: $r('app.float.wh_value_24')
|
||||
}).onAreaChange((oldArea, newArea) => {
|
||||
this.scrollerHeight = newArea.height as number;
|
||||
})
|
||||
|
||||
Column() {
|
||||
ScrollBar({
|
||||
scroller: this.scroller,
|
||||
direction: ScrollBarDirection.Vertical,
|
||||
state: BarState.Auto
|
||||
}).margin({
|
||||
bottom: $r('app.float.wh_value_24')
|
||||
})
|
||||
}.height(this.scrollerHeight)
|
||||
}.padding({
|
||||
top: this.headRectHeight
|
||||
})
|
||||
}
|
||||
}
|
||||
.hideTitleBar(true)
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(this.sheetParam?.lastSheetPage === NavEntryKey.AUTHORIZED_APP_ENTRY ?
|
||||
WidthPercent.WH_AUTO : this.sheetParam?.sheetMinHeight)
|
||||
.backgroundColor($r('sys.color.background_secondary'))
|
||||
.onReady((ctx: NavDestinationContext) => {
|
||||
this.stack = ctx.pathStack;
|
||||
try {
|
||||
this.presenter = (ctx.pathInfo.param as AuthorizedAppManagementParam).presenter;
|
||||
} catch (err) {
|
||||
let error = err as BusinessError;
|
||||
console.error(TAG + 'Get presenter failed: ' + error?.code + ', message: ' + error?.message);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
getScrollMinHeight() {
|
||||
if (this.sheetParam === undefined || this.headRectHeightReal === 0 ||
|
||||
this.sheetParam.sheetMinHeight < this.headRectHeightReal) {
|
||||
return 0;
|
||||
}
|
||||
return this.sheetParam.sheetMinHeight - this.headRectHeightReal;
|
||||
}
|
||||
}
|
||||
@@ -1,375 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import HeadComponent from '../../common/component/headComponent';
|
||||
import { NavEntryKey } from '../../common/NavEntryKey';
|
||||
import { WidthPercent } from '../../common/util/ConfigData';
|
||||
import CmShowSysCaPresenter from '../../presenter/CmShowSysCaPresenter';
|
||||
import { SheetParam } from '../../common/util/SheetParam';
|
||||
|
||||
@Component
|
||||
export struct DialogSubjectComponent {
|
||||
private map?: Map<string, string>;
|
||||
private subjectNameCN: string = '';
|
||||
private subjectNameO: string = '';
|
||||
private subjectNameOU: string = '';
|
||||
private serial: string = '';
|
||||
|
||||
aboutToAppear() {
|
||||
if (this.map != null) {
|
||||
let subjectNameCN = this.map.get('常用名称:');
|
||||
if (subjectNameCN !== undefined) {
|
||||
this.subjectNameCN = subjectNameCN;
|
||||
}
|
||||
|
||||
let subjectNameO = this.map.get('组织:');
|
||||
if (subjectNameO !== undefined) {
|
||||
this.subjectNameO = subjectNameO;
|
||||
}
|
||||
|
||||
let subjectNameOU = this.map.get('组织单位:');
|
||||
if (subjectNameOU !== undefined) {
|
||||
this.subjectNameOU = subjectNameOU;
|
||||
}
|
||||
|
||||
let serial = this.map.get('序列号:');
|
||||
if (serial !== undefined) {
|
||||
this.serial = serial;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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.sys_elements_margin_vertical_l')
|
||||
})
|
||||
Text(this.subjectNameCN)
|
||||
.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.sys_elements_margin_vertical_m')
|
||||
})
|
||||
Text(this.subjectNameO)
|
||||
.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.sys_elements_margin_vertical_m')
|
||||
})
|
||||
Text(this.subjectNameOU)
|
||||
.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.sys_elements_margin_vertical_m')
|
||||
})
|
||||
Text(this.serial)
|
||||
.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
|
||||
export struct DialogIssuerComponent {
|
||||
private map?: Map<string, string>;
|
||||
private issuerNameCN: string = '';
|
||||
private issuerNameO: string = '';
|
||||
private issuerNameOU: string = '';
|
||||
|
||||
aboutToAppear() {
|
||||
if (this.map != null) {
|
||||
let issuerNameCN = this.map.get('常用名称:');
|
||||
if (issuerNameCN !== undefined) {
|
||||
this.issuerNameCN = issuerNameCN;
|
||||
}
|
||||
|
||||
let issuerNameO = this.map.get('组织:');
|
||||
if (issuerNameO !== undefined) {
|
||||
this.issuerNameO = issuerNameO;
|
||||
}
|
||||
|
||||
let issuerNameOU = this.map.get('组织单位:');
|
||||
if (issuerNameOU !== undefined) {
|
||||
this.issuerNameOU = issuerNameOU;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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.sys_elements_margin_vertical_l')
|
||||
})
|
||||
Text(this.issuerNameCN)
|
||||
.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.sys_elements_margin_vertical_m')
|
||||
})
|
||||
Text(this.issuerNameO)
|
||||
.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.sys_elements_margin_vertical_m')
|
||||
})
|
||||
Text(this.issuerNameOU)
|
||||
.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
|
||||
export struct DialogDateComponent {
|
||||
private map?: Map<string, string>;
|
||||
private notBefore: string = '';
|
||||
private notAfter: string = '';
|
||||
|
||||
aboutToAppear() {
|
||||
if (this.map != null) {
|
||||
let notBefore = this.map.get('颁发时间:');
|
||||
if (notBefore != undefined) {
|
||||
this.notBefore = notBefore;
|
||||
}
|
||||
|
||||
let notAfter = this.map.get('有效期至:');
|
||||
if (notAfter != undefined) {
|
||||
this.notAfter = notAfter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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.sys_elements_margin_vertical_l')
|
||||
})
|
||||
Text(this.notBefore)
|
||||
.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.sys_elements_margin_vertical_m')
|
||||
})
|
||||
Text(this.notAfter)
|
||||
.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
|
||||
export 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.sys_elements_margin_vertical_l')
|
||||
})
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
export struct CaSystemDetailPage {
|
||||
@State mShowSysCaPresenter: CmShowSysCaPresenter = CmShowSysCaPresenter.getInstance();
|
||||
|
||||
private stack?: NavPathStack;
|
||||
|
||||
@State headRectHeight: number = 64;
|
||||
@State headRectHeightReal: number = 0;
|
||||
@Prop sheetParam: SheetParam;
|
||||
private scroller: Scroller = new Scroller();
|
||||
@State scrollerHeight: number = 0;
|
||||
|
||||
build() {
|
||||
NavDestination() {
|
||||
Stack({ alignContent: Alignment.Top }) {
|
||||
Column() {
|
||||
HeadComponent({ headName: $r('app.string.CustomDialogExample_firText'), isStartBySheet: true, onBackClicked: () => {
|
||||
this.stack?.pop();
|
||||
} })
|
||||
.margin({
|
||||
left: $r('app.float.wh_value_12'),
|
||||
top: 8
|
||||
})
|
||||
}.zIndex(1)
|
||||
.onAreaChange((oldArea, newArea) => {
|
||||
this.headRectHeight = newArea.height as number;
|
||||
this.headRectHeightReal = newArea.height as number;
|
||||
})
|
||||
|
||||
Stack({ alignContent: Alignment.TopEnd }) {
|
||||
Scroll(this.scroller) {
|
||||
this.buildContent()
|
||||
}
|
||||
.padding({
|
||||
left: 16, right: 16,
|
||||
bottom: $r('app.float.wh_value_24')
|
||||
})
|
||||
.align(Alignment.Top)
|
||||
.scrollable(ScrollDirection.Vertical)
|
||||
.edgeEffect(EdgeEffect.Spring)
|
||||
.scrollBar(BarState.Off)
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(WidthPercent.WH_AUTO)
|
||||
.constraintSize({
|
||||
minHeight: this.getScrollMinHeight()
|
||||
}).onAreaChange((oldArea, newArea) => {
|
||||
this.scrollerHeight = newArea.height as number;
|
||||
})
|
||||
|
||||
Column() {
|
||||
ScrollBar({
|
||||
scroller: this.scroller,
|
||||
direction: ScrollBarDirection.Vertical,
|
||||
state: BarState.Auto
|
||||
}).margin({
|
||||
bottom: $r('app.float.wh_value_24')
|
||||
})
|
||||
}.height(this.scrollerHeight)
|
||||
}.padding({
|
||||
top: this.headRectHeight
|
||||
})
|
||||
}
|
||||
}
|
||||
.hideTitleBar(true)
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(this.sheetParam?.lastSheetPage === NavEntryKey.CA_SYSTEM_DETAIL_ENTRY ?
|
||||
WidthPercent.WH_AUTO : this.sheetParam?.sheetMinHeight)
|
||||
.backgroundColor($r('sys.color.background_secondary'))
|
||||
.onReady((ctx: NavDestinationContext) => {
|
||||
this.stack = ctx.pathStack;
|
||||
})
|
||||
}
|
||||
|
||||
getScrollMinHeight() {
|
||||
if (this.sheetParam === undefined || this.headRectHeightReal === 0 ||
|
||||
this.sheetParam.sheetMinHeight < this.headRectHeightReal) {
|
||||
return 0;
|
||||
}
|
||||
return this.sheetParam.sheetMinHeight - this.headRectHeightReal;
|
||||
}
|
||||
|
||||
@Builder
|
||||
private buildContent() {
|
||||
Column() {
|
||||
Text(this.mShowSysCaPresenter.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_8'),
|
||||
bottom: $r('app.float.wh_value_24')
|
||||
})
|
||||
.alignSelf(ItemAlign.Start)
|
||||
|
||||
Text($r('app.string.CustomDialogExample_firListItem_text'))
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body1'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
|
||||
DialogSubjectComponent({ map: this.mShowSysCaPresenter.certInfo.subjectNameMap })
|
||||
|
||||
Text($r('app.string.CustomDialogExample_secListItem_text'))
|
||||
.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_24')
|
||||
})
|
||||
|
||||
DialogIssuerComponent({ map: this.mShowSysCaPresenter.certInfo.issuerNameMap })
|
||||
|
||||
Text($r('app.string.CustomDialogExample_thdListItem_text'))
|
||||
.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_24')
|
||||
})
|
||||
|
||||
DialogDateComponent({ map: this.mShowSysCaPresenter.certInfo.dateMap })
|
||||
|
||||
Text($r('app.string.CustomDialogExample_fouListItem_text'))
|
||||
.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_24')
|
||||
})
|
||||
|
||||
DialogFingerPrintComponent({ fingerprintSha256: this.mShowSysCaPresenter.certInfo.fingerprintSha256 })
|
||||
}
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
.width(WidthPercent.WH_100_100)
|
||||
}
|
||||
}
|
||||
@@ -1,269 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import HeadComponent from '../../common/component/headComponent';
|
||||
import { WidthPercent } from '../../common/util/ConfigData';
|
||||
import CmShowUserCaPresenter from '../../presenter/CmShowUserCaPresenter';
|
||||
import {
|
||||
DialogDateComponent,
|
||||
DialogFingerPrintComponent,
|
||||
DialogIssuerComponent,
|
||||
DialogSubjectComponent
|
||||
} from './CaSystemDetailPage';
|
||||
import { AlertDialog } from '@ohos.arkui.advanced.Dialog';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
import { SheetParam } from '../../common/util/SheetParam';
|
||||
import { NavEntryKey } from '../../common/NavEntryKey';
|
||||
|
||||
const TAG: string = 'CaUserDetailPage: ';
|
||||
|
||||
export class CaUserDetailParam {
|
||||
public showUserCaPresenter: CmShowUserCaPresenter;
|
||||
|
||||
constructor(presenter: CmShowUserCaPresenter) {
|
||||
this.showUserCaPresenter = presenter;
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
export struct CaUserDetailPage {
|
||||
private showUserCaPresenter: CmShowUserCaPresenter = CmShowUserCaPresenter.getInstance();
|
||||
|
||||
private stack?: NavPathStack;
|
||||
|
||||
@State private bottomRectHeight: number = 80;
|
||||
@State private headRectHeight: number = 64;
|
||||
@State private headRectHeightReal: number = 0;
|
||||
|
||||
@State toggleStatus: boolean = false;
|
||||
@Prop sheetParam: SheetParam;
|
||||
|
||||
rootCertificateDialog: CustomDialogController = new CustomDialogController({
|
||||
alignment: DialogAlignment.Center,
|
||||
cancel: () => {
|
||||
this.toggleStatus = false;
|
||||
},
|
||||
builder: AlertDialog({
|
||||
primaryTitle: $r('app.string.root_certificate'),
|
||||
content: $r('app.string.root_certificate_message'),
|
||||
primaryButton: {
|
||||
value: $r('app.string.root_certificate_cancel'),
|
||||
buttonStyle: ButtonStyleMode.TEXTUAL,
|
||||
action: () => {
|
||||
this.toggleStatus = false;
|
||||
this.showUserCaPresenter.updateUserTrustedCertificateList();
|
||||
}
|
||||
},
|
||||
secondaryButton: {
|
||||
value: $r('app.string.root_certificate_continue'),
|
||||
buttonStyle: ButtonStyleMode.TEXTUAL,
|
||||
action: () => {
|
||||
this.showUserCaPresenter.setUserCertificateStatus(this.showUserCaPresenter.certInfo.uri, true)
|
||||
.then(result => {
|
||||
if (result) {
|
||||
this.showUserCaPresenter.updateUserTrustedCertificateList();
|
||||
} else {
|
||||
this.toggleStatus = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
deleteCertWarnDialog: CustomDialogController = new CustomDialogController({
|
||||
builder: AlertDialog({
|
||||
primaryTitle: $r('app.string.CustomDialogExampleUser_warning_Button_title_text'),
|
||||
content: $r('app.string.CustomDialogExampleUser_warning_Button_message_text'),
|
||||
primaryButton: {
|
||||
value: $r('app.string.deleteAllCredCancel'),
|
||||
buttonStyle: ButtonStyleMode.TEXTUAL,
|
||||
action: () => {
|
||||
}
|
||||
},
|
||||
secondaryButton: {
|
||||
value: $r('app.string.deleteAllCredDelete'),
|
||||
buttonStyle: ButtonStyleMode.TEXTUAL,
|
||||
action: () => {
|
||||
this.showUserCaPresenter.deleteUserCertificate(this.showUserCaPresenter.certInfo.uri, () => {
|
||||
this.showUserCaPresenter.updateUserTrustedCertificateList();
|
||||
})
|
||||
this.stack?.pop();
|
||||
},
|
||||
role: ButtonRole.ERROR
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
build() {
|
||||
NavDestination() {
|
||||
Stack({ alignContent: Alignment.Bottom }) {
|
||||
Stack({ alignContent: Alignment.Top }) {
|
||||
Column() {
|
||||
HeadComponent({ headName: $r('app.string.CustomDialogExample_firText'), isStartBySheet: true, onBackClicked: () => {
|
||||
this.stack?.pop();
|
||||
} })
|
||||
.margin({
|
||||
left: $r('app.float.wh_value_12'),
|
||||
top: 8
|
||||
})
|
||||
}.zIndex(1)
|
||||
.onAreaChange((oldArea, newArea) => {
|
||||
this.headRectHeight = newArea.height as number;
|
||||
this.headRectHeightReal = newArea.height as number;
|
||||
})
|
||||
|
||||
Stack({ alignContent: Alignment.TopEnd }) {
|
||||
Scroll() {
|
||||
this.buildContent()
|
||||
}
|
||||
.padding({
|
||||
left: 16, right: 16
|
||||
})
|
||||
.align(Alignment.Top)
|
||||
.scrollable(ScrollDirection.Vertical)
|
||||
.scrollBar(BarState.Auto)
|
||||
.edgeEffect(EdgeEffect.Spring)
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(WidthPercent.WH_AUTO)
|
||||
.constraintSize({
|
||||
minHeight: this.getScrollMinHeight()
|
||||
})
|
||||
}.padding({
|
||||
top: this.headRectHeight
|
||||
})
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(WidthPercent.WH_AUTO)
|
||||
.padding({
|
||||
bottom: this.bottomRectHeight
|
||||
})
|
||||
|
||||
Column() {
|
||||
Button($r('app.string.CustomDialogExampleUser_warning_Button_title_text'))
|
||||
.onClick(() => {
|
||||
this.deleteCertWarnDialog.open();
|
||||
})
|
||||
.role(ButtonRole.ERROR)
|
||||
.buttonStyle(ButtonStyleMode.NORMAL)
|
||||
.margin({
|
||||
top: $r('app.float.distance_16'),
|
||||
bottom: $r('app.float.distance_24')
|
||||
})
|
||||
.width(WidthPercent.WH_100_100)
|
||||
}.onAreaChange((oldArea: Area, newArea: Area) => {
|
||||
this.bottomRectHeight = newArea.height as number;
|
||||
})
|
||||
.padding({
|
||||
left: 16, right: 16
|
||||
})
|
||||
}
|
||||
}
|
||||
.hideTitleBar(true)
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(this.sheetParam?.lastSheetPage === NavEntryKey.CA_USER_DETAIL_ENTRY ?
|
||||
WidthPercent.WH_AUTO : this.sheetParam?.sheetMinHeight)
|
||||
.backgroundColor($r('sys.color.background_secondary'))
|
||||
.onReady((ctx: NavDestinationContext) => {
|
||||
this.stack = ctx.pathStack;
|
||||
try {
|
||||
this.showUserCaPresenter = (ctx.pathInfo.param as CaUserDetailParam).showUserCaPresenter;
|
||||
this.toggleStatus = this.showUserCaPresenter.certInfo.status;
|
||||
} catch (err) {
|
||||
let error = err as BusinessError;
|
||||
console.error(TAG + 'Get presenter failed: ' + error?.code + ', message: ' + error?.message);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@Builder
|
||||
private buildContent() {
|
||||
Column() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
|
||||
Column() {
|
||||
Text(this.showUserCaPresenter.certInfo.certAlias)
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body1'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
}.alignItems(HorizontalAlign.Start);
|
||||
|
||||
Toggle({ type: ToggleType.Switch, isOn: $$this.toggleStatus })
|
||||
.margin({
|
||||
left: $r('app.float.wh_value_5')
|
||||
})
|
||||
.flexShrink(0)
|
||||
.onChange((isOn: boolean) => {
|
||||
if (isOn) {
|
||||
this.rootCertificateDialog.open();
|
||||
} else {
|
||||
this.showUserCaPresenter.setUserCertificateStatus(this.showUserCaPresenter.certInfo.uri, false);
|
||||
}
|
||||
})
|
||||
}.margin({ top: 8 })
|
||||
|
||||
Text($r('app.string.CustomDialogExample_firListItem_text'))
|
||||
.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_24')
|
||||
})
|
||||
|
||||
DialogSubjectComponent({ map: this.showUserCaPresenter.certInfo.subjectNameMap })
|
||||
|
||||
Text($r('app.string.CustomDialogExample_secListItem_text'))
|
||||
.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_24')
|
||||
})
|
||||
|
||||
DialogIssuerComponent({ map: this.showUserCaPresenter.certInfo.issuerNameMap })
|
||||
|
||||
Text($r('app.string.CustomDialogExample_thdListItem_text'))
|
||||
.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_24')
|
||||
})
|
||||
|
||||
DialogDateComponent({ map: this.showUserCaPresenter.certInfo.dateMap })
|
||||
|
||||
Text($r('app.string.CustomDialogExample_fouListItem_text'))
|
||||
.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_24')
|
||||
})
|
||||
|
||||
DialogFingerPrintComponent({
|
||||
fingerprintSha256: this.showUserCaPresenter.certInfo.fingerprintSha256
|
||||
})
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
}
|
||||
|
||||
getScrollMinHeight() {
|
||||
if (this.sheetParam === undefined || this.headRectHeightReal === 0 ||
|
||||
this.sheetParam.sheetMinHeight < (this.headRectHeightReal + this.bottomRectHeight)) {
|
||||
return 0;
|
||||
}
|
||||
return this.sheetParam.sheetMinHeight - this.headRectHeightReal - this.bottomRectHeight;
|
||||
}
|
||||
}
|
||||
@@ -1,207 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import HeadComponent from '../../common/component/headComponent';
|
||||
import { ConfigValue, WidthPercent } from '../../common/util/ConfigData';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
import { CMModelErrorCode } from '../../model/CertMangerModel';
|
||||
import { RouterFileVo } from '../../model/CertManagerVo/RouterInfoVo';
|
||||
import { GlobalContext } from '../../common/GlobalContext';
|
||||
import CmInstallPresenter from '../../presenter/CmInstallPresenter';
|
||||
import { SheetParam } from '../../common/util/SheetParam';
|
||||
import { NavEntryKey } from '../../common/NavEntryKey';
|
||||
|
||||
const TAG: string = 'CredPwdInputPage: ';
|
||||
|
||||
export class CredPwdInputParam {
|
||||
public credFile: RouterFileVo;
|
||||
|
||||
constructor(file: RouterFileVo) {
|
||||
this.credFile = file;
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
export struct CredPwdInputPage {
|
||||
private stack?: NavPathStack;
|
||||
|
||||
private credFile?: RouterFileVo;
|
||||
|
||||
@State private bottomRectHeight: number = 80;
|
||||
@State private headRectHeight: number = 64;
|
||||
@State private headRectHeightReal: number = 0;
|
||||
|
||||
@State certPwd: string = '';
|
||||
@State isPasswordError: boolean = false;
|
||||
@State passWordWarn: number = 0;
|
||||
@Prop sheetParam: SheetParam;
|
||||
|
||||
build() {
|
||||
NavDestination() {
|
||||
Stack({ alignContent: Alignment.Bottom }) {
|
||||
Stack({ alignContent: Alignment.Top }) {
|
||||
Column() {
|
||||
HeadComponent({ headName: $r('app.string.certificatePwdTab'), isStartBySheet: true, onBackClicked: () => {
|
||||
this.stack?.pop();
|
||||
} })
|
||||
.margin({
|
||||
left: $r('app.float.wh_value_12'),
|
||||
top: 8
|
||||
})
|
||||
}.zIndex(1)
|
||||
.onAreaChange((oldArea, newArea) => {
|
||||
this.headRectHeight = newArea.height as number;
|
||||
this.headRectHeightReal = newArea.height as number;
|
||||
})
|
||||
|
||||
Stack({ alignContent: Alignment.TopEnd }) {
|
||||
Scroll() {
|
||||
this.buildContent()
|
||||
}
|
||||
.align(Alignment.Top)
|
||||
.scrollable(ScrollDirection.Vertical)
|
||||
.scrollBar(BarState.Off)
|
||||
.edgeEffect(EdgeEffect.Spring)
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(WidthPercent.WH_AUTO)
|
||||
.constraintSize({
|
||||
minHeight: this.getScrollMinHeight()
|
||||
})
|
||||
}.padding({
|
||||
top: this.headRectHeight
|
||||
})
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(WidthPercent.WH_AUTO)
|
||||
.padding({
|
||||
bottom: this.bottomRectHeight
|
||||
})
|
||||
|
||||
Column() {
|
||||
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(WidthPercent.WH_100_100)
|
||||
.height($r('app.float.wh_value_40'))
|
||||
.margin({
|
||||
top: $r('app.float.distance_16'),
|
||||
bottom: $r('app.float.distance_24')
|
||||
})
|
||||
.enabled(this.certPwd !== undefined && this.certPwd.length > 0)
|
||||
.onClick(() => {
|
||||
if (this.credFile === undefined || this.credFile === null) {
|
||||
console.error(TAG + 'Cred file is undefined');
|
||||
return;
|
||||
}
|
||||
this.isPasswordError = false;
|
||||
GlobalContext.getContext().getPwdStore().setCertPwd(this.certPwd);
|
||||
CmInstallPresenter.getInstance().installCert(this.credFile.uri, '', this.credFile.suffix, false).then((resultCode) => {
|
||||
this.passWordWarn = resultCode;
|
||||
console.log(TAG + 'install cred result code = ' + resultCode);
|
||||
if (resultCode === CMModelErrorCode.CM_MODEL_ERROR_PASSWORD_ERR) {
|
||||
this.isPasswordError = true;
|
||||
} else {
|
||||
this.stack?.pop();
|
||||
}
|
||||
});
|
||||
})
|
||||
}.onAreaChange((oldArea: Area, newArea: Area) => {
|
||||
this.bottomRectHeight = newArea.height as number;
|
||||
})
|
||||
.padding({
|
||||
left: 16, right: 16
|
||||
})
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(WidthPercent.WH_AUTO)
|
||||
}
|
||||
.expandSafeArea([SafeAreaType.KEYBOARD])
|
||||
.hideTitleBar(true)
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(this.sheetParam?.lastSheetPage === NavEntryKey.CRED_PWD_INPUT_ENTRY ?
|
||||
WidthPercent.WH_AUTO : this.sheetParam?.sheetMinHeight)
|
||||
.backgroundColor($r('sys.color.background_secondary'))
|
||||
.onReady((ctx: NavDestinationContext) => {
|
||||
this.stack = ctx.pathStack;
|
||||
try {
|
||||
this.credFile = (ctx.pathInfo.param as CredPwdInputParam).credFile;
|
||||
} catch (err) {
|
||||
let error = err as BusinessError;
|
||||
console.error(TAG + 'Get cred file failed: ' + error?.code + ', message: ' + error?.message);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@Builder
|
||||
private buildContent() {
|
||||
Column() {
|
||||
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({ text: this.certPwd })
|
||||
.type(InputType.Password)
|
||||
.focusable(true)
|
||||
.border(this.isPasswordError ? {
|
||||
width: $r('app.float.wh_value_1'),
|
||||
color: $r('sys.color.ohos_id_color_warning')
|
||||
} : { width: $r('app.float.wh_value_0') })
|
||||
.maxLength(ConfigValue.PWD_MAX_LENGTH)
|
||||
.margin({
|
||||
top: $r('app.float.distance_16'),
|
||||
left: $r('app.float.distance_24'),
|
||||
right: $r('app.float.distance_24')
|
||||
})
|
||||
.height($r('app.float.wh_value_40'))
|
||||
.onChange((value: string) => {
|
||||
this.certPwd = value;
|
||||
})
|
||||
|
||||
Row() {
|
||||
Text($r('app.string.Password_Message'))
|
||||
.fontFamily('HarmonyHeiTi')
|
||||
.fontSize($r('app.float.distance_14'))
|
||||
.fontWeight(FontWeight.Regular)
|
||||
.lineHeight($r('app.float.distance_19'))
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.textAlign(TextAlign.Center)
|
||||
.fontColor($r('sys.color.ohos_id_color_warning'))
|
||||
.visibility(this.passWordWarn === CMModelErrorCode.CM_MODEL_ERROR_PASSWORD_ERR
|
||||
? Visibility.Visible : Visibility.None)
|
||||
}
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
}
|
||||
|
||||
getScrollMinHeight() {
|
||||
if (this.sheetParam === undefined || this.headRectHeightReal === 0 ||
|
||||
this.sheetParam.sheetMinHeight < (this.headRectHeightReal + this.bottomRectHeight)) {
|
||||
return 0;
|
||||
}
|
||||
return this.sheetParam.sheetMinHeight - this.headRectHeightReal - this.bottomRectHeight;
|
||||
}
|
||||
}
|
||||
@@ -1,205 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import HeadComponent from '../../common/component/headComponent';
|
||||
import { WidthPercent } from '../../common/util/ConfigData';
|
||||
import { AlertDialog, CustomContentDialog } from '@ohos.arkui.advanced.Dialog';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
import CmShowSysCredPresenter from '../../presenter/CmShowSysCredPresenter';
|
||||
import { SheetParam } from '../../common/util/SheetParam';
|
||||
import { NavEntryKey } from '../../common/NavEntryKey';
|
||||
|
||||
const TAG: string = 'CredSystemDetailPage: ';
|
||||
|
||||
export class CredSystemDetailParam {
|
||||
public presenter: CmShowSysCredPresenter;
|
||||
|
||||
constructor(presenter: CmShowSysCredPresenter) {
|
||||
this.presenter = presenter;
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
export struct CredSystemDetailPage {
|
||||
private presenter: CmShowSysCredPresenter = CmShowSysCredPresenter.getInstance();
|
||||
|
||||
private stack?: NavPathStack;
|
||||
|
||||
@State private bottomRectHeight: number = 80;
|
||||
@State private headRectHeight: number = 64;
|
||||
@State private headRectHeightReal: number = 0;
|
||||
@Prop private sheetParam: SheetParam;
|
||||
|
||||
deleteWarnDialog: CustomDialogController = new CustomDialogController({
|
||||
builder: AlertDialog({
|
||||
primaryTitle: $r('app.string.warning_title'),
|
||||
content: $r('app.string.warning_message'),
|
||||
primaryButton: {
|
||||
value: $r('app.string.cancelAuthApp'),
|
||||
buttonStyle: ButtonStyleMode.TEXTUAL,
|
||||
action: () => {
|
||||
}
|
||||
},
|
||||
secondaryButton: {
|
||||
value: $r('app.string.deleteAllCredDelete'),
|
||||
buttonStyle: ButtonStyleMode.TEXTUAL,
|
||||
action: () => {
|
||||
this.presenter.deleteSystemCred(this.presenter.credInfo.keyUri);
|
||||
this.presenter.updateSystemCredList();
|
||||
this.stack?.pop();
|
||||
},
|
||||
role: ButtonRole.ERROR
|
||||
}
|
||||
}),
|
||||
})
|
||||
|
||||
build() {
|
||||
NavDestination() {
|
||||
Stack({ alignContent: Alignment.Bottom }) {
|
||||
Stack({ alignContent: Alignment.Top }) {
|
||||
Column() {
|
||||
HeadComponent({ headName: $r('app.string.evidenceDetails'), isStartBySheet: true, onBackClicked: () => {
|
||||
this.stack?.pop();
|
||||
} })
|
||||
.margin({
|
||||
left: $r('app.float.wh_value_12'),
|
||||
top: 8
|
||||
})
|
||||
}.zIndex(1)
|
||||
.onAreaChange((oldArea, newArea) => {
|
||||
this.headRectHeight = newArea.height as number;
|
||||
this.headRectHeightReal = newArea.height as number;
|
||||
})
|
||||
|
||||
Column() {
|
||||
Scroll() {
|
||||
this.buildContent()
|
||||
}
|
||||
.align(Alignment.Top)
|
||||
.scrollable(ScrollDirection.Vertical)
|
||||
.scrollBar(BarState.Auto)
|
||||
.edgeEffect(EdgeEffect.Spring)
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(WidthPercent.WH_AUTO)
|
||||
.constraintSize({
|
||||
minHeight: this.getScrollMinHeight()
|
||||
})
|
||||
}.padding({
|
||||
top: this.headRectHeight
|
||||
})
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(WidthPercent.WH_AUTO)
|
||||
.padding({
|
||||
bottom: this.bottomRectHeight
|
||||
})
|
||||
|
||||
Column() {
|
||||
Button($r('app.string.warning_title'))
|
||||
.onClick(() => {
|
||||
this.deleteWarnDialog.open();
|
||||
})
|
||||
.role(ButtonRole.ERROR)
|
||||
.buttonStyle(ButtonStyleMode.NORMAL)
|
||||
.margin({
|
||||
top: $r('app.float.distance_16'),
|
||||
bottom: $r('app.float.distance_24')
|
||||
})
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.constraintSize({
|
||||
minHeight: $r('app.float.wh_value_40')
|
||||
})
|
||||
}.onAreaChange((oldArea: Area, newArea: Area) => {
|
||||
this.bottomRectHeight = newArea.height as number;
|
||||
})
|
||||
.padding({
|
||||
left: 16, right: 16
|
||||
})
|
||||
}
|
||||
}
|
||||
.hideTitleBar(true)
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(this.sheetParam?.lastSheetPage === NavEntryKey.CRED_SYSTEM_DETAIL_ENTRY ?
|
||||
WidthPercent.WH_AUTO : this.sheetParam?.sheetMinHeight)
|
||||
.backgroundColor($r('sys.color.background_secondary'))
|
||||
.onReady((ctx: NavDestinationContext) => {
|
||||
this.stack = ctx.pathStack;
|
||||
try {
|
||||
this.presenter = (ctx.pathInfo.param as CredSystemDetailParam).presenter;
|
||||
} catch (err) {
|
||||
let error = err as BusinessError;
|
||||
console.error(TAG + 'Get presenter failed: ' + error?.code + ', message: ' + error?.message);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@Builder
|
||||
private buildContent() {
|
||||
Column() {
|
||||
Text(this.presenter.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.presenter.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_10'),
|
||||
right: $r('app.float.wh_value_10')
|
||||
})
|
||||
.opacity($r('app.float.opacity_100_60'))
|
||||
.alignSelf(ItemAlign.Start)
|
||||
|
||||
Text($r('app.string.userCerNum', String(this.presenter.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_10'),
|
||||
right: $r('app.float.wh_value_10')
|
||||
})
|
||||
.opacity($r('app.float.opacity_100_60'))
|
||||
.alignSelf(ItemAlign.Start)
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
}
|
||||
|
||||
getScrollMinHeight() {
|
||||
if (this.sheetParam === undefined || this.headRectHeightReal === 0 ||
|
||||
this.sheetParam.sheetMinHeight < (this.headRectHeightReal + this.bottomRectHeight)) {
|
||||
return 0;
|
||||
}
|
||||
return this.sheetParam.sheetMinHeight - this.headRectHeightReal - this.bottomRectHeight;
|
||||
}
|
||||
}
|
||||
@@ -1,249 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import HeadComponent from '../../common/component/headComponent';
|
||||
import { WidthPercent } from '../../common/util/ConfigData';
|
||||
import { AlertDialog } from '@ohos.arkui.advanced.Dialog';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
import CmShowAppCredPresenter from '../../presenter/CmShowAppCredPresenter';
|
||||
import { NavEntryKey } from '../../common/NavEntryKey';
|
||||
import { AuthorizedAppManagementParam } from './AuthorizedAppManagementPage';
|
||||
import { SheetParam } from '../../common/util/SheetParam';
|
||||
|
||||
const TAG: string = 'CredUserDetailPage: ';
|
||||
|
||||
export class CredUserDetailParam {
|
||||
public presenter: CmShowAppCredPresenter;
|
||||
|
||||
constructor(presenter: CmShowAppCredPresenter) {
|
||||
this.presenter = presenter;
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
export struct CredUserDetailPage {
|
||||
private presenter: CmShowAppCredPresenter = CmShowAppCredPresenter.getInstance();
|
||||
|
||||
private stack?: NavPathStack;
|
||||
|
||||
@State private bottomRectHeight: number = 80;
|
||||
@State private headRectHeight: number = 64;
|
||||
@State private headRectHeightReal: number = 0;
|
||||
@Prop private sheetParam: SheetParam;
|
||||
|
||||
@State private itemBackgroundColor: ResourceColor = '';
|
||||
|
||||
@Styles pressedStyles(): void { .backgroundColor($r('sys.color.ohos_id_color_click_effect')) }
|
||||
|
||||
@Styles normalStyles(): void { .backgroundColor(this.itemBackgroundColor) }
|
||||
|
||||
deleteWarnDialog: CustomDialogController = new CustomDialogController({
|
||||
builder: AlertDialog({
|
||||
primaryTitle: $r('app.string.warning_title'),
|
||||
content: $r('app.string.warning_message'),
|
||||
primaryButton: {
|
||||
value: $r('app.string.cancelAuthApp'),
|
||||
buttonStyle: ButtonStyleMode.TEXTUAL,
|
||||
action: () => {
|
||||
}
|
||||
},
|
||||
secondaryButton: {
|
||||
value: $r('app.string.deleteAllCredDelete'),
|
||||
buttonStyle: ButtonStyleMode.TEXTUAL,
|
||||
action: () => {
|
||||
this.presenter.deleteAppCred(this.presenter.credInfo.keyUri);
|
||||
this.stack?.pop();
|
||||
},
|
||||
role: ButtonRole.ERROR
|
||||
}
|
||||
}),
|
||||
})
|
||||
|
||||
build() {
|
||||
NavDestination() {
|
||||
Stack({ alignContent: Alignment.Bottom }) {
|
||||
Stack({ alignContent: Alignment.Top }) {
|
||||
Column() {
|
||||
HeadComponent({ headName: $r('app.string.evidenceDetails'), isStartBySheet: true, onBackClicked: () => {
|
||||
this.stack?.pop();
|
||||
} })
|
||||
.margin({
|
||||
left: $r('app.float.wh_value_12'),
|
||||
top: 8
|
||||
})
|
||||
}.onAreaChange((oldArea, newArea) => {
|
||||
this.headRectHeight = newArea.height as number;
|
||||
this.headRectHeightReal = newArea.height as number;
|
||||
}).zIndex(1)
|
||||
|
||||
Column() {
|
||||
Scroll() {
|
||||
this.buildContent()
|
||||
}
|
||||
.align(Alignment.Top)
|
||||
.scrollable(ScrollDirection.Vertical)
|
||||
.scrollBar(BarState.Auto)
|
||||
.edgeEffect(EdgeEffect.Spring)
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(WidthPercent.WH_AUTO)
|
||||
.constraintSize({
|
||||
minHeight: this.getScrollMinHeight()
|
||||
})
|
||||
}.padding({
|
||||
top: this.headRectHeight
|
||||
})
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(WidthPercent.WH_AUTO)
|
||||
.padding({
|
||||
bottom: this.bottomRectHeight
|
||||
})
|
||||
|
||||
Column() {
|
||||
Button($r('app.string.warning_title'))
|
||||
.onClick(() => {
|
||||
this.deleteWarnDialog.open();
|
||||
})
|
||||
.role(ButtonRole.ERROR)
|
||||
.buttonStyle(ButtonStyleMode.NORMAL)
|
||||
.margin({
|
||||
top: $r('app.float.distance_16'),
|
||||
bottom: $r('app.float.distance_24')
|
||||
})
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.constraintSize({
|
||||
minHeight: $r('app.float.wh_value_40')
|
||||
})
|
||||
}.onAreaChange((oldArea: Area, newArea: Area) => {
|
||||
this.bottomRectHeight = newArea.height as number;
|
||||
})
|
||||
.padding({
|
||||
left: 16, right: 16
|
||||
})
|
||||
}
|
||||
}
|
||||
.hideTitleBar(true)
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(this.sheetParam?.lastSheetPage === NavEntryKey.CRED_USER_DETAIL_ENTRY ?
|
||||
WidthPercent.WH_AUTO : this.sheetParam?.sheetMinHeight)
|
||||
.backgroundColor($r('sys.color.background_secondary'))
|
||||
.onReady((ctx: NavDestinationContext) => {
|
||||
this.stack = ctx.pathStack;
|
||||
try {
|
||||
this.presenter = (ctx.pathInfo.param as CredUserDetailParam).presenter;
|
||||
} catch (err) {
|
||||
let error = err as BusinessError;
|
||||
console.error(TAG + 'Get presenter failed: ' + error?.code + ', message: ' + error?.message);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@Builder
|
||||
private buildContent() {
|
||||
Column() {
|
||||
Text(this.presenter.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.presenter.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_10'),
|
||||
right: $r('app.float.wh_value_10')
|
||||
})
|
||||
.opacity($r('app.float.opacity_100_60'))
|
||||
.alignSelf(ItemAlign.Start)
|
||||
|
||||
Text($r('app.string.userCerNum', String(this.presenter.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_10'),
|
||||
right: $r('app.float.wh_value_10')
|
||||
})
|
||||
.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.stack?.pushPath(new NavPathInfo(NavEntryKey.AUTHORIZED_APP_ENTRY,
|
||||
new AuthorizedAppManagementParam(this.presenter)));
|
||||
})
|
||||
.margin({
|
||||
top: $r('app.float.wh_value_12'),
|
||||
left: $r('app.float.wh_value_16'),
|
||||
right: $r('app.float.wh_value_16')
|
||||
})
|
||||
.borderRadius($r('sys.float.corner_radius_level8'))
|
||||
.backgroundColor(this.itemBackgroundColor)
|
||||
.onHover((isHover?: boolean) => {
|
||||
this.itemBackgroundColor = isHover ? $r('sys.color.ohos_id_color_hover') : '';
|
||||
})
|
||||
.stateStyles({
|
||||
pressed: this.pressedStyles,
|
||||
normal: this.normalStyles
|
||||
})
|
||||
.padding($r('app.float.wh_value_8'))
|
||||
.constraintSize({
|
||||
minHeight: $r('app.float.wh_value_48')
|
||||
})
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
}
|
||||
|
||||
getScrollMinHeight() {
|
||||
if (this.sheetParam === undefined || this.headRectHeightReal === 0 ||
|
||||
this.sheetParam.sheetMinHeight < (this.headRectHeightReal + this.bottomRectHeight)) {
|
||||
return 0;
|
||||
}
|
||||
return this.sheetParam.sheetMinHeight - this.headRectHeightReal - this.bottomRectHeight;
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { NavEntryKey } from '../../common/NavEntryKey';
|
||||
import { WidthPercent } from '../../common/util/ConfigData';
|
||||
import { TrustedEvidence } from '../trustedCa';
|
||||
import { SheetParam } from '../../common/util/SheetParam';
|
||||
|
||||
@Component
|
||||
export struct CaCertPage {
|
||||
private stack?: NavPathStack;
|
||||
|
||||
@Prop sheetParam: SheetParam;
|
||||
|
||||
build() {
|
||||
NavDestination() {
|
||||
Column() {
|
||||
TrustedEvidence({
|
||||
isStartBySheet: true,
|
||||
sheetParam: this.sheetParam,
|
||||
selected: (path, param) => {
|
||||
if (path === undefined || path === null || path.length === 0) {
|
||||
return;
|
||||
}
|
||||
if (path === NavEntryKey.POP) {
|
||||
this.stack?.pop();
|
||||
} else {
|
||||
this.stack?.pushPath(new NavPathInfo(path, param));
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
.hideTitleBar(true)
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(this.sheetParam?.lastSheetPage === NavEntryKey.CA_CERTIFICATE_ENTRY ?
|
||||
WidthPercent.WH_AUTO : this.sheetParam?.sheetMinHeight)
|
||||
.backgroundColor($r('sys.color.background_secondary'))
|
||||
.onReady((ctx: NavDestinationContext) => {
|
||||
this.stack = ctx.pathStack;
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,377 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { WidthPercent } from '../../common/util/ConfigData';
|
||||
import { CertificateComponent } from '../certManagerFa';
|
||||
import { NavEntryKey } from '../../common/NavEntryKey';
|
||||
import { CaCertPage } from './CaCertPage';
|
||||
import { CredListPage } from './CredListPage';
|
||||
import { InstallPage } from './InstallPage';
|
||||
import { CaSystemDetailPage } from '../detail/CaSystemDetailPage';
|
||||
import { CaUserDetailPage } from '../detail/CaUserDetailPage';
|
||||
import { CredSystemDetailPage } from '../detail/CredSystemDetailPage';
|
||||
import { CredUserDetailPage } from '../detail/CredUserDetailPage';
|
||||
import { AuthorizedAppManagementPage } from '../detail/AuthorizedAppManagementPage';
|
||||
import { CredPwdInputPage } from '../detail/CredPwdInputPage';
|
||||
import Want from '@ohos.app.ability.Want';
|
||||
import deviceInfo from '@ohos.deviceInfo';
|
||||
import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession';
|
||||
import { TrustedEvidence } from '../trustedCa';
|
||||
import { evidenceList } from '../cerEvidenceFa';
|
||||
import { CertInstallFromStorage } from '../certInstallFromStorage';
|
||||
import window from '@ohos.window';
|
||||
import { SheetParam } from '../../common/util/SheetParam';
|
||||
import uiExtensionHost from '@ohos.uiExtensionHost';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
import PreventScreenshotsPresenter from '../../model/PreventScreenshotsModel';
|
||||
|
||||
const TAG: string = 'CertManagerSheetFa:';
|
||||
|
||||
let storage = LocalStorage.getShared();
|
||||
|
||||
const PAGE_MAIN: number = 1;
|
||||
const PAGE_CA_CERTIFICATE: number = 2;
|
||||
const PAGE_CREDENTIAL: number = 3;
|
||||
const PAGE_INSTALL_CERTIFICATE: number = 4;
|
||||
const PAGE_TYPE: string = 'pageType';
|
||||
|
||||
const BOTTOM_SHEET_MIN_PERCENT = 0.6;
|
||||
const CENTER_SHEET_MAX_PERCENT = 0.9;
|
||||
const CENTER_SHEET_MIN_HEIGHT = 560;
|
||||
|
||||
interface AvoidAreaParam {
|
||||
type: window.AvoidAreaType;
|
||||
area: window.AvoidArea;
|
||||
}
|
||||
|
||||
@Entry(storage)
|
||||
@Component
|
||||
export struct CertManagerSheetFa {
|
||||
private sheetSession: UIExtensionContentSession =
|
||||
storage.get<UIExtensionContentSession>('session') as UIExtensionContentSession;
|
||||
private want: Want = storage.get<Want>('want') as Want;
|
||||
private preventScreenshotsPresenter: PreventScreenshotsPresenter = PreventScreenshotsPresenter.getInstance();
|
||||
|
||||
@State @Watch('onSheetPageChanged') private stack: NavPathStack = new NavPathStack();
|
||||
@State private sheetParam: SheetParam = new SheetParam();
|
||||
@State private pageType: number = PAGE_MAIN;
|
||||
@State private maxSheetPageHeight: number = 0;
|
||||
@State private rootWidth: number = 0;
|
||||
@State private rootHeight: number = 0;
|
||||
@State private statusBarHeight: number = 0;
|
||||
@State private aiBarHeight: number = 0;
|
||||
|
||||
private avoidAreaChangedCallback: Callback<AvoidAreaParam> = (avoidArea) => {
|
||||
if (avoidArea.type === window.AvoidAreaType.TYPE_SYSTEM) {
|
||||
this.statusBarHeight = px2vp(avoidArea.area.topRect.height);
|
||||
this.updateSheetHeightLimit();
|
||||
} else if (avoidArea.type === window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR) {
|
||||
this.aiBarHeight = px2vp(avoidArea.area.bottomRect.height);
|
||||
this.updateSheetHeightLimit();
|
||||
} else {
|
||||
console.warn(TAG + 'avoidAreaChangedCallback, sheet type is invalid:' + this.sheetParam.sheetType);
|
||||
}
|
||||
}
|
||||
|
||||
onSheetPageChanged(): void {
|
||||
let allPageArray = this.stack.getAllPathName();
|
||||
if (allPageArray === undefined || allPageArray.length === 0) {
|
||||
this.preventScreenshotsPresenter.PreventScreenshots(false, this.sheetSession);
|
||||
this.sheetParam.lastSheetPage = '';
|
||||
return;
|
||||
}
|
||||
let lastPage = allPageArray[allPageArray.length - 1];
|
||||
this.sheetParam.lastSheetPage = lastPage;
|
||||
if (lastPage !== NavEntryKey.CRED_PWD_INPUT_ENTRY) {
|
||||
this.preventScreenshotsPresenter.PreventScreenshots(false, this.sheetSession);
|
||||
return;
|
||||
}
|
||||
this.preventScreenshotsPresenter.PreventScreenshots(true, this.sheetSession);
|
||||
}
|
||||
|
||||
aboutToAppear(): void {
|
||||
this.registerAvoidChangedListener();
|
||||
const parameters = this.want?.parameters;
|
||||
if (parameters === undefined || parameters[PAGE_TYPE] === undefined) {
|
||||
console.warn(TAG + 'page type param is undefined');
|
||||
return;
|
||||
}
|
||||
this.pageType = parameters[PAGE_TYPE] as number;
|
||||
console.log(TAG + 'page type = ' + this.pageType);
|
||||
}
|
||||
|
||||
aboutToDisappear(): void {
|
||||
this.unregisterAvoidChangedListener();
|
||||
}
|
||||
|
||||
initStatusBarHeight(extWindow: uiExtensionHost.UIExtensionHostWindowProxy): void {
|
||||
try {
|
||||
let avoidArea: window.AvoidArea = extWindow.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM);
|
||||
if (avoidArea === undefined) {
|
||||
console.warn(TAG + 'initStatusBarHeight, avoid area is undefined');
|
||||
}
|
||||
this.statusBarHeight = px2vp(avoidArea.topRect.height);
|
||||
} catch (err) {
|
||||
let error = err as BusinessError;
|
||||
console.error(TAG + 'initStatusBarHeight, occur error:' + error?.code + ', msg:' + error?.message);
|
||||
}
|
||||
}
|
||||
|
||||
initAiBarHeight(extWindow: uiExtensionHost.UIExtensionHostWindowProxy): void {
|
||||
try {
|
||||
let avoidArea: window.AvoidArea = extWindow.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR);
|
||||
if (avoidArea === undefined) {
|
||||
console.warn(TAG + 'initAiBarHeight, avoid area is undefined');
|
||||
}
|
||||
this.aiBarHeight = px2vp(avoidArea.bottomRect.height);
|
||||
} catch (err) {
|
||||
let error = err as BusinessError;
|
||||
console.error(TAG + 'initAiBarHeight, occur error:' + error?.code + ', msg:' + error?.message);
|
||||
}
|
||||
}
|
||||
|
||||
registerAvoidChangedListener(): void {
|
||||
try {
|
||||
let extWindow: uiExtensionHost.UIExtensionHostWindowProxy = this.sheetSession?.getUIExtensionHostWindowProxy();
|
||||
if (extWindow === undefined) {
|
||||
console.error(TAG + 'registerAvoidChangedListener, get extra window is undefined');
|
||||
return;
|
||||
}
|
||||
this.initStatusBarHeight(extWindow);
|
||||
this.initAiBarHeight(extWindow);
|
||||
extWindow.on('avoidAreaChange', this.avoidAreaChangedCallback);
|
||||
} catch (err) {
|
||||
let error = err as BusinessError;
|
||||
console.error(TAG + 'registerAvoidChangedListener, occur error:' + error?.code + ', msg:' + error?.message);
|
||||
}
|
||||
}
|
||||
|
||||
unregisterAvoidChangedListener(): void {
|
||||
try {
|
||||
let extWindow: uiExtensionHost.UIExtensionHostWindowProxy = this.sheetSession?.getUIExtensionHostWindowProxy();
|
||||
if (extWindow === undefined) {
|
||||
console.error(TAG + 'unregisterAvoidChangedListener, get extra window is undefined');
|
||||
return;
|
||||
}
|
||||
extWindow.off('avoidAreaChange', this.avoidAreaChangedCallback);
|
||||
} catch (err) {
|
||||
let error = err as BusinessError;
|
||||
console.error(TAG + 'unregisterAvoidChangedListener, occur error:' + error?.code + ', msg:' + error?.message);
|
||||
}
|
||||
}
|
||||
|
||||
private updateSheetHeightLimit(): void {
|
||||
if (this.rootHeight === 0) {
|
||||
return;
|
||||
}
|
||||
if (this.sheetParam.sheetType === SheetType.BOTTOM) {
|
||||
this.maxSheetPageHeight = this.rootHeight - this.statusBarHeight - 8;
|
||||
this.sheetParam.sheetMinHeight = this.rootHeight * BOTTOM_SHEET_MIN_PERCENT;
|
||||
} else if (this.sheetParam.sheetType === SheetType.CENTER) {
|
||||
let shortSide = Math.min(this.rootWidth, (this.rootHeight - this.statusBarHeight - this.aiBarHeight));
|
||||
this.maxSheetPageHeight = shortSide * CENTER_SHEET_MAX_PERCENT;
|
||||
this.sheetParam.sheetMinHeight = CENTER_SHEET_MIN_HEIGHT;
|
||||
} else {
|
||||
console.warn(TAG + 'updateSheetHeightLimit, sheet type is invalid:' + this.sheetParam.sheetType);
|
||||
}
|
||||
}
|
||||
|
||||
@Builder
|
||||
private routerMap(name: string, param?: Object) {
|
||||
if (name === NavEntryKey.CA_CERTIFICATE_ENTRY) {
|
||||
CaCertPage({
|
||||
sheetParam: this.sheetParam
|
||||
})
|
||||
} else if (name === NavEntryKey.CREDENTIAL_LIST_ENTRY) {
|
||||
CredListPage({
|
||||
sheetParam: this.sheetParam
|
||||
})
|
||||
} else if (name === NavEntryKey.INSTALL_ENTRY) {
|
||||
InstallPage({
|
||||
sheetParam: this.sheetParam
|
||||
})
|
||||
} else if (name === NavEntryKey.CA_SYSTEM_DETAIL_ENTRY) {
|
||||
CaSystemDetailPage({
|
||||
sheetParam: this.sheetParam
|
||||
})
|
||||
} else if (name === NavEntryKey.CA_USER_DETAIL_ENTRY) {
|
||||
CaUserDetailPage({
|
||||
sheetParam: this.sheetParam
|
||||
})
|
||||
} else if (name === NavEntryKey.CRED_SYSTEM_DETAIL_ENTRY) {
|
||||
CredSystemDetailPage({
|
||||
sheetParam: this.sheetParam
|
||||
})
|
||||
} else if (name === NavEntryKey.CRED_USER_DETAIL_ENTRY) {
|
||||
CredUserDetailPage({
|
||||
sheetParam: this.sheetParam
|
||||
})
|
||||
} else if (name === NavEntryKey.AUTHORIZED_APP_ENTRY) {
|
||||
AuthorizedAppManagementPage({
|
||||
sheetParam: this.sheetParam
|
||||
})
|
||||
} else if (name === NavEntryKey.CRED_PWD_INPUT_ENTRY) {
|
||||
CredPwdInputPage({
|
||||
sheetParam: this.sheetParam
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Column() {
|
||||
}.bindSheet(true, this.buildContent(), {
|
||||
height: SheetSize.FIT_CONTENT,
|
||||
preferType: ['2in1', 'tablet'].includes(deviceInfo.deviceType) ? SheetType.CENTER : null,
|
||||
showClose: true,
|
||||
onTypeDidChange: (type) => {
|
||||
this.sheetParam.sheetType = type;
|
||||
console.log(TAG + 'sheet type:' + this.sheetParam.sheetType);
|
||||
if (this.rootHeight === 0) {
|
||||
return;
|
||||
}
|
||||
this.updateSheetHeightLimit();
|
||||
},
|
||||
onDisappear: () => {
|
||||
console.debug(TAG + 'Sheet page disappear, session is undefined?' + (this.sheetSession === undefined));
|
||||
this.sheetSession?.sendData({'action': 'exit'})
|
||||
}
|
||||
})
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(WidthPercent.WH_100_100)
|
||||
.onAreaChange((oldArea, newArea) => {
|
||||
this.rootWidth = newArea.width as number;
|
||||
this.rootHeight = newArea.height as number;
|
||||
this.updateSheetHeightLimit();
|
||||
})
|
||||
}
|
||||
|
||||
@Builder
|
||||
private buildContent() {
|
||||
Navigation(this.stack) {
|
||||
if (this.pageType === PAGE_CA_CERTIFICATE) {
|
||||
this.buildCaCertPage()
|
||||
} else if (this.pageType === PAGE_CREDENTIAL) {
|
||||
this.buildCredListPage()
|
||||
} else if (this.pageType === PAGE_INSTALL_CERTIFICATE) {
|
||||
this.buildInstallPage()
|
||||
} else {
|
||||
this.buildHomePage()
|
||||
}
|
||||
}
|
||||
.hideTitleBar(true)
|
||||
.titleMode(NavigationTitleMode.Mini)
|
||||
.mode(NavigationMode.Stack)
|
||||
.navDestination(this.routerMap)
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(WidthPercent.WH_AUTO)
|
||||
.constraintSize({
|
||||
maxHeight: this.maxSheetPageHeight
|
||||
})
|
||||
.backgroundColor($r('sys.color.background_secondary'))
|
||||
}
|
||||
|
||||
@Builder
|
||||
private buildHomePage() {
|
||||
Column() {
|
||||
CertificateComponent({
|
||||
isStartBySheet: true,
|
||||
sheetParam: this.sheetParam,
|
||||
selected: (path) => {
|
||||
if (path === undefined || path === null || path.length === 0) {
|
||||
console.warn(TAG + 'buildHomePage, empty path');
|
||||
return;
|
||||
}
|
||||
this.stack.pushPath(new NavPathInfo(path, ''));
|
||||
}
|
||||
})
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(WidthPercent.WH_AUTO)
|
||||
}
|
||||
|
||||
@Builder
|
||||
private buildCaCertPage() {
|
||||
Column() {
|
||||
TrustedEvidence({
|
||||
isStartBySheetFirst: true,
|
||||
isStartBySheet: true,
|
||||
sheetParam: this.sheetParam,
|
||||
selected: (path, param) => {
|
||||
if (path === undefined || path === null || path.length === 0) {
|
||||
console.warn(TAG + 'buildCaCertPage, empty path');
|
||||
return;
|
||||
}
|
||||
if (path === NavEntryKey.POP) {
|
||||
this.stack?.pop();
|
||||
} else {
|
||||
this.stack?.pushPath(new NavPathInfo(path, param));
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(WidthPercent.WH_AUTO)
|
||||
}
|
||||
|
||||
@Builder
|
||||
private buildCredListPage() {
|
||||
Column() {
|
||||
evidenceList({
|
||||
isStartBySheetFirst: true,
|
||||
isStartBySheet: true,
|
||||
sheetParam: this.sheetParam,
|
||||
selected: (path, param) => {
|
||||
if (path === undefined || path === null || path.length === 0) {
|
||||
console.warn(TAG + 'buildCredListPage, empty path');
|
||||
return;
|
||||
}
|
||||
if (path === NavEntryKey.POP) {
|
||||
this.stack?.pop();
|
||||
} else {
|
||||
this.stack?.pushPath(new NavPathInfo(path, param));
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(WidthPercent.WH_AUTO)
|
||||
}
|
||||
|
||||
@Builder
|
||||
private buildInstallPage() {
|
||||
Column() {
|
||||
CertInstallFromStorage({
|
||||
isStartBySheetFirst: true,
|
||||
isStartBySheet: true,
|
||||
sheetParam: this.sheetParam,
|
||||
selected: (path, param) => {
|
||||
if (path === undefined || path === null || path.length === 0) {
|
||||
console.warn(TAG + 'buildInstallPage, empty path');
|
||||
return;
|
||||
}
|
||||
if (path === NavEntryKey.POP) {
|
||||
this.stack?.pop();
|
||||
} else {
|
||||
this.stack?.pushPath(new NavPathInfo(path, param));
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(WidthPercent.WH_AUTO)
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { NavEntryKey } from '../../common/NavEntryKey';
|
||||
import { WidthPercent } from '../../common/util/ConfigData';
|
||||
import { evidenceList } from '../cerEvidenceFa';
|
||||
import { SheetParam } from '../../common/util/SheetParam';
|
||||
|
||||
@Component
|
||||
export struct CredListPage {
|
||||
private stack?: NavPathStack;
|
||||
|
||||
@Prop sheetParam: SheetParam;
|
||||
|
||||
build() {
|
||||
NavDestination() {
|
||||
Column() {
|
||||
evidenceList({
|
||||
isStartBySheet: true,
|
||||
sheetParam: this.sheetParam,
|
||||
selected: (path, param) => {
|
||||
if (path === NavEntryKey.POP) {
|
||||
this.stack?.pop();
|
||||
} else {
|
||||
this.stack?.pushPath(new NavPathInfo(path, param));
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
.hideTitleBar(true)
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(this.sheetParam?.lastSheetPage === NavEntryKey.CREDENTIAL_LIST_ENTRY ?
|
||||
WidthPercent.WH_AUTO : this.sheetParam?.sheetMinHeight)
|
||||
.backgroundColor($r('sys.color.background_secondary'))
|
||||
.onReady((ctx: NavDestinationContext) => {
|
||||
this.stack = ctx.pathStack;
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { NavEntryKey } from '../../common/NavEntryKey';
|
||||
import { WidthPercent } from '../../common/util/ConfigData';
|
||||
import { CertInstallFromStorage } from '../certInstallFromStorage';
|
||||
import { SheetParam } from '../../common/util/SheetParam';
|
||||
|
||||
@Component
|
||||
export struct InstallPage {
|
||||
private stack?: NavPathStack;
|
||||
|
||||
@Prop sheetParam: SheetParam;
|
||||
|
||||
build() {
|
||||
NavDestination() {
|
||||
Column() {
|
||||
CertInstallFromStorage({
|
||||
isStartBySheet: true,
|
||||
sheetParam: this.sheetParam,
|
||||
selected: (path, param) => {
|
||||
if (path === NavEntryKey.POP) {
|
||||
this.stack?.pop();
|
||||
} else {
|
||||
this.stack?.pushPath(new NavPathInfo(path, param));
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
.hideTitleBar(true)
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(WidthPercent.WH_AUTO)
|
||||
.backgroundColor($r('sys.color.background_secondary'))
|
||||
.onReady((ctx: NavDestinationContext) => {
|
||||
this.stack = ctx.pathStack;
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,249 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import CmAppCredAuthPresenter from '../presenter/CmAppCredAuthPresenter';
|
||||
import router from '@ohos.router';
|
||||
import { WidthPercent, ConfigValue } from '../common/util/ConfigData';
|
||||
import { CredentialAbstractVo } from '../model/CertManagerVo/CredentialAbstractVo';
|
||||
import { RouterAppUidVo } from '../model/CertManagerVo/RouterInfoVo';
|
||||
import { CustomContentDialog } from '@ohos.arkui.advanced.Dialog';
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct RadioAuth {
|
||||
@State mAppCredAuthPresenter: CmAppCredAuthPresenter = CmAppCredAuthPresenter.getInstance();
|
||||
selectUri: string = '';
|
||||
private authScroller: Scroller = new Scroller();
|
||||
|
||||
dialogController: CustomDialogController = new CustomDialogController({
|
||||
cancel: () => {
|
||||
this.mAppCredAuthPresenter.cancelProcess();
|
||||
},
|
||||
builder: CustomContentDialog({
|
||||
contentBuilder: () => {
|
||||
this.dialogControllerContent();
|
||||
},
|
||||
contentAreaPadding: {right: $r('app.float.wh_value_0')},
|
||||
buttons: [
|
||||
{
|
||||
value: $r('app.string.requestAuthCancel'),
|
||||
buttonStyle: ButtonStyleMode.TEXTUAL,
|
||||
action: () => {
|
||||
this.mAppCredAuthPresenter.cancelProcess();
|
||||
this.dialogController?.close();
|
||||
}
|
||||
},
|
||||
{
|
||||
value: $r('app.string.requestAuthFinish'),
|
||||
buttonStyle: ButtonStyleMode.TEXTUAL,
|
||||
action: () => {
|
||||
console.debug('requestAuthorize uri: ' + this.selectUri);
|
||||
let appUidInfo: RouterAppUidVo = router.getParams() as RouterAppUidVo;
|
||||
if (appUidInfo !== undefined && appUidInfo.appUid != undefined) {
|
||||
console.debug('requestAuthorize appUid: ' + appUidInfo.appUid);
|
||||
this.mAppCredAuthPresenter.requestAuthorize(this.selectUri, appUidInfo.appUid);
|
||||
this.dialogController?.close();
|
||||
} else {
|
||||
console.info('requestAuthorize fail');
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}),
|
||||
})
|
||||
|
||||
@Builder
|
||||
dialogControllerContent(): void {
|
||||
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({
|
||||
left: $r('app.float.wh_value_24'),
|
||||
right: $r('app.float.wh_value_24')
|
||||
})
|
||||
.alignSelf(ItemAlign.Start)
|
||||
|
||||
if (this.mAppCredAuthPresenter.credList.length > ConfigValue.REQUEST_AUTH_MAX_LENGTH) {
|
||||
Stack({ alignContent: Alignment.End }) {
|
||||
Scroll(this.authScroller) {
|
||||
List() {
|
||||
ForEach(this.mAppCredAuthPresenter.credList, (item: CredentialAbstractVo, index: number) => {
|
||||
ListItem() {
|
||||
Column() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
|
||||
Column() {
|
||||
Text(item.alias)
|
||||
.fontSize($r('app.float.font_18'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.textAlign(TextAlign.Start);
|
||||
}
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
|
||||
Column() {
|
||||
Radio({ value: item.alias, group: 'appCredGroup' })
|
||||
.checked(false)
|
||||
.onChange((value: boolean) => {
|
||||
console.info(item.alias + ' status is ' + value);
|
||||
if (value) {
|
||||
this.selectUri = item.keyUri;
|
||||
}
|
||||
})
|
||||
}
|
||||
.alignItems(HorizontalAlign.End)
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
|
||||
Divider()
|
||||
.color($r('sys.color.ohos_id_color_list_separator'))
|
||||
.margin({
|
||||
top: $r('app.float.distance_12')
|
||||
})
|
||||
.visibility(index === (this.mAppCredAuthPresenter.credList.length - 1)
|
||||
? Visibility.None : Visibility.Visible)
|
||||
}
|
||||
}
|
||||
.height($r('app.float.wh_value_64'))
|
||||
}, (item: CredentialAbstractVo) => JSON.stringify(item))
|
||||
}
|
||||
.scrollBar(BarState.Off)
|
||||
.backgroundColor($r('sys.color.ohos_id_color_dialog_bg'))
|
||||
.visibility(this.mAppCredAuthPresenter.credList.length > 0 ? Visibility.Visible : Visibility.None)
|
||||
}
|
||||
.scrollBar(BarState.Off)
|
||||
.margin({
|
||||
left: $r('app.float.wh_value_24'),
|
||||
right: $r('app.float.wh_value_24')
|
||||
})
|
||||
|
||||
ScrollBar({ scroller: this.authScroller, direction: ScrollBarDirection.Vertical,
|
||||
state: BarState.Auto }) {
|
||||
Text()
|
||||
.width($r('app.float.wh_value_3'))
|
||||
.height($r('app.float.wh_value_50'))
|
||||
.borderRadius($r('app.float.wh_value_10'))
|
||||
.backgroundColor($r('sys.color.ohos_id_color_foreground'))
|
||||
.opacity($r('app.float.text_opacity_0_4'))
|
||||
}
|
||||
.width($r('app.float.wh_value_3'))
|
||||
.margin({
|
||||
right: $r('app.float.wh_value_3')
|
||||
})
|
||||
}
|
||||
.height(WidthPercent.WH_50_100)
|
||||
} else {
|
||||
List() {
|
||||
ForEach(this.mAppCredAuthPresenter.credList, (item: CredentialAbstractVo, index: number) => {
|
||||
ListItem() {
|
||||
Column() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
|
||||
Column() {
|
||||
Text(item.alias)
|
||||
.fontSize($r('app.float.font_18'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.textAlign(TextAlign.Start);
|
||||
}
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
|
||||
Column() {
|
||||
Radio({ value: item.alias, group: 'appCredGroup' })
|
||||
.checked(false)
|
||||
.onChange((value: boolean) => {
|
||||
console.info(item.alias + ' status is ' + value);
|
||||
if (value) {
|
||||
this.selectUri = item.keyUri;
|
||||
}
|
||||
})
|
||||
}
|
||||
.alignItems(HorizontalAlign.End)
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
|
||||
Divider()
|
||||
.color($r('sys.color.ohos_id_color_list_separator'))
|
||||
.margin({
|
||||
top: $r('app.float.distance_12')
|
||||
})
|
||||
.visibility(index === (this.mAppCredAuthPresenter.credList.length - 1)
|
||||
? Visibility.None : Visibility.Visible)
|
||||
}
|
||||
}
|
||||
.height($r('app.float.wh_value_64'))
|
||||
}, (item: CredentialAbstractVo) => JSON.stringify(item))
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
|
||||
Column() {
|
||||
Text()
|
||||
}
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
|
||||
Column() {
|
||||
Radio({ value: 'null', group: 'appCredGroup' })
|
||||
.checked(false)
|
||||
.onChange((value: boolean) => {
|
||||
if (value) {
|
||||
this.selectUri = 'null';
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
.visibility(Visibility.None)
|
||||
}
|
||||
}
|
||||
.margin({
|
||||
left: $r('app.float.wh_value_24'),
|
||||
right: $r('app.float.wh_value_24')
|
||||
})
|
||||
.scrollBar(BarState.Off)
|
||||
.backgroundColor($r('sys.color.ohos_id_color_dialog_bg'))
|
||||
.visibility(this.mAppCredAuthPresenter.credList.length > 0 ? Visibility.Visible : Visibility.None)
|
||||
}
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.borderRadius($r('app.float.user_list_divider_borderRadius_value'))
|
||||
.backgroundColor($r('sys.color.ohos_id_color_dialog_bg'))
|
||||
}
|
||||
|
||||
aboutToAppear() {
|
||||
console.debug('enter requestAuth page');
|
||||
let appUidInfo: RouterAppUidVo = router.getParams() as RouterAppUidVo;
|
||||
if (appUidInfo !== undefined && appUidInfo.appUid != undefined) {
|
||||
this.mAppCredAuthPresenter.updateAppNameFromUid(appUidInfo.appUid as string);
|
||||
this.mAppCredAuthPresenter.updateAppCredList();
|
||||
this.dialogController.open();
|
||||
} else {
|
||||
console.error('requestAuth appear failed');
|
||||
router.pushUrl({ url: 'pages/certManagerFa' });
|
||||
}
|
||||
}
|
||||
|
||||
build() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,841 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { WidthPercent } 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';
|
||||
import { GlobalContext } from '../common/GlobalContext';
|
||||
import { CertAbstractVo } from '../model/CertManagerVo/CertAbstractVo';
|
||||
import ComponentConfig from '../common/component/ComponentConfig';
|
||||
import router from '@ohos.router';
|
||||
import { CustomContentDialog } from '@ohos.arkui.advanced.Dialog';
|
||||
import { NavEntryKey } from '../common/NavEntryKey';
|
||||
import { CaUserDetailParam } from './detail/CaUserDetailPage';
|
||||
import { SheetParam } from '../common/util/SheetParam';
|
||||
import {
|
||||
DialogDateComponent,
|
||||
DialogFingerPrintComponent,
|
||||
DialogIssuerComponent,
|
||||
DialogSubjectComponent
|
||||
} from './detail/CaSystemDetailPage';
|
||||
|
||||
const COPIES_NUM: number = 12;
|
||||
|
||||
@Component
|
||||
struct ComponentSystem {
|
||||
private certAlias: string = '';
|
||||
private subjectName: string = '';
|
||||
private uri: string = '';
|
||||
@Link setStatus: CmShowSysCaPresenter;
|
||||
private sysCaScroller: Scroller = new Scroller();
|
||||
|
||||
onItemClicked?: () => void;
|
||||
|
||||
@State isHoverBackgroundColor: ResourceColor = '';
|
||||
@Styles pressedStyles(): void {
|
||||
.backgroundColor($r('sys.color.ohos_id_color_click_effect'))
|
||||
}
|
||||
@Styles normalStyles(): void {
|
||||
.backgroundColor(this.isHoverBackgroundColor)
|
||||
}
|
||||
|
||||
systemDetailsDialog: CustomDialogController = new CustomDialogController({
|
||||
alignment: DialogAlignment.Center,
|
||||
builder: CustomContentDialog({
|
||||
contentBuilder: () => {
|
||||
this.systemDetailContent();
|
||||
},
|
||||
contentAreaPadding: { right: $r('app.float.wh_value_0') },
|
||||
buttons: [{
|
||||
value: $r('app.string.CustomDialogExample_Button_text'),
|
||||
buttonStyle: ButtonStyleMode.TEXTUAL,
|
||||
action: () => {
|
||||
this.systemDetailsDialog?.close();
|
||||
}
|
||||
}]
|
||||
})
|
||||
})
|
||||
|
||||
@Builder
|
||||
systemDetailContent(): void {
|
||||
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)
|
||||
.height($r('app.float.wh_value_56'))
|
||||
.margin({
|
||||
bottom: $r('app.float.wh_value_8'),
|
||||
right: $r('app.float.wh_value_24')
|
||||
})
|
||||
.alignSelf(ItemAlign.Start)
|
||||
|
||||
Text(this.setStatus.certInfo.certAlias)
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body1'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.margin({
|
||||
bottom: $r('app.float.wh_value_24'),
|
||||
right: $r('app.float.wh_value_24')
|
||||
})
|
||||
.alignSelf(ItemAlign.Start)
|
||||
|
||||
Scroll(this.sysCaScroller) {
|
||||
List() {
|
||||
ListItem() {
|
||||
Text($r('app.string.CustomDialogExample_firListItem_text'))
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body1'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
}.width(ComponentConfig.WH_100_100).align(Alignment.Start)
|
||||
|
||||
ListItem() {
|
||||
DialogSubjectComponent({ map: this.setStatus.certInfo.subjectNameMap });
|
||||
}.width(ComponentConfig.WH_100_100).align(Alignment.Start)
|
||||
|
||||
ListItem() {
|
||||
Text($r('app.string.CustomDialogExample_secListItem_text'))
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body1'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
}.width(ComponentConfig.WH_100_100).align(Alignment.Start)
|
||||
.margin({
|
||||
top: $r('app.float.wh_value_24')
|
||||
})
|
||||
|
||||
ListItem() {
|
||||
DialogIssuerComponent({ map: this.setStatus.certInfo.issuerNameMap });
|
||||
}.width(ComponentConfig.WH_100_100).align(Alignment.Start)
|
||||
|
||||
ListItem() {
|
||||
Text($r('app.string.CustomDialogExample_thdListItem_text'))
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body1'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
}.width(ComponentConfig.WH_100_100).align(Alignment.Start)
|
||||
.margin({
|
||||
top: $r('app.float.wh_value_24')
|
||||
})
|
||||
|
||||
ListItem() {
|
||||
DialogDateComponent({ map: this.setStatus.certInfo.dateMap });
|
||||
}.width(ComponentConfig.WH_100_100).align(Alignment.Start)
|
||||
|
||||
ListItem() {
|
||||
Text($r('app.string.CustomDialogExample_fouListItem_text'))
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body1'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
}.width(ComponentConfig.WH_100_100).align(Alignment.Start)
|
||||
.margin({
|
||||
top: $r('app.float.wh_value_24')
|
||||
})
|
||||
|
||||
ListItem() {
|
||||
DialogFingerPrintComponent({ fingerprintSha256: this.setStatus.certInfo.fingerprintSha256 });
|
||||
}.width(ComponentConfig.WH_100_100).align(Alignment.Start)
|
||||
}
|
||||
.margin({ right: $r('app.float.wh_value_24') })
|
||||
.scrollBar(BarState.Off)
|
||||
}
|
||||
.scrollable(ScrollDirection.Vertical)
|
||||
.scrollBarWidth('3vp')
|
||||
.height($r('app.float.CustomDialogExample_list_height_value'))
|
||||
}
|
||||
.padding({
|
||||
left: $r('app.float.wh_value_24'),
|
||||
})
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.borderRadius($r('app.float.user_list_divider_borderRadius_value'))
|
||||
.backgroundColor($r('sys.color.ohos_id_color_dialog_bg'))
|
||||
}
|
||||
|
||||
build() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
|
||||
Column() {
|
||||
Text(this.certAlias)
|
||||
.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)
|
||||
.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);
|
||||
}
|
||||
.onHover((isHover?: boolean) => {
|
||||
this.isHoverBackgroundColor = isHover ? $r('sys.color.ohos_id_color_hover') : ''
|
||||
})
|
||||
.backgroundColor(this.isHoverBackgroundColor)
|
||||
.stateStyles({
|
||||
pressed: this.pressedStyles,
|
||||
normal: this.normalStyles
|
||||
})
|
||||
.padding({
|
||||
left: $r('app.float.wh_value_8'),
|
||||
right: $r('app.float.wh_value_8')
|
||||
})
|
||||
.borderRadius($r('app.float.wh_value_20'))
|
||||
.onClick(() => {
|
||||
this.setStatus.getSystemTrustedCertificate(this.uri, () => {
|
||||
if (this.onItemClicked !== undefined) {
|
||||
this.onItemClicked();
|
||||
} else {
|
||||
this.systemDetailsDialog.open();
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
struct ComponentUser {
|
||||
private certAlias: string = '';
|
||||
private subjectName: string = '';
|
||||
private indexNum: number = -1;
|
||||
private uri: string = '';
|
||||
@State statusText: Resource = $r('app.string.CustomDialogExampleUser_Status_false');
|
||||
@Link setStatus: CMShowUserCaPresenter;
|
||||
@State mUserCaPresenterDetail: CMShowUserCaPresenter = CMShowUserCaPresenter.getInstance();
|
||||
private userCaScroller: Scroller = new Scroller();
|
||||
|
||||
onItemClicked?: () => void;
|
||||
|
||||
@State isHoverBackgroundColor: ResourceColor = '';
|
||||
@Styles pressedStyles(): void {
|
||||
.backgroundColor($r('sys.color.ohos_id_color_click_effect'))
|
||||
}
|
||||
@Styles normalStyles(): void {
|
||||
.backgroundColor(this.isHoverBackgroundColor)
|
||||
}
|
||||
|
||||
rootCertificateDialog: CustomDialogController = new CustomDialogController({
|
||||
alignment: DialogAlignment.Center,
|
||||
cancel: () => {
|
||||
this.setStatus.updateUserTrustedCertificateList();
|
||||
},
|
||||
builder: CustomContentDialog({
|
||||
contentBuilder: () => {
|
||||
this.rootCertificateContent();
|
||||
},
|
||||
contentAreaPadding: { right: $r('app.float.wh_value_0') },
|
||||
buttons: [
|
||||
{
|
||||
value: $r('app.string.root_certificate_cancel'),
|
||||
buttonStyle: ButtonStyleMode.TEXTUAL,
|
||||
action: () => {
|
||||
this.setStatus.updateUserTrustedCertificateList();
|
||||
}
|
||||
},
|
||||
{
|
||||
value: $r('app.string.root_certificate_continue'),
|
||||
buttonStyle: ButtonStyleMode.TEXTUAL,
|
||||
action: () => {
|
||||
this.setStatus.setUserCertificateStatus(this.mUserCaPresenterDetail.certInfo.uri, true).then(result => {
|
||||
if (result) {
|
||||
this.setStatus.updateUserTrustedCertificateList();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
})
|
||||
|
||||
userDetailsDialog: CustomDialogController = new CustomDialogController({
|
||||
alignment: DialogAlignment.Center,
|
||||
cancel: () => {
|
||||
this.setStatus.updateUserTrustedCertificateList();
|
||||
},
|
||||
builder: CustomContentDialog({
|
||||
contentBuilder: () => {
|
||||
this.userDetailContent(this.setStatus.certList[this.indexNum].status);
|
||||
},
|
||||
contentAreaPadding: { right: $r('app.float.wh_value_0') },
|
||||
buttons: [
|
||||
{
|
||||
value: $r('app.string.CustomDialogExampleUser_Flex_firButton_text'),
|
||||
buttonStyle: ButtonStyleMode.TEXTUAL,
|
||||
action: () => {
|
||||
this.setStatus.updateUserTrustedCertificateList();
|
||||
this.userDetailsDialog?.close();
|
||||
}
|
||||
},
|
||||
{
|
||||
value: $r('app.string.CustomDialogExampleUser_Flex_secButton_text'),
|
||||
buttonStyle: ButtonStyleMode.TEXTUAL,
|
||||
action: () => {
|
||||
this.onShowDeleteWarnDialog();
|
||||
},
|
||||
role: ButtonRole.ERROR
|
||||
}
|
||||
]
|
||||
})
|
||||
})
|
||||
|
||||
deleteCertWarnDialog: CustomDialogController = new CustomDialogController({
|
||||
cancel: () => {
|
||||
this.setStatus.updateUserTrustedCertificateList();
|
||||
},
|
||||
builder: CustomContentDialog({
|
||||
contentBuilder: () => {
|
||||
this.deleteWarnContent();
|
||||
},
|
||||
contentAreaPadding: { right: $r('app.float.wh_value_0') },
|
||||
buttons: [
|
||||
{
|
||||
value: $r('app.string.deleteAllCredCancel'),
|
||||
buttonStyle: ButtonStyleMode.TEXTUAL,
|
||||
action: () => {
|
||||
this.deleteCertWarnDialog?.close();
|
||||
this.setStatus.updateUserTrustedCertificateList();
|
||||
}
|
||||
},
|
||||
{
|
||||
value: $r('app.string.deleteAllCredDelete'),
|
||||
buttonStyle: ButtonStyleMode.TEXTUAL,
|
||||
action: () => {
|
||||
this.setStatus.deleteUserCertificate(this.mUserCaPresenterDetail.certInfo.uri, () => {
|
||||
this.setStatus.updateUserTrustedCertificateList();
|
||||
this.deleteCertWarnDialog?.close();
|
||||
})
|
||||
},
|
||||
role: ButtonRole.ERROR
|
||||
}
|
||||
]
|
||||
})
|
||||
})
|
||||
|
||||
@Builder
|
||||
rootCertificateContent(): void {
|
||||
Column() {
|
||||
Text($r('app.string.root_certificate'))
|
||||
.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.root_certificate_message'))
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body1'))
|
||||
.fontWeight(FontWeight.Regular)
|
||||
.fontColor($r('sys.color.ohos_id_color_primary'))
|
||||
.margin({
|
||||
left: $r('app.float.wh_value_24'),
|
||||
right: $r('app.float.wh_value_24')
|
||||
})
|
||||
.alignSelf(ItemAlign.Start)
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.borderRadius($r('app.float.user_list_divider_borderRadius_value'))
|
||||
.backgroundColor($r('sys.color.ohos_id_color_dialog_bg'))
|
||||
}
|
||||
|
||||
@Builder
|
||||
deleteWarnContent(): void {
|
||||
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({
|
||||
left: $r('app.float.wh_value_24'),
|
||||
right: $r('app.float.wh_value_24')
|
||||
})
|
||||
.alignSelf(ItemAlign.Start)
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.borderRadius($r('app.float.user_list_divider_borderRadius_value'))
|
||||
.backgroundColor($r('sys.color.ohos_id_color_dialog_bg'))
|
||||
}
|
||||
|
||||
@Builder
|
||||
userDetailContent($$: boolean): void {
|
||||
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)
|
||||
.height($r('app.float.wh_value_56'))
|
||||
.margin({
|
||||
bottom: $r('app.float.wh_value_8'),
|
||||
right: $r('app.float.wh_value_24')
|
||||
})
|
||||
.alignSelf(ItemAlign.Start)
|
||||
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
|
||||
Column() {
|
||||
Text(this.mUserCaPresenterDetail.certInfo.certAlias)
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body1'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
}.alignItems(HorizontalAlign.Start);
|
||||
|
||||
Toggle({ type: ToggleType.Switch, isOn: $$ })
|
||||
.margin({
|
||||
left: $r('app.float.wh_value_16'),
|
||||
right: $r('app.float.wh_value_24')
|
||||
})
|
||||
.flexShrink(0)
|
||||
.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.onShowRootCertificateDialog();
|
||||
} else {
|
||||
this.setStatus.setUserCertificateStatus(this.mUserCaPresenterDetail.certInfo.uri, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Scroll(this.userCaScroller) {
|
||||
List() {
|
||||
ListItem() {
|
||||
Text($r('app.string.CustomDialogExample_firListItem_text'))
|
||||
.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_24')
|
||||
})
|
||||
}.width(ComponentConfig.WH_100_100).align(Alignment.Start)
|
||||
|
||||
ListItem() {
|
||||
DialogSubjectComponent({ map: this.mUserCaPresenterDetail.certInfo.subjectNameMap });
|
||||
}.width(ComponentConfig.WH_100_100).align(Alignment.Start)
|
||||
|
||||
ListItem() {
|
||||
Text($r('app.string.CustomDialogExample_secListItem_text'))
|
||||
.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_24')
|
||||
})
|
||||
}.width(ComponentConfig.WH_100_100).align(Alignment.Start)
|
||||
|
||||
ListItem() {
|
||||
DialogIssuerComponent({ map: this.mUserCaPresenterDetail.certInfo.issuerNameMap });
|
||||
}.width(ComponentConfig.WH_100_100).align(Alignment.Start)
|
||||
|
||||
ListItem() {
|
||||
Text($r('app.string.CustomDialogExample_thdListItem_text'))
|
||||
.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_24')
|
||||
})
|
||||
}.width(ComponentConfig.WH_100_100).align(Alignment.Start)
|
||||
|
||||
ListItem() {
|
||||
DialogDateComponent({ map: this.mUserCaPresenterDetail.certInfo.dateMap });
|
||||
}.width(ComponentConfig.WH_100_100).align(Alignment.Start)
|
||||
|
||||
ListItem() {
|
||||
Text($r('app.string.CustomDialogExample_fouListItem_text'))
|
||||
.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_24')
|
||||
})
|
||||
}.width(ComponentConfig.WH_100_100).align(Alignment.Start)
|
||||
|
||||
ListItem() {
|
||||
DialogFingerPrintComponent({
|
||||
fingerprintSha256: this.mUserCaPresenterDetail.certInfo.fingerprintSha256
|
||||
});
|
||||
}.width(ComponentConfig.WH_100_100).align(Alignment.Start)
|
||||
}
|
||||
.margin({
|
||||
right: $r('app.float.wh_value_24')
|
||||
})
|
||||
.scrollBar(BarState.Off)
|
||||
}
|
||||
.height($r('app.float.CustomDialogExample_list_height_value'))
|
||||
.scrollable(ScrollDirection.Vertical)
|
||||
.scrollBarWidth('3vp')
|
||||
}
|
||||
.padding({
|
||||
left: $r('app.float.wh_value_24')
|
||||
})
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.borderRadius($r('app.float.user_list_divider_borderRadius_value'))
|
||||
.backgroundColor($r('sys.color.ohos_id_color_dialog_bg'))
|
||||
}
|
||||
|
||||
onShowRootCertificateDialog() {
|
||||
this.userDetailsDialog?.close();
|
||||
this.rootCertificateDialog.open();
|
||||
}
|
||||
|
||||
onShowDeleteWarnDialog() {
|
||||
this.deleteCertWarnDialog.open();
|
||||
this.userDetailsDialog?.close();
|
||||
}
|
||||
|
||||
aboutToAppear() {
|
||||
console.info('in ComponentUser aboutToAppear');
|
||||
if (this.setStatus.certList[this.indexNum].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)
|
||||
.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)
|
||||
.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'));
|
||||
}
|
||||
.flexShrink(0)
|
||||
.margin($r('app.float.wh_value_12'))
|
||||
}
|
||||
.onHover((isHover?: boolean) => {
|
||||
this.isHoverBackgroundColor = isHover ? $r('sys.color.ohos_id_color_hover') : ''
|
||||
})
|
||||
.backgroundColor(this.isHoverBackgroundColor)
|
||||
.stateStyles({
|
||||
pressed: this.pressedStyles,
|
||||
normal: this.normalStyles
|
||||
})
|
||||
.padding({
|
||||
left: $r('app.float.wh_value_8'),
|
||||
right: $r('app.float.wh_value_8')
|
||||
})
|
||||
.borderRadius($r('app.float.wh_value_20'))
|
||||
.onClick(() => {
|
||||
this.mUserCaPresenterDetail.getUserTrustedCertificate(this.uri, () => {
|
||||
if (this.onItemClicked !== undefined) {
|
||||
this.onItemClicked();
|
||||
} else {
|
||||
this.userDetailsDialog.open();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
export struct TrustedEvidence {
|
||||
@State mShowSysCaPresenter: CmShowSysCaPresenter = CmShowSysCaPresenter.getInstance();
|
||||
@State mShowUserCaPresenter: CMShowUserCaPresenter = CMShowUserCaPresenter.getInstance();
|
||||
@State mFaPresenter: CmFaPresenter = CmFaPresenter.getInstance();
|
||||
@State currentIndex: number = 0;
|
||||
@State fontColor: Resource = $r('app.color.TrustedEvidence_TabBuilder_fontColor_182431');
|
||||
@State selectedFontColor: Resource = $r('app.color.font_color_007DFF');
|
||||
private controller: TabsController = new TabsController();
|
||||
private sysCaScroller: Scroller = new Scroller();
|
||||
private userCaScroller: Scroller = new Scroller();
|
||||
@State animationDurationNum: number = 400;
|
||||
|
||||
isStartBySheetFirst: boolean = false;
|
||||
isStartBySheet: boolean = false;
|
||||
selected?: (path: string, param?: Object) => void;
|
||||
@Prop sheetParam: SheetParam;
|
||||
@State headRectHeight: number = 64;
|
||||
@State headRectHeightReal: number = 0;
|
||||
@State private sysScrollerHeight: number = 0;
|
||||
@State private userScrollerHeight: number = 0;
|
||||
|
||||
@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') })
|
||||
.color(this.selectedFontColor)
|
||||
.alignSelf(ItemAlign.Center)
|
||||
}
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
}
|
||||
|
||||
aboutToAppear() {
|
||||
this.mShowSysCaPresenter.updateSystemTrustedCertificateList();
|
||||
this.mShowUserCaPresenter.updateUserTrustedCertificateList();
|
||||
}
|
||||
|
||||
onPageShow() {
|
||||
let uri = GlobalContext.getContext().getAbilityWant().uri;
|
||||
GlobalContext.getContext().clearAbilityWantUri();
|
||||
|
||||
if (uri === 'certInstall') {
|
||||
router.pushUrl({
|
||||
url: 'pages/certInstallFromStorage'
|
||||
})
|
||||
} else if (uri === 'requestAuthorize') {
|
||||
this.mFaPresenter.startRequestAuth(GlobalContext.getContext().getAbilityWant().parameters?.appUid as string);
|
||||
} else {
|
||||
console.error('The want type is not supported');
|
||||
}
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
GridRow({ columns: COPIES_NUM, gutter: vp2px(1) === 2 ? $r('app.float.wh_value_12') : $r('app.float.wh_value_0') }) {
|
||||
GridCol({ span: COPIES_NUM }) {
|
||||
Row() {
|
||||
Stack({ alignContent: Alignment.Top }) {
|
||||
Column() {
|
||||
HeadComponent({ headName: $r('app.string.CA_cert'), isStartBySheet: this.isStartBySheet,
|
||||
icBackIsVisibility: !this.isStartBySheetFirst,
|
||||
onBackClicked: () => {
|
||||
this.selected?.(NavEntryKey.POP);
|
||||
}})
|
||||
.margin({
|
||||
left: $r('app.float.wh_value_12'),
|
||||
top: this.isStartBySheet ? 8 : 0
|
||||
})
|
||||
}.onAreaChange((oldArea, newArea) => {
|
||||
this.headRectHeight = newArea.height as number;
|
||||
this.headRectHeightReal = newArea.height as number;
|
||||
}).zIndex(1)
|
||||
|
||||
Column() {
|
||||
Tabs({ barPosition: BarPosition.Start, index: 0, controller: this.controller }) {
|
||||
TabContent() {
|
||||
Stack({ alignContent: Alignment.TopEnd }) {
|
||||
Scroll(this.sysCaScroller) {
|
||||
List() {
|
||||
ForEach(this.mShowSysCaPresenter.certList, (item: CertAbstractVo) => {
|
||||
ListItem() {
|
||||
ComponentSystem({
|
||||
certAlias: item.certAlias,
|
||||
subjectName: item.subjectNameCN,
|
||||
uri: item.uri,
|
||||
setStatus: $mShowSysCaPresenter,
|
||||
onItemClicked: this.isStartBySheet ? () => {
|
||||
this.selected?.(NavEntryKey.CA_SYSTEM_DETAIL_ENTRY);
|
||||
} : undefined
|
||||
})
|
||||
}
|
||||
}, (item: CertAbstractVo) => JSON.stringify(item))
|
||||
}
|
||||
.borderRadius($r('sys.float.padding_level10'))
|
||||
.backgroundColor($r('sys.color.ohos_id_color_card_bg'))
|
||||
.scrollBar(BarState.Off)
|
||||
.padding({
|
||||
right: $r('app.float.wh_value_4'),
|
||||
left: $r('app.float.wh_value_4'),
|
||||
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('sys.color.ohos_id_color_list_separator'),
|
||||
startMargin: $r('app.float.wh_value_8'),
|
||||
endMargin: $r('app.float.wh_value_8')
|
||||
})
|
||||
.visibility(this.mShowSysCaPresenter.certList.length > 0
|
||||
? Visibility.Visible : Visibility.None)
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(this.isStartBySheet ? WidthPercent.WH_AUTO : WidthPercent.WH_100_100)
|
||||
.align(Alignment.Top)
|
||||
.edgeEffect(EdgeEffect.Spring)
|
||||
.scrollable(ScrollDirection.Vertical)
|
||||
.scrollBar(BarState.Off)
|
||||
.padding({
|
||||
left: $r('app.float.wh_value_16'),
|
||||
right: $r('app.float.wh_value_16'),
|
||||
bottom: this.isStartBySheet ? $r('app.float.wh_value_80') : $r('app.float.wh_value_24')
|
||||
})
|
||||
.constraintSize({
|
||||
minHeight: this.getScrollMinHeight()
|
||||
}).onAreaChange((oldArea, newArea) => {
|
||||
this.sysScrollerHeight = newArea.height as number;
|
||||
})
|
||||
|
||||
Column() {
|
||||
ScrollBar({
|
||||
scroller: this.sysCaScroller,
|
||||
direction: ScrollBarDirection.Vertical,
|
||||
state: BarState.Auto
|
||||
}).margin({
|
||||
bottom: this.isStartBySheet ? $r('app.float.wh_value_80') : $r('app.float.wh_value_24')
|
||||
})
|
||||
}.height(this.sysScrollerHeight)
|
||||
}
|
||||
}
|
||||
.tabBar(this.TabBuilder(0))
|
||||
|
||||
TabContent() {
|
||||
Stack({ alignContent: Alignment.TopEnd }) {
|
||||
Scroll(this.userCaScroller) {
|
||||
List() {
|
||||
ForEach(this.mShowUserCaPresenter.certList, (item: CertAbstractVo, index) => {
|
||||
ListItem() {
|
||||
ComponentUser({
|
||||
certAlias: item.certAlias,
|
||||
subjectName: item.subjectNameCN,
|
||||
uri: item.uri,
|
||||
setStatus: $mShowUserCaPresenter,
|
||||
indexNum: index,
|
||||
onItemClicked: this.isStartBySheet ? () => {
|
||||
this.selected?.(NavEntryKey.CA_USER_DETAIL_ENTRY,
|
||||
new CaUserDetailParam(this.mShowUserCaPresenter));
|
||||
} : undefined
|
||||
})
|
||||
}
|
||||
}, (item: CertAbstractVo) => JSON.stringify(item))
|
||||
}
|
||||
.borderRadius($r('sys.float.padding_level10'))
|
||||
.backgroundColor($r('sys.color.ohos_id_color_card_bg'))
|
||||
.divider({
|
||||
strokeWidth: $r('app.float.sys_list_divider_strokeWidth_value'),
|
||||
color: $r('sys.color.ohos_id_color_list_separator'),
|
||||
startMargin: $r('app.float.wh_value_8'),
|
||||
endMargin: $r('app.float.wh_value_8')
|
||||
})
|
||||
.scrollBar(BarState.Off)
|
||||
.padding({
|
||||
left: $r('app.float.wh_value_4'),
|
||||
right: $r('app.float.wh_value_4'),
|
||||
top: $r('app.float.wh_value_4'),
|
||||
bottom: $r('app.float.wh_value_4')
|
||||
})
|
||||
.visibility(this.mShowUserCaPresenter.certList.length > 0
|
||||
? Visibility.Visible : Visibility.None)
|
||||
}
|
||||
.position({ y: $r('app.float.wh_value_0') })
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(this.isStartBySheet ? WidthPercent.WH_AUTO : WidthPercent.WH_100_100)
|
||||
.align(Alignment.Top)
|
||||
.edgeEffect(EdgeEffect.Spring)
|
||||
.scrollable(ScrollDirection.Vertical)
|
||||
.scrollBar(BarState.Off)
|
||||
.padding({
|
||||
left: $r('app.float.wh_value_16'),
|
||||
right: $r('app.float.wh_value_16'),
|
||||
bottom: this.isStartBySheet ? $r('app.float.wh_value_80') : $r('app.float.wh_value_24')
|
||||
})
|
||||
.constraintSize({
|
||||
minHeight: this.getScrollMinHeight()
|
||||
}).onAreaChange((oldArea, newArea) => {
|
||||
this.userScrollerHeight = newArea.height as number;
|
||||
})
|
||||
|
||||
Column() {
|
||||
ScrollBar({
|
||||
scroller: this.userCaScroller,
|
||||
direction: ScrollBarDirection.Vertical,
|
||||
state: BarState.Auto
|
||||
}).margin({
|
||||
bottom: this.isStartBySheet ? $r('app.float.wh_value_80') : $r('app.float.wh_value_24')
|
||||
})
|
||||
}.height(this.userScrollerHeight)
|
||||
}
|
||||
}
|
||||
.tabBar(this.TabBuilder(1))
|
||||
}
|
||||
.vertical(false)
|
||||
.scrollable(true)
|
||||
.barMode(BarMode.Fixed)
|
||||
.barWidth($r('app.float.tabs_barWidth_value'))
|
||||
.barHeight($r('app.float.tabs_barHeight_value'))
|
||||
.animationDuration(this.animationDurationNum)
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(this.isStartBySheet ? WidthPercent.WH_AUTO : WidthPercent.WH_100_100)
|
||||
.onChange((index: number) => {
|
||||
this.currentIndex = index;
|
||||
})
|
||||
}
|
||||
.height(this.isStartBySheet ? WidthPercent.WH_AUTO : WidthPercent.WH_100_100)
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.padding({
|
||||
top: this.headRectHeight
|
||||
})
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(this.isStartBySheet ? WidthPercent.WH_AUTO : WidthPercent.WH_100_100)
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(this.isStartBySheet ? WidthPercent.WH_AUTO : WidthPercent.WH_100_100);
|
||||
}
|
||||
}
|
||||
.backgroundColor($r('sys.color.ohos_id_color_sub_background'))
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(this.isStartBySheet ? WidthPercent.WH_AUTO : WidthPercent.WH_100_100);
|
||||
}
|
||||
}
|
||||
|
||||
getScrollMinHeight() {
|
||||
if (this.sheetParam === undefined || this.headRectHeightReal === 0 ||
|
||||
this.sheetParam.sheetMinHeight < this.headRectHeightReal) {
|
||||
return 0;
|
||||
}
|
||||
return this.sheetParam.sheetMinHeight - this.headRectHeightReal - 56;
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import certManagerModel from '../model/CertMangerModel';
|
||||
import BundleModel from '../model/BundleModel';
|
||||
import { CMModelErrorCode, CMModelOptType } from '../model/CertMangerModel';
|
||||
import { CredentialAbstractVo } from '../model/CertManagerVo/CredentialAbstractVo';
|
||||
import router from '@ohos.router';
|
||||
import { GlobalContext } from '../common/GlobalContext';
|
||||
import { AppInfoVo } from '../model/CertManagerVo/AppInfoVo';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
import Common from '@ohos.app.ability.common'
|
||||
|
||||
const TAG = 'CMAppCredAuthPresenter Presenter: ';
|
||||
const SUCCESS = 0;
|
||||
const FAIL = -1;
|
||||
|
||||
export default class CmAppCredAuthPresenter {
|
||||
private static sInstance: CmAppCredAuthPresenter;
|
||||
public credList: CredentialAbstractVo[] = [];
|
||||
public appName: string = '';
|
||||
|
||||
public static getInstance(): CmAppCredAuthPresenter {
|
||||
if (CmAppCredAuthPresenter.sInstance == null) {
|
||||
CmAppCredAuthPresenter.sInstance = new CmAppCredAuthPresenter();
|
||||
}
|
||||
return CmAppCredAuthPresenter.sInstance;
|
||||
}
|
||||
|
||||
onAboutToAppear(): void {
|
||||
|
||||
}
|
||||
|
||||
aboutToDisappear(): void {
|
||||
this.credList = [];
|
||||
}
|
||||
|
||||
updateAppNameFromUid(uid: string): void {
|
||||
try {
|
||||
BundleModel.getAppInfoList(Number(uid), (errCode: CMModelErrorCode, appInfo: AppInfoVo) => {
|
||||
if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) {
|
||||
this.appName = appInfo.appName;
|
||||
console.info('getAppNameFromUid success, appName = ' + this.appName);
|
||||
} else {
|
||||
console.error('getAppNameFromUid fail, uid = ' + uid);
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
let e: BusinessError = err as BusinessError;
|
||||
console.error('updateAppNameFromUid failed with err, message: ' + e.message + ', code: ' + e.code);
|
||||
}
|
||||
}
|
||||
|
||||
updateAppCredList(): void {
|
||||
certManagerModel.getCertOrCredList(CMModelOptType.CM_MODEL_OPT_APP_CRED,
|
||||
(errCode: CMModelErrorCode, credList: Array<CredentialAbstractVo>) => {
|
||||
if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) {
|
||||
this.credList = credList;
|
||||
console.info('updateAppCredList success.');
|
||||
} else {
|
||||
console.error('updateAppCredList failed');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
requestAuthorize(uri: string, appUid: string): void {
|
||||
let want = GlobalContext.getContext().getAbilityWant();
|
||||
certManagerModel.setAppAuth(CMModelOptType.CM_MODEL_OPT_APP_CRED, uri, appUid,
|
||||
true, (errCode: CMModelErrorCode, result: string) => {
|
||||
router.clear();
|
||||
if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) {
|
||||
console.info('requestAuthorize success result: ' + result);
|
||||
if (want.parameters != undefined) {
|
||||
want.parameters.authUri = result;
|
||||
let ret1: Common.AbilityResult = {
|
||||
resultCode: SUCCESS,
|
||||
want: want
|
||||
};
|
||||
GlobalContext.getContext().getCmContext().terminateSelfWithResult(ret1);
|
||||
} else {
|
||||
let ret2: Common.AbilityResult = {
|
||||
resultCode: FAIL,
|
||||
want: want
|
||||
};
|
||||
console.error(TAG + 'requestAuthorize failed, undefined');
|
||||
GlobalContext.getContext().getCmContext().terminateSelfWithResult(ret2);
|
||||
}
|
||||
} else {
|
||||
console.error('requestAuthorize fail');
|
||||
let ret3: Common.AbilityResult = {
|
||||
resultCode: FAIL,
|
||||
want: want
|
||||
};
|
||||
GlobalContext.getContext().getCmContext().terminateSelfWithResult(ret3);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
cancelProcess(): void {
|
||||
console.info('cancelProcess start');
|
||||
router.clear();
|
||||
let ret: Common.AbilityResult = {
|
||||
resultCode: FAIL,
|
||||
want: GlobalContext.getContext().getAbilityWant()
|
||||
};
|
||||
GlobalContext.getContext().getCmContext().terminateSelfWithResult(ret);
|
||||
}
|
||||
}
|
||||
@@ -1,193 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import picker from '@ohos.file.picker';
|
||||
import router from '@ohos.router';
|
||||
import certManagerModel from '../model/CertMangerModel';
|
||||
import FileIoModel from '../model/FileIoModel';
|
||||
import { CMModelErrorCode, CMModelOptType } from '../model/CertMangerModel';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
import { RouterFileVo, RouterAppUidVo } from '../model/CertManagerVo/RouterInfoVo';
|
||||
import checkUserAuthModel from '../model/CheckUserAuthModel';
|
||||
import CmInstallPresenter from './CmInstallPresenter';
|
||||
import FilterParams from '../common/constants/FileFilterParams';
|
||||
|
||||
const TAG = 'CMFaPresenter: ';
|
||||
const gridCountNum: number = 4;
|
||||
|
||||
export default class CmFaPresenter {
|
||||
private static sInstance: CmFaPresenter;
|
||||
|
||||
public static getInstance(): CmFaPresenter {
|
||||
if (CmFaPresenter.sInstance == null) {
|
||||
CmFaPresenter.sInstance = new CmFaPresenter();
|
||||
}
|
||||
return CmFaPresenter.sInstance;
|
||||
}
|
||||
|
||||
onAboutToAppear(): void {
|
||||
|
||||
}
|
||||
|
||||
aboutToDisappear(): void {
|
||||
}
|
||||
|
||||
unrecognizedFileTips(): void {
|
||||
AlertDialog.show({
|
||||
message: $r('app.string.Install_Error_NOT_FOUND'),
|
||||
autoCancel: true,
|
||||
alignment: DialogAlignment.Bottom,
|
||||
offset: {
|
||||
dx: $r('app.float.wh_value_0'), dy: $r('app.float.wh_value_0')
|
||||
},
|
||||
gridCount: gridCountNum,
|
||||
primaryButton: {
|
||||
value: $r('app.string.OK'),
|
||||
action: () => {
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
routeToNextInstallCert(fileUri: string): void {
|
||||
FileIoModel.getMediaFileSuffix(fileUri, (suffix: string | undefined) => {
|
||||
if (suffix !== undefined) {
|
||||
console.debug(TAG, 'suffix = ', suffix);
|
||||
if ((suffix === 'cer') || (suffix === 'pem') || (suffix === 'crt') || (suffix === 'der')) {
|
||||
CmInstallPresenter.getInstance().installCert(fileUri, '', suffix, true);
|
||||
} else {
|
||||
this.unrecognizedFileTips();
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
routeToNextInstallEvidence(fileUri: string): void {
|
||||
FileIoModel.getMediaFileSuffix(fileUri, (suffix: string | undefined) => {
|
||||
if (suffix !== undefined) {
|
||||
console.debug(TAG, 'suffix = ', suffix);
|
||||
if ((suffix === 'p12') || (suffix === 'pfx')) {
|
||||
let fileInfo = new RouterFileVo(fileUri, suffix);
|
||||
router.pushUrl({
|
||||
url: 'pages/certPwdInput',
|
||||
params: fileInfo
|
||||
})
|
||||
} else {
|
||||
this.unrecognizedFileTips();
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
startInstallCert(context: Context): void {
|
||||
if (context === undefined || context === null) {
|
||||
console.error(TAG + 'startInstallCert, context is undefined');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
let documentSelectOptions = new picker.DocumentSelectOptions();
|
||||
documentSelectOptions.maxSelectNumber = FilterParams.MAX_SELECT_FILE_NUM;
|
||||
documentSelectOptions.fileSuffixFilters = FilterParams.CERT_FILE_SUFFIX;
|
||||
let documentPicker = new picker.DocumentViewPicker(context);
|
||||
console.info(TAG + 'start documentPicker.select');
|
||||
documentPicker.select(documentSelectOptions).then((documentSelectResult) => {
|
||||
if (documentSelectResult.length >= 1) {
|
||||
this.routeToNextInstallCert(String(documentSelectResult[0]))
|
||||
} else {
|
||||
console.error(TAG + 'documentPicker.select length invalid:' + documentSelectResult.length);
|
||||
}
|
||||
}).catch((err: BusinessError) => {
|
||||
console.error(TAG + 'documentPicker.select failed with err, message: ' + err.message + ', code: ' + err.code);
|
||||
});
|
||||
} catch (err) {
|
||||
let e: BusinessError = err as BusinessError;
|
||||
console.error(TAG + 'DocumentViewPicker failed with err, message: ' + e.message + ', code: ' + e.code);
|
||||
}
|
||||
}
|
||||
|
||||
startInstallEvidence(context: Context): void {
|
||||
if (context === undefined || context === null) {
|
||||
console.error(TAG + 'startInstallEvidence, context is undefined');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
let documentSelectOptions = new picker.DocumentSelectOptions();
|
||||
documentSelectOptions.maxSelectNumber = FilterParams.MAX_SELECT_FILE_NUM;
|
||||
documentSelectOptions.fileSuffixFilters = FilterParams.CREDENTIAL_FILE_SUFFIX;
|
||||
let documentPicker = new picker.DocumentViewPicker(context);
|
||||
console.info(TAG + 'start documentPicker.select');
|
||||
documentPicker.select(documentSelectOptions).then((documentSelectResult) => {
|
||||
if (documentSelectResult.length >= 1) {
|
||||
this.routeToNextInstallEvidence(String(documentSelectResult[0]))
|
||||
} else {
|
||||
console.error(TAG + 'documentPicker.select length invalid:' + documentSelectResult.length);
|
||||
}
|
||||
}).catch((err: BusinessError) => {
|
||||
console.error(TAG + 'documentPicker.select failed with err, message: ' + err.message + ', code: ' + err.code);
|
||||
});
|
||||
} catch (err) {
|
||||
let e: BusinessError = err as BusinessError;
|
||||
console.error(TAG + 'DocumentViewPicker failed with err, message: ' + e.message + ', code: ' + e.code);
|
||||
}
|
||||
}
|
||||
|
||||
startRequestAuth(uri: string): void {
|
||||
let appUidInfo = new RouterAppUidVo(uri);
|
||||
router.pushUrl({
|
||||
url: 'pages/requestAuth',
|
||||
params: appUidInfo
|
||||
});
|
||||
}
|
||||
|
||||
uninstallAllCert(): void {
|
||||
certManagerModel.delAllCertOrCred(CMModelOptType.CM_MODEL_OPT_USER_CA, (errCode: CMModelErrorCode) => {
|
||||
if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) {
|
||||
console.info(TAG + 'uninstallAllCert CM_MODEL_OPT_USER_CA success');
|
||||
} else {
|
||||
console.error(TAG + 'uninstallAllCert CM_MODEL_OPT_USER_CA failed');
|
||||
}
|
||||
});
|
||||
|
||||
certManagerModel.delAllCertOrCred(CMModelOptType.CM_MODEL_OPT_APP_CRED, (errCode: CMModelErrorCode) => {
|
||||
if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) {
|
||||
console.info(TAG + 'uninstallAllCert CM_MODEL_OPT_APP_CRED success');
|
||||
} else {
|
||||
console.error(TAG + 'uninstallAllCert CM_MODEL_OPT_APP_CRED failed');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
startInstall(installType: string, fileUri: string) {
|
||||
if (installType === 'CACert') {
|
||||
let titleStr = getContext().resourceManager.getStringSync($r('app.string.Identity_Authentication'));
|
||||
checkUserAuthModel.auth(titleStr, (authResult: boolean) => {
|
||||
if (authResult) {
|
||||
console.info('checkUserAuth success');
|
||||
this.routeToNextInstallCert(fileUri);
|
||||
}
|
||||
})
|
||||
} else if (installType === 'userCred') {
|
||||
AppStorage.setOrCreate('installSystemCred', false);
|
||||
AppStorage.setOrCreate('installUserCred', true);
|
||||
this.routeToNextInstallEvidence(fileUri);
|
||||
} else if (installType === 'systemCred') {
|
||||
AppStorage.setOrCreate('installSystemCred', true);
|
||||
AppStorage.setOrCreate('installUserCred', false);
|
||||
this.routeToNextInstallEvidence(fileUri);
|
||||
} else {
|
||||
console.error(TAG, 'The installType is not supported');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,197 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import certManagerModel from '../model/CertMangerModel';
|
||||
import FileIoModel from '../model/FileIoModel';
|
||||
import { CMModelErrorCode, CMModelOptType } from '../model/CertMangerModel';
|
||||
import router from '@ohos.router';
|
||||
import { GlobalContext } from '../common/GlobalContext';
|
||||
import promptAction from '@ohos.promptAction';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
|
||||
const TAG = 'CMInstallPresenter: ';
|
||||
const DURATION = 2000;
|
||||
const gridCountNum: number = 4;
|
||||
const bottomNum: number = 100;
|
||||
|
||||
export default class CmInstallPresenter {
|
||||
private static sInstance: CmInstallPresenter;
|
||||
private optType: CMModelOptType = CMModelOptType.CM_MODEL_OPT_UNKNOWN;
|
||||
|
||||
public static getInstance(): CmInstallPresenter {
|
||||
if (CmInstallPresenter.sInstance == null) {
|
||||
CmInstallPresenter.sInstance = new CmInstallPresenter();
|
||||
}
|
||||
return CmInstallPresenter.sInstance;
|
||||
}
|
||||
|
||||
onAboutToAppear(): void {
|
||||
|
||||
}
|
||||
|
||||
aboutToDisappear(): void {
|
||||
this.optType = CMModelOptType.CM_MODEL_OPT_UNKNOWN;
|
||||
AppStorage.setOrCreate('installUserCred',false);
|
||||
AppStorage.setOrCreate('installSystemCred',false);
|
||||
}
|
||||
|
||||
updateCertFileType(suffix: string): void {
|
||||
console.debug(TAG + 'updateCertFileType suffix: ' + suffix);
|
||||
if ((suffix === 'cer') || (suffix === 'pem') || (suffix === 'crt') || (suffix === 'der')) {
|
||||
this.optType = CMModelOptType.CM_MODEL_OPT_USER_CA;
|
||||
} else if (((suffix === 'p12') || (suffix === 'pfx')) &&
|
||||
AppStorage.get('installUserCred') === true) {
|
||||
this.optType = CMModelOptType.CM_MODEL_OPT_APP_CRED;
|
||||
} else if (((suffix === 'p12') || (suffix === 'pfx')) &&
|
||||
AppStorage.get('installSystemCred') === true) {
|
||||
this.optType = CMModelOptType.CM_MODEL_OPT_SYSTEM_CRED;
|
||||
} else {
|
||||
console.debug(TAG, 'The file type is not supported. suffix: ' + suffix);
|
||||
}
|
||||
}
|
||||
|
||||
getFileDataFromUri(uri: string, callback: Function): void {
|
||||
FileIoModel.getMediaFileData(uri, (data: Uint8Array) => {
|
||||
callback(data);
|
||||
});
|
||||
}
|
||||
|
||||
checkCertNameLength(uri: string, alias: string, suffix: string, pwd: string): Promise<number> {
|
||||
return new Promise((resolve) => {
|
||||
this.updateCertFileType(suffix);
|
||||
this.getFileDataFromUri(uri, (data: Uint8Array) => {
|
||||
certManagerModel.installCertOrCred(this.optType, alias, data, pwd, (errCode: CMModelErrorCode) => {
|
||||
if (errCode === CMModelErrorCode.CM_MODEL_ERROR_ALIAS_LENGTH_REACHED_LIMIT) {
|
||||
resolve(errCode)
|
||||
} else {
|
||||
resolve(0)
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
installSuccessTips(): void {
|
||||
try {
|
||||
promptAction.showToast({
|
||||
message: this.optType === CMModelOptType.CM_MODEL_OPT_USER_CA ?
|
||||
$r('app.string.Install_Cert_Success') : $r('app.string.Install_Cred_Success'),
|
||||
duration: DURATION,
|
||||
bottom: bottomNum
|
||||
})
|
||||
} catch (err) {
|
||||
let e: BusinessError = err as BusinessError;
|
||||
console.error(TAG, 'show result failed, message: ' + e.message + ', code: ' + e.code)
|
||||
}
|
||||
}
|
||||
|
||||
errorFormatTips(): void {
|
||||
AlertDialog.show({
|
||||
message: $r('app.string.Install_ERROR_INCORRECT_FORMAT'),
|
||||
autoCancel: true,
|
||||
alignment: DialogAlignment.Bottom,
|
||||
offset: {
|
||||
dx: $r('app.float.wh_value_0'), dy: $r('app.float.wh_value_0')
|
||||
},
|
||||
gridCount: gridCountNum,
|
||||
primaryButton: {
|
||||
value: $r('app.string.OK'),
|
||||
action: () => {
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
maxQuantityReachedTips(): void {
|
||||
AlertDialog.show({
|
||||
message: $r('app.string.Install_Error_MAX_QUANTITY_REACHED'),
|
||||
autoCancel: true,
|
||||
alignment: DialogAlignment.Bottom,
|
||||
offset: {
|
||||
dx: $r('app.float.wh_value_0'), dy: $r('app.float.wh_value_0')
|
||||
},
|
||||
gridCount: gridCountNum,
|
||||
primaryButton: {
|
||||
value: $r('app.string.OK'),
|
||||
action: () => {
|
||||
router.back({
|
||||
url: 'pages/certManagerFa'
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
installFailedTips(): void {
|
||||
try {
|
||||
promptAction.showToast({
|
||||
message: this.optType === CMModelOptType.CM_MODEL_OPT_USER_CA ?
|
||||
$r('app.string.Install_Cert_Failed') : $r('app.string.Install_Cred_Failed'),
|
||||
duration: DURATION,
|
||||
bottom: bottomNum
|
||||
})
|
||||
} catch (err) {
|
||||
let e: BusinessError = err as BusinessError;
|
||||
console.error(TAG, 'show result failed, message: ' + e.message + ', code: ' + e.code)
|
||||
}
|
||||
}
|
||||
|
||||
installCert(uri: string, alias: string, suffix: string, isNeedJumpBack: boolean): Promise<CMModelErrorCode> {
|
||||
return new Promise((resolve => {
|
||||
this.updateCertFileType(suffix);
|
||||
this.getFileDataFromUri(uri, (data: Uint8Array) => {
|
||||
certManagerModel.installCertOrCred(this.optType, alias, data,
|
||||
GlobalContext.getContext().getPwdStore().getCertPwd(), (errCode: CMModelErrorCode) => {
|
||||
GlobalContext.getContext().getPwdStore().clearCertPwd();
|
||||
this.handleInstallResult(errCode, isNeedJumpBack);
|
||||
resolve(errCode);
|
||||
});
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
private handleInstallResult(errCode: CMModelErrorCode, isNeedJumpBack: boolean) {
|
||||
console.info(TAG + 'installCertOrCred result: ' + JSON.stringify(errCode));
|
||||
let isNeedJumpHomePage = true;
|
||||
switch (errCode) {
|
||||
case CMModelErrorCode.CM_MODEL_ERROR_SUCCESS:
|
||||
this.installSuccessTips();
|
||||
break;
|
||||
|
||||
case CMModelErrorCode.CM_MODEL_ERROR_INCORRECT_FORMAT:
|
||||
this.errorFormatTips();
|
||||
break;
|
||||
|
||||
case CMModelErrorCode.CM_MODEL_ERROR_MAX_QUANTITY_REACHED:
|
||||
this.maxQuantityReachedTips();
|
||||
break;
|
||||
|
||||
case CMModelErrorCode.CM_MODEL_ERROR_PASSWORD_ERR:
|
||||
isNeedJumpHomePage = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
this.installFailedTips();
|
||||
break;
|
||||
}
|
||||
if (!isNeedJumpHomePage || !isNeedJumpBack) {
|
||||
return;
|
||||
}
|
||||
router.clear();
|
||||
router.replaceUrl({
|
||||
url: 'pages/certManagerFa'
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,147 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import 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';
|
||||
import { AppInfoVo } from '../model/CertManagerVo/AppInfoVo';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
|
||||
export default class CmShowAppCredPresenter {
|
||||
private static sInstance: CmShowAppCredPresenter;
|
||||
public credList: CredentialAbstractVo[] = [];
|
||||
public appInfoList: AppAuthorVo[] = [];
|
||||
public credInfo: CredentialVo = new CredentialVo('', '', '', 0, 0, new Uint8Array());
|
||||
|
||||
public static getInstance(): CmShowAppCredPresenter {
|
||||
if (CmShowAppCredPresenter.sInstance == null) {
|
||||
CmShowAppCredPresenter.sInstance = new CmShowAppCredPresenter();
|
||||
}
|
||||
return CmShowAppCredPresenter.sInstance;
|
||||
}
|
||||
|
||||
aboutToDisappear(): void {
|
||||
this.credList = [];
|
||||
this.credInfo = new CredentialVo('', '', '', 0, 0, new Uint8Array());
|
||||
this.appInfoList = [];
|
||||
}
|
||||
|
||||
updateAppCredListCallback(callback: Function): void {
|
||||
certManagerModel.getCertOrCredList(CMModelOptType.CM_MODEL_OPT_APP_CRED,
|
||||
(errCode: CMModelErrorCode, credList: Array<CredentialAbstractVo>) => {
|
||||
if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) {
|
||||
credList.sort((certAbs, certAbsOther): number => {
|
||||
let certAlias = certAbs.alias;
|
||||
let certAliasOther = certAbsOther.alias;
|
||||
if (certAlias <= certAliasOther) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
this.credList = credList;
|
||||
callback();
|
||||
} else {
|
||||
console.error('updateAppCredList error :' + JSON.stringify(errCode));
|
||||
this.credList = [];
|
||||
callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
updateAppCredList(): void {
|
||||
certManagerModel.getCertOrCredList(CMModelOptType.CM_MODEL_OPT_APP_CRED,
|
||||
(errCode: CMModelErrorCode, credList: Array<CredentialAbstractVo>) => {
|
||||
if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) {
|
||||
credList.sort((certAbs, certAbsOther): number => {
|
||||
let certAlias = certAbs.alias;
|
||||
let certAliasOther = certAbsOther.alias;
|
||||
if (certAlias <= certAliasOther) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
this.credList = credList;
|
||||
} else {
|
||||
console.error('updateAppCredList error :' + JSON.stringify(errCode));
|
||||
this.credList = [];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
getAppCred(uri: string, callback: Function): void {
|
||||
certManagerModel.getCertOrCred(CMModelOptType.CM_MODEL_OPT_APP_CRED, uri,
|
||||
(errCode: CMModelErrorCode, credInfo: CredentialVo) => {
|
||||
if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) {
|
||||
this.credInfo = credInfo;
|
||||
} else {
|
||||
console.error('getAppCred error :' + JSON.stringify(errCode));
|
||||
this.credInfo.clearCredentialVo();
|
||||
}
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
deleteAppCred(uri: string): void {
|
||||
certManagerModel.deleteCertOrCred(CMModelOptType.CM_MODEL_OPT_APP_CRED, uri, (errCode: CMModelErrorCode) => {
|
||||
if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) {
|
||||
this.updateAppCredList();
|
||||
} else {
|
||||
console.error('deleteAppCred error :' + JSON.stringify(errCode));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
getAuthorizedAppList(uri: string): void {
|
||||
this.appInfoList = [];
|
||||
certManagerModel.getAuthAppList(CMModelOptType.CM_MODEL_OPT_APP_CRED, uri,
|
||||
(errCode: CMModelErrorCode, appUidList: Array<string>) => {
|
||||
if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) {
|
||||
for (let i = 0; i < appUidList.length; i++) {
|
||||
bundleModel.getAppInfoList(Number(appUidList[i]), (errCode: CMModelErrorCode, appInfo: AppInfoVo) => {
|
||||
if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) {
|
||||
this.appInfoList.push(
|
||||
new AppAuthorVo(String(appInfo.appImage), String(appUidList[i]), String(appInfo.appName), true));
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
console.error('getAuthorizedAppList error :' + JSON.stringify(errCode));
|
||||
this.appInfoList = [];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async removeGrantedAppList(uri: string): Promise<void> {
|
||||
console.info('enter removeGrantedAppList');
|
||||
for (let i = 0; i < this.appInfoList.length; i++) {
|
||||
if (!this.appInfoList[i].status) {
|
||||
try {
|
||||
let res = await certManagerModel.setAppAuthPromise(CMModelOptType.CM_MODEL_OPT_APP_CRED, uri,
|
||||
this.appInfoList[i].uid, false);
|
||||
console.info('removeGrantedAppList succeed');
|
||||
} catch (error) {
|
||||
let e: BusinessError = error as BusinessError;
|
||||
console.error('removeGrantedAppList error, message: ' + e.message + ', code: ' + e.code);
|
||||
}
|
||||
}
|
||||
}
|
||||
console.info('leave removeGrantedAppList');
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import 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;
|
||||
public certList: CertAbstractVo[] = [];
|
||||
public certInfo: CertInfoVo = new CertInfoVo('', '', false, '', '', '', '', '', '',
|
||||
new Uint8Array(), new Map(), new Map(), new Map());
|
||||
|
||||
public static getInstance(): CmShowSysCaPresenter {
|
||||
if (CmShowSysCaPresenter.sInstance == null) {
|
||||
CmShowSysCaPresenter.sInstance = new CmShowSysCaPresenter();
|
||||
}
|
||||
return CmShowSysCaPresenter.sInstance;
|
||||
}
|
||||
|
||||
onAboutToAppear(): void {
|
||||
this.updateSystemTrustedCertificateList();
|
||||
}
|
||||
|
||||
aboutToDisappear(): void {
|
||||
this.certList = [];
|
||||
this.certInfo = new CertInfoVo('', '', false, '', '', '', '', '', '',
|
||||
new Uint8Array(), new Map(), new Map(), new Map());
|
||||
}
|
||||
|
||||
updateSystemTrustedCertificateList(): void {
|
||||
certManagerModel.getCertOrCredList(CMModelOptType.CM_MODEL_OPT_SYSTEM_CA,
|
||||
(errCode: CMModelErrorCode, certList: Array<CertAbstractVo>) => {
|
||||
if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) {
|
||||
certList.sort((certAbs, certAbsOther): number => {
|
||||
let certAlias = certAbs.certAlias;
|
||||
let certAliasOther = certAbsOther.certAlias;
|
||||
if (certAlias <= certAliasOther) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
this.certList = certList;
|
||||
} else {
|
||||
console.error(TAG + 'updateSystemTrustedCertificateList fail,errCode is' + errCode);
|
||||
this.certList = [];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
getSystemTrustedCertificate(uri: string, callback: Function): void {
|
||||
certManagerModel.getCertOrCred(CMModelOptType.CM_MODEL_OPT_SYSTEM_CA, uri,
|
||||
(errCode: CMModelErrorCode, certInfo: CertInfoVo) => {
|
||||
if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) {
|
||||
console.info(TAG + 'getSystemTrustedCertificate success,errCode is ' + errCode);
|
||||
this.certInfo = certInfo;
|
||||
callback();
|
||||
} else {
|
||||
console.error(TAG + 'getSystemTrustedCertificate fail,errCode is' + errCode);
|
||||
this.certInfo.clearCertInfoVo();
|
||||
callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
setSystemCertificateStatus(uri: string, status: boolean): void {
|
||||
certManagerModel.setCertStatus(CMModelOptType.CM_MODEL_OPT_SYSTEM_CA, uri, status,
|
||||
(errCode: CMModelErrorCode) => {
|
||||
if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) {
|
||||
console.info(TAG + 'setSystemCertificateStatus success,errCode is' + errCode);
|
||||
this.updateSystemTrustedCertificateList();
|
||||
} else {
|
||||
console.error(TAG + 'setSystemCertificateStatus fail,errCode is' + errCode);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import certManagerModel from '../model/CertMangerModel';
|
||||
import { CMModelErrorCode, CMModelOptType } from '../model/CertMangerModel';
|
||||
import { CredentialAbstractVo } from '../model/CertManagerVo/CredentialAbstractVo';
|
||||
import { CredentialVo } from '../model/CertManagerVo/CredentialVo';
|
||||
import { AppAuthorVo } from '../model/CertManagerVo/AppAuthorVo';
|
||||
@Observed
|
||||
export default class CmShowSysCredPresenter {
|
||||
private static sInstance: CmShowSysCredPresenter;
|
||||
public credList: CredentialAbstractVo[] = [];
|
||||
public appInfoList: AppAuthorVo[] = [];
|
||||
public credInfo: CredentialVo = new CredentialVo('', '', '', 0, 0, new Uint8Array());
|
||||
|
||||
public static getInstance(): CmShowSysCredPresenter {
|
||||
if (CmShowSysCredPresenter.sInstance == null) {
|
||||
CmShowSysCredPresenter.sInstance = new CmShowSysCredPresenter();
|
||||
}
|
||||
return CmShowSysCredPresenter.sInstance;
|
||||
}
|
||||
|
||||
aboutToDisappear(): void {
|
||||
this.credList = [];
|
||||
this.credInfo = new CredentialVo('', '', '', 0, 0, new Uint8Array());
|
||||
this.appInfoList = [];
|
||||
}
|
||||
|
||||
updateSystemCredListCallback(callback: Function): void {
|
||||
certManagerModel.getCertOrCredList(CMModelOptType.CM_MODEL_OPT_SYSTEM_CRED,
|
||||
(errCode: CMModelErrorCode, credList: Array<CredentialAbstractVo>) => {
|
||||
if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) {
|
||||
credList.sort((certAbs, certAbsOther): number => {
|
||||
let certAlias = certAbs.alias;
|
||||
let certAliasOther = certAbsOther.alias;
|
||||
if (certAlias <= certAliasOther) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
this.credList = credList;
|
||||
callback();
|
||||
} else {
|
||||
console.error('updateAppCredList error :' + JSON.stringify(errCode));
|
||||
this.credList = [];
|
||||
callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
updateSystemCredList(): void {
|
||||
certManagerModel.getCertOrCredList(CMModelOptType.CM_MODEL_OPT_SYSTEM_CRED,
|
||||
(errCode: CMModelErrorCode, credList: Array<CredentialAbstractVo>) => {
|
||||
if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) {
|
||||
credList.sort((certAbs, certAbsOther): number => {
|
||||
let certAlias = certAbs.alias;
|
||||
let certAliasOther = certAbsOther.alias;
|
||||
if (certAlias <= certAliasOther) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
this.credList = credList;
|
||||
} else {
|
||||
console.error('updateSystemCredList error :' + JSON.stringify(errCode));
|
||||
this.credList = [];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
getSystemCred(uri: string, callback: Function): void {
|
||||
certManagerModel.getCertOrCred(CMModelOptType.CM_MODEL_OPT_SYSTEM_CRED, uri,
|
||||
(errCode: CMModelErrorCode, credInfo: CredentialVo) => {
|
||||
if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) {
|
||||
this.credInfo = credInfo;
|
||||
} else {
|
||||
console.error('getAppCred error :' + JSON.stringify(errCode));
|
||||
this.credInfo.clearCredentialVo();
|
||||
}
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
deleteSystemCred(uri: string): void {
|
||||
certManagerModel.deleteCertOrCred(CMModelOptType.CM_MODEL_OPT_SYSTEM_CRED, uri, (errCode: CMModelErrorCode) => {
|
||||
if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) {
|
||||
this.updateSystemCredList();
|
||||
} else {
|
||||
console.error('deleteAppCred error :' + JSON.stringify(errCode));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import 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;
|
||||
public certList: CertAbstractVo[] = [];
|
||||
public certInfo: CertInfoVo = new CertInfoVo('', '', false, '', '', '', '', '', '',
|
||||
new Uint8Array(), new Map(), new Map(), new Map());
|
||||
|
||||
public static getInstance(): CmShowUserCaPresenter {
|
||||
if (CmShowUserCaPresenter.sInstance == null) {
|
||||
CmShowUserCaPresenter.sInstance = new CmShowUserCaPresenter();
|
||||
}
|
||||
return CmShowUserCaPresenter.sInstance;
|
||||
}
|
||||
|
||||
onAboutToAppear(): void {
|
||||
|
||||
}
|
||||
|
||||
aboutToDisappear(): void {
|
||||
this.certList = [];
|
||||
this.certInfo = new CertInfoVo('', '', false, '', '', '', '', '', '',
|
||||
new Uint8Array(), new Map(), new Map(), new Map());
|
||||
}
|
||||
|
||||
updateUserTrustedCertificateList(): void {
|
||||
certManagerModel.getCertOrCredList(CMModelOptType.CM_MODEL_OPT_USER_CA,
|
||||
(errCode: CMModelErrorCode, certList: Array<CertAbstractVo>) => {
|
||||
if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) {
|
||||
certList.sort((certAbs, certAbsOther): number => {
|
||||
let certAlias = certAbs.certAlias;
|
||||
let certAliasOther = certAbsOther.certAlias;
|
||||
if (certAlias <= certAliasOther) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
this.certList = certList;
|
||||
} else {
|
||||
console.error(TAG + 'updateUserTrustedCertificateList fail,errCode is ' + errCode);
|
||||
this.certList = [];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
getUserTrustedCertificate(uri: string, callback: Function): void {
|
||||
certManagerModel.getCertOrCred(CMModelOptType.CM_MODEL_OPT_USER_CA, uri,
|
||||
(errCode: CMModelErrorCode, certInfo: CertInfoVo) => {
|
||||
if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) {
|
||||
console.info(TAG + 'getUserTrustedCertificate success, errCode is ' + errCode);
|
||||
this.certInfo = certInfo;
|
||||
callback();
|
||||
} else {
|
||||
console.error(TAG + 'getUserTrustedCertificate fail, errCode is ' + errCode);
|
||||
this.certInfo.clearCertInfoVo();
|
||||
callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
setUserCertificateStatus(uri: string, status: boolean): Promise<boolean> {
|
||||
return new Promise<boolean>(resolve => {
|
||||
certManagerModel.setCertStatus(CMModelOptType.CM_MODEL_OPT_USER_CA, uri, status, (errCode: CMModelErrorCode) => {
|
||||
if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) {
|
||||
this.getUserTrustedCertificate(uri, () => {
|
||||
console.info(TAG + 'setCerStatus then getUserTrustedCertificate,errCode is' + errCode);
|
||||
});
|
||||
return resolve(true);
|
||||
} else {
|
||||
console.error(TAG + 'setUserCertificateStatus fail,errCode is ' + errCode);
|
||||
return resolve(false);
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
deleteUserCertificate(uri: string, callback: Function): void {
|
||||
certManagerModel.deleteCertOrCred(CMModelOptType.CM_MODEL_OPT_USER_CA, uri, (errCode: CMModelErrorCode) => {
|
||||
if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) {
|
||||
this.updateUserTrustedCertificateList();
|
||||
} else {
|
||||
console.error(TAG + 'deleteUserCertificate fail,errCode is ' + errCode);
|
||||
}
|
||||
callback();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
{
|
||||
"module": {
|
||||
"name": "CertManager",
|
||||
"type": "feature",
|
||||
"description": "$string:mainability_description",
|
||||
"mainElement": "MainAbility",
|
||||
"deviceTypes": [
|
||||
"default"
|
||||
],
|
||||
"metadata": [
|
||||
{
|
||||
"name": "ArkTSPartialUpdate",
|
||||
"value": "true"
|
||||
},
|
||||
{
|
||||
"name": "partialUpdateStrictCheck",
|
||||
"value": "all"
|
||||
}
|
||||
],
|
||||
"deliveryWithInstall": true,
|
||||
"installationFree": false,
|
||||
"pages": "$profile:main_pages",
|
||||
"abilities": [
|
||||
{
|
||||
"name": "MainAbility",
|
||||
"srcEntry": "./ets/MainAbility/MainAbility.ts",
|
||||
"description": "$string:mainability_description",
|
||||
"icon": "$media:icon",
|
||||
"label": "$string:entry_MainAbility",
|
||||
"exported": true,
|
||||
"launchType": "singleton",
|
||||
"startWindowIcon": "$media:icon",
|
||||
"startWindowBackground": "$color:color_1",
|
||||
"orientation": "auto_rotation_restricted",
|
||||
"skills": [
|
||||
{
|
||||
"entities": [
|
||||
"entity.system.home"
|
||||
],
|
||||
"actions": [
|
||||
"action.system.home"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"extensionAbilities": [
|
||||
{
|
||||
"name": "MainExtensionAbility",
|
||||
"srcEntry": "./ets/MainAbility/MainExtensionAbility.ts",
|
||||
"description": "$string:mainability_description",
|
||||
"icon": "$media:icon",
|
||||
"label": "$string:entry_MainAbility",
|
||||
"exported": true,
|
||||
"permissions": ['ohos.permission.ACCESS_CERT_MANAGER'],
|
||||
"type": "sys/commonUI",
|
||||
"skills": [
|
||||
{
|
||||
"entities": [
|
||||
"entity.system.home"
|
||||
],
|
||||
"actions": [
|
||||
"action.system.home",
|
||||
"action.access.privacy.center",
|
||||
"ohos.want.action.viewData"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": [
|
||||
{
|
||||
"name": 'metadata.access.privacy.center',
|
||||
"value": 'security_privacy.json'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CertPickerUIExtAbility",
|
||||
"srcEntry": "./ets/MainAbility/CertPickerUiExtAbility.ets",
|
||||
"exported": true,
|
||||
"permissions": ['ohos.permission.ACCESS_CERT_MANAGER'],
|
||||
"type": "sys/commonUI"
|
||||
}
|
||||
],
|
||||
"requestPermissions": [
|
||||
{
|
||||
"name": "ohos.permission.GET_BUNDLE_INFO"
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.ACCESS_CERT_MANAGER_INTERNAL"
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.ACCESS_CERT_MANAGER"
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.GET_BUNDLE_RESOURCES"
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.ACCESS_SECURITY_PRIVACY_CENTER"
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.ACCESS_BIOMETRIC"
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.PRIVACY_WINDOW"
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.ACCESS_SYSTEM_APP_CERT"
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.ACCESS_USER_TRUSTED_CERT"
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,272 +0,0 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,435 +0,0 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "entry_MainAbility",
|
||||
"value": "证书管理"
|
||||
},
|
||||
{
|
||||
"name": "mainability_description",
|
||||
"value": "ETS_Empty Feature Ability"
|
||||
},
|
||||
{
|
||||
"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": "注:证书名称仅支持英文和数字"
|
||||
},
|
||||
{
|
||||
"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 指纹:"
|
||||
},
|
||||
{
|
||||
"name": "root_certificate",
|
||||
"value": "根证书"
|
||||
},
|
||||
{
|
||||
"name": "root_certificate_message",
|
||||
"value": "警告:为网站启用此证书将允许第三方查看发送给网站的任何私人数据。"
|
||||
},
|
||||
{
|
||||
"name": "root_certificate_cancel",
|
||||
"value": "取消"
|
||||
},
|
||||
{
|
||||
"name": "root_certificate_continue",
|
||||
"value": "继续"
|
||||
},
|
||||
{
|
||||
"name": "CA_cert",
|
||||
"value": "CA证书"
|
||||
},
|
||||
{
|
||||
"name": "user_certificate_credentials",
|
||||
"value": "用户凭据"
|
||||
},
|
||||
{
|
||||
"name": "delete_success",
|
||||
"value": "删除成功"
|
||||
},
|
||||
{
|
||||
"name": "importCertDialogTitle",
|
||||
"value": "安装用户受信任的证书"
|
||||
},
|
||||
{
|
||||
"name": "importCertDialogMessage",
|
||||
"value": "即将安装用户受信任的证书。是否安装?"
|
||||
},
|
||||
{
|
||||
"name": "importCredDialogTitle",
|
||||
"value": "安装公共凭据"
|
||||
},
|
||||
{
|
||||
"name": "importCredDialogMessage",
|
||||
"value": "即将安装公共凭据。是否安装?"
|
||||
},
|
||||
{
|
||||
"name": "invalidCertAndCredDialogTitle",
|
||||
"value": "无法使用此文件"
|
||||
},
|
||||
{
|
||||
"name": "invalidCertAndCredDialogMessage",
|
||||
"value": "无法将此文件用作证书和凭据"
|
||||
},
|
||||
{
|
||||
"name": "importCancel",
|
||||
"value": "取消"
|
||||
},
|
||||
{
|
||||
"name": "importConfirm",
|
||||
"value": "确认"
|
||||
},
|
||||
{
|
||||
"name": "invalidCertAndCredConfirm",
|
||||
"value": "关闭"
|
||||
},
|
||||
{
|
||||
"name": "authenticationTitle",
|
||||
"value": "请进行身份认证"
|
||||
},
|
||||
{
|
||||
"name": "certInputPassword",
|
||||
"value": "输入证书密码"
|
||||
},
|
||||
{
|
||||
"name": "inputConfirm",
|
||||
"value": "确认"
|
||||
},
|
||||
{
|
||||
"name": "setCertName",
|
||||
"value": "设置证书名称"
|
||||
},
|
||||
{
|
||||
"name": "setCertMessage",
|
||||
"value": "此证书颁布者可能会检查进出设备的所有流量,该数据包含:CA证书"
|
||||
},
|
||||
{
|
||||
"name": "Install_Cert_Success",
|
||||
"value": "安装证书成功"
|
||||
},
|
||||
{
|
||||
"name": "Install_Cred_Success",
|
||||
"value": "安装凭据成功"
|
||||
},
|
||||
{
|
||||
"name": "Install_Cert_Failed",
|
||||
"value": "安装证书失败"
|
||||
},
|
||||
{
|
||||
"name": "Install_Cred_Failed",
|
||||
"value": "安装凭据失败"
|
||||
},
|
||||
{
|
||||
"name": "Install_Error_NOT_FOUND",
|
||||
"value": "无法识别此文件。"
|
||||
},
|
||||
{
|
||||
"name": "Install_ERROR_INCORRECT_FORMAT",
|
||||
"value": "证书已损坏。"
|
||||
},
|
||||
{
|
||||
"name": "Install_Error_MAX_QUANTITY_REACHED",
|
||||
"value": "证书数量已达上限,请清理证书。"
|
||||
},
|
||||
{
|
||||
"name": "OK",
|
||||
"value": "知道了"
|
||||
},
|
||||
{
|
||||
"name": "Password_Message",
|
||||
"value": "密码错误"
|
||||
},
|
||||
{
|
||||
"name": "Identity_Authentication",
|
||||
"value": "请进行身份验证"
|
||||
},
|
||||
{
|
||||
"name": "inputAliasWarn",
|
||||
"value": "已达到长度上限"
|
||||
},
|
||||
{
|
||||
"name": "system_credentials",
|
||||
"value": "系统凭据"
|
||||
},
|
||||
{
|
||||
"name": "cert_install_success",
|
||||
"value": "安装成功"
|
||||
},
|
||||
{
|
||||
"name": "cert_install_failed",
|
||||
"value": "安装失败"
|
||||
},
|
||||
{ "name": "cert_install_tip",
|
||||
"value": "“%s”请求安装CA 证书"
|
||||
},
|
||||
{
|
||||
"name": "cert_install_success_tip",
|
||||
"value": "CA 证书已安装。"
|
||||
},
|
||||
{
|
||||
"name":"cert_install_warning",
|
||||
"value":"为网站启用此证书将允许第三方查看发送给网站的任何私人数据。"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>Public/ic_public_back</title>
|
||||
<defs>
|
||||
<path d="M5.31079777,13.7499686 L11.2803301,19.7196699 L11.3140714,19.7556673 C11.5727547,20.0502619 11.5615076,20.4991526 11.2803301,20.7803301 C10.9991526,21.0615076 10.5502619,21.0727547 10.2556673,20.8140714 L10.2196699,20.7803301 L3.18929777,13.7499686 L5.31079777,13.7499686 Z M11.2803301,3.21966991 C11.5615076,3.5008474 11.5727547,3.94973814 11.3140714,4.24433269 L11.2803301,4.28033009 L4.3105,11.25 L21,11.25 C21.3994202,11.25 21.7259152,11.56223 21.7487268,11.9559318 L21.75,12 C21.75,12.3994202 21.43777,12.7259152 21.0440682,12.7487268 L21,12.75 L3.10355339,12.75 C2.8383369,12.75 2.58398299,12.6446432 2.39644661,12.4571068 C2.01893979,12.0796 2.00635623,11.4753589 2.35869593,11.0827365 L2.39644661,11.0428932 L10.2196699,3.21966991 C10.5125631,2.9267767 10.9874369,2.9267767 11.2803301,3.21966991 Z" id="path-1"></path>
|
||||
</defs>
|
||||
<g id="Public/ic_public_back" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<mask id="mask-2" fill="white">
|
||||
<use xlink:href="#path-1"></use>
|
||||
</mask>
|
||||
<use id="形状结合" fill="#000000" fill-rule="nonzero" xlink:href="#path-1"></use>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 1.4 KiB |
@@ -1,3 +0,0 @@
|
||||
<svg id="图层_1" data-name="图层 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96"><defs>
|
||||
<style>.cls-1{fill:#1a1a1a;}</style>
|
||||
</defs><title>_ic</title><path class="cls-1" d="M76.29,72.05,52.24,48,76.29,24a3,3,0,1,0-4.24-4.24l-24,24-24-24A3,3,0,1,0,19.71,24L43.76,48l-24,24A3,3,0,1,0,24,76.29L48,52.24l24,24.05a3,3,0,0,0,4.24-4.24Z"/></svg>
|
||||
|
Before Width: | Height: | Size: 356 B |
@@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>xxxhdpi/ic_delete</title>
|
||||
<defs>
|
||||
<path d="M5.629,7.5 L6.72612901,18.4738834 C6.83893748,19.6019681 7.77211147,20.4662096 8.89848718,20.4990325 L8.96496269,20.5 L15.0342282,20.5 C16.1681898,20.5 17.1211231,19.6570911 17.2655686,18.5392856 L17.2731282,18.4732196 L18.1924161,9.2527383 L18.369,7.5 L19.877,7.5 L19.6849078,9.40262938 L18.7657282,18.6220326 C18.5772847,20.512127 17.0070268,21.9581787 15.1166184,21.9991088 L15.0342282,22 L8.96496269,22 C7.06591715,22 5.47142703,20.5815579 5.24265599,18.7050136 L5.23357322,18.6231389 L4.121,7.5 L5.629,7.5 Z M10.25,11.75 C10.6642136,11.75 11,12.0857864 11,12.5 L11,18.5 C11,18.9142136 10.6642136,19.25 10.25,19.25 C9.83578644,19.25 9.5,18.9142136 9.5,18.5 L9.5,12.5 C9.5,12.0857864 9.83578644,11.75 10.25,11.75 Z M13.75,11.75 C14.1642136,11.75 14.5,12.0857864 14.5,12.5 L14.5,18.5 C14.5,18.9142136 14.1642136,19.25 13.75,19.25 C13.3357864,19.25 13,18.9142136 13,18.5 L13,12.5 C13,12.0857864 13.3357864,11.75 13.75,11.75 Z M12,1.75 C13.7692836,1.75 15.2083571,3.16379796 15.2491124,4.92328595 L15.25,5 L21,5 C21.4142136,5 21.75,5.33578644 21.75,5.75 C21.75,6.14942022 21.43777,6.47591522 21.0440682,6.49872683 L21,6.5 L14.5,6.5 C14.1005798,6.5 13.7740848,6.18777001 13.7512732,5.7940682 L13.75,5.75 L13.75,5 C13.75,4.03350169 12.9664983,3.25 12,3.25 C11.0536371,3.25 10.2827253,4.00119585 10.2510148,4.93983756 L10.25,5 L10.25,5.75 C10.25,6.14942022 9.93777001,6.47591522 9.5440682,6.49872683 L9.5,6.5 L2.75,6.5 C2.33578644,6.5 2,6.16421356 2,5.75 C2,5.35057978 2.31222999,5.02408478 2.7059318,5.00127317 L2.75,5 L8.75,5 C8.75,3.20507456 10.2050746,1.75 12,1.75 Z" id="path-1"></path>
|
||||
</defs>
|
||||
<g id="ic_delete" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<mask id="mask-2" fill="white">
|
||||
<use xlink:href="#path-1"></use>
|
||||
</mask>
|
||||
<use id="形状结合" fill="#000000" fill-rule="nonzero" xlink:href="#path-1"></use>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 2.1 KiB |
@@ -1 +0,0 @@
|
||||
<svg id="图层_1" data-name="图层 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96"><defs><style>.cls-1{fill:#1a1a1a;}</style></defs><title>ic</title><path class="cls-1" d="M15,42H81a3,3,0,0,0,0-6H15a3,3,0,0,0,0,6Z"/><path class="cls-1" d="M81,54H15a3,3,0,0,0,0,6H81a3,3,0,0,0,0-6Z"/></svg>
|
||||
|
Before Width: | Height: | Size: 301 B |
@@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>Public/ic_public_cancel</title>
|
||||
<defs>
|
||||
<path d="M19.7781746,4.22182541 C20.0710678,4.51471863 20.0710678,4.98959236 19.7781746,5.28248558 L5.28248558,19.7781746 C4.98959236,20.0710678 4.51471863,20.0710678 4.22182541,19.7781746 C3.92893219,19.4852814 3.92893219,19.0104076 4.22182541,18.7175144 L10.9395166,11.9994697 L4.22182541,5.28248558 C3.92893219,4.98959236 3.92893219,4.51471863 4.22182541,4.22182541 C4.51471863,3.92893219 4.98959236,3.92893219 5.28248558,4.22182541 L12,10.9389863 L18.7175144,4.22182541 C19.0104076,3.92893219 19.4852814,3.92893219 19.7781746,4.22182541 Z M19.7781746,18.7175144 C20.0710678,19.0104076 20.0710678,19.4852814 19.7781746,19.7781746 C19.4852814,20.0710678 19.0104076,20.0710678 18.7175144,19.7781746 L12.7072836,13.7675902 L13.767767,12.7071068 L19.7781746,18.7175144 Z" id="path-1"></path>
|
||||
</defs>
|
||||
<g id="Public/ic_public_cancel" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<mask id="mask-2" fill="white">
|
||||
<use xlink:href="#path-1"></use>
|
||||
</mask>
|
||||
<use id="形状" fill="#000000" xlink:href="#path-1"></use>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 1.3 KiB |
@@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>Public/ic_public_close</title>
|
||||
<defs>
|
||||
<path d="M12,1 C18.0751322,1 23,5.92486775 23,12 C23,18.0751322 18.0751322,23 12,23 C5.92486775,23 1,18.0751322 1,12 C1,5.92486775 5.92486775,1 12,1 Z M12,2.5 C6.75329488,2.5 2.5,6.75329488 2.5,12 C2.5,17.2467051 6.75329488,21.5 12,21.5 C17.2467051,21.5 21.5,17.2467051 21.5,12 C21.5,6.75329488 17.2467051,2.5 12,2.5 Z M8.81801948,7.75735931 L12.0007071,10.9386327 L15.1819805,7.75735931 C15.4748737,7.46446609 15.9497475,7.46446609 16.2426407,7.75735931 C16.5355339,8.05025253 16.5355339,8.52512627 16.2426407,8.81801948 L8.81801948,16.2426407 C8.52512627,16.5355339 8.05025253,16.5355339 7.75735931,16.2426407 C7.46446609,15.9497475 7.46446609,15.4748737 7.75735931,15.1819805 L10.9400469,11.9992929 L7.75735931,8.81801948 C7.46446609,8.52512627 7.46446609,8.05025253 7.75735931,7.75735931 C8.05025253,7.46446609 8.52512627,7.46446609 8.81801948,7.75735931 Z M13.767767,12.7071068 L16.2426407,15.1819805 C16.5355339,15.4748737 16.5355339,15.9497475 16.2426407,16.2426407 C15.9497475,16.5355339 15.4748737,16.5355339 15.1819805,16.2426407 L12.7071068,13.767767 L13.767767,12.7071068 Z" id="path-1"></path>
|
||||
</defs>
|
||||
<g id="Public/ic_public_close" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<mask id="mask-2" fill="white">
|
||||
<use xlink:href="#path-1"></use>
|
||||
</mask>
|
||||
<use id="形状结合" fill="#000000" fill-rule="nonzero" xlink:href="#path-1"></use>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 1.6 KiB |
@@ -1,28 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 18.1.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1"
|
||||
id="图层_1"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
x="0px"
|
||||
y="0px"
|
||||
viewBox="0 0 48 96"
|
||||
enable-background="new 0 0 48 96"
|
||||
xml:space="preserve">
|
||||
<path
|
||||
fill="#CCCCCC"
|
||||
d="M37.1,45.9l-22-22c-1.2-1.2-3.1-1.2-4.2,0c-1.2,1.2-1.2,3.1,0,4.2L30.8,48L10.9,67.9c-1.2,1.2-1.2,3.1,0,4.2
|
||||
c0.6,0.6,1.4,0.9,2.1,0.9s1.5-0.3,2.1-0.9l22-22C38.3,48.9,38.3,47.1,37.1,45.9z"/>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 681 B |
|
Before Width: | Height: | Size: 6.6 KiB |
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"src": [
|
||||
"pages/certManagerFa",
|
||||
"pages/certPwdInput",
|
||||
"pages/trustedCa",
|
||||
"pages/cerEvidenceFa",
|
||||
"pages/requestAuth",
|
||||
"pages/certInstallFromStorage",
|
||||
"pages/CertificateInstallPage",
|
||||
"pages/picker/CertManagerSheetFa"
|
||||
]
|
||||
}
|
||||
@@ -1,436 +0,0 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "entry_MainAbility",
|
||||
"value": "Certificate Manager"
|
||||
},
|
||||
{
|
||||
"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: certificate names only support English and numbers"
|
||||
},
|
||||
{
|
||||
"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:"
|
||||
},
|
||||
{
|
||||
"name": "root_certificate",
|
||||
"value": "root certificate"
|
||||
},
|
||||
{
|
||||
"name": "root_certificate_message",
|
||||
"value": "Warning: Enabling this certificate for a website will allow third parties to view any private data sent to the website."
|
||||
},
|
||||
{
|
||||
"name": "root_certificate_cancel",
|
||||
"value": "Cancel"
|
||||
},
|
||||
{
|
||||
"name": "root_certificate_continue",
|
||||
"value": "Continue"
|
||||
},
|
||||
{
|
||||
"name": "CA_cert",
|
||||
"value": "CA certificate"
|
||||
},
|
||||
{
|
||||
"name": "user_certificate_credentials",
|
||||
"value": "User credentials"
|
||||
},
|
||||
{
|
||||
"name": "delete_success",
|
||||
"value": "delete success"
|
||||
},
|
||||
{
|
||||
"name": "importCertDialogTitle",
|
||||
"value": "importCertDialogTitle"
|
||||
},
|
||||
{
|
||||
"name": "importCertDialogMessage",
|
||||
"value": "User trusted certificate is about to be installed. Whether or not to install?"
|
||||
},
|
||||
{
|
||||
"name": "importCredDialogTitle",
|
||||
"value": "Install Public Credential"
|
||||
},
|
||||
{
|
||||
"name": "importCredDialogMessage",
|
||||
"value": "Public credential is about to be installed. Whether or not to install?"
|
||||
},
|
||||
{
|
||||
"name": "invalidCertAndCredDialogTitle",
|
||||
"value": "Cannot use This File "
|
||||
},
|
||||
{
|
||||
"name": "invalidCertAndCredDialogMessage",
|
||||
"value": "Cannot use this file as a certificate and credential"
|
||||
},
|
||||
{
|
||||
"name": "importCancel",
|
||||
"value": "Cancel"
|
||||
},
|
||||
{
|
||||
"name": "importConfirm",
|
||||
"value": "Confirm"
|
||||
},
|
||||
{
|
||||
"name": "invalidCertAndCredConfirm",
|
||||
"value": "Close"
|
||||
},
|
||||
{
|
||||
"name": "authenticationTitle",
|
||||
"value": "Please authenticate"
|
||||
},
|
||||
{
|
||||
"name": "certInputPassword",
|
||||
"value": "Enter the certificate password."
|
||||
},
|
||||
{
|
||||
"name": "inputConfirm",
|
||||
"value": "Confirm"
|
||||
},
|
||||
{
|
||||
"name": "setCertName",
|
||||
"value": "Set certificate name"
|
||||
},
|
||||
{
|
||||
"name": "setCertMessage",
|
||||
"value": "The certificate issuer may check all traffic to and from the device, including: CA certificate"
|
||||
},
|
||||
{
|
||||
"name": "Install_Cert_Success",
|
||||
"value": "The certificate is successfully installed."
|
||||
},
|
||||
{
|
||||
"name": "Install_Cred_Success",
|
||||
"value": "Install credentials successfully"
|
||||
},
|
||||
{
|
||||
"name": "Install_Cert_Failed",
|
||||
"value": "Install certificate failure"
|
||||
},
|
||||
{
|
||||
"name": "Install_Cred_Failed",
|
||||
"value": "Install credentials failure"
|
||||
},
|
||||
{
|
||||
"name": "Install_Error_NOT_FOUND",
|
||||
"value": "This file is not recognized."
|
||||
},
|
||||
{
|
||||
"name": "Install_ERROR_INCORRECT_FORMAT",
|
||||
"value": "Certificate corrupted."
|
||||
},
|
||||
{
|
||||
"name": "Install_Error_MAX_QUANTITY_REACHED",
|
||||
"value": "The number of certificates has reached the upper limit, Please clear the certificates."
|
||||
},
|
||||
{
|
||||
"name": "OK",
|
||||
"value": "OK"
|
||||
},
|
||||
{
|
||||
"name": "Password_Message",
|
||||
"value": "Password error"
|
||||
},
|
||||
{
|
||||
"name": "Identity_Authentication",
|
||||
"value": "Please authenticate"
|
||||
},
|
||||
{
|
||||
"name": "inputAliasWarn",
|
||||
"value": "Maximum length reached"
|
||||
},
|
||||
{
|
||||
"name": "system_credentials",
|
||||
"value": "System credentials"
|
||||
},
|
||||
{
|
||||
"name": "cert_install_success",
|
||||
"value": "Installation succeeded"
|
||||
},
|
||||
{
|
||||
"name": "cert_install_failed",
|
||||
"value": "Installation failed"
|
||||
},
|
||||
{
|
||||
"name": "cert_install_tip",
|
||||
"value": "\"%s\" is requesting to install the CA certificate"
|
||||
},
|
||||
{
|
||||
"name": "cert_install_success_tip",
|
||||
"value": "CA certificate installed."
|
||||
},
|
||||
{
|
||||
"name":"cert_install_warning",
|
||||
"value":"Enabling this certificate for a website will allow third parties to view any private data sent to the website."
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "entry_MainAbility",
|
||||
"value": "证书管理"
|
||||
},
|
||||
{
|
||||
"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": "删除所有证书与凭据"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"displayedMode": "list",
|
||||
"mainTitleResource": "$string:certificateTab",
|
||||
"dstAbilityMode": 1,
|
||||
"dstAbilityName": "MainExtensionAbility",
|
||||
"dstBundleName": "com.ohos.certmanager"
|
||||
}
|
||||
@@ -54,10 +54,8 @@
|
||||
<filefilterlist>
|
||||
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for binary file policies">
|
||||
<filteritem type="filepath" name="AppScope/resources/base/media/app_icon.png" desc="self developed image"/>
|
||||
<filteritem type="filepath" name="CertManager/src/main/resources/base/media/icon.png" desc="self developed image"/>
|
||||
<filteritem type="filepath" name="entry/src/ohosTest/resources/base/media/icon.png" desc="self developed image"/>
|
||||
<filteritem type="filepath" name="entry/src/main/resources/base/media/icon.png" desc="self developed image"/>
|
||||
<filteritem type="filepath" name="CertManager/doc/image/image-20220727141455437.png" desc="self developed image"/>
|
||||
<filteritem type="filepath" name="doc/image/20240318-193751.png" desc="self developed image"/>
|
||||
<filteritem type="filepath" name="doc/image/spc-structure.png" desc="self developed image"/>
|
||||
</filefilter>
|
||||
|
||||
@@ -60,18 +60,6 @@
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CertManager",
|
||||
"srcPath": "./CertManager",
|
||||
"targets": [
|
||||
{
|
||||
"name": "default",
|
||||
"applyToProducts": [
|
||||
"default"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||