开发者社区> 问答> 正文

IoT固件安全检测的调用方式有哪些?

IoT固件安全检测的调用方式有哪些?

展开
收起
保持可爱mmm 2020-03-27 15:38:16 603 0
1 条回答
写回答
取消 提交回答
  • 引入依赖包

    在您的项目中集成SDK,下载FSS OpenAPI SDK,将src/main/java/com/aliyuncs/fss_api文件夹拷贝到您项目中的对应位置。 引入以下包:

    com.aliyun aliyun-java-sdk-core [version]

    创建接口调用客户端实例

    String regionId ="cn-shanghai"; String domain = "fssapi.cn-shanghai.aliyuncs.com"; String akId = "";//您账号的AccessKeyId String akSecret = "";//您账号的AccessKeySecret DefaultProfile.addEndpoint(regionId, "Fss-api", domain); DefaultProfile profile = DefaultProfile.getProfile(regionId, akId, akSecret); iAcsClient = DefaultAcsClient(profile);

    创建检测任务

    CreateScanTaskRequest createScanTaskRequest = new CreateScanTaskRequest(); createScanTaskRequest.setEmail(" ");//邮箱地址用于接收任务检测完成通知 createScanTaskRequest.setFwId("test-fwId"); createScanTaskRequest.setFwName("固件名称"); createScanTaskRequest.setFwVersion("1.0.0"); createScanTaskRequest.setFwUrl("固件的OSS链接地址"); CreateScanTaskResponse cResponse = iAcsClient.getAcsResponse(createScanTaskRequest); System.out.println("TaskId:"+ cResponse.getData().getTaskId()); System.out.println("Code:"+ cResponse.getCode()); System.out.println("Message:"+ cResponse.getMessage());

    说明 OSS文件的权限应允许:读。 查询任务检测状态

    QueryTaskStatusRequest queryTaskStatusRequest = new QueryTaskStatusRequest(); queryTaskStatusRequest.setTaskId(" ");//创建检测任务时,返回的任务ID QueryTaskStatusResponse response = iAcsClient.getAcsResponse(queryTaskStatusRequest); System.out.println("code:"+response.getCode()); System.out.println("description:"+response.getData().getDescription()); System.out.println("scannedRate:"+response.getData().getScannedRate()); System.out.println("ScanStatus:"+response.getData().getScanStatus());

    查询任务检测结果

    QueryTaskReportRequest queryTaskReportRequest = new QueryTaskReportRequest(); queryTaskReportRequest.setTaskId(" ");//创建检测任务时,返回的任务ID QueryTaskReportResponse qtResponse = iAcsClient.getAcsResponse(queryTaskReportRequest); System.out.println("reportJson:"+qtResponse.getData().getReportJson()); System.out.println("reportUrl:"+qtResponse.getData().getReportUrl());

    删除任务

    DeleteScanTaskRequest deleteScanTaskRequest = new DeleteScanTaskRequest(); deleteScanTaskRequest.setTaskId(" ");//创建检测任务时,返回的任务ID DeleteScanTaskResponse dResponse = iAcsClient.getAcsResponse(deleteScanTaskRequest); System.out.println("删除任务:"+dResponse.getCode()+":"+dResponse.getMessage());

    查询主账号授权

    QueryLicenseRequest queryLicenseRequest = new QueryLicenseRequest(); QueryLicenseResponse qlrResponse = iAcsClient.getAcsResponse(queryLicenseRequest); System.out.println("MaxCount:"+qlrResponse.getData().getMaxCount()); System.out.println("UsedCount:"+qlrResponse.getData().getUsedCount()); System.out.println("scanningCount:" + qlrResponse.getData().getScanningCount());

    2020-03-27 15:39:08
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
阿里云IoT芯片模组合作策略介绍 立即下载
面向多端的AliOS开放策略 立即下载
面向多端的AliOS 开放策略 立即下载