安全检测Device Security Kit的实现

安全检测Device Security Kit的实现

HarmonyOS
2024-08-07 10:18:02
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
milchcow
import { hilog } from '@kit.PerformanceAnalysisKit';
import { safetyDetect } from '@kit.DeviceSecurityKit';
import { BusinessError} from '@kit.BasicServicesKit';

const TAG: string = '[SafetyDetectModel]';

// 请求设备完整性检测,并处理结果
let req : safetyDetect.SysIntegrityRequest = {
  nonce : 'imEe1PCRcjGkBCAhOCh6ImADztOZ8ygxlWRs' // 从服务器生成的随机的nonce值
};
try {
  hilog.info(0x0000, TAG, 'CheckSysIntegrity begin.');
  const data: safetyDetect.SysIntegrityResponse = await safetyDetect.checkSysIntegrity(req);
  hilog.info(0x0000, TAG, 'Succeeded in checkSysIntegrity: %{public}s', data.result);
} catch (err) {
  let e: BusinessError = err as BusinessError;
  hilog.error(0x0000, TAG, 'CheckSysIntegrity failed: %{public}d %{public}s', e.code, e.message);
}

// 请求URL检测,并处理结果
let req : safetyDetect.UrlCheckRequest = {
  urls : ['https://test1.com']
};
try {
  hilog.info(0x0000, TAG, 'CheckUrlThreat begin.');
  const data: safetyDetect.UrlCheckResponse = await safetyDetect.checkUrlThreat(req);
  hilog.info(0x0000, TAG, 'Succeeded in checkUrlThreat: %{public}s %{public}d', data.results[0].url, data.results[0].threat);
} catch (err) {
  let e: BusinessError = err as BusinessError;
  hilog.error(0x0000, TAG, 'CheckUrlThreat failed: %{public}d %{public}s', e.code, e.message);
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
分享
微博
QQ
微信
回复
2024-08-07 15:11:00


相关问题
HarmonyOS 人脸活体检测Vision Kit
634浏览 • 1回复 待解决
import asset from '@ohos.security.asset'报错
2803浏览 • 1回复 待解决
HarmonyOS 怎么实现线程安全单例类
709浏览 • 1回复 待解决
HarmonyOS 应用卡顿时长检测如何实现
528浏览 • 1回复 待解决
HarmonyOS Location Kit和Map Kit
544浏览 • 1回复 待解决
获取安全地理位置信息接口实现
816浏览 • 1回复 待解决
RSA非对称加密-@hms-security/agoh-crypto
1031浏览 • 1回复 待解决
HarmonyOS Share Kit使用
646浏览 • 1回复 待解决
如何检测相机可用状态?
530浏览 • 0回复 待解决
HarmonyOS自带活体检测
565浏览 • 1回复 待解决