[3.4.0] add auth key sdk in httpdnsStartUp, funbiz add limit in speed limit ,plus fix bugs
This commit is contained in:
@@ -124,7 +124,7 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
|
||||
// 使用中台长链接
|
||||
clientConfig.isUseOriginSocket = true
|
||||
// 设置是否输出网络日志
|
||||
clientConfig.isShowNetDebugLog = false
|
||||
clientConfig.isShowNetDebugLog = true //todo test
|
||||
|
||||
clientConfig.passportUrl = FunctionBuildConfig.urlJson.passportUrl
|
||||
clientConfig.socketBaseUrl = FunctionBuildConfig.urlJson.socketBaseUrl
|
||||
@@ -250,52 +250,55 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
|
||||
mStartParams["app_identity_mode"] = FunctionBuildConfig.appIdentityMode
|
||||
MogoAnalyticUtils.track("app_start_time", mStartParams)
|
||||
|
||||
context?.let {
|
||||
val authStatus = SharedPrefsMgr.getInstance(it).getBoolean("passportAuth", false)
|
||||
if (authStatus) {
|
||||
// clientConfig设置auth值,并带入header
|
||||
clientConfig.authPubKey = SharedPrefsMgr.getInstance(it)
|
||||
.getString("passportAuthKey", "")
|
||||
return@let
|
||||
}
|
||||
// 安全校验
|
||||
try {
|
||||
PassPortSecret.getInstance().init(sn, it.filesDir.path, object :
|
||||
IPassportSecret {
|
||||
if (FunctionBuildConfig.isSecure) {
|
||||
context?.let {
|
||||
val authStatus =
|
||||
SharedPrefsMgr.getInstance(it).getBoolean("passportAuth-${DebugConfig.getNetMode()}", false)
|
||||
if (authStatus) {
|
||||
// clientConfig设置auth值,并带入header
|
||||
clientConfig.authPubKey = SharedPrefsMgr.getInstance(it)
|
||||
.getString("passportAuthKey-${DebugConfig.getNetMode()}", "")
|
||||
return@let
|
||||
}
|
||||
// 安全校验
|
||||
try {
|
||||
PassPortSecret.getInstance().init(sn, it.filesDir.path, object :
|
||||
IPassportSecret {
|
||||
|
||||
@ChainLog(
|
||||
linkChainLog = CHAIN_TYPE_INIT_STATUS,
|
||||
linkCode = CHAIN_SOURCE_CLOUD,
|
||||
nodeAliasCode = CHAIN_CODE_CLOUD_PASSPORT_AUTH_OK,
|
||||
paramIndexes = [0]
|
||||
)
|
||||
override fun onSuccess(secretKey: String) {
|
||||
CallerLogger.d(
|
||||
"$M_MAIN$TAG",
|
||||
"onSuccess secretKey:$secretKey , thread:${Thread.currentThread().name}"
|
||||
@ChainLog(
|
||||
linkChainLog = CHAIN_TYPE_INIT_STATUS,
|
||||
linkCode = CHAIN_SOURCE_CLOUD,
|
||||
nodeAliasCode = CHAIN_CODE_CLOUD_PASSPORT_AUTH_OK,
|
||||
paramIndexes = [0]
|
||||
)
|
||||
clientConfig.authPubKey = secretKey
|
||||
SharedPrefsMgr.getInstance(it).putString("passportAuthKey", secretKey)
|
||||
SharedPrefsMgr.getInstance(it).putBoolean("passportAuth", true)
|
||||
}
|
||||
|
||||
@ChainLog(
|
||||
linkChainLog = CHAIN_TYPE_INIT_STATUS,
|
||||
linkCode = CHAIN_SOURCE_CLOUD,
|
||||
nodeAliasCode = CHAIN_CODE_CLOUD_PASSPORT_AUTH_FAILED,
|
||||
paramIndexes = [0, 1]
|
||||
)
|
||||
override fun onFailed(errorCode: Int, errorMsg: String) {
|
||||
logError(
|
||||
getPrReason(
|
||||
"PassPortSecret-onFailed , errorCode:$errorCode" +
|
||||
",errorMsg:$errorMsg
|
||||
override fun onSuccess(secretKey: String) {
|
||||
CallerLogger.d(
|
||||
"$M_MAIN$TAG",
|
||||
"onSuccess secretKey:$secretKey , thread:${Thread.currentThread().name}"
|
||||
)
|
||||
clientConfig.authPubKey = secretKey
|
||||
SharedPrefsMgr.getInstance(it)
|
||||
.putString("passportAuthKey-${DebugConfig.getNetMode()}", secretKey)
|
||||
SharedPrefsMgr.getInstance(it).putBoolean("passportAuth-${DebugConfig.getNetMode()}", true)
|
||||
}
|
||||
|
||||
@ChainLog(
|
||||
linkChainLog = CHAIN_TYPE_INIT_STATUS,
|
||||
linkCode = CHAIN_SOURCE_CLOUD,
|
||||
nodeAliasCode = CHAIN_CODE_CLOUD_PASSPORT_AUTH_FAILED,
|
||||
paramIndexes = [0, 1]
|
||||
)
|
||||
}
|
||||
})
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
override fun onFailed(errorCode: Int, errorMsg: String) {
|
||||
logError(
|
||||
getPrReason(
|
||||
"PassPortSecret-onFailed , errorCode:$errorCode,errorMsg:$errorMsg"
|
||||
)
|
||||
)
|
||||
}
|
||||
})
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,27 @@
|
||||
package com.mogo.eagle.core.function.startup.stageone.secret;
|
||||
|
||||
import android.util.Base64;
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.eagle.core.data.app.UrlConfig;
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.Utils;
|
||||
import com.zhidao.utils.digest.Base64Utils;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import constant.ErrorCode;
|
||||
import domain.Passport;
|
||||
import service.PassportService;
|
||||
|
||||
public class PassPortSecret {
|
||||
|
||||
// # 云端正式环境
|
||||
// # passport_active=https://mygateway.zhidaozhixing.com/openapi/security/deviceCert/active
|
||||
// # passport_refresh=https://mygateway.zhidaozhixing.com/openapi/security/deviceCert/refresh
|
||||
// # passport_auth=https://mygateway.zhidaozhixing.com/openapi/security/deviceCert/auth
|
||||
|
||||
private PassPortSecret() {
|
||||
}
|
||||
|
||||
@@ -33,16 +49,23 @@ public class PassPortSecret {
|
||||
domain.R<String> res = passportService.deviceActive(passport);
|
||||
if (res.getCode() != ErrorCode.OK.getCode()) {
|
||||
secretCB.onFailed(res.getCode(), res.getMsg());
|
||||
}else{
|
||||
String secretKey = res.getData();
|
||||
try {
|
||||
String result = new String(Base64.encode(secretKey.getBytes("utf-8"), Base64.NO_WRAP),"utf-8");
|
||||
secretCB.onSuccess(result);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
secretCB.onFailed(5000,"url encode error :" + secretKey);
|
||||
}
|
||||
|
||||
}
|
||||
String secretKey = res.getData();
|
||||
secretCB.onSuccess(secretKey);
|
||||
}
|
||||
|
||||
private static domain.R<Passport> initLow(PassportService passportService, String deviceId, String path) {
|
||||
return passportService.init(Passport.builder().type(1)
|
||||
.deviceActive("http://gateway.ee-private-dev1.myghost.zhidaoauto.com/openapi/security/deviceCert/active")
|
||||
.deviceRefresh("http://gateway.ee-private-dev1.myghost.zhidaoauto.com/openapi/security/deviceCert/refresh")
|
||||
.deviceAuth("http://gateway.ee-private-dev1.myghost.zhidaoauto.com/openapi/security/deviceCert/auth")
|
||||
.deviceActive(FunctionBuildConfig.urlJson.getSecureActive())
|
||||
.deviceRefresh(FunctionBuildConfig.urlJson.getSecureRefresh())
|
||||
.deviceAuth(FunctionBuildConfig.urlJson.getSecureAuth())
|
||||
.productId("10019")
|
||||
.productSecret("5cbcdc2240fa4104a70f28cdbe5ca69b")
|
||||
.sn(deviceId)
|
||||
|
||||
Reference in New Issue
Block a user