From 6a01c945c156008d84226087f32f450c0ae6d35f Mon Sep 17 00:00:00 2001 From: tan-qingliu Date: Tue, 29 Apr 2025 19:50:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E9=80=80=EF=BC=9A=E7=94=A8=E6=88=B7CA?= =?UTF-8?q?=E8=AF=81=E4=B9=A6=E5=AE=89=E8=A3=85=E6=94=AF=E6=8C=81p7b?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E7=9A=84=E8=AF=81=E4=B9=A6=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tan-qingliu --- .../main/ets/@ohos.security.certManager.d.ts | 12 ----------- .../MainAbility/CertPickerUiExtAbility.ets | 2 +- .../ets/MainAbility/MainExtensionAbility.ts | 2 +- .../ets/common/constants/FileFilterParams.ets | 2 +- .../src/main/ets/model/CertMangerModel.ets | 21 ++++--------------- .../ets/model/PreventScreenshotsModel.ets | 2 +- .../main/ets/pages/certInstallFromStorage.ets | 10 +++------ .../src/main/ets/pages/certPwdInput.ets | 1 + .../ets/pages/detail/CredPwdInputPage.ets | 1 + .../src/main/ets/presenter/CmFaPresenter.ets | 3 +-- .../main/ets/presenter/CmInstallPresenter.ets | 6 ++---- 11 files changed, 16 insertions(+), 46 deletions(-) diff --git a/certmanager/src/main/ets/@ohos.security.certManager.d.ts b/certmanager/src/main/ets/@ohos.security.certManager.d.ts index c3b6d48..bc6fa8d 100755 --- a/certmanager/src/main/ets/@ohos.security.certManager.d.ts +++ b/certmanager/src/main/ets/@ohos.security.certManager.d.ts @@ -148,21 +148,9 @@ declare namespace CertManagerFunc { keyUri: string; } - export enum CertFileFormat { - PEM_DER = 0, - P7B = 1, - } - - export enum CertScope { - CURRENT_USER = 1, - GLOBAL_USER = 2 - } - export interface CertBlob { inData: Uint8Array; alias: string; - certFormat? : CertFileFormat; - certScope? : CertScope; } export interface CMResult { diff --git a/certmanager/src/main/ets/MainAbility/CertPickerUiExtAbility.ets b/certmanager/src/main/ets/MainAbility/CertPickerUiExtAbility.ets index e6dc8d7..3200a81 100755 --- a/certmanager/src/main/ets/MainAbility/CertPickerUiExtAbility.ets +++ b/certmanager/src/main/ets/MainAbility/CertPickerUiExtAbility.ets @@ -67,7 +67,7 @@ export default class CertPickerUiExtAbility extends UIExtensionAbility { } private isStartToInstall(parameters: Record | undefined): boolean { - if (parameters === undefined) { + if(parameters === undefined) { return false; } return parameters['pageType'] === PAGE_CA_INSTALL; diff --git a/certmanager/src/main/ets/MainAbility/MainExtensionAbility.ts b/certmanager/src/main/ets/MainAbility/MainExtensionAbility.ts index f008ac2..81f58b6 100755 --- a/certmanager/src/main/ets/MainAbility/MainExtensionAbility.ts +++ b/certmanager/src/main/ets/MainAbility/MainExtensionAbility.ts @@ -37,7 +37,7 @@ export default class MainExtensionAbility extends UIExtensionAbility { let param: Record = { 'session': session, 'want': want - }; + } let storage: LocalStorage = new LocalStorage(param); let pullType: string = want.parameters.pullType as string; diff --git a/certmanager/src/main/ets/common/constants/FileFilterParams.ets b/certmanager/src/main/ets/common/constants/FileFilterParams.ets index caab03a..5e601ee 100755 --- a/certmanager/src/main/ets/common/constants/FileFilterParams.ets +++ b/certmanager/src/main/ets/common/constants/FileFilterParams.ets @@ -15,6 +15,6 @@ export default class FilterParams { public static readonly MAX_SELECT_FILE_NUM = 1; - public static readonly CERT_FILE_SUFFIX = ['.pem,.cer,.crt,.der,.p7b,.spc']; + public static readonly CERT_FILE_SUFFIX = ['.pem,.cer,.crt,.der']; public static readonly CREDENTIAL_FILE_SUFFIX = ['.pfx,.p12']; } \ No newline at end of file diff --git a/certmanager/src/main/ets/model/CertMangerModel.ets b/certmanager/src/main/ets/model/CertMangerModel.ets index f5500fc..cf9e57b 100755 --- a/certmanager/src/main/ets/model/CertMangerModel.ets +++ b/certmanager/src/main/ets/model/CertMangerModel.ets @@ -34,8 +34,7 @@ export enum CMModelErrorCode { CM_MODEL_ERROR_MAX_QUANTITY_REACHED = -7, CM_MODEL_ERROR_ALIAS_LENGTH_REACHED_LIMIT = -8, CM_MODEL_ERROR_PASSWORD_ERR = -9, - CM_MODEL_ERROR_ADVANCED_SECURITY = -10, - CM_MODEL_ERROR_ + CM_MODEL_ERROR_ADVANCED_SECURITY = -10 } export enum CMModelOptType { @@ -45,7 +44,6 @@ export enum CMModelOptType { CM_MODEL_OPT_APP_CRED = 3, CM_MODEL_OPT_PRIVATE_CRED = 4, CM_MODEL_OPT_SYSTEM_CRED = 5, - CM_MODEL_OPT_USER_CA_P7B = 6, } export enum CertManagerStore { @@ -261,12 +259,7 @@ export class CertMangerModel { console.info(TAG + 'installCertOrCred start'); switch (optType) { case CMModelOptType.CM_MODEL_OPT_USER_CA: - this.installUserCertificate(data, alias, optType, (errCode: CMModelErrorCode, uri: string) => { - callback(errCode, uri); - }); - break; - case CMModelOptType.CM_MODEL_OPT_USER_CA_P7B: - this.installUserCertificate(data, alias, optType, (errCode: CMModelErrorCode, uri: string) => { + this.installUserCertificate(data, alias, (errCode: CMModelErrorCode, uri: string) => { callback(errCode, uri); }); break; @@ -671,7 +664,7 @@ export class CertMangerModel { } } - private async installUserCertificate(data: Uint8Array, alias: string, optType: CMModelOptType, callback: Function): Promise { + private async installUserCertificate(data: Uint8Array, alias: string, callback: Function): Promise { console.info(TAG + 'installUserCertificate start'); if ((data === undefined) || (data.length === 0)) { callback(CMModelErrorCode.CM_MODEL_ERROR_INCORRECT_FORMAT); @@ -679,15 +672,9 @@ export class CertMangerModel { return; } try { - let certFormat: CertManager.CertFileFormat = CertManager.CertFileFormat.PEM_DER; - if (optType == CMModelOptType.CM_MODEL_OPT_USER_CA_P7B) { - certFormat = CertManager.CertFileFormat.P7B; - } let result = await CertManager.installUserTrustedCertificate({ inData: data, - alias: alias, - certFormat: certFormat, - certScope: CertManager.CertScope.CURRENT_USER + alias: alias }); console.info(TAG + 'installUserCertificate end'); callback(CMModelErrorCode.CM_MODEL_ERROR_SUCCESS, result.uri); diff --git a/certmanager/src/main/ets/model/PreventScreenshotsModel.ets b/certmanager/src/main/ets/model/PreventScreenshotsModel.ets index 45763f1..114b611 100755 --- a/certmanager/src/main/ets/model/PreventScreenshotsModel.ets +++ b/certmanager/src/main/ets/model/PreventScreenshotsModel.ets @@ -47,7 +47,7 @@ export default class PreventScreenshotsModel { window.getLastWindow(context).then((window) => { windowClass = window; - console.info(TAG, 'Success in obtaining the top window data'); + console.info(TAG,'Success in obtaining the top window data'); windowClass.setWindowPrivacyMode(isPrivacyMode).catch((err: BusinessError) => { console.error(TAG, 'setWindowPrivacyMode failed: ' + JSON.stringify(err)); }) diff --git a/certmanager/src/main/ets/pages/certInstallFromStorage.ets b/certmanager/src/main/ets/pages/certInstallFromStorage.ets index e0e8814..0823a6a 100755 --- a/certmanager/src/main/ets/pages/certInstallFromStorage.ets +++ b/certmanager/src/main/ets/pages/certInstallFromStorage.ets @@ -30,8 +30,6 @@ import { RouterFileVo } from '../model/CertManagerVo/RouterInfoVo'; import { CredPwdInputParam } from './detail/CredPwdInputPage'; import { SheetParam } from '../common/util/SheetParam'; import FilterParams from '../common/constants/FileFilterParams'; -import { UIContext } from '@kit.ArkUI'; -import { common } from '@kit.AbilityKit'; const COPIES_NUM: number = 12; @@ -166,8 +164,7 @@ export struct CertInstallFromStorage { FileIoModel.getMediaFileSuffix(fileUri, (suffix: string | undefined) => { if (suffix !== undefined) { console.debug(TAG, 'suffix = ', suffix); - if ((suffix === 'cer') || (suffix === 'pem') || (suffix === 'crt') || (suffix === 'der') || - (suffix === 'p7b') || (suffix === 'spc')) { + if ((suffix === 'cer') || (suffix === 'pem') || (suffix === 'crt') || (suffix === 'der')) { CmInstallPresenter.getInstance().installCert(fileUri, '', suffix, false); } else { this.mFaPresenter.unrecognizedFileTips(); @@ -280,7 +277,7 @@ export struct CertInstallFromStorage { .onClick(() => { this.installCertFlag = false; AppStorage.setOrCreate('installSystemCred', true); - AppStorage.setOrCreate('installUserCred', false); + AppStorage.setOrCreate('installUserCred',false); if (this.isStartBySheet) { this.startInstallEvidenceBySheet(); } else { @@ -315,12 +312,11 @@ export struct CertInstallFromStorage { .onClick(() => { this.installCertFlag = false; AppStorage.setOrCreate('installUserCred', true); - AppStorage.setOrCreate('installSystemCred', false); + AppStorage.setOrCreate('installSystemCred',false); if (this.isStartBySheet) { this.startInstallEvidenceBySheet(); } else { this.mFaPresenter.startInstallEvidence(this.context); - new UIContext().getHostContext() as common.Context; } }) } diff --git a/certmanager/src/main/ets/pages/certPwdInput.ets b/certmanager/src/main/ets/pages/certPwdInput.ets index 07c1970..620ee65 100755 --- a/certmanager/src/main/ets/pages/certPwdInput.ets +++ b/certmanager/src/main/ets/pages/certPwdInput.ets @@ -135,6 +135,7 @@ struct CertPwdInput { left: $r('app.float.distance_16'), right: $r('app.float.distance_24'), }) + .enabled(this.certPwd !== undefined && this.certPwd.length > 0) .onClick(() => { let fileInfo: RouterFileVo = router.getParams() as RouterFileVo; this.isPasswordError = false; diff --git a/certmanager/src/main/ets/pages/detail/CredPwdInputPage.ets b/certmanager/src/main/ets/pages/detail/CredPwdInputPage.ets index 9e37050..1769719 100755 --- a/certmanager/src/main/ets/pages/detail/CredPwdInputPage.ets +++ b/certmanager/src/main/ets/pages/detail/CredPwdInputPage.ets @@ -104,6 +104,7 @@ export struct CredPwdInputPage { top: $r('app.float.distance_16'), bottom: $r('app.float.distance_24') }) + .enabled(this.certPwd !== undefined && this.certPwd.length > 0) .onClick(() => { if (this.credFile === undefined || this.credFile === null) { console.error(TAG + 'Cred file is undefined'); diff --git a/certmanager/src/main/ets/presenter/CmFaPresenter.ets b/certmanager/src/main/ets/presenter/CmFaPresenter.ets index e215154..f0e4060 100755 --- a/certmanager/src/main/ets/presenter/CmFaPresenter.ets +++ b/certmanager/src/main/ets/presenter/CmFaPresenter.ets @@ -65,8 +65,7 @@ export default class CmFaPresenter { FileIoModel.getMediaFileSuffix(fileUri, (suffix: string | undefined) => { if (suffix !== undefined) { console.debug(TAG, 'suffix = ', suffix); - if ((suffix === 'cer') || (suffix === 'pem') || (suffix === 'crt') || (suffix === 'der') || - (suffix === 'p7b') || (suffix === 'spc')) { + if ((suffix === 'cer') || (suffix === 'pem') || (suffix === 'crt') || (suffix === 'der')) { CmInstallPresenter.getInstance().installCert(fileUri, '', suffix, true); } else { this.unrecognizedFileTips(); diff --git a/certmanager/src/main/ets/presenter/CmInstallPresenter.ets b/certmanager/src/main/ets/presenter/CmInstallPresenter.ets index 8434ec2..d45a7a5 100755 --- a/certmanager/src/main/ets/presenter/CmInstallPresenter.ets +++ b/certmanager/src/main/ets/presenter/CmInstallPresenter.ets @@ -43,16 +43,14 @@ export default class CmInstallPresenter { aboutToDisappear(): void { this.optType = CMModelOptType.CM_MODEL_OPT_UNKNOWN; - AppStorage.setOrCreate('installUserCred', false); - AppStorage.setOrCreate('installSystemCred', false); + AppStorage.setOrCreate('installUserCred',false); + AppStorage.setOrCreate('installSystemCred',false); } updateCertFileType(suffix: string): void { console.debug(TAG + 'updateCertFileType suffix: ' + suffix); if ((suffix === 'cer') || (suffix === 'pem') || (suffix === 'crt') || (suffix === 'der')) { this.optType = CMModelOptType.CM_MODEL_OPT_USER_CA; - } else if ((suffix === 'p7b') || (suffix === 'spc')) { - this.optType = CMModelOptType.CM_MODEL_OPT_USER_CA_P7B; } else if (((suffix === 'p12') || (suffix === 'pfx')) && AppStorage.get('installUserCred') === true) { this.optType = CMModelOptType.CM_MODEL_OPT_APP_CRED; -- Gitee