improve code for suporting no cacert

Signed-off-by: huyiqi <huyiqi3@huawei.com>
This commit is contained in:
huyiqi 2024-07-02 11:11:04 +08:00
parent 0340da5361
commit d839a06588
3 changed files with 8 additions and 48 deletions

View File

@ -280,22 +280,6 @@ export class CertMangerModel {
} }
} }
checkPassword(data: Uint8Array, pwd: string, callback: Function): void {
console.info(TAG + 'checkPassword start');
try {
cert.createTrustAnchorsWithKeyStore(data, pwd).then((data) => {
console.info(TAG + 'checkPassword success');
callback(0)
}).catch((err: BusinessError) => {
console.info(TAG + 'checkPassword failed:' + JSON.stringify(err));
callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION)
})
} catch (err) {
console.error(TAG + 'call create failed:' + JSON.stringify(err));
callback(CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION);
}
}
private async getSystemTrustedCertificateList(callback: Function): Promise<void> { private async getSystemTrustedCertificateList(callback: Function): Promise<void> {
console.info(TAG + 'getSystemTrustedCertificateList start'); console.info(TAG + 'getSystemTrustedCertificateList start');
try { try {

View File

@ -138,23 +138,14 @@ struct CertPwdInput {
.onClick(() => { .onClick(() => {
let fileInfo: RouterFileVo = router.getParams() as RouterFileVo; let fileInfo: RouterFileVo = router.getParams() as RouterFileVo;
this.isPasswordError = false; this.isPasswordError = false;
this.mAppCredAuthPresenter.AuthenticationPassword(fileInfo.uri, fileInfo.suffix, this.certPwd) GlobalContext.getContext().getPwdStore().setCertPwd(this.certPwd);
.then((result: number) => { router.replaceUrl({
this.passWordWarn = result; url: 'pages/certInstallAliasInput',
if (this.passWordWarn !== CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION) { params: {
GlobalContext.getContext().getPwdStore().setCertPwd(this.certPwd); fileInfo: fileInfo,
let fileInfo: RouterFileVo = router.getParams() as RouterFileVo; pwd: this.certPwd
router.replaceUrl({ }
url: 'pages/certInstallAliasInput', })
params: {
fileInfo: fileInfo,
pwd: this.certPwd
}
})
} else {
this.isPasswordError = true;
}
})
}) })
} }
.margin({ bottom: $r('app.float.wh_value_24') }) .margin({ bottom: $r('app.float.wh_value_24') })

View File

@ -68,21 +68,6 @@ export default class CmInstallPresenter {
}); });
} }
AuthenticationPassword(uri: string, suffix: string, pwd: string): Promise<number> {
return new Promise((resolve) => {
this.updateCertFileType(suffix);
this.getFileDataFromUri(uri, (data: Uint8Array) => {
certManagerModel.checkPassword(data, pwd, (err: CMModelErrorCode) => {
if (err === CMModelErrorCode.CM_MODEL_ERROR_EXCEPTION) {
resolve(err)
} else {
resolve(0)
}
})
})
})
}
checkCertNameLength(uri: string, alias: string, suffix: string, pwd: string): Promise<number> { checkCertNameLength(uri: string, alias: string, suffix: string, pwd: string): Promise<number> {
return new Promise((resolve) => { return new Promise((resolve) => {
this.updateCertFileType(suffix); this.updateCertFileType(suffix);