Password log safety fix

Signed-off-by: zhanghaima <zhanghaima1@huawei.com>
This commit is contained in:
zhanghaima 2022-02-17 12:07:29 +08:00
parent 2846465a91
commit 5ca54d2993
15 changed files with 164 additions and 123 deletions

View File

@ -50,7 +50,7 @@ export default class SearchModel {
// table SEARCH_DATA init
await this.rdbStore.executeSql(SearchConfig.search.DDL_TABLE_CREATE, null);
console.log('settings table SEARCH_DATA is ready.');
LogUtil.log('settings table SEARCH_DATA is ready.');
}
}

View File

@ -15,6 +15,7 @@
import BaseModel from '../model/BaseModel.ets';
import Rsm from '@ohos.resourceManager';
import ConfigData from './ConfigData.ets';
import LogUtil from './LogUtil.ets';
export class GlobalResourceManager extends BaseModel {
@ -31,16 +32,16 @@ export class GlobalResourceManager extends BaseModel {
result.getString(id)
.then((resource) => {
resolve(resource);
console.info('getStringById resolve(resource) : ' + resolve(resource));
console.info('getStringById resource : ' + resource);
console.info('getStringById resource2 : ' + JSON.stringify(resource));
LogUtil.info('getStringById resolve(resource) : ' + resolve(resource));
LogUtil.info('getStringById resource : ' + resource);
LogUtil.info('getStringById resource2 : ' + JSON.stringify(resource));
})
.catch((err) => {
console.info('getStringById err : ' + JSON.stringify(err));
LogUtil.info('getStringById err : ' + JSON.stringify(err));
});
});
});
console.info('getStringById promise: ' + JSON.stringify(promise));
LogUtil.info('getStringById promise: ' + JSON.stringify(promise));
return promise;
}
}

View File

@ -17,55 +17,67 @@ import BaseModel from '../model/BaseModel.ets';
/**
* Log level
*/
let LOG_LEVEL = {
let LogLevel = {
/**
* debug
*/
DEBUG: 'debug',
DEBUG: 3,
/**
* log
*/
LOG: 'log',
LOG: 4,
/**
* info
*/
INFO: 'info',
INFO: 5,
/**
* warn
*/
WARN: 'warn',
WARN: 6,
/**
* error
*/
ERROR: 'error'
ERROR: 7
};
const LOG_LEVEL = LogLevel.INFO
/**
* log package tool class
*/
export class LogUtil extends BaseModel {
debug(msg): void {
console.info(msg);
if (LogLevel.DEBUG >= LOG_LEVEL) {
console.info(msg);
}
}
log(msg): void {
console.log(msg);
if (LogLevel.INFO >= LOG_LEVEL) {
console.log(msg);
}
}
info(msg): void {
console.info(msg);
if (LogLevel.INFO >= LOG_LEVEL) {
console.info(msg);
}
}
warn(msg): void {
console.warn(msg);
if (LogLevel.WARN >= LOG_LEVEL) {
console.warn(msg);
}
}
error(msg): void {
console.error(msg);
if (LogLevel.ERROR >= LOG_LEVEL) {
console.error(msg);
}
}
}

View File

@ -13,7 +13,7 @@
* limitations under the License.
*/
import BaseModel from '../model/BaseModel.ets';
import LogUtil from './LogUtil.ets';
import LogUtil from './LogUtil.ets';
import ohosDataRdb from '@ohos.data.rdb';
const TAG = "RdbStoreUtil.js->";
@ -38,16 +38,16 @@ export default {
* create data
*/
createRdbStore(callback) {
console.info(TAG + 'get data')
LogUtil.info(TAG + 'get data')
if (!rdbStore) {
ohosDataRdb.getRdbStore(STORE_CONFIG, 1)
.then((store) => {
console.info(TAG + 'get data create success' + JSON.stringify(store))
rdbStore = store
callback(true)
LogUtil.info(TAG + 'get data create success' + JSON.stringify(store))
rdbStore = store
callback(true)
})
.catch((err) => {
console.info(TAG + 'get data createRdbStore err' + err)
LogUtil.info(TAG + 'get data createRdbStore err' + err)
callback(false)
})
}
@ -64,7 +64,7 @@ export default {
* insert
*/
insert(tableName, rowValue) {
console.info('get data start: ' + tableName);
LogUtil.info('get data start: ' + tableName);
return rdbStore.insert(tableName, rowValue);
},
/**
@ -76,7 +76,7 @@ export default {
async update(predicates, rowValue) {
LogUtil.info(TAG + 'update start');
let changedRows = await rdbStore.update(rowValue, predicates);
console.info(TAG + 'update row count: ' + changedRows);
LogUtil.info(TAG + 'update row count: ' + changedRows);
},
/**
* delete

View File

@ -13,7 +13,8 @@
* limitations under the License.
*/
import { LogAll } from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets';
import LogUtil from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets';
import ConfigData from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets';
const PASSWORD_MIN_LENGTH = 4
const PASSWORD_MAX_LENGTH = 32
@ -21,8 +22,8 @@ const PASSWORD_MAX_LENGTH = 32
/**
* Check whether the string is legal.
*/
@LogAll
export class Checker {
private TAG = ConfigData.TAG + 'Password Checker ';
/**
* check if the character string more than 4 digits
@ -30,6 +31,7 @@ export class Checker {
* @param str : character string
*/
checkMinDigits(str: string): boolean {
LogUtil.info(this.TAG + 'checkMinDigits in.');
return str.length >= PASSWORD_MIN_LENGTH;
}
@ -39,6 +41,7 @@ export class Checker {
* @param str : character string
*/
checkMaxDigits(str: string): boolean {
LogUtil.info(this.TAG + 'checkMaxDigits in.');
return str.length <= PASSWORD_MAX_LENGTH;
}
@ -48,6 +51,7 @@ export class Checker {
* @param str : character string
*/
isNumber6(str: string): boolean {
LogUtil.info(this.TAG + 'isNumber6 in.');
var reg = /^[0-9]{6}$/;
return reg.test(str);
}
@ -58,6 +62,7 @@ export class Checker {
* @param str : character string
*/
containsOnlyNumbers(str: string): boolean {
LogUtil.info(this.TAG + 'containsOnlyNumbers in.');
var reg = /^[0-9]{4,32}$/;
return reg.test(str);
}
@ -68,6 +73,7 @@ export class Checker {
* @param str : character string
*/
isOnlyNumber(str: string): boolean {
LogUtil.info(this.TAG + 'isOnlyNumber in.');
var reg = /^[0-9]+$/;
return reg.test(str);
}
@ -78,6 +84,7 @@ export class Checker {
* @param str : character string
*/
containCharacter(str: string): boolean {
LogUtil.info(this.TAG + 'containCharacter in.');
var reg = /^(?=.*[a-zA-Z])[\x20-\x7E]{4,32}$/;
return reg.test(str);
}
@ -88,6 +95,7 @@ export class Checker {
* @param str : character string
*/
isContainLetters(str: string): boolean {
LogUtil.info(this.TAG + 'isContainLetters in.');
var reg = /^(?=.*[a-zA-Z])/;
return reg.test(str);
}
@ -98,6 +106,7 @@ export class Checker {
* @param str : character string
*/
isContainIllegalCharacter(str: string): boolean {
LogUtil.info(this.TAG + 'isContainIllegalCharacter in.');
var reg = /[^\x20-\x7E]/;
return reg.test(str);
}

View File

@ -15,13 +15,12 @@
import BaseSettingsController from '../../../../../../../../common/component/src/main/ets/default/controller/BaseSettingsController.ets';
import ConfigData from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets';
import LogUtil from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets';
import {LogAll} from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets';
import Log from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets';
import ISettingsController from '../../../../../../../../common/component/src/main/ets/default/controller/ISettingsController';
import PasswordModel, {ResultCode, PinSubType} from '../../model/passwordImpl/PasswordModel.ets';
import PasswordModel, {ResultCode} from '../../model/passwordImpl/PasswordModel.ets';
import Router from '@system.router';
import Prompt from '@system.prompt';
@LogAll
export default class PasswordCheckController extends BaseSettingsController {
private TAG = ConfigData.TAG + 'PasswordCheckController ';
private pageRequestCode: number = -1;
@ -35,6 +34,7 @@ export default class PasswordCheckController extends BaseSettingsController {
// private Properties
private password: string = ''
@Log
initData(): ISettingsController {
this.loadData()
return this
@ -57,16 +57,17 @@ export default class PasswordCheckController extends BaseSettingsController {
* @param value : inputting password
*/
passwordOnChange(value: string) {
LogUtil.info(this.TAG + 'passwordOnChange in.')
this.password = value;
LogUtil.info(this.TAG + 'passwordOnChange : passwordType = ' + this.passwordType + ', password = ' + this.password)
}
LogUtil.debug(this.TAG + 'passwordOnChange : passwordType = ' + this.passwordType + ', password = ' + this.password)
LogUtil.info(this.TAG + 'passwordOnChange out.') }
//------------------------------ check ---------------------------
/**
* Input finish. Start simple check.
*/
inputFinish(event?: ClickEvent) {
LogUtil.info(this.TAG + 'inputFinish : password = ' + this.password)
LogUtil.debug(this.TAG + 'inputFinish : password = ' + this.password)
if (!this.password) {
LogUtil.info(this.TAG + 'inputFinish return : password is none.')
@ -85,15 +86,15 @@ export default class PasswordCheckController extends BaseSettingsController {
*/
checkInputSuccess() {
this.checkPasswordCorrect((result, extraInfo) => {
LogUtil.info(this.TAG + 'checkInputSuccess : checkPasswordCorrect callback : result = ' + result + ', extraInfo = ' + JSON.stringify(extraInfo));
LogUtil.info(this.TAG + 'checkInputSuccess : checkPasswordCorrect callback : result = ' + result );
LogUtil.debug(this.TAG + 'checkInputSuccess : checkPasswordCorrect callback : extraInfo = ' + JSON.stringify(extraInfo));
if (result === ResultCode.SUCCESS) {
if (extraInfo) {
if (this.pinChallenge) {
this.pinToken = extraInfo.token;
}
}
LogUtil.info(this.TAG + 'checkInputSuccess : callback success. pinChallenge = ' + this.pinChallenge + ', pinToken = ' + this.pinToken);
LogUtil.debug(this.TAG + 'checkInputSuccess : callback success. pinChallenge = ' + this.pinChallenge + ', pinToken = ' + this.pinToken);
this.authSuccess()
} else {
@ -101,7 +102,7 @@ export default class PasswordCheckController extends BaseSettingsController {
this.freezingTime = extraInfo.freezingTime;
this.remainTimes = extraInfo.remainTimes;
} else {
LogUtil.info(this.TAG + 'checkInputSuccess : callback not success. extraInfo? == false.');
LogUtil.info(this.TAG + 'checkInputSuccess : callback not success. And there is no extra info.');
Prompt.showToast({
message: 'Pin auth is not success.\nAnd extraInfo has no data.\nresult = ' + result,
duration: 3500
@ -114,6 +115,7 @@ export default class PasswordCheckController extends BaseSettingsController {
/**
* Check password result changed.
*/
@Log
authSuccess() {
LogUtil.info(`${this.TAG}resultChanged: pageRequestCode = ${this.pageRequestCode}`);
if (this.pinToken && this.pageRequestCode == ConfigData.PAGE_REQUEST_CODE_PASSWORD_CHANGE) {
@ -131,8 +133,9 @@ export default class PasswordCheckController extends BaseSettingsController {
/**
* Go to password create page
*/
@Log
gotoPasswordCreatePage() {
LogUtil.info(`${this.TAG}gotoPasswordCreatePage : pageRequestCode: ${this.pageRequestCode}, prevPageUri = ${this.prevPageUri}, pageRequestCode: ${this.pageRequestCode}, pinChallenge: ${this.pinChallenge}, pinToken: ${this.pinToken}`);
LogUtil.debug(`${this.TAG}gotoPasswordCreatePage : pageRequestCode: ${this.pageRequestCode}, prevPageUri = ${this.prevPageUri}, pageRequestCode: ${this.pageRequestCode}, pinChallenge: ${this.pinChallenge}, pinToken: ${this.pinToken}`);
Router.replace({
uri: 'pages/passwordInput',
params: {
@ -147,6 +150,7 @@ export default class PasswordCheckController extends BaseSettingsController {
/**
* Auth check ok, return OK result.
*/
@Log
goBackCorrect() {
Router.back()
}
@ -155,9 +159,10 @@ export default class PasswordCheckController extends BaseSettingsController {
/**
* Call api to check if has the password
*/
@Log
loadData() {
PasswordModel.hasPinPassword((havePassword) => {
LogUtil.info(this.TAG + 'hasPinPassword : havePassword = ' + havePassword);
LogUtil.debug(this.TAG + 'hasPinPassword : havePassword = ' + havePassword);
if (havePassword) {
this.getAuthProperty();
} else {
@ -173,11 +178,11 @@ export default class PasswordCheckController extends BaseSettingsController {
*/
checkPasswordCorrect(successCallback: (result: number, extraInfo: any) => void): void {
PasswordModel.authPin(this.pinChallenge, this.password, (result, extraInfo) => {
LogUtil.info(this.TAG + 'checkPasswordCorrect : result = ' + JSON.stringify(result) + ', extraInfo = ' + JSON.stringify(extraInfo));
LogUtil.debug(this.TAG + 'checkPasswordCorrect : result = ' + JSON.stringify(result) + ', extraInfo = ' + JSON.stringify(extraInfo));
if (result === ResultCode.SUCCESS) {
LogUtil.info(`${this.TAG}checkPasswordCorrect success`);
LogUtil.info(`${this.TAG}check password correct success`);
} else {
LogUtil.info(`${this.TAG}checkPasswordCorrect failed`);
LogUtil.info(`${this.TAG}check password correct failed`);
}
successCallback(result, extraInfo)
});
@ -190,7 +195,7 @@ export default class PasswordCheckController extends BaseSettingsController {
*/
getAuthProperty() {
PasswordModel.getAuthProperty((data: any) => {
LogUtil.info(this.TAG + `getAuthProperty data:${JSON.stringify(data)}`);
LogUtil.debug(this.TAG + `getAuthProperty data:${JSON.stringify(data)}`);
if (data.result === ResultCode.SUCCESS) {
this.passwordType = data.authSubType ? data.authSubType : -1;
this.freezingTime = data.freezingTime ? data.freezingTime : 0;
@ -209,7 +214,7 @@ export default class PasswordCheckController extends BaseSettingsController {
*/
delCredential(successCallback) {
PasswordModel.delAllCredential(this.pinToken, (result, extraInfo) => {
LogUtil.info(`${this.TAG}delAllCredential->result:${result}, extraInfo:${JSON.stringify(extraInfo)}`);
LogUtil.debug(`${this.TAG}delAllCredential->result:${result}, extraInfo:${JSON.stringify(extraInfo)}`);
if (result === ResultCode.SUCCESS) {
LogUtil.info(`${this.TAG}delAllCredential success`);
this.pinToken = '';

View File

@ -17,7 +17,7 @@ import BaseSettingsController from '../../../../../../../../common/component/src
import ConfigData from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets';
import LogUtil from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets';
import ISettingsController from '../../../../../../../../common/component/src/main/ets/default/controller/ISettingsController';
import {LogAll} from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets';
import Log from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets';
import {PinSubType} from '../../model/passwordImpl/PasswordModel.ets';
import {Checker} from './Checker.ets';
import Router from '@system.router';
@ -25,7 +25,6 @@ import Router from '@system.router';
const PASSWORD_SIX_LENGTH = 6
const AUTH_SUB_TYPE_DEFAULT = PinSubType.PIN_SIX
@LogAll
export default class PasswordInputController extends BaseSettingsController {
private TAG = ConfigData.TAG + 'PasswordInputController ';
private checker = new Checker();
@ -40,6 +39,7 @@ export default class PasswordInputController extends BaseSettingsController {
/**
* Initialize data.
*/
@Log
initData(): ISettingsController {
LogUtil.info(this.TAG + 'initData start : passwordType = ' + this.passwordType)
@ -59,6 +59,7 @@ export default class PasswordInputController extends BaseSettingsController {
*
* @param value : password type
*/
@Log
changePasswordType(value) {
this.passwordType = value;
}
@ -69,23 +70,25 @@ export default class PasswordInputController extends BaseSettingsController {
* @param value : inputting password
*/
passwordOnChange(value: string) {
LogUtil.info(this.TAG + 'passwordOnChange in.')
this.password = value;
LogUtil.info(this.TAG + 'passwordOnChange : passwordType = ' + this.passwordType + ', password = ' + this.password)
LogUtil.debug(this.TAG + 'passwordOnChange : passwordType = ' + this.passwordType + ', password = ' + this.password)
this.checkMessage = this.checkInputDigits(value)
LogUtil.info(this.TAG + 'passwordOnChange : checkInputDigits over : checkMessage = ' + JSON.stringify(this.checkMessage));
LogUtil.debug(this.TAG + 'passwordOnChange : checkInputDigits over : checkMessage = ' + JSON.stringify(this.checkMessage));
if (this.passwordType == PinSubType.PIN_SIX && !this.checkMessage && this.checker.isNumber6(this.password)) {
// When password is 6 numbers, finish input
this.inputFinish();
}
LogUtil.info(this.TAG + 'passwordOnChange out.')
}
/**
* Input finish. Start simple check.
*/
@Log
inputFinish() {
LogUtil.info(this.TAG + 'inputFinish : password = ' + this.password)
LogUtil.debug(this.TAG + 'inputFinish : password = ' + this.password)
if (!this.password) {
LogUtil.info(this.TAG + 'inputFinish return : password is none.')
@ -125,7 +128,7 @@ export default class PasswordInputController extends BaseSettingsController {
* @return error message
*/
checkInputDigits(pwd: string): string | Resource {
LogUtil.info(this.TAG + 'checkInputDigits in.')
switch (this.passwordType) {
case PinSubType.PIN_SIX:
@ -174,6 +177,7 @@ export default class PasswordInputController extends BaseSettingsController {
/**
* Input check success.
*/
@Log
checkInputSuccess() {
this.gotoRepeatPage();
}
@ -182,6 +186,7 @@ export default class PasswordInputController extends BaseSettingsController {
/**
* When password illegality check is ok, go to repeat input password page.
*/
@Log
gotoRepeatPage() {
Router.replace({
uri: 'pages/passwordRepeat',

View File

@ -17,14 +17,13 @@ import BaseSettingsController from '../../../../../../../../common/component/src
import ConfigData from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets';
import LogUtil from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets';
import ISettingsController from '../../../../../../../../common/component/src/main/ets/default/controller/ISettingsController';
import {LogAll} from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets';
import Log from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets';
import PasswordModel, {PinSubType, ResultCode} from '../../model/passwordImpl/PasswordModel.ets';
import {Checker} from './Checker.ets';
import Router from '@system.router';
const PASSWORD_SIX_LENGTH = 6
@LogAll
export default class PasswordRepeatController extends BaseSettingsController {
private TAG = ConfigData.TAG + 'PasswordRepeatController ';
private checker = new Checker();
@ -51,22 +50,24 @@ export default class PasswordRepeatController extends BaseSettingsController {
* @param value : inputting password
*/
passwordOnChange(value: string) {
LogUtil.info(this.TAG + 'passwordOnChange in.')
this.password = value;
LogUtil.info(this.TAG + 'passwordOnChange : passwordType = ' + this.passwordType + ', password = ' + this.password)
LogUtil.debug(this.TAG + 'passwordOnChange : passwordType = ' + this.passwordType + ', password = ' + this.password)
this.checkMessage = this.checkInputDigits(value)
LogUtil.info(this.TAG + 'passwordOnChange : checkInputDigits over : checkMessage = ' + JSON.stringify(this.checkMessage));
LogUtil.debug(this.TAG + 'passwordOnChange : checkInputDigits over : checkMessage = ' + JSON.stringify(this.checkMessage));
if (this.passwordType == PinSubType.PIN_SIX && !this.checkMessage && this.checker.isNumber6(this.password)) {
// When password is 6 numbers, finish input
this.inputFinish();
}
LogUtil.info(this.TAG + 'passwordOnChange in.')
}
/**
* Input finish. Start simple check.
*/
inputFinish() {
LogUtil.info(this.TAG + 'inputFinish : password = ' + this.password + ', inputPassword = ' + this.inputPassword)
LogUtil.debug(this.TAG + 'inputFinish : password = ' + this.password + ', inputPassword = ' + this.inputPassword)
if (!this.password) {
LogUtil.info(this.TAG + 'inputFinish return : password is none.')
@ -115,13 +116,13 @@ export default class PasswordRepeatController extends BaseSettingsController {
} else if (this.passwordType == PinSubType.PIN_MIXED) {
return $r('app.string.password_check_max_error')
}
}
//------------------------------ Router -----------------------------
/**
* Return OK result.
*/
@Log
goBackCorrect() {
Router.back()
}
@ -132,12 +133,12 @@ export default class PasswordRepeatController extends BaseSettingsController {
*/
createPassword() {
PasswordModel.addPinCredential(this.passwordType, this.password, (result) => {
LogUtil.info(this.TAG + 'createPassword->result = ' + JSON.stringify(result));
LogUtil.info(this.TAG + 'create password->result = ' + JSON.stringify(result));
if (result === ResultCode.SUCCESS) {
LogUtil.info(`${this.TAG}createPassword success`);
LogUtil.info(`${this.TAG}create password success`);
this.goBackCorrect()
} else {
LogUtil.info(`${this.TAG}createPassword failed`);
LogUtil.info(`${this.TAG}create password failed`);
//TODO show api message to view
this.checkMessage = 'create failed.'
}
@ -149,13 +150,13 @@ export default class PasswordRepeatController extends BaseSettingsController {
*/
updatePassword() {
PasswordModel.updateCredential(this.passwordType, this.password, this.pinToken, (result, extraInfo) => {
LogUtil.info(this.TAG + 'updateCredential->result = ' + JSON.stringify(result));
LogUtil.info(this.TAG + 'updateCredential->extraInfo = ' + JSON.stringify(extraInfo));
LogUtil.info(this.TAG + 'update credential->result = ' + JSON.stringify(result));
LogUtil.debug(this.TAG + 'update credential->extraInfo = ' + JSON.stringify(extraInfo));
if (result === ResultCode.SUCCESS) {
LogUtil.info(`${this.TAG}updatePassword success`);
LogUtil.info(`${this.TAG}update password success`);
this.goBackCorrect()
} else {
LogUtil.info(`${this.TAG}updatePassword failed`);
LogUtil.info(`${this.TAG}update password failed`);
//TODO show error message to view
this.checkMessage = 'update failed.'
}

View File

@ -28,7 +28,7 @@ export default class PasswordSettingController extends BaseSettingsController {
subscribe(): ISettingsController {
PasswordModel.closeSession();
PasswordModel.openSession((data) => {
LogUtil.info(`${this.TAG}subscribe->openSession data:${data}`);
LogUtil.debug(`${this.TAG}subscribe->openSession data:${data}`);
if (data === '0') {
LogUtil.info(`${this.TAG}subscribe->openSession failed`);
} else {

View File

@ -92,7 +92,7 @@ export class AbilityInfoModel extends BaseModel {
if (metaBase.labelId > 0) {
item.getString(parseInt(metaBase.labelId), (error, value) => {
if (error != null) {
console.info('settings getAbilityInfoListener getString error:' + error);
LogUtil.info('settings getAbilityInfoListener getString error:' + error);
label = '';
}
LogUtil.info('settings getAbilityInfoListener getResourceManager value.length:' + value.length);
@ -111,7 +111,7 @@ export class AbilityInfoModel extends BaseModel {
LogUtil.info('settings getAbilityInfoListener getResourceManager getString() finish label:' + label);
item.getMediaBase64(parseInt(metaBase.iconId), (error, value) => {
if (error != null) {
console.info('settings getAbilityInfoListener getMediaBase64 error:' + error);
LogUtil.info('settings getAbilityInfoListener getMediaBase64 error:' + error);
imageValue = deaultAppIcon;
this.getMetaDataList(label, imageValue, metaBase, callback)
}

View File

@ -84,9 +84,9 @@ export class AppManagementModel extends BaseModel {
LogUtil.info('settings AppManagementModel getResourceManager getString() finish label:' + label);
if (appInfo.iconId > 0) {
item.getMediaBase64(appInfo.iconId, (error, value) => {
console.info('settings AppManagementModel getMediaBase64 error:' + error);
LogUtil.info('settings AppManagementModel getMediaBase64 error:' + error);
if (error != null) {
console.info('settings AppManagementModel getMediaBase64 error!=null:' + error);
LogUtil.info('settings AppManagementModel getMediaBase64 error!=null:' + error);
this.mBundleInfoList.push({
settingIcon: icon_default,
settingTitle: label,

View File

@ -23,7 +23,7 @@ class DataRdbService {
*/
queryAllData(callback) {
DataRdbModel.queryAllData(Stable.tableName.Global, res => {
console.info(ConfigData.TAG + 'get data query model result: ' + JSON.stringify(res));
LogUtil.info(ConfigData.TAG + 'get data query model result: ' + JSON.stringify(res));
callback(res);
});
}
@ -32,7 +32,7 @@ class DataRdbService {
*/
querySingleData(key, callback) {
DataRdbModel.querySingleData(Stable.tableName.Global, key, res => {
console.info(ConfigData.TAG + 'get data query model querySingleData result: ' + JSON.stringify(res));
LogUtil.info(ConfigData.TAG + 'get data query model querySingleData result: ' + JSON.stringify(res));
callback(res);
});
}

View File

@ -13,7 +13,6 @@
* limitations under the License.
*/
import BaseModel from '../../../../../../../../common/utils/src/main/ets/default/model/BaseModel.ets';
import { LogAll } from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets';
import ConfigData from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets';
import LogUtil from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets';
import util from '@ohos.util';
@ -118,7 +117,6 @@ enum GetPropertyType {
FREEZING_TIME = 3
}
@LogAll
export class PasswordModel extends BaseModel {
private TAG = ConfigData.TAG + 'PasswordModel#';
pinAuth: any;
@ -139,6 +137,7 @@ export class PasswordModel extends BaseModel {
u8AToStr(val: Uint8Array): any{
if (!val) {
LogUtil.debug(`${this.TAG}u8AToStr : param is null.`);
return ''
}
var dataString = "";
@ -147,6 +146,7 @@ export class PasswordModel extends BaseModel {
arrNumber.push(val[i]);
}
dataString = JSON.stringify(arrNumber);
LogUtil.debug(`${this.TAG}u8AToStr out.`);
return dataString
}
@ -157,10 +157,12 @@ export class PasswordModel extends BaseModel {
*/
strToU8A(val: string): Uint8Array{
if (!val) {
LogUtil.debug(`${this.TAG}strToU8A : param is null.`);
return new Uint8Array([])
}
var arr = JSON.parse(val);
var tmpUint8Array = new Uint8Array(arr);
LogUtil.debug(`${this.TAG}strToU8A out.`);
return tmpUint8Array
}
@ -171,9 +173,11 @@ export class PasswordModel extends BaseModel {
*/
encodeToU8A(val: string): Uint8Array{
if (!val) {
LogUtil.debug(`${this.TAG}encodeToU8A : param is null.`);
return new Uint8Array([])
}
var textEncoder = new util.TextEncoder();
LogUtil.debug(`${this.TAG}encodeToU8A out.`);
return textEncoder.encode(val);
}
@ -185,31 +189,31 @@ export class PasswordModel extends BaseModel {
try {
result = this.pinAuth.registerInputer({
onGetData: (authSubType, inputData) => {
LogUtil.info(`${this.TAG}registerInputer->onGetData pAuthSubType:${authSubType}`);
LogUtil.info(`${this.TAG}registerInputer->onGetData inAuthSubType:${this.pinSubType}`);
LogUtil.info(`${this.TAG}registerInputer->onGetData inPassword:${this.password}`);
LogUtil.debug(`${this.TAG}registerInputer->onGetData pAuthSubType:${authSubType}`);
LogUtil.debug(`${this.TAG}registerInputer->onGetData inAuthSubType:${this.pinSubType}`);
LogUtil.debug(`${this.TAG}registerInputer->onGetData inPassword:${this.password}`);
let u8aPwd = this.encodeToU8A(this.password);
LogUtil.info(`${this.TAG}registerInputer->onGetData inputData.onSetData : encodeToU8A password:${u8aPwd}`);
LogUtil.debug(`${this.TAG}registerInputer->onGetData inputData.onSetData : encodeToU8A password:${u8aPwd}`);
inputData.onSetData(this.pinSubType, u8aPwd);
}
});
LogUtil.info(`${this.TAG}registerInputer->result:${result}`);
LogUtil.debug(`${this.TAG}registerInputer->result:${result}`);
if(!result){
this.unregisterInputer();
result = this.pinAuth.registerInputer({
onGetData: (authSubType, inputData) => {
LogUtil.info(`${this.TAG}registerInputer->onGetData(retry) pAuthSubType:${authSubType}`);
LogUtil.info(`${this.TAG}registerInputer->onGetData(retry) inAuthSubType:${this.pinSubType}`);
LogUtil.info(`${this.TAG}registerInputer->onGetData(retry) inPassword:${this.password}`);
LogUtil.debug(`${this.TAG}registerInputer->onGetData(retry) pAuthSubType:${authSubType}`);
LogUtil.debug(`${this.TAG}registerInputer->onGetData(retry) inAuthSubType:${this.pinSubType}`);
LogUtil.debug(`${this.TAG}registerInputer->onGetData(retry) inPassword:${this.password}`);
let u8aPwd = this.encodeToU8A(this.password);
LogUtil.info(`${this.TAG}registerInputer->onGetData(retry) inputData.onSetData : encodeToU8A password:${u8aPwd}`);
inputData.onSetData(this.pinSubType, u8aPwd);
}
});
LogUtil.info(`${this.TAG}registerInputer->result(retry):${result}`);
LogUtil.debug(`${this.TAG}registerInputer->result(retry):${result}`);
}
} catch {
LogUtil.info(`${this.TAG}registerInputer failed`);
LogUtil.debug(`${this.TAG}registerInputer failed`);
}
return result;
}
@ -218,10 +222,11 @@ export class PasswordModel extends BaseModel {
* UnregisterInputer
*/
unregisterInputer(): void {
LogUtil.debug(`${this.TAG}unregisterInputer in.`);
try {
this.pinAuth.unregisterInputer();
} catch {
LogUtil.info(`${this.TAG}unregisterInputer failed`);
LogUtil.debug(`${this.TAG}unregisterInputer failed`);
}
}
@ -234,11 +239,11 @@ export class PasswordModel extends BaseModel {
openSession(callback: (challenge: string) => void): void {
try {
this.userIdentityManager.openSession((data) => {
LogUtil.info(`${this.TAG}openSession challenge:${data}`);
LogUtil.debug(`${this.TAG}openSession challenge:${data}`);
callback(this.u8AToStr(data));
})
} catch {
LogUtil.info(`${this.TAG}openSession failed`);
LogUtil.debug(`${this.TAG}openSession failed`);
callback('0');
}
}
@ -249,9 +254,9 @@ export class PasswordModel extends BaseModel {
closeSession(): void {
try {
this.userIdentityManager.closeSession()
LogUtil.info(`${this.TAG}closeSession success`);
LogUtil.debug(`${this.TAG}closeSession success`);
} catch (e) {
LogUtil.info(`${this.TAG}closeSession failed:` + e);
LogUtil.debug(`${this.TAG}closeSession failed:` + e);
}
}
@ -265,9 +270,9 @@ export class PasswordModel extends BaseModel {
try {
let data = this.strToU8A(challenge);
let result = this.userIdentityManager.cancel(data)
LogUtil.info(`${this.TAG}cancel success`);
LogUtil.debug(`${this.TAG}cancel success`);
} catch (e) {
LogUtil.info(`${this.TAG}cancel failed:` + e);
LogUtil.debug(`${this.TAG}cancel failed:` + e);
}
return result;
}
@ -282,6 +287,7 @@ export class PasswordModel extends BaseModel {
* @param onResultCall Get results callback.
*/
addPinCredential(pinSubType: number, password: string, onResultCall: (result: number) => void): void {
LogUtil.debug(`${this.TAG}addPinCredential in.`);
try {
this.pinSubType = pinSubType;
this.password = password;
@ -291,7 +297,7 @@ export class PasswordModel extends BaseModel {
}
let callback = {
onResult: (result, extraInfo) => {
LogUtil.info(`${this.TAG}addPinCredential result:${JSON.stringify(result)}, extraInfo:${JSON.stringify(extraInfo)}`);
LogUtil.debug(`${this.TAG}addPinCredential result:${JSON.stringify(result)}, extraInfo:${JSON.stringify(extraInfo)}`);
onResultCall(result);
}
};
@ -310,6 +316,7 @@ export class PasswordModel extends BaseModel {
updateCredential(pinSubType: number, password: string, token: string, onResultCall: (result: number, extraInfo: {
credentialId?: string;
}) => void): void {
LogUtil.debug(`${this.TAG}updateCredential in.`);
try {
this.pinSubType = pinSubType;
this.password = password;
@ -319,15 +326,15 @@ export class PasswordModel extends BaseModel {
}
let callback = {
onResult: (result, extraInfo) => {
LogUtil.info(`${this.TAG}updateCredential result:${JSON.stringify(result)}`);
LogUtil.info(`${this.TAG}updateCredential extraInfo:${JSON.stringify(extraInfo)}`);
LogUtil.debug(`${this.TAG}updateCredential result:${JSON.stringify(result)}`);
LogUtil.debug(`${this.TAG}updateCredential extraInfo:${JSON.stringify(extraInfo)}`);
let retExtraInfo = {}
onResultCall(result, retExtraInfo);
}
};
this.userIdentityManager.updateCredential(credentialInfo, callback);
} catch (e) {
LogUtil.info(`${this.TAG}updateCredential failed:` + e);
LogUtil.debug(`${this.TAG}updateCredential failed:` + e);
}
}
@ -338,11 +345,12 @@ export class PasswordModel extends BaseModel {
* @param onResultCallback Get results callback.
*/
delAllCredential(token: string, onResultCallback: (result: number, extraInfo: {}) => void): void {
LogUtil.debug(`${this.TAG}delAllCredential in.`);
try{
let callback = {
onResult:(result, extraInfo) => {
LogUtil.info(`${this.TAG}delAllCredential result:${JSON.stringify(result)}`);
LogUtil.info(`${this.TAG}delAllCredential extraInfo:${JSON.stringify(extraInfo)}`);
LogUtil.debug(`${this.TAG}delAllCredential result:${JSON.stringify(result)}`);
LogUtil.debug(`${this.TAG}delAllCredential extraInfo:${JSON.stringify(extraInfo)}`);
let retExtraInfo = {}
onResultCallback(result, retExtraInfo);
}
@ -350,7 +358,7 @@ export class PasswordModel extends BaseModel {
let data = this.strToU8A(token);
this.userIdentityManager.delUser(data, callback);
} catch (e) {
LogUtil.info(`${this.TAG}updateCredential failed:` + e);
LogUtil.debug(`${this.TAG}updateCredential failed:` + e);
}
}
@ -361,12 +369,12 @@ export class PasswordModel extends BaseModel {
*/
hasPinPassword(callback: (havePassword: boolean) => void): void {
this.getPinAuthInfo((data) => {
LogUtil.info(`${this.TAG}hasPinPassword->getPinAuthInfo data:${JSON.stringify(data)}`);
LogUtil.debug(`${this.TAG}hasPinPassword->getPinAuthInfo data:${JSON.stringify(data)}`);
let passwordHasSet = false;
if(data?.length && data.length > 0){
passwordHasSet = true;
}
LogUtil.info(`${this.TAG}hasPinPassword->getPinAuthInfo : before callback: passwordHasSet = ${passwordHasSet}`);
LogUtil.debug(`${this.TAG}hasPinPassword->getPinAuthInfo : before callback: passwordHasSet = ${passwordHasSet}`);
callback(passwordHasSet)
});
}
@ -383,7 +391,7 @@ export class PasswordModel extends BaseModel {
}>) => void): void {
try {
this.userIdentityManager.getAuthInfo(AuthType.PIN, (data) => {
LogUtil.info(`${this.TAG}getPinAuthInfo->getAuthInfo data:${JSON.stringify(data)}`);
LogUtil.debug(`${this.TAG}getPinAuthInfo->getAuthInfo data:${JSON.stringify(data)}`);
let arrCredInfo = [];
try{
for(let i = 0; i < data.length; i++) {
@ -394,13 +402,13 @@ export class PasswordModel extends BaseModel {
arrCredInfo.push(credInfo);
}
} catch(e) {
console.info('faceDemo pin.getAuthInfo error = ' + e);
console.debug('faceDemo pin.getAuthInfo error = ' + e);
}
LogUtil.info(`${this.TAG}getPinAuthInfo->getAuthInfo before callback: data array:${JSON.stringify(arrCredInfo)}`);
LogUtil.debug(`${this.TAG}getPinAuthInfo->getAuthInfo before callback: data array:${JSON.stringify(arrCredInfo)}`);
callback(arrCredInfo);
})
} catch (e) {
LogUtil.info(`${this.TAG}getPinAuthInfo failed:` + e);
LogUtil.error(`${this.TAG}getPinAuthInfo failed:` + e);
}
}
@ -418,43 +426,43 @@ export class PasswordModel extends BaseModel {
}) => void): void {
this.password = password;
try {
LogUtil.info(`${this.TAG}authPin : ( ${challenge}, ${AuthType.PIN}, ${AuthTrustLevel.ATL4} )`);
LogUtil.debug(`${this.TAG}authPin : ( ${challenge}, ${AuthType.PIN}, ${AuthTrustLevel.ATL4} )`);
this.userAuth.auth(this.strToU8A(challenge), AuthType.PIN, AuthTrustLevel.ATL4, {
onResult: (result, extraInfo) => {
try{
LogUtil.info(`${this.TAG}userAuth.auth onResult: challenge = ${challenge}, result:${result}, extraInfo:${extraInfo}`);
LogUtil.debug(`${this.TAG}userAuth.auth onResult: challenge = ${challenge}, result:${result}, extraInfo:${extraInfo}`);
if (result === ResultCode.SUCCESS) {
LogUtil.info(`${this.TAG}userAuth.auth onResult: result = success`);
LogUtil.debug(`${this.TAG}userAuth.auth onResult: result = success`);
} else {
LogUtil.info(`${this.TAG}userAuth.auth onResult: result = failed`);
LogUtil.debug(`${this.TAG}userAuth.auth onResult: result = failed`);
}
let info = {
'token': this.u8AToStr(extraInfo?.token),
'remainTimes': extraInfo.remainTimes,
'freezingTime': extraInfo.freezingTime
}
LogUtil.info(`${this.TAG}userAuth.auth onResult: before callback: info = ${JSON.stringify(info)}`);
LogUtil.debug(`${this.TAG}userAuth.auth onResult: before callback: info = ${JSON.stringify(info)}`);
onResult(result, info)
}
catch(e) {
LogUtil.info(`${this.TAG}userAuth.auth onResult error = ${JSON.stringify(e)}`);
LogUtil.debug(`${this.TAG}userAuth.auth onResult error = ${JSON.stringify(e)}`);
}
},
onAcquireInfo: (acquireModule, acquire, extraInfo) => {
try{
LogUtil.info(this.TAG + 'faceDemo pin.auth onAcquireInfo acquireModule = ' + acquireModule);
console.info(this.TAG + 'faceDemo pin.auth onAcquireInfo acquire = ' + acquire);
LogUtil.info(this.TAG + 'faceDemo pin.auth onAcquireInfo extraInfo = ' + JSON.stringify(extraInfo));
LogUtil.debug(this.TAG + 'faceDemo pin.auth onAcquireInfo acquireModule = ' + acquireModule);
LogUtil.debug(this.TAG + 'faceDemo pin.auth onAcquireInfo acquire = ' + acquire);
LogUtil.debug(this.TAG + 'faceDemo pin.auth onAcquireInfo extraInfo = ' + JSON.stringify(extraInfo));
}
catch(e) {
LogUtil.info(this.TAG + 'faceDemo pin.auth onAcquireInfo error = ' + e);
LogUtil.error(this.TAG + 'faceDemo pin.auth onAcquireInfo error = ' + e);
}
}
})
} catch (e) {
LogUtil.info(`${this.TAG}AuthPin failed:` + e);
LogUtil.error(`${this.TAG}AuthPin failed:` + e);
}
}
@ -474,19 +482,19 @@ export class PasswordModel extends BaseModel {
'authType': AuthType.PIN,
'keys': [GetPropertyType.AUTH_SUB_TYPE, GetPropertyType.REMAIN_TIMES, GetPropertyType.FREEZING_TIME]
}
LogUtil.info(`${this.TAG}getAuthProperty->call api request = ${JSON.stringify(request)}`);
LogUtil.debug(`${this.TAG}getAuthProperty->call api request = ${JSON.stringify(request)}`);
this.userAuth.getProperty(request)
.then((data)=> {
let i = JSON.stringify(data);
console.info('faceDemo promise.getProperty result i = ' + i);
console.info('faceDemo promise.getProperty result = ' + data);
LogUtil.debug('faceDemo promise.getProperty result i = ' + i);
LogUtil.debug('faceDemo promise.getProperty result = ' + data);
LogUtil.info(`${this.TAG}getAuthProperty->getProperty data:${JSON.stringify(data)}`);
LogUtil.debug(`${this.TAG}getAuthProperty->getProperty data:${JSON.stringify(data)}`);
callback(data);
})
.catch(e =>{
LogUtil.info(`${this.TAG}getAuthProperty->getProperty failed:` + e);
LogUtil.debug(`${this.TAG}getAuthProperty->getProperty failed:` + e);
});
} catch (e) {
LogUtil.info(`${this.TAG}getAuthProperty failed:` + e);

View File

@ -79,7 +79,7 @@ struct PasswordCheck {
@Log
getRouterParam() {
param = Router.getParams()
LogUtil.info(this.TAG_PAGE + ' getRouterParam : Router param = ' + JSON.stringify(param))
LogUtil.debug(this.TAG_PAGE + ' getRouterParam : Router param = ' + JSON.stringify(param))
if (!param) {
return;
}
@ -87,7 +87,7 @@ struct PasswordCheck {
this.prevPageUri = param.prevPageUri;
this.pinChallenge = param.pinChallenge;
this.passwordType = param.passwordType;
LogUtil.info(this.TAG_PAGE + ' getRouterParam : from router : pageRequestCode = ' + this.pageRequestCode
LogUtil.debug(this.TAG_PAGE + ' getRouterParam : from router : pageRequestCode = ' + this.pageRequestCode
+ ', prevPageUri = ' + this.prevPageUri
+ ', pinChallenge = ' + this.pinChallenge)
}

View File

@ -79,7 +79,7 @@ struct PasswordRepeat {
@Log
getRouterParam() {
param = Router.getParams()
LogUtil.info(this.TAG_PAGE + 'aboutToAppear : Router param = ' + JSON.stringify(param))
LogUtil.debug(this.TAG_PAGE + 'aboutToAppear : Router param = ' + JSON.stringify(param))
if (!param) {
return;
@ -90,7 +90,7 @@ struct PasswordRepeat {
this.pinToken = param.pinToken;
this.inputPassword = param.inputPassword;
this.passwordType = param.passwordType;
LogUtil.info(this.TAG_PAGE + 'aboutToAppear : from router : pageRequestCode = ' + this.pageRequestCode
LogUtil.debug(this.TAG_PAGE + 'aboutToAppear : from router : pageRequestCode = ' + this.pageRequestCode
+ ', prevPageUri = ' + this.prevPageUri
+ ', pinChallenge = ' + this.pinChallenge
+ ', pinToken = ' + this.pinToken