[6.3.0] add func of security down load and add caller

This commit is contained in:
EmArrow
2024-03-06 18:21:31 +08:00
parent fd32c452ed
commit 40cc7b72f0
13 changed files with 174 additions and 196 deletions

View File

@@ -8,7 +8,6 @@ import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager
import com.mogo.eagle.core.function.datacenter.location.MoGoLocationDispatcher
import com.mogo.eagle.core.function.datacenter.v2x.SpeedLimitDispatcher
import com.mogo.eagle.core.function.datacenter.v2x.TrafficLightDispatcher
import com.mogo.eagle.core.function.secure.CertFileManager
@Route(path = MogoServicePaths.PATH_DATA_CENTER_MODULE)
class DataCenterProvider: IDataCenterProvider {
@@ -22,17 +21,12 @@ class DataCenterProvider: IDataCenterProvider {
MoGoLocationDispatcher.initListener()
mContext = context
mContext?.let {
CertFileManager.INSTANCE.init(it)
CallerMsgBoxManager.queryAllMessages(it)
TrafficLightDispatcher.INSTANCE.initServer(it)
SpeedLimitDispatcher.INSTANCE.initLimit(it)
}
}
override fun certificateDownLoad(callback: (String, String) -> Unit) {
CertFileManager.INSTANCE.downloadCert()
}
override fun onDestroy() {
TrafficLightDispatcher.INSTANCE.destroy()
SpeedLimitDispatcher.INSTANCE.destroy()

View File

@@ -1,86 +0,0 @@
package com.mogo.eagle.core.function.secure
import android.content.Context
import com.mogo.commons.debug.DebugConfig
import com.mogo.commons.storage.SharedPrefsMgr
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.deva.chain.ChainConstant
import com.mogo.eagle.core.function.call.cloud.CallerCloudListenerManager
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
import com.zhjt.service.chain.ChainLog
class CertFileManager {
private var context: Context? = null
companion object{
val INSTANCE by lazy(LazyThreadSafetyMode.SYNCHRONIZED){
CertFileManager()
}
}
fun init(context: Context?) {
this.context = context
}
fun downloadCert() {
if (FunctionBuildConfig.isSecure) {
context?.let {
val authStatus =
SharedPrefsMgr.getInstance()
.getBoolean("securityKeyStatus-${DebugConfig.getNetMode()}", false)
if (authStatus) {
// clientConfig设置auth值并带入header //todo 作为使用方invoke出去设置
clientConfig.authPubKey = SharedPrefsMgr.getInstance()
.getString("securityKey-${DebugConfig.getNetMode()}", "")
return@let
}
// 安全校验
try {
PassPortSecret.getInstance().init(sn, it.filesDir.path, object :
IPassportSecret {
@ChainLog(
linkChainLog = ChainConstant.CHAIN_TYPE_STATUS,
linkCode = ChainConstant.CHAIN_SOURCE_CLOUD,
nodeAliasCode = ChainConstant.CHAIN_CODE_CLOUD_PASSPORT_AUTH_OK,
paramIndexes = [0,1]
)
override fun onSuccess(securityKey: String, rootKey: String) {
CallerLogger.d(
"${SceneConstant.M_MAIN}$TAG",
"onSuccess securityKey:$securityKey , thread:${Thread.currentThread().name}"
)
clientConfig.securityKey = securityKey
SharedPrefsMgr.getInstance()
.putString(
"securityKey-${DebugConfig.getNetMode()}",
securityKey
)
SharedPrefsMgr.getInstance()
.putBoolean("securityKeyStatus-${DebugConfig.getNetMode()}", true)
CallerCloudListenerManager.invokeCloudCrtFile(securityKey, rootKey)
}
@ChainLog(
linkChainLog = ChainConstant.CHAIN_TYPE_STATUS,
linkCode = ChainConstant.CHAIN_SOURCE_CLOUD,
nodeAliasCode = ChainConstant.CHAIN_CODE_CLOUD_PASSPORT_AUTH_FAILED,
paramIndexes = [0, 1]
)
override fun onFailed(errorCode: Int, errorMsg: String) {
// logError(
// getPrReason(
// "PassPortSecret-onFailed , errorCode:$errorCode,errorMsg:$errorMsg"
// )
// )
}
})
} catch (e: Exception) {
e.printStackTrace()
}
}
}
}
}