mirror of
https://gitee.com/openharmony/security_privacy_center
synced 2024-11-27 01:40:23 +00:00
commit
c4e66057ee
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
@ -41,14 +41,14 @@ declare namespace CertManagerFunc {
|
||||
function uninstallUserTrustedCertificate(certUri: string, callback: AsyncCallback<boolean>) : void;
|
||||
function uninstallUserTrustedCertificate(certUri: string) : Promise<boolean>;
|
||||
|
||||
function getUserTrustedCertificateList(callback: AsyncCallback<CMResult>) : void;
|
||||
function getUserTrustedCertificateList() : Promise<CMResult>;
|
||||
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 installAppCertificate(keystore: Uint8Array, keystorePwd: string, certAlias: string, callback: AsyncCallback<CMResult>) : void;
|
||||
function installAppCertificate(keystore: Uint8Array, keystorePwd: string, certAlias: 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>;
|
||||
@ -62,26 +62,26 @@ declare namespace CertManagerFunc {
|
||||
function uninstallAllAppCertificate(callback: AsyncCallback<boolean>) : void;
|
||||
function uninstallAllAppCertificate() : Promise<boolean>;
|
||||
|
||||
function uninstallAppCertificate(keyUri: string, callback: AsyncCallback<boolean>) : void;
|
||||
function uninstallAppCertificate(keyUri: string) : 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 getAppCertificateList(callback: AsyncCallback<CMResult>) : void;
|
||||
function getAppCertificateList() : Promise<CMResult>;
|
||||
function getAllPublicCertificates(callback: AsyncCallback<CMResult>) : void;
|
||||
function getAllPublicCertificates() : Promise<CMResult>;
|
||||
|
||||
function getPrivateCertificateList(callback: AsyncCallback<CMResult>) : void;
|
||||
function getPrivateCertificateList() : Promise<CMResult>;
|
||||
|
||||
function getAppCertificate(keyUri: string, callback: AsyncCallback<CMResult>) : void;
|
||||
function getAppCertificate(keyUri: string, ) : 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 grantAppCertificate(keyUri: string, clientAppUid: string, callback: AsyncCallback<CMResult>) : void;
|
||||
function grantAppCertificate(keyUri: string, clientAppUid: 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>;
|
||||
@ -89,8 +89,8 @@ declare namespace CertManagerFunc {
|
||||
function getAuthorizedAppList(keyUri: string, callback: AsyncCallback<CMResult>) : void;
|
||||
function getAuthorizedAppList(keyUri: string) : Promise<CMResult>;
|
||||
|
||||
function removeGrantedAppCertificate(keyUri: string, clientAppUid: string, callback: AsyncCallback<boolean>) : void;
|
||||
function removeGrantedAppCertificate(keyUri: string, clientAppUid: string) : Promise<boolean>;
|
||||
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>;
|
||||
@ -182,10 +182,12 @@ declare namespace CertManagerFunc {
|
||||
|
||||
export enum CMErrorCode {
|
||||
CM_SUCCESS = 0,
|
||||
CM_ERROR_INNER_ERROR = 17500001,
|
||||
CM_ERROR_NO_PERMISSION = 17500002,
|
||||
CM_ERROR_NO_FOUND = 17500003,
|
||||
CM_ERROR_X509_FORMATE = 17500004,
|
||||
CM_ERROR_GENERIC = 17500001,
|
||||
CM_ERROR_NO_FOUND = 17500002,
|
||||
CM_ERROR_INCORRECT_FORMAT = 17500003,
|
||||
CM_ERROR_CERT_NUM_REACHED_LIMIT = 17500004,
|
||||
CM_ERROR_NO_AUTHORIZATION = 17500005,
|
||||
CM_ERROR_ALIAS_LENGTH_REACHED_LIMIT = 17500006
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
@ -25,6 +25,7 @@ export default class MainAbility extends Ability {
|
||||
GlobalContext.getContext().setCmContext(this.context);
|
||||
GlobalContext.getContext().setPwdStore(pwdStore);
|
||||
GlobalContext.getContext().setAbilityWant(want);
|
||||
GlobalContext.getContext().setFlag(false);
|
||||
}
|
||||
|
||||
onDestroy(): void {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
@ -20,38 +20,39 @@ import { GlobalContext, PwdStore } from '../common/GlobalContext';
|
||||
import UIExtensionAbility from '@ohos.app.ability.UIExtensionAbility';
|
||||
|
||||
export default class MainExtensionAbility extends UIExtensionAbility {
|
||||
onCreate() {
|
||||
onCreate(): void {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'MainExtensionAbility onCreate');
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
onDestroy(): void {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'UIExtensionAbility onDestroy');
|
||||
}
|
||||
|
||||
onSessionCreate(want: Want,session: UIExtensionContentSession) {
|
||||
onSessionCreate(want: Want, session: UIExtensionContentSession): void {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'MainExtensionAbility onSessionCreate');
|
||||
let param: Record<string,Object> = {
|
||||
'session':session
|
||||
let param: Record<string, Object> = {
|
||||
'session': session
|
||||
}
|
||||
let storage: LocalStorage = new LocalStorage(param)
|
||||
session.loadContent('pages/certManagerFa',storage)
|
||||
GlobalContext.getContext().setAbilityWant(want)
|
||||
GlobalContext.getContext().setSession(session)
|
||||
let storage: LocalStorage = new LocalStorage(param);
|
||||
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() {
|
||||
onSessionDestroy(): void {
|
||||
// Main window is destroyed, release UI related resources
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'MainExtensionAbility onSessionDestroy');
|
||||
}
|
||||
|
||||
onForeground() {
|
||||
onForeground(): void {
|
||||
// Ability has brought to foreground
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'MainExtensionAbility onForeground');
|
||||
}
|
||||
|
||||
onBackground() {
|
||||
onBackground(): void {
|
||||
// Ability has back to background
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'MainExtensionAbility onBackground');
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
@ -35,10 +35,11 @@ export class PwdStore {
|
||||
export class GlobalContext {
|
||||
private constructor() {};
|
||||
private static instance: GlobalContext;
|
||||
private session: UIExtensionContentSession;
|
||||
private context: UIAbilityContext;
|
||||
private want: Want;
|
||||
private pwdStore: PwdStore;
|
||||
private context: UIAbilityContext;
|
||||
private session: UIExtensionContentSession;
|
||||
private flag: Boolean;
|
||||
|
||||
public static getContext(): GlobalContext {
|
||||
if (!GlobalContext.instance) {
|
||||
@ -51,14 +52,6 @@ export class GlobalContext {
|
||||
return this.context;
|
||||
}
|
||||
|
||||
setCmContext(context: UIAbilityContext): void {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
getSession(): UIExtensionContentSession {
|
||||
return this.session;
|
||||
}
|
||||
|
||||
getPwdStore(): PwdStore {
|
||||
return this.pwdStore;
|
||||
}
|
||||
@ -67,8 +60,16 @@ export class GlobalContext {
|
||||
return this.want;
|
||||
}
|
||||
|
||||
setSession(session: UIExtensionContentSession): void {
|
||||
this.session = session;
|
||||
getSession(): UIExtensionContentSession {
|
||||
return this.session;
|
||||
}
|
||||
|
||||
getFlag(): Boolean{
|
||||
return this.flag;
|
||||
}
|
||||
|
||||
setCmContext(context: UIAbilityContext): void {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
setPwdStore(pwdStore: PwdStore): void {
|
||||
@ -79,6 +80,14 @@ export class GlobalContext {
|
||||
this.want = want;
|
||||
}
|
||||
|
||||
setSession(session: UIExtensionContentSession): void {
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
setFlag(flag: Boolean): void{
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
clearAbilityWantUri(): void {
|
||||
this.want.uri = '';
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
@ -41,7 +41,11 @@ export default struct HeadComponent {
|
||||
.onClick(() => {
|
||||
let length = Router.getLength();
|
||||
console.log(TAG + 'router length: ' + Number(length));
|
||||
Number(length) == 1 ? GlobalContext.getContext().getCmContext().terminateSelf() : Router.back();
|
||||
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 !== undefined) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
@ -28,6 +28,10 @@ export enum CMModelErrorCode {
|
||||
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
|
||||
}
|
||||
|
||||
export enum CMModelOptType {
|
||||
@ -60,7 +64,7 @@ export class CertMangerModel {
|
||||
});
|
||||
break;
|
||||
case CMModelOptType.CM_MODEL_OPT_USER_CA:
|
||||
this.getUserTrustedCertificateList((errCode: CMModelErrorCode, certList: Array<CertAbstractVo>) => {
|
||||
this.getAllUserTrustedCertificates((errCode: CMModelErrorCode, certList: Array<CertAbstractVo>) => {
|
||||
callback(errCode, certList);
|
||||
});
|
||||
break;
|
||||
@ -69,11 +73,6 @@ export class CertMangerModel {
|
||||
callback(errCode, credList);
|
||||
});
|
||||
break;
|
||||
case CMModelOptType.CM_MODEL_OPT_PRIVATE_CRED:
|
||||
this.getPrivateCredList((errCode: CMModelErrorCode, credList: Array<CredentialAbstractVo>) => {
|
||||
callback(errCode, credList);
|
||||
});
|
||||
break;
|
||||
default:
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_UNKNOWN_OPT, undefined);
|
||||
break;
|
||||
@ -100,11 +99,6 @@ export class CertMangerModel {
|
||||
callback(errCode, credInfo);
|
||||
});
|
||||
break;
|
||||
case CMModelOptType.CM_MODEL_OPT_PRIVATE_CRED:
|
||||
this.getPrivateCred(uri, (errCode: CMModelErrorCode, credInfo: CredentialVo) => {
|
||||
callback(errCode, credInfo);
|
||||
});
|
||||
break;
|
||||
default:
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_UNKNOWN_OPT, undefined);
|
||||
break;
|
||||
@ -255,7 +249,7 @@ export class CertMangerModel {
|
||||
});
|
||||
break;
|
||||
case CMModelOptType.CM_MODEL_OPT_APP_CRED:
|
||||
this.installAppCertificate(data, alias, pwd, (errCode: CMModelErrorCode) => {
|
||||
this.installPublicCertificate(data, alias, pwd, (errCode: CMModelErrorCode) => {
|
||||
callback(errCode);
|
||||
});
|
||||
break;
|
||||
@ -357,15 +351,15 @@ export class CertMangerModel {
|
||||
}
|
||||
}
|
||||
|
||||
private async getUserTrustedCertificateList(callback: Function): Promise<void> {
|
||||
console.log(TAG + 'getUserTrustedCertificateList start');
|
||||
private async getAllUserTrustedCertificates(callback: Function): Promise<void> {
|
||||
console.log(TAG + 'getAllUserTrustedCertificates start');
|
||||
try {
|
||||
let subjectNameCN: string = '';
|
||||
let result = await CertManager.getUserTrustedCertificateList();
|
||||
let result = await CertManager.getAllUserTrustedCertificates();
|
||||
let certList: CertAbstractVo[] = [];
|
||||
let regex: RegExp = new RegExp('(?<=CN=).*?(?=,)', 'g');
|
||||
if (result.certList !== undefined) {
|
||||
console.log(TAG + 'getUserTrustedCertificateList result: ' + JSON.stringify(result));
|
||||
console.log(TAG + 'getAllUserTrustedCertificates result: ' + JSON.stringify(result));
|
||||
for (let i = 0; i < result.certList.length; i++) {
|
||||
if (result.certList[i].subjectName.length !== 0) {
|
||||
let temp = result.certList[i].subjectName.match(regex);
|
||||
@ -377,15 +371,15 @@ export class CertMangerModel {
|
||||
Boolean(result.certList[i].status), String(result.certList[i].subjectName), String(subjectNameCN)));
|
||||
}
|
||||
}
|
||||
console.log(TAG + 'getUserTrustedCertificateList end');
|
||||
console.log(TAG + 'getAllUserTrustedCertificates end');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS, certList);
|
||||
} else {
|
||||
console.error(TAG + 'getUserTrustedCertificateList failed, undefined');
|
||||
console.error(TAG + 'getAllUserTrustedCertificates failed, undefined');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_FAILED, undefined);
|
||||
}
|
||||
} catch (err) {
|
||||
let e: BusinessError = err as BusinessError;
|
||||
console.error(TAG + 'getUserTrustedCertificateList err, message: ' + e.message + ', code: ' + e.code);
|
||||
console.error(TAG + 'getAllUserTrustedCertificates err, message: ' + e.message + ', code: ' + e.code);
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION);
|
||||
}
|
||||
}
|
||||
@ -477,7 +471,7 @@ export class CertMangerModel {
|
||||
console.log(TAG + 'getAppCredList start');
|
||||
|
||||
try {
|
||||
let result = await CertManager.getAppCertificateList();
|
||||
let result = await CertManager.getAllPublicCertificates();
|
||||
let credList: CredentialAbstractVo[] = [];
|
||||
if (result.credentialList !== undefined) {
|
||||
for (let i = 0; i < result.credentialList.length; i++) {
|
||||
@ -500,7 +494,7 @@ export class CertMangerModel {
|
||||
private async getAppCredential(certUri: string, callback: Function): Promise<void> {
|
||||
console.log(TAG + 'getAppCredential start');
|
||||
try {
|
||||
let result = await CertManager.getAppCertificate(certUri);
|
||||
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),
|
||||
@ -522,7 +516,7 @@ export class CertMangerModel {
|
||||
private async deleteAppCredential(certUri: string, callback: Function): Promise<void> {
|
||||
console.log(TAG + 'deleteAppCredential start');
|
||||
try {
|
||||
await CertManager.uninstallAppCertificate(certUri);
|
||||
await CertManager.uninstallPublicCertificate(certUri);
|
||||
console.log(TAG + 'deleteAppCredential end');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS);
|
||||
} catch (err) {
|
||||
@ -532,52 +526,6 @@ export class CertMangerModel {
|
||||
}
|
||||
}
|
||||
|
||||
private async getPrivateCredList(callback: Function): Promise<void> {
|
||||
console.log(TAG + 'getPrivateCredList start');
|
||||
|
||||
try {
|
||||
let result = await CertManager.getPrivateCertificateList();
|
||||
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.log(TAG + 'getPrivateCredList end');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS, credList);
|
||||
} else {
|
||||
console.error(TAG + 'getPrivateCredList failed, undefined');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_FAILED);
|
||||
}
|
||||
} catch (err) {
|
||||
let e: BusinessError = err as BusinessError;
|
||||
console.error(TAG + 'getPrivateCredList failed with err, message: ' + e.message + ', code: ' + e.code);
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
private async getPrivateCred(certUri: string, callback: Function): Promise<void> {
|
||||
console.log(TAG + 'getPrivateCred start');
|
||||
try {
|
||||
let result = await CertManager.getPrivateCertificate(String(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.log(TAG + 'getPrivateCred end');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS, credInfo);
|
||||
} else {
|
||||
console.error(TAG + 'getPrivateCred failed, undefined');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION, undefined);
|
||||
}
|
||||
} catch (err) {
|
||||
let e: BusinessError = err as BusinessError;
|
||||
console.error(TAG + 'getPrivateCred failed with err, message: ' + e.message + ', code: ' + e.code);
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION, undefined);
|
||||
}
|
||||
}
|
||||
|
||||
private async delAllUserCertificate(callback: Function): Promise<void> {
|
||||
console.log(TAG + 'delAllUserCertificate start');
|
||||
try {
|
||||
@ -622,12 +570,12 @@ export class CertMangerModel {
|
||||
console.log(TAG + 'setAuthorizedAppStatus start');
|
||||
try {
|
||||
if (status) {
|
||||
let result = await CertManager.grantAppCertificate(uri, appUid);
|
||||
let result = await CertManager.grantPublicCertificate(uri, appUid);
|
||||
console.log(TAG + 'setAuthorizedAppStatus true end');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS, result.uri);
|
||||
} else {
|
||||
console.log(TAG + 'appId:' + appUid + 'uri:' + uri);
|
||||
await CertManager.removeGrantedAppCertificate(uri, appUid);
|
||||
await CertManager.removeGrantedPublicCertificate(uri, appUid);
|
||||
console.log(TAG + 'setAuthorizedAppStatus false end');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS);
|
||||
}
|
||||
@ -645,26 +593,32 @@ export class CertMangerModel {
|
||||
inData: data,
|
||||
alias: alias
|
||||
});
|
||||
|
||||
console.info(TAG + 'installUserCertificate end');
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS);
|
||||
} catch (err) {
|
||||
let e: BusinessError = err as BusinessError;
|
||||
console.error(TAG + 'installUserCertificate failed with err, message: ' + e.message + ', code: ' + e.code);
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION);
|
||||
if (e.code === CertManager.CMErrorCode.CM_ERROR_INCORRECT_FORMAT) {
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_INCORRECT_FORMAT)
|
||||
} else if (e.code === CertManager.CMErrorCode.CM_ERROR_CERT_NUM_REACHED_LIMIT) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async installAppCertificate(data: Uint8Array, alias: string,
|
||||
private async installPublicCertificate(data: Uint8Array, alias: string,
|
||||
pwd: string, callback: Function): Promise<void> {
|
||||
console.info(TAG + 'installAppCertificate start');
|
||||
console.info(TAG + 'installPublicCertificate start');
|
||||
try {
|
||||
await CertManager.installAppCertificate(data, pwd, alias);
|
||||
console.info(TAG + 'installAppCertificate end');
|
||||
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;
|
||||
console.error(TAG + 'installAppCertificate failed with err, message: ' + e.message + ', code: ' + e.code);
|
||||
console.error(TAG + 'installPublicCertificate failed with err, message: ' + e.message + ', code: ' + e.code);
|
||||
callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
@ -16,11 +16,11 @@
|
||||
import { WidthPercent, LocationChoice, ConfigValue } from '../common/util/ConfigData';
|
||||
import HeadComponent from '../common/component/headComponent';
|
||||
import CmShowAppCredPresenter from '../presenter/CmShowAppCredPresenter';
|
||||
import CMShowPrivateCredPresenter from '../presenter/CmShowPrivateCredPresenter';
|
||||
import CMFaPresenter from '../presenter/CmFaPresenter';
|
||||
import { GlobalContext } from '../common/GlobalContext';
|
||||
import { CredentialAbstractVo } from '../model/CertManagerVo/CredentialAbstractVo';
|
||||
import { AppAuthorVo } from '../model/CertManagerVo/AppAuthorVo';
|
||||
import router from '@ohos.router';
|
||||
|
||||
@Component
|
||||
export struct DialogComponent {
|
||||
@ -68,21 +68,8 @@ struct CustomDialogExampleAuthor {
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
GridContainer({
|
||||
columns: 12,
|
||||
sizeType: SizeType.Auto,
|
||||
gutter: vp2px(1) === 2 ? '12vp' : '0vp',
|
||||
margin: vp2px(1) === 2 ? '24vp' : '0vp'
|
||||
}) {
|
||||
Row({}) {
|
||||
Column() {
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.useSizeType({
|
||||
xs: { span: 0, offset: 0 }, sm: { span: 0, offset: 0 },
|
||||
md: { span: 0, offset: 0 }, lg: { span: 2, offset: 0 }
|
||||
});
|
||||
|
||||
GridRow({ columns: 12, gutter: vp2px(1) === 2 ? '12vp' : '0vp', }) {
|
||||
GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 8 }, offset: { xs: 0, sm: 0, md: 0, lg: 2 } }) {
|
||||
Column() {
|
||||
Text($r('app.string.managerAuthApp'))
|
||||
.height($r('app.float.wh_value_56'))
|
||||
@ -202,148 +189,8 @@ struct CustomDialogExampleAuthor {
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.borderRadius($r('app.float.user_list_divider_borderRadius_value'))
|
||||
.backgroundColor($r('sys.color.ohos_id_color_foreground_contrary'))
|
||||
.useSizeType({
|
||||
xs: { span: 12, offset: 0 }, sm: { span: 12, offset: 0 },
|
||||
md: { span: 12, offset: 0 }, lg: { span: 8, offset: 2 }
|
||||
});
|
||||
|
||||
Column() {
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.useSizeType({
|
||||
xs: { span: 0, offset: 12 }, sm: { span: 0, offset: 12 },
|
||||
md: { span: 0, offset: 12 }, lg: { span: 2, offset: 10 }
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
.margin({
|
||||
bottom: $r('sys.float.ohos_id_dialog_margin_bottom'),
|
||||
left: $r('sys.float.ohos_id_dialog_margin_start'),
|
||||
right: $r('sys.float.ohos_id_dialog_margin_end'),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@CustomDialog
|
||||
@Component
|
||||
struct CustomDialogExamplePrivate {
|
||||
controller?: CustomDialogController;
|
||||
@State priCerInfoPresenter: CMShowPrivateCredPresenter = CMShowPrivateCredPresenter.getInstance();
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
GridContainer({
|
||||
columns: 12,
|
||||
sizeType: SizeType.Auto,
|
||||
gutter: vp2px(1) === 2 ? '12vp' : '0vp',
|
||||
margin: vp2px(1) === 2 ? '24vp' : '0vp'
|
||||
}) {
|
||||
Row({}) {
|
||||
Column() {
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.useSizeType({
|
||||
xs: { span: 0, offset: 0 }, sm: { span: 0, offset: 0 },
|
||||
md: { span: 0, offset: 0 }, lg: { span: 2, offset: 0 }
|
||||
});
|
||||
|
||||
Column() {
|
||||
Text($r('app.string.evidenceDetails'))
|
||||
.height($r('app.float.wh_value_56'))
|
||||
.fontSize($r('sys.float.ohos_id_text_size_dialog_tittle'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.margin({
|
||||
left: $r('app.float.wh_value_24'),
|
||||
right: $r('app.float.wh_value_24')
|
||||
})
|
||||
.alignSelf(ItemAlign.Start)
|
||||
|
||||
Text(this.priCerInfoPresenter.credInfo.alias)
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body1'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.margin({
|
||||
left: $r('app.float.wh_value_24'),
|
||||
right: $r('app.float.wh_value_24')
|
||||
})
|
||||
.alignSelf(ItemAlign.Start)
|
||||
|
||||
Text($r('app.string.entryContains'))
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body2'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary'))
|
||||
.fontWeight(FontWeight.Regular)
|
||||
.margin({
|
||||
top: $r('app.float.wh_value_24'),
|
||||
left: $r('app.float.wh_value_24'),
|
||||
right: $r('app.float.wh_value_24')
|
||||
})
|
||||
.alignSelf(ItemAlign.Start)
|
||||
|
||||
Text($r('app.string.keyNum', String(this.priCerInfoPresenter.credInfo.keyNum)))
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body2'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary'))
|
||||
.fontWeight(FontWeight.Regular)
|
||||
.margin({
|
||||
left: $r('app.float.wh_value_24'),
|
||||
right: $r('app.float.wh_value_24')
|
||||
})
|
||||
.opacity($r('app.float.opacity_100_60'))
|
||||
.alignSelf(ItemAlign.Start)
|
||||
|
||||
Text($r('app.string.userCerNum', String(this.priCerInfoPresenter.credInfo.certNum)))
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body2'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary'))
|
||||
.fontWeight(FontWeight.Regular)
|
||||
.margin({
|
||||
left: $r('app.float.wh_value_24'),
|
||||
right: $r('app.float.wh_value_24')
|
||||
})
|
||||
.opacity($r('app.float.opacity_100_60'))
|
||||
.alignSelf(ItemAlign.Start)
|
||||
|
||||
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center,
|
||||
justifyContent: FlexAlign.SpaceAround }) {
|
||||
Button($r('app.string.privateDetailsClose'))
|
||||
.onClick(() => {
|
||||
if (this.controller !== undefined) {
|
||||
this.controller.close();
|
||||
}
|
||||
})
|
||||
.backgroundColor($r('app.color.credentials_app_finish_backgroundColor'))
|
||||
.fontSize($r('sys.float.ohos_id_text_size_button1'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_hyperlink'))
|
||||
.width($r('app.float.wh_value_152'))
|
||||
.height($r('app.float.wh_value_40'))
|
||||
}
|
||||
.height($r('app.float.wh_value_64'))
|
||||
.padding({
|
||||
bottom: $r('app.float.wh_value_16')
|
||||
})
|
||||
.margin({
|
||||
top: $r('app.float.wh_value_16'),
|
||||
left: $r('app.float.wh_value_24'),
|
||||
right: $r('app.float.wh_value_24')
|
||||
})
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.borderRadius($r('app.float.user_list_divider_borderRadius_value'))
|
||||
.backgroundColor($r('sys.color.ohos_id_color_foreground_contrary'))
|
||||
.useSizeType({
|
||||
xs: { span: 12, offset: 0 }, sm: { span: 12, offset: 0 },
|
||||
md: { span: 12, offset: 0 }, lg: { span: 8, offset: 2 }
|
||||
});
|
||||
|
||||
Column() {
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.useSizeType({
|
||||
xs: { span: 0, offset: 12 }, sm: { span: 0, offset: 12 },
|
||||
md: { span: 0, offset: 12 }, lg: { span: 2, offset: 10 }
|
||||
});
|
||||
}
|
||||
}
|
||||
}.margin(vp2px(1) === 2 ? '24vp' : '0vp')
|
||||
}
|
||||
.margin({
|
||||
bottom: $r('sys.float.ohos_id_dialog_margin_bottom'),
|
||||
@ -362,21 +209,8 @@ struct CustomDialogDeleteWarning {
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
GridContainer({
|
||||
columns: 12,
|
||||
sizeType: SizeType.Auto,
|
||||
gutter: vp2px(1) === 2 ? '12vp' : '0vp',
|
||||
margin: vp2px(1) === 2 ? '24vp' : '0vp'
|
||||
}) {
|
||||
Row({}) {
|
||||
Column() {
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.useSizeType({
|
||||
xs: { span: 0, offset: 0 }, sm: { span: 0, offset: 0 },
|
||||
md: { span: 0, offset: 0 }, lg: { span: 2, offset: 0 }
|
||||
});
|
||||
|
||||
GridRow({ columns: 12, gutter: vp2px(1) === 2 ? '12vp' : '0vp', }) {
|
||||
GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 8 }, offset: { xs: 0, sm: 0, md: 0, lg: 2 } }) {
|
||||
Column() {
|
||||
Text($r('app.string.warning_title'))
|
||||
.height($r('app.float.wh_value_56'))
|
||||
@ -446,20 +280,8 @@ struct CustomDialogDeleteWarning {
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.borderRadius($r('app.float.user_list_divider_borderRadius_value'))
|
||||
.backgroundColor($r('sys.color.ohos_id_color_foreground_contrary'))
|
||||
.useSizeType({
|
||||
xs: { span: 12, offset: 0 }, sm: { span: 12, offset: 0 },
|
||||
md: { span: 12, offset: 0 }, lg: { span: 8, offset: 2 }
|
||||
});
|
||||
|
||||
Column() {
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.useSizeType({
|
||||
xs: { span: 0, offset: 12 }, sm: { span: 0, offset: 12 },
|
||||
md: { span: 0, offset: 12 }, lg: { span: 2, offset: 10 }
|
||||
});
|
||||
}
|
||||
}
|
||||
}.margin(vp2px(1) === 2 ? '24vp' : '0vp')
|
||||
}
|
||||
.margin({
|
||||
bottom: $r('sys.float.ohos_id_dialog_margin_bottom'),
|
||||
@ -483,21 +305,8 @@ struct CustomDialogExampleApp {
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
GridContainer({
|
||||
columns: 12,
|
||||
sizeType: SizeType.Auto,
|
||||
gutter: vp2px(1) === 2 ? '12vp' : '0vp',
|
||||
margin: vp2px(1) === 2 ? '24vp' : '0vp'
|
||||
}) {
|
||||
Row({}) {
|
||||
Column() {
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.useSizeType({
|
||||
xs: { span: 0, offset: 0 }, sm: { span: 0, offset: 0 },
|
||||
md: { span: 0, offset: 0 }, lg: { span: 2, offset: 0 }
|
||||
});
|
||||
|
||||
GridRow({ columns: 12, gutter: vp2px(1) === 2 ? '12vp' : '0vp' }) {
|
||||
GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 8 }, offset: { xs: 0, sm: 0, md: 0, lg: 2 } }) {
|
||||
Column() {
|
||||
Text($r('app.string.evidenceDetails'))
|
||||
.height($r('app.float.wh_value_56'))
|
||||
@ -627,20 +436,8 @@ struct CustomDialogExampleApp {
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.borderRadius($r('app.float.user_list_divider_borderRadius_value'))
|
||||
.backgroundColor($r('sys.color.ohos_id_color_foreground_contrary'))
|
||||
.useSizeType({
|
||||
xs: { span: 12, offset: 0 }, sm: { span: 12, offset: 0 },
|
||||
md: { span: 12, offset: 0 }, lg: { span: 8, offset: 2 }
|
||||
});
|
||||
|
||||
Column() {
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.useSizeType({
|
||||
xs: { span: 0, offset: 12 }, sm: { span: 0, offset: 12 },
|
||||
md: { span: 0, offset: 12 }, lg: { span: 2, offset: 10 }
|
||||
});
|
||||
}
|
||||
}
|
||||
}.margin(vp2px(1) === 2 ? '24vp' : '0vp')
|
||||
}
|
||||
.margin({
|
||||
bottom: $r('sys.float.ohos_id_dialog_margin_bottom'),
|
||||
@ -657,6 +454,7 @@ export struct componentPublic {
|
||||
@Link mShowAppCaPresenter: CmShowAppCredPresenter;
|
||||
@State @Watch('onShowAuthMngChange') isShowAuthMng: boolean = false;
|
||||
@State @Watch('onShowDeleteWarnDialog') isShowWarning: boolean = false;
|
||||
|
||||
detailsDialogController: CustomDialogController = new CustomDialogController({
|
||||
builder: CustomDialogExampleApp({
|
||||
isShowAuthDialog: $isShowAuthMng,
|
||||
@ -664,19 +462,18 @@ export struct componentPublic {
|
||||
mShowAppCaPresenter: $mShowAppCaPresenter
|
||||
}),
|
||||
autoCancel: true,
|
||||
alignment: DialogAlignment.Bottom,
|
||||
customStyle: true,
|
||||
})
|
||||
|
||||
appDialogController: CustomDialogController = new CustomDialogController({
|
||||
builder: CustomDialogExampleAuthor({ isShowAuthDialog: $isShowAuthMng, authorInfo: $mShowAppCaPresenter }),
|
||||
autoCancel: false,
|
||||
alignment: DialogAlignment.Bottom,
|
||||
customStyle: true,
|
||||
})
|
||||
|
||||
deleteWarnDialog: CustomDialogController = new CustomDialogController({
|
||||
builder: CustomDialogDeleteWarning({ isShowWarnDialog: $isShowWarning, deleteWarn: $mShowAppCaPresenter }),
|
||||
autoCancel: false,
|
||||
alignment: DialogAlignment.Bottom,
|
||||
customStyle: true,
|
||||
})
|
||||
|
||||
@ -723,82 +520,20 @@ export struct componentPublic {
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
export struct componentPrivate {
|
||||
private alias: string = '';
|
||||
private keyUri: string = '';
|
||||
@State privateCerPresenter: CMShowPrivateCredPresenter = CMShowPrivateCredPresenter.getInstance();
|
||||
privateDetailDialog: CustomDialogController = new CustomDialogController({
|
||||
builder: CustomDialogExamplePrivate(),
|
||||
autoCancel: true,
|
||||
alignment: DialogAlignment.Bottom,
|
||||
customStyle: true,
|
||||
})
|
||||
|
||||
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'))
|
||||
.onClick(() => {
|
||||
this.privateCerPresenter.getPrivateCred(this.keyUri, () => {
|
||||
this.privateDetailDialog.open();
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct evidenceList {
|
||||
@State mShowAppCaPresenter: CmShowAppCredPresenter = CmShowAppCredPresenter.getInstance();
|
||||
@State mShowPrivateCaPresenter: CMShowPrivateCredPresenter = CMShowPrivateCredPresenter.getInstance();
|
||||
@State mFaPresenter: CMFaPresenter = CMFaPresenter.getInstance();
|
||||
@State isTouched: boolean = false;
|
||||
@State currentIndex: number = 0
|
||||
@State fontColor: Resource = $r('app.color.evidenceList_TabBuilder_fontColor_182431')
|
||||
private controller: TabsController = new TabsController();
|
||||
private publicScroller: Scroller = new Scroller();
|
||||
private privateScroller: Scroller = new Scroller();
|
||||
|
||||
@Builder
|
||||
TabBuilder(index: number) {
|
||||
Column() {
|
||||
Text(index == 0 ? $r('app.string.tabName_public') : $r('app.string.tabName_private'))
|
||||
.fontColor(this.currentIndex === index ? $r('sys.color.ohos_id_color_bottom_tab_icon') : this.fontColor)
|
||||
.fontSize($r('app.float.font_16'))
|
||||
.fontWeight(this.currentIndex === index ? FontWeight.Medium : FontWeight.Regular)
|
||||
.alignSelf(ItemAlign.Center)
|
||||
.margin({
|
||||
top: $r('app.float.TrustedEvidence_TabBuilder_Text_padding_top_value') })
|
||||
if (this.currentIndex === index) {
|
||||
Divider()
|
||||
.width($r('app.float.TrustedEvidence_TabBuilder_Divider_width_value'))
|
||||
.margin({ top: $r('app.float.TrustedEvidence_TabBuilder_Divider_padding_top_value') })
|
||||
.strokeWidth(2)
|
||||
.color($r('sys.color.ohos_id_color_bottom_tab_icon'))
|
||||
.alignSelf(ItemAlign.Center)
|
||||
}
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
}
|
||||
|
||||
aboutToAppear() {
|
||||
console.info('in aboutToAppear');
|
||||
this.mShowAppCaPresenter.updateAppCredListCallback(() => {
|
||||
console.info('get AppCredList first and then get PrivateCredList')
|
||||
this.mShowPrivateCaPresenter.updatePrivateCredList();
|
||||
console.info('get AppCredList first');
|
||||
})
|
||||
}
|
||||
|
||||
@ -807,7 +542,9 @@ struct evidenceList {
|
||||
GlobalContext.getContext().clearAbilityWantUri();
|
||||
|
||||
if (uri === 'certInstall') {
|
||||
this.mFaPresenter.startInstall();
|
||||
router.pushUrl({
|
||||
url: 'pages/certInstallFromStorage'
|
||||
})
|
||||
} else if (uri === 'requestAuthorize') {
|
||||
this.mFaPresenter.startRequestAuth(GlobalContext.getContext().getAbilityWant().parameters?.appUid as string);
|
||||
}
|
||||
@ -815,193 +552,85 @@ struct evidenceList {
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
GridContainer({
|
||||
columns: 12,
|
||||
sizeType: SizeType.Auto,
|
||||
gutter: vp2px(1) === 2 ? '12vp' : '0vp',
|
||||
margin: vp2px(1) === 2 ? '24vp' : '0vp'
|
||||
}) {
|
||||
Row() {
|
||||
Column() {
|
||||
HeadComponent({ headName: $r('app.string.userEvidence') })
|
||||
.margin({
|
||||
left: $r('app.float.wh_value_12')
|
||||
})
|
||||
|
||||
GridRow({ columns: 12, gutter: vp2px(1) === 2 ? '12vp' : '0vp' }) {
|
||||
GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 8 }, offset: { xs: 0, sm: 0, md: 0, lg: 2 } }) {
|
||||
Row() {
|
||||
Column() {
|
||||
Tabs({ barPosition: BarPosition.Start, index: 0, controller: this.controller }) {
|
||||
TabContent() {
|
||||
Stack({ alignContent: Alignment.End }) {
|
||||
Scroll(this.publicScroller) {
|
||||
List() {
|
||||
ForEach(this.mShowAppCaPresenter.credList, (item: CredentialAbstractVo) => {
|
||||
ListItem() {
|
||||
componentPublic({
|
||||
alias: item.alias,
|
||||
keyUri: item.keyUri,
|
||||
mShowAppCaPresenter: $mShowAppCaPresenter
|
||||
})
|
||||
}
|
||||
}, (item: CredentialAbstractVo) => JSON.stringify(item))
|
||||
}
|
||||
.scrollBar(BarState.Off)
|
||||
.padding({
|
||||
right: $r('app.float.wh_value_12'),
|
||||
left: $r('app.float.wh_value_12'),
|
||||
top: $r('app.float.wh_value_4'),
|
||||
bottom: $r('app.float.wh_value_4')
|
||||
})
|
||||
.divider({
|
||||
strokeWidth: $r('app.float.user_list_divider_strokeWidth_value'),
|
||||
color: $r('app.color.user_list_divider_color_000000'),
|
||||
endMargin: '3vp'
|
||||
})
|
||||
.visibility(this.mShowAppCaPresenter.credList.length > 0 ? Visibility.Visible : Visibility.None)
|
||||
}
|
||||
.position({ y: 0 })
|
||||
.scrollable(ScrollDirection.Vertical)
|
||||
.scrollBar(BarState.Off)
|
||||
.margin({
|
||||
left: $r('app.float.wh_value_12'),
|
||||
right: $r('app.float.wh_value_12')
|
||||
})
|
||||
.borderRadius($r('app.float.Evidence_borderRadius'))
|
||||
.backgroundColor($r('app.color.credentials_app_finish_backgroundColor'))
|
||||
HeadComponent({ headName: $r('app.string.userEvidence') })
|
||||
.margin({
|
||||
left: $r('app.float.wh_value_16')
|
||||
})
|
||||
|
||||
ScrollBar({ scroller: this.publicScroller, 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(0.4)
|
||||
Column() {
|
||||
Stack({ alignContent: Alignment.End }) {
|
||||
Scroll(this.publicScroller) {
|
||||
List() {
|
||||
ForEach(this.mShowAppCaPresenter.credList, (item: CredentialAbstractVo) => {
|
||||
ListItem() {
|
||||
componentPublic({
|
||||
alias: item.alias,
|
||||
keyUri: item.keyUri,
|
||||
mShowAppCaPresenter: $mShowAppCaPresenter
|
||||
})
|
||||
}
|
||||
}, (item: CredentialAbstractVo) => JSON.stringify(item))
|
||||
}
|
||||
.width($r('app.float.wh_value_3'))
|
||||
.margin({
|
||||
right: $r('app.float.wh_value_3')
|
||||
.scrollBar(BarState.Off)
|
||||
.padding({
|
||||
right: $r('app.float.wh_value_12'),
|
||||
left: $r('app.float.wh_value_12'),
|
||||
top: $r('app.float.wh_value_4'),
|
||||
bottom: $r('app.float.wh_value_4')
|
||||
})
|
||||
.divider({
|
||||
strokeWidth: $r('app.float.user_list_divider_strokeWidth_value'),
|
||||
color: $r('app.color.user_list_divider_color_000000'),
|
||||
endMargin: '3vp'
|
||||
})
|
||||
.visibility(this.mShowAppCaPresenter.credList.length > 0 ? Visibility.Visible : Visibility.None)
|
||||
}
|
||||
}
|
||||
.tabBar(this.TabBuilder(0))
|
||||
.onTouch((event?: TouchEvent) => {
|
||||
if (event !== undefined) {
|
||||
if (event.type === TouchType.Down) {
|
||||
this.isTouched = true;
|
||||
}
|
||||
if (event.type === TouchType.Up) {
|
||||
this.isTouched = false;
|
||||
}
|
||||
.position({ y: 0 })
|
||||
.scrollable(ScrollDirection.Vertical)
|
||||
.scrollBar(BarState.Off)
|
||||
.margin({
|
||||
left: $r('app.float.wh_value_12'),
|
||||
right: $r('app.float.wh_value_12')
|
||||
})
|
||||
.borderRadius($r('app.float.Evidence_borderRadius'))
|
||||
.backgroundColor($r('app.color.credentials_app_finish_backgroundColor'))
|
||||
|
||||
ScrollBar({ scroller: this.publicScroller, 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(0.4)
|
||||
}
|
||||
.width($r('app.float.wh_value_3'))
|
||||
.margin({
|
||||
right: $r('app.float.wh_value_3')
|
||||
})
|
||||
.visibility(this.mShowAppCaPresenter.credList.length > 0 ? Visibility.Visible : Visibility.None)
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.margin({
|
||||
bottom: $r('app.float.wh_value_24')
|
||||
})
|
||||
|
||||
TabContent() {
|
||||
Stack({ alignContent: Alignment.End }) {
|
||||
Scroll(this.privateScroller) {
|
||||
List() {
|
||||
ForEach(this.mShowPrivateCaPresenter.credList, (item: CredentialAbstractVo) => {
|
||||
ListItem() {
|
||||
componentPrivate({ alias: item.alias, keyUri: item.keyUri })
|
||||
}
|
||||
}, (item: CredentialAbstractVo) => JSON.stringify(item))
|
||||
}
|
||||
.scrollBar(BarState.Off)
|
||||
.padding({
|
||||
right: $r('app.float.wh_value_12'),
|
||||
left: $r('app.float.wh_value_12'),
|
||||
top: $r('app.float.wh_value_4'),
|
||||
bottom: $r('app.float.wh_value_4')
|
||||
})
|
||||
.divider({
|
||||
strokeWidth: $r('app.float.user_list_divider_strokeWidth_value'),
|
||||
color: $r('app.color.user_list_divider_color_000000'),
|
||||
endMargin: '3vp'
|
||||
})
|
||||
.borderRadius($r('app.float.Evidence_borderRadius'))
|
||||
.backgroundColor($r('app.color.credentials_app_finish_backgroundColor'))
|
||||
.visibility(
|
||||
this.mShowPrivateCaPresenter.credList.length > 0 ? Visibility.Visible : Visibility.None)
|
||||
}
|
||||
.position({ y: 0 })
|
||||
.scrollable(ScrollDirection.Vertical)
|
||||
.scrollBar(BarState.Off)
|
||||
.margin({
|
||||
left: $r('app.float.wh_value_12'),
|
||||
right: $r('app.float.wh_value_12')
|
||||
})
|
||||
.borderRadius($r('app.float.Evidence_borderRadius'))
|
||||
.backgroundColor($r('app.color.credentials_app_finish_backgroundColor'))
|
||||
|
||||
ScrollBar({
|
||||
scroller: this.privateScroller,
|
||||
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(0.4)
|
||||
}
|
||||
.width($r('app.float.wh_value_3'))
|
||||
.margin({
|
||||
right: $r('app.float.wh_value_3')
|
||||
})
|
||||
.visibility(
|
||||
this.mShowPrivateCaPresenter.credList.length > 0 ? Visibility.Visible : Visibility.None)
|
||||
}
|
||||
}
|
||||
.tabBar(this.TabBuilder(1))
|
||||
.onTouch((event?: TouchEvent) => {
|
||||
if (event !== undefined) {
|
||||
if (event.type === TouchType.Down) {
|
||||
this.isTouched = true;
|
||||
}
|
||||
if (event.type === TouchType.Up) {
|
||||
this.isTouched = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
.backgroundColor($r('sys.color.ohos_id_color_sub_background'))
|
||||
}
|
||||
.vertical(false)
|
||||
.scrollable(true)
|
||||
.barMode(BarMode.Fixed)
|
||||
.barWidth('192vp')
|
||||
.barHeight($r('app.float.Evidence_barHeight'))
|
||||
.animationDuration(400)
|
||||
.height(WidthPercent.WH_94_100)
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.margin({
|
||||
bottom: $r('app.float.wh_value_24')
|
||||
})
|
||||
.backgroundColor($r('app.color.TrustedEvidence_tabs_backgroundColor_F1F3F5'))
|
||||
.onChange((index: number) => {
|
||||
this.currentIndex = index
|
||||
});
|
||||
}
|
||||
.height(WidthPercent.WH_94_100)
|
||||
.backgroundColor($r('sys.color.ohos_id_color_sub_background'))
|
||||
.width(WidthPercent.WH_100_100)
|
||||
}
|
||||
.backgroundColor($r('sys.color.ohos_id_color_sub_background'))
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(WidthPercent.WH_100_100)
|
||||
.useSizeType({
|
||||
xs: { span: 12, offset: 0 }, sm: { span: 12, offset: 0 },
|
||||
md: { span: 12, offset: 0 }, lg: { span: 8, offset: 2 }
|
||||
});
|
||||
|
||||
Column() {
|
||||
.height(WidthPercent.WH_100_100)
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(WidthPercent.WH_100_100)
|
||||
.useSizeType({
|
||||
xs: { span: 0, offset: 12 }, sm: { span: 0, offset: 12 },
|
||||
md: { span: 0, offset: 12 }, lg: { span: 2, offset: 10 }
|
||||
})
|
||||
.height(WidthPercent.WH_100_100);
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(WidthPercent.WH_100_100);
|
||||
.margin(vp2px(1) === 2 ? '24vp' : '0vp')
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(WidthPercent.WH_100_100);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
@ -33,7 +33,9 @@ struct CertInstallAliasInput {
|
||||
GlobalContext.getContext().clearAbilityWantUri();
|
||||
|
||||
if (uri === 'certInstall') {
|
||||
this.mFaPresenter.startInstall();
|
||||
router.pushUrl({
|
||||
url: 'pages/certInstallFromStorage'
|
||||
})
|
||||
} else if (uri === 'requestAuthorize') {
|
||||
this.mFaPresenter.startRequestAuth(GlobalContext.getContext().getAbilityWant().parameters?.appUid as string);
|
||||
}
|
||||
|
217
CertManager/src/main/ets/pages/certInstallFromStorage.ets
Normal file
217
CertManager/src/main/ets/pages/certInstallFromStorage.ets
Normal file
@ -0,0 +1,217 @@
|
||||
/**
|
||||
* 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 userAuth from '@ohos.userIAM.userAuth';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
import router from '@ohos.router';
|
||||
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct CertificateComponent {
|
||||
@State touchedItem: boolean = false;
|
||||
@State columnMargin: string = '12vp';
|
||||
@State mFaPresenter: CmFaPresenter = CmFaPresenter.getInstance();
|
||||
@State isTouched: boolean = false;
|
||||
@State installCertFlag: boolean = false;
|
||||
@State pageKey: string = '';
|
||||
|
||||
getIdentity() {
|
||||
const authParam: userAuth.AuthParam = {
|
||||
challenge: new Uint8Array([49, 49, 49, 49, 49, 49]),
|
||||
authType: [userAuth.UserAuthType.FINGERPRINT, userAuth.UserAuthType.PIN],
|
||||
authTrustLevel: userAuth.AuthTrustLevel.ATL3
|
||||
}
|
||||
const widgetParam: userAuth.WidgetParam = {
|
||||
title: '请进行身份验证'
|
||||
};
|
||||
let that = this;
|
||||
try {
|
||||
let userAuthInstance = userAuth.getUserAuthInstance(authParam, widgetParam);
|
||||
console.log('get userAuth instance success: ' + userAuthInstance);
|
||||
userAuthInstance.on('result', {
|
||||
onResult(result) {
|
||||
userAuthInstance.off('result');
|
||||
if (result.result === userAuth.UserAuthResultCode.SUCCESS) {
|
||||
if (that.installCertFlag) {
|
||||
that.mFaPresenter.startInstallCert();
|
||||
} else {
|
||||
that.mFaPresenter.startInstallEvidence();
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
userAuthInstance.start();
|
||||
} catch (error) {
|
||||
const err: BusinessError = error as BusinessError;
|
||||
console.log(`auth catch error.code is ${err?.code},message is ${err?.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
checkUserAuth() {
|
||||
try {
|
||||
userAuth.getAvailableStatus(userAuth.UserAuthType.FINGERPRINT, userAuth.AuthTrustLevel.ATL3)
|
||||
this.getIdentity()
|
||||
} catch (error) {
|
||||
const err: BusinessError = error as BusinessError;
|
||||
console.log(`not support.code is ${err.code}, mesage is ${err.message}`);
|
||||
if (err.code === userAuth.UserAuthResultCode.TYPE_NOT_SUPPORT ||
|
||||
err.code === userAuth.UserAuthResultCode.NOT_ENROLLED) {
|
||||
try {
|
||||
userAuth.getAvailableStatus(userAuth.UserAuthType.PIN, userAuth.AuthTrustLevel.ATL3);
|
||||
this.getIdentity();
|
||||
} catch (error) {
|
||||
const err: BusinessError = error as BusinessError;
|
||||
console.log(`not support.code is ${err.code}, mesage is ${err.message}`);
|
||||
if (err.code === userAuth.UserAuthResultCode.NOT_ENROLLED ||
|
||||
err.code === userAuth.UserAuthResultCode.TYPE_NOT_SUPPORT) {
|
||||
if (this.installCertFlag) {
|
||||
this.mFaPresenter.startInstallCert();
|
||||
} else {
|
||||
this.mFaPresenter.startInstallEvidence();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
GridRow({ columns: 12, gutter: vp2px(1) === 2 ? '12vp' : '0vp' }) {
|
||||
GridCol({ span: 12 }) {
|
||||
Row({}) {
|
||||
Column({ space: this.columnMargin }) {
|
||||
HeadComponent({ headName: $r('app.string.installInStorageDevice') })
|
||||
Column({ space: this.columnMargin }) {
|
||||
Column() {
|
||||
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)
|
||||
}
|
||||
}
|
||||
.margin({ top: $r('app.float.wh_value_4') })
|
||||
.height($r('app.float.wh_value_48'))
|
||||
.onClick(() => {
|
||||
AlertDialog.show({
|
||||
title: $r('app.string.root_certificate'),
|
||||
message: $r('app.string.root_certificate_message'),
|
||||
autoCancel: true,
|
||||
alignment:DialogAlignment.Center,
|
||||
offset: { dx: 0, dy: 0},
|
||||
gridCount: 4,
|
||||
primaryButton: {
|
||||
value: $r('app.string.root_certificate_cancel'),
|
||||
action: () => {
|
||||
}
|
||||
},
|
||||
secondaryButton: {
|
||||
value: $r('app.string.root_certificate_continue'),
|
||||
action: () => {
|
||||
this.installCertFlag = true
|
||||
this.checkUserAuth()
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Divider()
|
||||
.strokeWidth(1)
|
||||
.color($r("app.color.sys_list_divider_color_000000"))
|
||||
.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
|
||||
this.checkUserAuth()
|
||||
})
|
||||
}
|
||||
.height($r('app.float.wh_value_48'))
|
||||
}
|
||||
.backgroundColor($r('sys.color.ohos_id_color_card_bg'))
|
||||
.borderRadius($r('app.float.radius_20'))
|
||||
.height(ComponentConfig.WH_100_100)
|
||||
.width(ComponentConfig.WH_100_100)
|
||||
.linearGradient(this.isTouched ? {
|
||||
angle: 90,
|
||||
direction: GradientDirection.Right,
|
||||
colors: [[$r("app.color.DCEAF9"), 0.0], [$r("app.color.FAFAFA"), 1.0]]
|
||||
} : {
|
||||
angle: 90,
|
||||
direction: GradientDirection.Right,
|
||||
colors: [
|
||||
[$r("sys.color.ohos_id_color_foreground_contrary"), 1],
|
||||
[$r("sys.color.ohos_id_color_foreground_contrary"), 1]
|
||||
]
|
||||
})
|
||||
}
|
||||
.height($r('app.float.wh_value_104'))
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
}
|
||||
.backgroundColor($r("sys.color.ohos_id_color_sub_background"))
|
||||
.padding({ left: $r('app.float.wh_value_16'), right: $r('app.float.wh_value_16') })
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(WidthPercent.WH_100_100)
|
||||
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(WidthPercent.WH_100_100);
|
||||
}
|
||||
}
|
||||
.margin(vp2px(1) === 2 ? '24vp' : '0vp')
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(WidthPercent.WH_100_100);
|
||||
}
|
||||
.backgroundColor($r("sys.color.ohos_id_color_sub_background"))
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(WidthPercent.WH_100_100);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
@ -13,11 +13,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { WidthPercent, LocationChoice, ConfigValue } from '../common/util/ConfigData';
|
||||
import { WidthPercent, ConfigValue } 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';
|
||||
|
||||
const DISPLAY_DURATION: number = 2000;
|
||||
|
||||
class CertListItem {
|
||||
public targetPage: string = '';
|
||||
@ -37,22 +41,8 @@ struct CertificateComponent {
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
GridContainer({
|
||||
columns: 12,
|
||||
sizeType: SizeType.Auto,
|
||||
gutter: vp2px(1) === 2 ? '12vp' : '0vp',
|
||||
margin: vp2px(1) === 2 ? '24vp' : '0vp'
|
||||
}) {
|
||||
Row({}) {
|
||||
Column() {
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(WidthPercent.WH_100_100)
|
||||
.useSizeType({
|
||||
xs: { span: 0, offset: 0 }, sm: { span: 0, offset: 0 },
|
||||
md: { span: 0, offset: 0 }, lg: { span: 2, offset: 0 }
|
||||
});
|
||||
|
||||
GridRow({ columns: 12, gutter: vp2px(1) === 2 ? '12vp' : '0vp' }) {
|
||||
GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 8 }, offset: { xs: 0, sm: 0, md: 0, lg: 2 } }) {
|
||||
Column({ space: this.columnMargin }) {
|
||||
HeadComponent({ headName: $r('app.string.certificateTab') })
|
||||
Column({ space: this.columnMargin }) {
|
||||
@ -67,8 +57,8 @@ struct CertificateComponent {
|
||||
.divider({
|
||||
strokeWidth: $r('app.float.sys_list_divider_strokeWidth_value'),
|
||||
color: $r('app.color.sys_list_divider_color_000000'),
|
||||
startMargin: '8vp',
|
||||
endMargin: '8vp'
|
||||
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('app.color.user_list_backgroundColor_FFFFFF'))
|
||||
@ -83,23 +73,9 @@ struct CertificateComponent {
|
||||
.padding({ left: $r('app.float.wh_value_12'), right: $r('app.float.wh_value_12') })
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(WidthPercent.WH_100_100)
|
||||
.useSizeType({
|
||||
xs: { span: 12, offset: 0 }, sm: { span: 12, offset: 0 },
|
||||
md: { span: 12, offset: 0 }, lg: { span: 8, offset: 2 }
|
||||
});
|
||||
|
||||
Column() {
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(WidthPercent.WH_100_100)
|
||||
.useSizeType({
|
||||
xs: { span: 0, offset: 12 }, sm: { span: 0, offset: 12 },
|
||||
md: { span: 0, offset: 12 }, lg: { span: 2, offset: 10 }
|
||||
})
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(WidthPercent.WH_100_100);
|
||||
}
|
||||
.margin(vp2px(1) === 2 ? '24vp' : '0vp')
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.height(WidthPercent.WH_100_100);
|
||||
}
|
||||
@ -113,7 +89,9 @@ struct CertificateComponent {
|
||||
GlobalContext.getContext().clearAbilityWantUri();
|
||||
|
||||
if (uri === 'certInstall') {
|
||||
this.mFaPresenter.startInstall();
|
||||
router.pushUrl({
|
||||
url: 'pages/certInstallFromStorage'
|
||||
})
|
||||
} else if (uri === 'requestAuthorize') {
|
||||
this.mFaPresenter.startRequestAuth(GlobalContext.getContext().getAbilityWant().parameters?.appUid as string);
|
||||
}
|
||||
@ -128,21 +106,8 @@ struct CustomDialogExampleDeleteAll {
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
GridContainer({
|
||||
columns: 12,
|
||||
sizeType: SizeType.Auto,
|
||||
gutter: vp2px(1) === 2 ? '12vp' : '0vp',
|
||||
margin: vp2px(1) === 2 ? '24vp' : '0vp'
|
||||
}) {
|
||||
Row({}) {
|
||||
Column() {
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.useSizeType({
|
||||
xs: { span: 0, offset: 0 }, sm: { span: 0, offset: 0 },
|
||||
md: { span: 0, offset: 0 }, lg: { span: 2, offset: 0 }
|
||||
});
|
||||
|
||||
GridRow({ columns: 12, gutter: vp2px(1) === 2 ? '12vp' : '0vp', }) {
|
||||
GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 8 }, offset: { xs: 0, sm: 0, md: 0, lg: 2 } }) {
|
||||
Column() {
|
||||
Text($r('app.string.deleteAllCredDialogTitle'))
|
||||
.height($r('app.float.wh_value_56'))
|
||||
@ -189,6 +154,10 @@ struct CustomDialogExampleDeleteAll {
|
||||
this.deleteAll.uninstallAllCert();
|
||||
if (this.controller !== undefined) {
|
||||
this.controller.close()
|
||||
promptAction.showToast({
|
||||
message: $r('app.string.delete_success'),
|
||||
duration: DISPLAY_DURATION,
|
||||
})
|
||||
}
|
||||
})
|
||||
.backgroundColor($r('app.color.credentials_app_finish_backgroundColor'))
|
||||
@ -210,18 +179,6 @@ struct CustomDialogExampleDeleteAll {
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.borderRadius($r('app.float.user_list_divider_borderRadius_value'))
|
||||
.backgroundColor($r('sys.color.ohos_id_color_foreground_contrary'))
|
||||
.useSizeType({
|
||||
xs: { span: 12, offset: 0 }, sm: { span: 12, offset: 0 },
|
||||
md: { span: 12, offset: 0 }, lg: { span: 8, offset: 2 }
|
||||
});
|
||||
|
||||
Column() {
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.useSizeType({
|
||||
xs: { span: 0, offset: 12 }, sm: { span: 0, offset: 12 },
|
||||
md: { span: 0, offset: 12 }, lg: { span: 2, offset: 10 }
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -341,7 +298,9 @@ export struct CertInstallComponent {
|
||||
.height($r('app.float.wh_value_56'))
|
||||
.borderRadius($r('app.float.radius_24'))
|
||||
.onClick(() => {
|
||||
this.mFaPresenter.startInstall()
|
||||
router.pushUrl({
|
||||
url: 'pages/certInstallFromStorage'
|
||||
}, router.RouterMode.Standard)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
@ -18,6 +18,7 @@ import { WidthPercent, LocationChoice, ConfigValue } from '../common/util/Config
|
||||
import router from '@ohos.router';
|
||||
import CmFaPresenter from '../presenter/CmFaPresenter';
|
||||
import { GlobalContext } from '../common/GlobalContext';
|
||||
import { RouterFileVo } from '../model/CertManagerVo/RouterInfoVo';
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
@ -30,7 +31,9 @@ struct CertPwdInput {
|
||||
GlobalContext.getContext().clearAbilityWantUri();
|
||||
|
||||
if (uri === 'certInstall') {
|
||||
this.mFaPresenter.startInstall();
|
||||
router.pushUrl({
|
||||
url: 'pages/certInstallFromStorage'
|
||||
})
|
||||
} else if (uri === 'requestAuthorize') {
|
||||
this.mFaPresenter.startRequestAuth(GlobalContext.getContext().getAbilityWant().parameters?.appUid as string);
|
||||
}
|
||||
@ -101,9 +104,10 @@ struct CertPwdInput {
|
||||
})
|
||||
.onClick(() => {
|
||||
GlobalContext.getContext().getPwdStore().setCertPwd(this.certPwd)
|
||||
let fileInfo: RouterFileVo = router.getParams() as RouterFileVo;
|
||||
router.pushUrl({
|
||||
url: 'pages/certInstallAliasInput',
|
||||
params: router.getParams()
|
||||
params: fileInfo
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
@ -15,7 +15,7 @@
|
||||
|
||||
import CmAppCredAuthPresenter from '../presenter/CmAppCredAuthPresenter';
|
||||
import router from '@ohos.router';
|
||||
import { WidthPercent, LocationChoice, ConfigValue } from '../common/util/ConfigData';
|
||||
import { WidthPercent, ConfigValue } from '../common/util/ConfigData';
|
||||
import { CredentialAbstractVo } from '../model/CertManagerVo/CredentialAbstractVo';
|
||||
import { RouterAppUidVo } from '../model/CertManagerVo/RouterInfoVo';
|
||||
|
||||
@ -36,241 +36,219 @@ struct CustomDialogAuthForApp {
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
GridContainer({
|
||||
columns: 12,
|
||||
sizeType: SizeType.Auto,
|
||||
gutter: vp2px(1) === 2 ? '12vp' : '0vp',
|
||||
margin: vp2px(1) === 2 ? '24vp' : '0vp'
|
||||
}) {
|
||||
Row({}) {
|
||||
Column() {
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.useSizeType({
|
||||
xs: { span: 0, offset: 0 }, sm: { span: 0, offset: 0 },
|
||||
md: { span: 0, offset: 0 }, lg: { span: 2, offset: 0 }
|
||||
});
|
||||
|
||||
Column() {
|
||||
Text($r('app.string.pickCredToAuth'))
|
||||
.fontSize($r('sys.float.ohos_id_text_size_dialog_tittle'))
|
||||
.height($r('app.float.wh_value_56'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.margin({
|
||||
left: $r('app.float.wh_value_24'),
|
||||
right: $r('app.float.wh_value_24')
|
||||
})
|
||||
.alignSelf(ItemAlign.Start)
|
||||
|
||||
Text($r('app.string.requestAuthMsg', this.mAppCredAuthPresenter.appName))
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body1'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary'))
|
||||
.fontWeight(FontWeight.Regular)
|
||||
.margin({
|
||||
top: $r('app.float.wh_value_8'),
|
||||
left: $r('app.float.wh_value_24'),
|
||||
right: $r('app.float.wh_value_24')
|
||||
})
|
||||
.alignSelf(ItemAlign.Start)
|
||||
|
||||
if (this.mAppCredAuthPresenter.credList.length > ConfigValue.REQUEST_AUTH_MAX_LENGTH) {
|
||||
Stack({ alignContent: Alignment.End }) {
|
||||
Scroll(this.authScroller) {
|
||||
List() {
|
||||
ForEach(this.mAppCredAuthPresenter.credList, (item: CredentialAbstractVo) => {
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
|
||||
|
||||
Column() {
|
||||
Text(item.alias)
|
||||
.fontSize($r('app.float.font_18'))
|
||||
.fontColor($r('app.color.request_auth_font_color'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.textAlign(TextAlign.Start);
|
||||
}
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
|
||||
Column() {
|
||||
Radio({ value: item.alias, group: 'appCredGroup' })
|
||||
.checked(false)
|
||||
.onChange((value: boolean) => {
|
||||
console.log(item.alias + ' status is ' + value)
|
||||
if (value) {
|
||||
this.selectUri = item.keyUri;
|
||||
console.log('selectUri is ' + this.selectUri)
|
||||
}
|
||||
})
|
||||
}
|
||||
.alignItems(HorizontalAlign.End)
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
}
|
||||
.height($r('app.float.wh_value_64'))
|
||||
}, (item: CredentialAbstractVo) => JSON.stringify(item))
|
||||
}
|
||||
.scrollBar(BarState.Off)
|
||||
.divider({
|
||||
strokeWidth: $r('app.float.request_auth_strokeWidth'),
|
||||
color: $r('app.color.request_auth_color'),
|
||||
endMargin: $r('app.float.request_auth_divider_endMargin') })
|
||||
.backgroundColor($r('app.color.request_auth_background_color'))
|
||||
.visibility(this.mAppCredAuthPresenter.credList.length > 0 ? Visibility.Visible : Visibility.None)
|
||||
}
|
||||
.scrollBar(BarState.Off)
|
||||
GridRow({ columns: 12, gutter: vp2px(1) === 2 ? '12vp' : '0vp' }) {
|
||||
GridCol({ span: { xs: 12, sm: 12, md: 12, lg: 8 }, offset: { xs: 0, sm: 0, md: 0, lg: 2 } }) {
|
||||
Row({}) {
|
||||
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)
|
||||
|
||||
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(0.4)
|
||||
}
|
||||
.width($r('app.float.wh_value_3'))
|
||||
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({
|
||||
right: $r('app.float.wh_value_3')
|
||||
top: $r('app.float.wh_value_8'),
|
||||
left: $r('app.float.wh_value_24'),
|
||||
right: $r('app.float.wh_value_24')
|
||||
})
|
||||
}
|
||||
.height(WidthPercent.WH_50_100)
|
||||
} else {
|
||||
List() {
|
||||
ForEach(this.mAppCredAuthPresenter.credList, (item: CredentialAbstractVo) => {
|
||||
.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) => {
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
|
||||
|
||||
Column() {
|
||||
Text(item.alias)
|
||||
.fontSize($r('app.float.font_18'))
|
||||
.fontColor($r('app.color.request_auth_font_color'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.textAlign(TextAlign.Start);
|
||||
}
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
|
||||
Column() {
|
||||
Radio({ value: item.alias, group: 'appCredGroup' })
|
||||
.checked(false)
|
||||
.onChange((value: boolean) => {
|
||||
console.log(item.alias + ' status is ' + value)
|
||||
if (value) {
|
||||
this.selectUri = item.keyUri;
|
||||
console.log('selectUri is ' + this.selectUri)
|
||||
}
|
||||
})
|
||||
}
|
||||
.alignItems(HorizontalAlign.End)
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
}
|
||||
.height($r('app.float.wh_value_64'))
|
||||
}, (item: CredentialAbstractVo) => JSON.stringify(item))
|
||||
}
|
||||
.scrollBar(BarState.Off)
|
||||
.divider({
|
||||
strokeWidth: $r('app.float.request_auth_strokeWidth'),
|
||||
color: $r('app.color.request_auth_color'),
|
||||
endMargin: $r('app.float.request_auth_divider_endMargin') })
|
||||
.backgroundColor($r('app.color.request_auth_background_color'))
|
||||
.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(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) => {
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
|
||||
Column() {
|
||||
Text(item.alias)
|
||||
.fontSize($r('app.float.font_18'))
|
||||
.fontColor($r('app.color.request_auth_font_color'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.textAlign(TextAlign.Start);
|
||||
}
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
|
||||
Column() {
|
||||
Radio({ value: item.alias, group: 'appCredGroup' })
|
||||
.checked(false)
|
||||
.onChange((value: boolean) => {
|
||||
console.log(item.alias + ' status is ' + value)
|
||||
if (value) {
|
||||
this.selectUri = item.keyUri;
|
||||
console.log('selectUri is ' + this.selectUri)
|
||||
}
|
||||
})
|
||||
}
|
||||
.alignItems(HorizontalAlign.End)
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
}
|
||||
.height($r('app.float.wh_value_64'))
|
||||
}, (item: CredentialAbstractVo) => JSON.stringify(item))
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
|
||||
Column() {
|
||||
Text(item.alias)
|
||||
.fontSize($r('app.float.font_18'))
|
||||
.fontColor($r('app.color.request_auth_font_color'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.textAlign(TextAlign.Start);
|
||||
Text()
|
||||
}
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
|
||||
Column() {
|
||||
Radio({ value: item.alias, group: 'appCredGroup' })
|
||||
Radio({ value: 'null', group: 'appCredGroup' })
|
||||
.checked(false)
|
||||
.onChange((value: boolean) => {
|
||||
console.log(item.alias + ' status is ' + value)
|
||||
if (value) {
|
||||
this.selectUri = item.keyUri;
|
||||
this.selectUri = 'null';
|
||||
console.log('selectUri is ' + this.selectUri)
|
||||
}
|
||||
})
|
||||
}
|
||||
.alignItems(HorizontalAlign.End)
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.visibility(Visibility.None)
|
||||
}
|
||||
.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';
|
||||
console.log('selectUri is ' + this.selectUri)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
.visibility(Visibility.None)
|
||||
}
|
||||
.margin({
|
||||
left: $r('app.float.wh_value_24'),
|
||||
right: $r('app.float.wh_value_24')
|
||||
})
|
||||
.scrollBar(BarState.Off)
|
||||
.divider({
|
||||
strokeWidth: $r('app.float.request_auth_strokeWidth'),
|
||||
color: $r('app.color.request_auth_color'),
|
||||
endMargin: $r('app.float.request_auth_divider_endMargin') })
|
||||
.backgroundColor($r('app.color.request_auth_background_color'))
|
||||
.visibility(this.mAppCredAuthPresenter.credList.length > 0 ? Visibility.Visible : Visibility.None)
|
||||
}
|
||||
|
||||
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center,
|
||||
justifyContent: FlexAlign.SpaceAround }) {
|
||||
Button($r('app.string.requestAuthCancel'))
|
||||
.onClick(() => {
|
||||
this.mAppCredAuthPresenter.cancelProcess();
|
||||
if (this.controller !== undefined) {
|
||||
this.controller.close();
|
||||
}
|
||||
})
|
||||
.backgroundColor($r('app.color.request_auth_background_color'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_hyperlink'))
|
||||
.fontSize($r('sys.float.ohos_id_text_size_button1'))
|
||||
.width($r('app.float.wh_value_152'))
|
||||
.height($r('app.float.wh_value_40'))
|
||||
|
||||
Divider()
|
||||
.strokeWidth(ConfigValue.VERTICAL_DIVIDER_WIDTH)
|
||||
.color($r('sys.color.ohos_id_color_list_separator'))
|
||||
.vertical(true)
|
||||
.height($r('app.float.wh_value_40'))
|
||||
.opacity($r('app.float.opacity_0_2'))
|
||||
|
||||
Button($r('app.string.requestAuthFinish'))
|
||||
.onClick(() => {
|
||||
console.info('requestAuthorize uri: ' + this.selectUri);
|
||||
let appUidInfo: RouterAppUidVo = router.getParams() as RouterAppUidVo;
|
||||
if (appUidInfo !== undefined && appUidInfo.appUid != undefined) {
|
||||
console.info('requestAuthorize appUid: ' + appUidInfo.appUid);
|
||||
this.mAppCredAuthPresenter.requestAuthorize(this.selectUri, appUidInfo.appUid);
|
||||
if (this.controller !== undefined) {
|
||||
this.controller.close();
|
||||
}
|
||||
} else {
|
||||
console.info('requestAuthorize fail');
|
||||
}
|
||||
})
|
||||
.backgroundColor($r('app.color.request_auth_background_color'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_hyperlink'))
|
||||
.fontSize($r('sys.float.ohos_id_text_size_button1'))
|
||||
.width($r('app.float.wh_value_152'))
|
||||
.height($r('app.float.wh_value_40'))
|
||||
}
|
||||
.height($r('app.float.wh_value_64'))
|
||||
.padding({
|
||||
bottom: $r('app.float.wh_value_16')
|
||||
})
|
||||
.margin({
|
||||
left: $r('app.float.wh_value_24'),
|
||||
right: $r('app.float.wh_value_24')
|
||||
})
|
||||
.scrollBar(BarState.Off)
|
||||
.divider({
|
||||
strokeWidth: $r('app.float.request_auth_strokeWidth'),
|
||||
color: $r('app.color.request_auth_color'),
|
||||
endMargin: $r('app.float.request_auth_divider_endMargin') })
|
||||
.backgroundColor($r('app.color.request_auth_background_color'))
|
||||
.visibility(this.mAppCredAuthPresenter.credList.length > 0 ? Visibility.Visible : Visibility.None)
|
||||
}
|
||||
|
||||
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center,
|
||||
justifyContent: FlexAlign.SpaceAround }) {
|
||||
Button($r('app.string.requestAuthCancel'))
|
||||
.onClick(() => {
|
||||
this.mAppCredAuthPresenter.cancelProcess();
|
||||
if (this.controller !== undefined) {
|
||||
this.controller.close();
|
||||
}
|
||||
})
|
||||
.backgroundColor($r('app.color.request_auth_background_color'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_hyperlink'))
|
||||
.fontSize($r('sys.float.ohos_id_text_size_button1'))
|
||||
.width($r('app.float.wh_value_152'))
|
||||
.height($r('app.float.wh_value_40'))
|
||||
|
||||
Divider()
|
||||
.strokeWidth(ConfigValue.VERTICAL_DIVIDER_WIDTH)
|
||||
.color($r('sys.color.ohos_id_color_list_separator'))
|
||||
.vertical(true)
|
||||
.height($r('app.float.wh_value_40'))
|
||||
.opacity($r('app.float.opacity_0_2'))
|
||||
|
||||
Button($r('app.string.requestAuthFinish'))
|
||||
.onClick(() => {
|
||||
console.info('requestAuthorize uri: ' + this.selectUri);
|
||||
let appUidInfo: RouterAppUidVo = router.getParams() as RouterAppUidVo;
|
||||
if (appUidInfo !== undefined && appUidInfo.appUid != undefined) {
|
||||
console.info('requestAuthorize appUid: ' + appUidInfo.appUid);
|
||||
this.mAppCredAuthPresenter.requestAuthorize(this.selectUri, appUidInfo.appUid);
|
||||
if (this.controller !== undefined) {
|
||||
this.controller.close();
|
||||
}
|
||||
} else {
|
||||
console.info('requestAuthorize fail');
|
||||
}
|
||||
})
|
||||
.backgroundColor($r('app.color.request_auth_background_color'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_hyperlink'))
|
||||
.fontSize($r('sys.float.ohos_id_text_size_button1'))
|
||||
.width($r('app.float.wh_value_152'))
|
||||
.height($r('app.float.wh_value_40'))
|
||||
}
|
||||
.height($r('app.float.wh_value_64'))
|
||||
.padding({
|
||||
bottom: $r('app.float.wh_value_16')
|
||||
})
|
||||
.margin({
|
||||
left: $r('app.float.wh_value_24'),
|
||||
right: $r('app.float.wh_value_24')
|
||||
})
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.borderRadius($r('app.float.user_list_divider_borderRadius_value'))
|
||||
.backgroundColor($r('sys.color.ohos_id_color_foreground_contrary'))
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.borderRadius($r('app.float.user_list_divider_borderRadius_value'))
|
||||
.backgroundColor($r('sys.color.ohos_id_color_foreground_contrary'))
|
||||
.useSizeType({
|
||||
xs: { span: 12, offset: 0 }, sm: { span: 12, offset: 0 },
|
||||
md: { span: 12, offset: 0 }, lg: { span: 8, offset: 2 }
|
||||
});
|
||||
|
||||
Column() {
|
||||
}
|
||||
.width(WidthPercent.WH_100_100)
|
||||
.useSizeType({
|
||||
xs: { span: 0, offset: 12 }, sm: { span: 0, offset: 12 },
|
||||
md: { span: 0, offset: 12 }, lg: { span: 2, offset: 10 }
|
||||
});
|
||||
}
|
||||
}
|
||||
.margin(vp2px(1) === 2 ? '24vp' : '0vp')
|
||||
}
|
||||
.margin({
|
||||
bottom: $r('sys.float.ohos_id_dialog_margin_bottom'),
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
@ -42,35 +42,96 @@ export default class CmFaPresenter {
|
||||
aboutToDisappear(): void {
|
||||
}
|
||||
|
||||
routeToNext(fileUri: string): void {
|
||||
console.info(TAG + 'routeToNext fileUri: ' + fileUri);
|
||||
routeToNextInstallCert(fileUri: string): void {
|
||||
console.log(TAG, 'routeToNext fileUri ' + fileUri);
|
||||
FileIoModel.getMediaFileSuffix(fileUri, (suffix: string | undefined) => {
|
||||
console.info(TAG + 'suffix ' + suffix);
|
||||
if (suffix !== undefined) {
|
||||
console.log(TAG, 'suffix = ', suffix);
|
||||
let fileInfo = new RouterFileVo(fileUri, suffix);
|
||||
if ((suffix === 'cer') || (suffix === 'pem')) {
|
||||
router.pushUrl({
|
||||
url: PAGE_URI_ALIAS_INPUT,
|
||||
router.replaceUrl({
|
||||
url: 'pages/certInstallAliasInput',
|
||||
params: fileInfo
|
||||
});
|
||||
})
|
||||
} else {
|
||||
router.pushUrl({
|
||||
url: PAGE_URI_PWD_INPUT,
|
||||
params: fileInfo
|
||||
});
|
||||
AlertDialog.show({
|
||||
message: $r('app.string.Install_Error_NOT_FOUND'),
|
||||
autoCancel: true,
|
||||
alignment: DialogAlignment.Bottom,
|
||||
offset: {
|
||||
dx: 0, dy: 0
|
||||
},
|
||||
gridCount: 4,
|
||||
primaryButton: {
|
||||
value: $r('app.string.OK'),
|
||||
action: () => {
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
startInstall(): void {
|
||||
routeToNextInstallEvidence(fileUri: string): void {
|
||||
console.log(TAG, 'routeToNext fileUri ' + fileUri);
|
||||
FileIoModel.getMediaFileSuffix(fileUri, (suffix: string | undefined) => {
|
||||
if (suffix !== undefined) {
|
||||
console.log(TAG, 'suffix = ', suffix);
|
||||
if ((suffix === 'p12') || (suffix === 'pfx')) {
|
||||
let fileInfo = new RouterFileVo(fileUri, suffix);
|
||||
router.replaceUrl({
|
||||
url: 'pages/certPwdInput',
|
||||
params: fileInfo
|
||||
})
|
||||
} else {
|
||||
AlertDialog.show({
|
||||
message: $r('app.string.Install_Error_NOT_FOUND'),
|
||||
autoCancel: true,
|
||||
alignment: DialogAlignment.Bottom,
|
||||
offset: {
|
||||
dx: 0, dy: -20
|
||||
},
|
||||
gridCount: 4,
|
||||
primaryButton: {
|
||||
value: $r('app.string.OK'),
|
||||
action: () => {
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
startInstallCert(): void {
|
||||
try {
|
||||
let documentSelectOptions = new picker.DocumentSelectOptions();
|
||||
let documentPicker = new picker.DocumentViewPicker();
|
||||
console.info(TAG + 'start documentPicker.select');
|
||||
documentPicker.select(documentSelectOptions).then((documentSelectResult) => {
|
||||
if (documentSelectResult.length >= 1) {
|
||||
this.routeToNext(String(documentSelectResult[0]));
|
||||
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(): void {
|
||||
try {
|
||||
let documentSelectOptions = new picker.DocumentSelectOptions();
|
||||
let documentPicker = new picker.DocumentViewPicker();
|
||||
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);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
@ -18,6 +18,8 @@ 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: ';
|
||||
|
||||
@ -53,7 +55,6 @@ export default class CmInstallPresenter {
|
||||
FileIoModel.getMediaFileData(uri, (data: Uint8Array) => {
|
||||
callback(data);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
installCert(uri: string, alias: string, suffix: string): void {
|
||||
@ -61,16 +62,70 @@ export default class CmInstallPresenter {
|
||||
this.getFileDataFromUri(uri, (data: Uint8Array) => {
|
||||
certManagerModel.installCertOrCred(this.optType, alias, data,
|
||||
GlobalContext.getContext().getPwdStore().getCertPwd(), (errCode: CMModelErrorCode) => {
|
||||
console.info(TAG + 'installCertOrCred result: ' + JSON.stringify(errCode));
|
||||
GlobalContext.getContext().getPwdStore().clearCertPwd();
|
||||
if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) {
|
||||
console.info(TAG + 'installCert success');
|
||||
} else {
|
||||
console.error(TAG + 'installCert failed');
|
||||
}
|
||||
router.clear();
|
||||
router.replaceUrl({ url: 'pages/certManagerFa' });
|
||||
});
|
||||
console.info(TAG + 'installCertOrCred result: ' + JSON.stringify(errCode));
|
||||
GlobalContext.getContext().getPwdStore().clearCertPwd();
|
||||
if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) {
|
||||
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: 2000,
|
||||
bottom: 100
|
||||
})
|
||||
} catch (err) {
|
||||
let e: BusinessError = err as BusinessError;
|
||||
console.error(TAG, 'show result failed, message: ' + e.message + ', code: ' + e.code)
|
||||
}
|
||||
} else if (errCode === CMModelErrorCode.CM_MODEL_ERROR_INCORRECT_FORMAT) {
|
||||
AlertDialog.show({
|
||||
message: $r('app.string.Install_ERROR_INCORRECT_FORMAT'),
|
||||
autoCancel: true,
|
||||
alignment: DialogAlignment.Bottom,
|
||||
offset: {
|
||||
dx: 0, dy: 0
|
||||
},
|
||||
gridCount: 4,
|
||||
primaryButton: {
|
||||
value: $r('app.string.OK'),
|
||||
action: () => {
|
||||
router.back()
|
||||
}
|
||||
},
|
||||
})
|
||||
} else if (errCode === CMModelErrorCode.CM_MODEL_ERROR_MAX_QUANTITY_REACHED) {
|
||||
AlertDialog.show({
|
||||
message: $r('app.string.Install_Error_MAX_QUANTITY_REACHED'),
|
||||
autoCancel: true,
|
||||
alignment: DialogAlignment.Bottom,
|
||||
offset: {
|
||||
dx: 0, dy: 0
|
||||
},
|
||||
gridCount: 4,
|
||||
primaryButton: {
|
||||
value: $r('app.string.OK'),
|
||||
action: () => {
|
||||
router.back()
|
||||
}
|
||||
},
|
||||
})
|
||||
} else {
|
||||
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: 2000,
|
||||
bottom: 100
|
||||
})
|
||||
} catch (err) {
|
||||
let e: BusinessError = err as BusinessError;
|
||||
console.error(TAG, 'show result failed, message: ' + e.message + ', code: ' + e.code)
|
||||
}
|
||||
}
|
||||
router.clear();
|
||||
router.replaceUrl({
|
||||
url: 'pages/certManagerFa'
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
|
@ -1,71 +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 certManagerModel from '../model/CertMangerModel';
|
||||
import { CMModelErrorCode, CMModelOptType } from '../model/CertMangerModel';
|
||||
import { CredentialAbstractVo } from '../model/CertManagerVo/CredentialAbstractVo';
|
||||
import { CredentialVo } from '../model/CertManagerVo/CredentialVo';
|
||||
|
||||
export default class CmShowPrivateCredPresenter {
|
||||
private static sInstance: CmShowPrivateCredPresenter;
|
||||
public credList: CredentialAbstractVo[] = [];
|
||||
public credInfo: CredentialVo = new CredentialVo('', '', '', 0, 0, new Uint8Array());
|
||||
|
||||
public static getInstance(): CmShowPrivateCredPresenter {
|
||||
if (CmShowPrivateCredPresenter.sInstance == null) {
|
||||
CmShowPrivateCredPresenter.sInstance = new CmShowPrivateCredPresenter();
|
||||
}
|
||||
return CmShowPrivateCredPresenter.sInstance;
|
||||
}
|
||||
|
||||
aboutToDisappear(): void {
|
||||
this.credList = [];
|
||||
this.credInfo = new CredentialVo('', '', '', 0, 0, new Uint8Array());
|
||||
}
|
||||
|
||||
updatePrivateCredList(): void {
|
||||
certManagerModel.getCertOrCredList(CMModelOptType.CM_MODEL_OPT_PRIVATE_CRED,
|
||||
(errCode: CMModelErrorCode, credList: Array<CredentialAbstractVo>) => {
|
||||
if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) {
|
||||
credList.sort((certAbs, certAbsOther) => {
|
||||
let certAlias = certAbs.alias;
|
||||
let certAliasOther = certAbsOther.alias;
|
||||
if (certAlias <= certAliasOther) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
this.credList = credList;
|
||||
} else {
|
||||
console.error('updatePrivateCredList error :' + JSON.stringify(errCode));
|
||||
this.credList = [];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
getPrivateCred(uri: string, callback: Function): void {
|
||||
certManagerModel.getCertOrCred(CMModelOptType.CM_MODEL_OPT_PRIVATE_CRED, uri,
|
||||
(errCode: CMModelErrorCode, credInfo: CredentialVo) => {
|
||||
if (errCode === CMModelErrorCode.CM_MODEL_ERROR_SUCCESS) {
|
||||
this.credInfo = credInfo;
|
||||
} else {
|
||||
console.error('getPrivateCred error :' + JSON.stringify(errCode));
|
||||
this.credInfo.clearCredentialVo();
|
||||
}
|
||||
callback();
|
||||
});
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
@ -16,7 +16,6 @@
|
||||
"module": {
|
||||
"name": "CertManager",
|
||||
"type": "feature",
|
||||
"srcEntry": "./ets/MainAbility/MainAbility.ts",
|
||||
"description": "$string:mainability_description",
|
||||
"mainElement": "MainAbility",
|
||||
"deviceTypes": [
|
||||
@ -42,7 +41,7 @@
|
||||
"description": "$string:mainability_description",
|
||||
"icon": "$media:icon",
|
||||
"label": "$string:entry_MainAbility",
|
||||
"visible": true,
|
||||
"exported": true,
|
||||
"launchType": "singleton",
|
||||
"startWindowIcon": "$media:icon",
|
||||
"startWindowBackground": "$color:color_1",
|
||||
@ -103,6 +102,9 @@
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.ACCESS_SECURITY_PRIVACY_CENTER"
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.ACCESS_BIOMETRIC"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -164,6 +164,10 @@
|
||||
"name": "wh_value_100",
|
||||
"value": "100vp"
|
||||
},
|
||||
{
|
||||
"name": "wh_value_104",
|
||||
"value": "104vp"
|
||||
},
|
||||
{
|
||||
"name": "wh_value_109",
|
||||
"value": "109vp"
|
||||
|
@ -281,6 +281,134 @@
|
||||
{
|
||||
"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": "已达到长度上限"
|
||||
}
|
||||
]
|
||||
}
|
@ -5,6 +5,7 @@
|
||||
"pages/trustedCa",
|
||||
"pages/cerEvidenceFa",
|
||||
"pages/requestAuth",
|
||||
"pages/certInstallAliasInput"
|
||||
"pages/certInstallAliasInput",
|
||||
"pages/certInstallFromStorage"
|
||||
]
|
||||
}
|
||||
|
@ -281,6 +281,134 @@
|
||||
{
|
||||
"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 certificate 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": "Certificate installation failure"
|
||||
},
|
||||
{
|
||||
"name": "Install_Cert_Failed",
|
||||
"value": "Install credentials successfully"
|
||||
},
|
||||
{
|
||||
"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"
|
||||
}
|
||||
]
|
||||
}
|
@ -160,6 +160,10 @@
|
||||
"name": "wh_value_100",
|
||||
"value": "100vp"
|
||||
},
|
||||
{
|
||||
"name": "wh_value_104",
|
||||
"value": "104vp"
|
||||
},
|
||||
{
|
||||
"name": "wh_value_109",
|
||||
"value": "109vp"
|
||||
|
@ -1,8 +1,6 @@
|
||||
{
|
||||
"displayedMode": "list",
|
||||
"iconResource": "$media:icon",
|
||||
"mainTitleResource": "$string:certificateTab",
|
||||
"subTitleResource": "sub_title",
|
||||
"dstAbilityMode": 1,
|
||||
"dstAbilityName": "MainExtensionAbility",
|
||||
"dstBundleName": "com.ohos.certmanager"
|
||||
|
Loading…
Reference in New Issue
Block a user