Commit 0f190781 by 霍志良

Merge remote-tracking branch 'origin/4.1.64' into 4.1.64

parents 297404a4 a1ed8f19
package com.yidianling.user.http;
import android.os.Build;
import android.support.annotation.RequiresApi;
import android.util.Log;
import com.ydl.burypointlib.MD5Util;
import com.ydl.ydlcommon.base.BaseApp;
import com.ydl.ydlcommon.base.config.HttpConfig;
import com.yidianling.common.tools.RxAppTool;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* Created by Ykai on 2021/1/11.
*
* 获取加密参数类
*/
public class EncryptionParams {
@RequiresApi(api = Build.VERSION_CODES.N)
public static Map<String,String> getParams(String path){
String timestamp = String.valueOf(System.currentTimeMillis()); //值应该为毫秒数的字符串形式
Map<String,String> map = new HashMap<>();
map.put("timestamp",timestamp);
map.put("path",path);
map.put("version", "1.0.0");
List<String> storedKeys = Arrays.stream(map.keySet()
.toArray(new String[]{}))
.sorted(Comparator.naturalOrder())
.collect(Collectors.toList());
String sign = storedKeys.stream()
// .map(key -> String.join("", key, map.get(key)))
.map(key -> key+map.get(key))
.collect(Collectors.joining()).trim()
.concat("ABA88F2FF7E64A688D2213B20A9B3A3E");
Log.e("sign",sign);
sign = MD5Util.md5(sign).toUpperCase();
// sign = MD5.md5(sign).toUpperCase();
Log.e("sign",sign);
Map<String,String> headersMap = new HashMap<>();
headersMap.put("appKey","20BB42485BD448DE888DD745899C457D");
headersMap.put("sign",sign);
// headersMap.put("sign","2410C6CDC7235DC6318F5CF0FFFAA0B7");
headersMap.put("timestamp",timestamp);
// headersMap.put("timestamp","1610352010360");
return headersMap;
}
}
...@@ -34,8 +34,8 @@ class LoginApiRequestUtil { ...@@ -34,8 +34,8 @@ class LoginApiRequestUtil {
/** /**
* 校验手机号:是否是用户版号码、是否有设置密码、是否被绑定 * 校验手机号:是否是用户版号码、是否有设置密码、是否被绑定
*/ */
fun checkPhoneStatus(map :Map<String,String>,phone: String, countryCode: String?): Observable<BaseResponse<ChcekPhoneResponeBean>> { fun checkPhoneStatus(phone: String, countryCode: String?): Observable<BaseResponse<ChcekPhoneResponeBean>> {
return getUserApi().checkPhoneStatus(map,phone, countryCode!!) return getUserApi().checkPhoneStatus(phone, countryCode!!)
} }
/** /**
......
package com.yidianling.user.http;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class MD5 {
public static final char HEX_DIGITS[] = { '0', '1', '2', '3', '4', '5',
'6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
public static String toHexString(byte[] b) {
StringBuffer sb = new StringBuffer(b.length * 2);
for (int i = 0; i < b.length; i++) {
sb.append(HEX_DIGITS[(b[i] & 0xf0) >>> 4]);
sb.append(HEX_DIGITS[b[i] & 0x0f]);
}
return sb.toString();
}
/**
* md5加密字符串
*
* @param s
* @return
*/
public static String md5(String s) {
try {
MessageDigest digest = MessageDigest.getInstance("MD5");
digest.update(s.getBytes());
byte messageDigest[] = digest.digest();
return toHexString(messageDigest);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return "";
}
}
...@@ -194,7 +194,7 @@ interface UserApi { ...@@ -194,7 +194,7 @@ interface UserApi {
*/ */
@GET("login/v2/phone_detection") @GET("login/v2/phone_detection")
@Headers(YDL_DOMAIN+ YDL_DOMAIN_LOGIN_BASE_URL,LOGIN_USER_PORT) @Headers(YDL_DOMAIN+ YDL_DOMAIN_LOGIN_BASE_URL,LOGIN_USER_PORT)
fun checkPhoneStatus(@HeaderMap headMap:Map<String,String>,@Query("phone") phone: String, @Query("countryCode") countryCode: String): Observable<BaseResponse<ChcekPhoneResponeBean>> fun checkPhoneStatus(@Query("phone") phone: String, @Query("countryCode") countryCode: String): Observable<BaseResponse<ChcekPhoneResponeBean>>
/** /**
* 验证重置密码的短信验证码 * 验证重置密码的短信验证码
......
...@@ -31,7 +31,6 @@ import com.yidianling.user.UserConstants; ...@@ -31,7 +31,6 @@ import com.yidianling.user.UserConstants;
import com.yidianling.user.UserHelper; import com.yidianling.user.UserHelper;
import com.yidianling.user.api.event.RefreshRecentContactListEvent; import com.yidianling.user.api.event.RefreshRecentContactListEvent;
import com.yidianling.user.event.UpdateBindStatusEvent; import com.yidianling.user.event.UpdateBindStatusEvent;
import com.yidianling.user.http.EncryptionParams;
import com.yidianling.user.http.LoginApiRequestUtil; import com.yidianling.user.http.LoginApiRequestUtil;
import com.yidianling.user.http.UserHttp; import com.yidianling.user.http.UserHttp;
import com.yidianling.user.http.UserHttpImpl; import com.yidianling.user.http.UserHttpImpl;
...@@ -118,8 +117,7 @@ public class AccountSettingActivity extends BaseActivity implements View.OnClick ...@@ -118,8 +117,7 @@ public class AccountSettingActivity extends BaseActivity implements View.OnClick
return; return;
} }
showProgressDialog(); showProgressDialog();
Map<String,String> map = EncryptionParams.getParams("/api/api/login/v2/phone_detection"); LoginApiRequestUtil.Companion.checkPhoneStatus(UserHelper.INSTANCE.getUserInfo().getUserInfo().getPhone(), UserHelper.INSTANCE.getUserInfo().getUserInfo().getCountry_code())
LoginApiRequestUtil.Companion.checkPhoneStatus(map,UserHelper.INSTANCE.getUserInfo().getUserInfo().getPhone(), UserHelper.INSTANCE.getUserInfo().getUserInfo().getCountry_code())
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(response -> { .subscribe(response -> {
......
...@@ -44,7 +44,6 @@ import com.yidianling.user.UserHelper ...@@ -44,7 +44,6 @@ import com.yidianling.user.UserHelper
import com.yidianling.user.api.bean.UserResponseBean import com.yidianling.user.api.bean.UserResponseBean
import com.yidianling.user.bean.AliAuthBean import com.yidianling.user.bean.AliAuthBean
import com.yidianling.user.constants.UserBIConstants import com.yidianling.user.constants.UserBIConstants
import com.yidianling.user.http.EncryptionParams
import com.yidianling.user.http.request.BindPhoneJavaParam import com.yidianling.user.http.request.BindPhoneJavaParam
import com.yidianling.user.http.request.PhoneLoginAutoParam import com.yidianling.user.http.request.PhoneLoginAutoParam
import com.yidianling.user.http.response.ChcekPhoneResponeBean import com.yidianling.user.http.response.ChcekPhoneResponeBean
...@@ -396,8 +395,7 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont ...@@ -396,8 +395,7 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
return@setOnClickListener return@setOnClickListener
} }
if (checkPhone()) { if (checkPhone()) {
val map = EncryptionParams.getParams("/api/api/login/v2/phone_detection") mPresenter.checkPhoneStatus(userPhoneNumber!!, countryCode!!, isUmengLoginState)
mPresenter.checkPhoneStatus(map,userPhoneNumber!!, countryCode!!, isUmengLoginState)
} }
} }
......
...@@ -97,7 +97,7 @@ interface ILoginContract { ...@@ -97,7 +97,7 @@ interface ILoginContract {
/** /**
* 校验手机号:是否是用户版号码、是否有设置密码、是否被绑定 * 校验手机号:是否是用户版号码、是否有设置密码、是否被绑定
*/ */
fun checkPhoneStatus(map: Map<String,String>,phone: String, countryCode: String, isBind: Boolean) fun checkPhoneStatus(phone: String, countryCode: String, isBind: Boolean)
/** /**
* 通过一键认证服务登陆 * 通过一键认证服务登陆
...@@ -120,7 +120,7 @@ interface ILoginContract { ...@@ -120,7 +120,7 @@ interface ILoginContract {
/** /**
* 校验手机号:是否是用户版号码、是否有设置密码、是否被绑定 * 校验手机号:是否是用户版号码、是否有设置密码、是否被绑定
*/ */
fun checkPhoneStatus(map: Map<String,String>,phone: String, countryCode: String): Observable<BaseResponse<ChcekPhoneResponeBean>> fun checkPhoneStatus(phone: String, countryCode: String): Observable<BaseResponse<ChcekPhoneResponeBean>>
/** /**
......
...@@ -48,8 +48,8 @@ class LoginModelImpl : ILoginContract.Model { ...@@ -48,8 +48,8 @@ class LoginModelImpl : ILoginContract.Model {
/** /**
* 校验手机号:是否是用户版号码、是否有设置密码、是否被绑定 * 校验手机号:是否是用户版号码、是否有设置密码、是否被绑定
*/ */
override fun checkPhoneStatus(map:Map<String,String>,phone: String, countryCode: String): Observable<BaseResponse<ChcekPhoneResponeBean>> { override fun checkPhoneStatus(phone: String, countryCode: String): Observable<BaseResponse<ChcekPhoneResponeBean>> {
return LoginApiRequestUtil.checkPhoneStatus(map,phone, countryCode) return LoginApiRequestUtil.checkPhoneStatus(phone, countryCode)
} }
/** /**
......
...@@ -131,9 +131,9 @@ class LoginPresenterImpl(view: ILoginContract.View) : BasePresenter<ILoginContra ...@@ -131,9 +131,9 @@ class LoginPresenterImpl(view: ILoginContract.View) : BasePresenter<ILoginContra
*@param isBind 是否是第三方登录成功后的绑定操作 *@param isBind 是否是第三方登录成功后的绑定操作
*/ */
@SuppressLint("CheckResult") @SuppressLint("CheckResult")
override fun checkPhoneStatus(map: Map<String,String>,phone: String, countryCode: String, isBind: Boolean) { override fun checkPhoneStatus(phone: String, countryCode: String, isBind: Boolean) {
mView.showLoading(true) mView.showLoading(true)
mModel.checkPhoneStatus(map,phone, countryCode) mModel.checkPhoneStatus(phone, countryCode)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe({ .subscribe({
......
...@@ -2,11 +2,9 @@ package com.ydl.ydlcommon.base.config; ...@@ -2,11 +2,9 @@ package com.ydl.ydlcommon.base.config;
import android.os.Build; import android.os.Build;
import android.support.annotation.RequiresApi; import android.support.annotation.RequiresApi;
import android.util.Log;
import com.ydl.burypointlib.MD5Util; import com.ydl.burypointlib.MD5Util;
import com.ydl.ydlcommon.base.BaseApp; import com.ydl.ydlcommon.utils.LogUtil;
import com.yidianling.common.tools.RxAppTool;
import java.util.Arrays; import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
...@@ -22,29 +20,23 @@ import java.util.stream.Collectors; ...@@ -22,29 +20,23 @@ import java.util.stream.Collectors;
*/ */
public class EncryptionParams { public class EncryptionParams {
public static String getSign(String path,String timestamp){
@RequiresApi(api = Build.VERSION_CODES.N) // Map<String,String> map = new HashMap<>();
public static Map<String,String> getParams(String path){ // map.put("timestamp",timestamp);
String timestamp = String.valueOf(System.currentTimeMillis()); //值应该为毫秒数的字符串形式 // map.put("path",path);
Map<String,String> map = new HashMap<>(); // map.put("version", "1.0.0");
map.put("timestamp",timestamp); //
map.put("path",path); // List<String> storedKeys = Arrays.stream(map.keySet()
map.put("version", RxAppTool.getAppVersionName(BaseApp.Companion.getApp())); // .toArray(new String[]{}))
// .sorted(Comparator.naturalOrder())
List<String> storedKeys = Arrays.stream(map.keySet() // .collect(Collectors.toList());
.toArray(new String[]{})) // String sign = storedKeys.stream()
.sorted(Comparator.naturalOrder()) // .map(key -> key+map.get(key))
.collect(Collectors.toList()); // .collect(Collectors.joining()).trim()
String sign = storedKeys.stream() // .concat();
.map(key -> String.join("", key, map.get(key))) String sign = ("path"+path+"timestamp"+timestamp+"version1.0.0").concat(HttpConfig.Companion.getENCRYPTION_APP_SECRET());
.collect(Collectors.joining()).trim() LogUtil.e("sign",sign);
.concat(HttpConfig.Companion.getENCRYPTION_APP_SECRET());
sign = MD5Util.md5(sign).toUpperCase(); sign = MD5Util.md5(sign).toUpperCase();
Log.e("sign",sign); return sign;
Map<String,String> headersMap = new HashMap<>();
headersMap.put("appKey",HttpConfig.Companion.getENCRYPTION_APP_KEY());
headersMap.put("sign",sign);
headersMap.put("timestamp",timestamp);
return headersMap;
} }
} }
...@@ -45,7 +45,7 @@ class HttpConfig { ...@@ -45,7 +45,7 @@ class HttpConfig {
private const val AUTHORIZATION_NAME = "Authorization" private const val AUTHORIZATION_NAME = "Authorization"
private const val AUTHORIZATION_JAVA_NAME = "AuthorizationJava" private const val AUTHORIZATION_JAVA_NAME = "AuthorizationJava"
private const val SESSION_KEY = "dc59cf294f37d237c1f06240568ffe21" private const val SESSION_KEY = "dc59cf294f37d237c1f06240568ffe21"
private var DYNAMIC_SESSION_KEY :String= "dc59cf294f37d237c1f06240568ffe21" private var DYNAMIC_SESSION_KEY: String = "dc59cf294f37d237c1f06240568ffe21"
private const val YDL = "Ydl" private const val YDL = "Ydl"
private const val UID = "uid" private const val UID = "uid"
...@@ -56,7 +56,9 @@ class HttpConfig { ...@@ -56,7 +56,9 @@ class HttpConfig {
private const val VERSION = "version" private const val VERSION = "version"
private const val TOKEN = "accessToken" private const val TOKEN = "accessToken"
private val OS_TYPE = "osType"// 1.ios 2.android private val OS_TYPE = "osType"// 1.ios 2.android
private val APP_NAME = "appName"//用于标识 是哪个应用 yidianling:用户版 xinlizixun:心理咨询 haoshi:情感壹点灵 zhuanjia:专家版 private val APP_NAME =
"appName"//用于标识 是哪个应用 yidianling:用户版 xinlizixun:心理咨询 haoshi:情感壹点灵 zhuanjia:专家版
//验证签名失败 //验证签名失败
private val AUTH_INEFFECTIVE_CODE = "-201" private val AUTH_INEFFECTIVE_CODE = "-201"
...@@ -65,38 +67,47 @@ class HttpConfig { ...@@ -65,38 +67,47 @@ class HttpConfig {
* PHP API 地址 * PHP API 地址
*/ */
var PHP_BASE_URL = "" var PHP_BASE_URL = ""
/** /**
* Java API 地址 * Java API 地址
*/ */
var JAVA_BASE_URL = "" var JAVA_BASE_URL = ""
/** /**
* YDL H5 地址 * YDL H5 地址
*/ */
var YDL_H5 = "" var YDL_H5 = ""
/** /**
* H5 地址 * H5 地址
*/ */
var H5_URL = "" var H5_URL = ""
/** /**
* M站 地址 * M站 地址
*/ */
var MH5_URL = "" var MH5_URL = ""
/** /**
* 新 H5 地址 * 新 H5 地址
*/ */
var WEB_URL = "" var WEB_URL = ""
/** /**
* Java API 域名 * Java API 域名
*/ */
var JAVA_URL = "" var JAVA_URL = ""
/** /**
* h5耗时统计 java服务器api地址 * h5耗时统计 java服务器api地址
*/ */
var SERVER_TEMP_JAVA_URL = "" var SERVER_TEMP_JAVA_URL = ""
/** /**
* Java 投放系统 地址 * Java 投放系统 地址
*/ */
var JAVA_CAST_URL = "" var JAVA_CAST_URL = ""
/** /**
* 行为数据 地址 * 行为数据 地址
*/ */
...@@ -124,13 +135,17 @@ class HttpConfig { ...@@ -124,13 +135,17 @@ class HttpConfig {
val builder = OkHttpConfig.Builder(context); val builder = OkHttpConfig.Builder(context);
if (appDebug) { if (appDebug) {
builder.setNetInterceptor(StethoInterceptor()) builder.setNetInterceptor(StethoInterceptor())
}else{ } else {
//使用预埋证书,校验服务端证书 //使用预埋证书,校验服务端证书
builder.setSslSocketFactory(cerInputStream) builder.setSslSocketFactory(cerInputStream)
} }
return builder return builder
.setInterceptor(commonParams(),requestHead(appName)) .setInterceptor(
commonParams(),
requestHead(appName),
addEncryptionHeaderParamsInterceptor()
)
.setRequestHandler(getRequestHandler()) .setRequestHandler(getRequestHandler())
.setReadTimeout(15) .setReadTimeout(15)
.setWriteTimeout(15) .setWriteTimeout(15)
...@@ -142,14 +157,37 @@ class HttpConfig { ...@@ -142,14 +157,37 @@ class HttpConfig {
/** /**
* 开启动态网关,请求头某些参数加密 * 开启动态网关,请求头某些参数加密
*/ */
// private fun addEncryptionHeaderParams():Interceptor{ private fun addEncryptionHeaderParamsInterceptor(): Interceptor {
// return Interceptor { return Interceptor {
// var request = it.request() if (isEncryption) {
// } val timestamp = System.currentTimeMillis().toString() //值应该为毫秒数的字符串形式
// } var path = HttpUrl.parse(JAVA_LOGIN_BASE_URL)?.encodedPath()
when {
private fun getRequestHandler():RequestHandler{ it.request().url().encodedPath().startsWith("/v3") -> {
return object :RequestHandler{ path += it.request().url().encodedPath().substring(4)
}
it.request().url().encodedPath().startsWith("/api") -> {
path += it.request().url().encodedPath().substring(5)
}
else -> {
path+it.request().url().encodedPath()
}
}
val sign = EncryptionParams.getSign(path, timestamp)
val request = it.request().newBuilder()
.addHeader("appKey", ENCRYPTION_APP_KEY)
.addHeader("sign", sign)
.addHeader("timestamp", timestamp)
.build()
it.proceed(request)
}else{
it.proceed(it.request())
}
}
}
private fun getRequestHandler(): RequestHandler {
return object : RequestHandler {
override fun onHttpResultResponse( override fun onHttpResultResponse(
httpResult: String, httpResult: String,
chain: Interceptor.Chain, chain: Interceptor.Chain,
...@@ -157,14 +195,17 @@ class HttpConfig { ...@@ -157,14 +195,17 @@ class HttpConfig {
): Response { ): Response {
try { try {
val gson = GsonProvider.getGson() val gson = GsonProvider.getGson()
val resultData= gson.fromJson(httpResult, BaseAPIResponse::class.java) val resultData = gson.fromJson(httpResult, BaseAPIResponse::class.java)
when (resultData.code) { when (resultData.code) {
AUTH_INEFFECTIVE_CODE -> { AUTH_INEFFECTIVE_CODE -> {
//签证签名失败 //签证签名失败
ToastUtil.toastShort(resultData.msg) ToastUtil.toastShort(resultData.msg)
//更新动态密钥 //更新动态密钥
if (resultData.data!=null){ if (resultData.data != null) {
var authBean = gson.fromJson<AuthBean>(gson.toJson(resultData.data),AuthBean::class.java) var authBean = gson.fromJson<AuthBean>(
gson.toJson(resultData.data),
AuthBean::class.java
)
DYNAMIC_SESSION_KEY = authBean?.appKey.toString() DYNAMIC_SESSION_KEY = authBean?.appKey.toString()
} }
} }
...@@ -187,7 +228,7 @@ class HttpConfig { ...@@ -187,7 +228,7 @@ class HttpConfig {
return Interceptor { return Interceptor {
var request = it.request() var request = it.request()
//如果是POST请求,则再在Body中增加公共参数 //如果是POST请求,则再在Body中增加公共参数
if ("POST"==request.method()){ if ("POST" == request.method()) {
var body = request.body() var body = request.body()
if (body is FormBody) { if (body is FormBody) {
...@@ -206,22 +247,21 @@ class HttpConfig { ...@@ -206,22 +247,21 @@ class HttpConfig {
val paramsValue = getCommonParams(paramsName) val paramsValue = getCommonParams(paramsName)
paramsValue.forEach { entry-> paramsValue.forEach { entry ->
bodyBuild.addEncoded(entry.key,entry.value) bodyBuild.addEncoded(entry.key, entry.value)
} }
body = bodyBuild.build() body = bodyBuild.build()
} }
it.proceed(request.newBuilder().post(body!!).build()) it.proceed(request.newBuilder().post(body!!).build())
} else if ("GET"==request.method()){ } else if ("GET" == request.method()) {
val url = request.url() val url = request.url()
val newBuilder = url.newBuilder() val newBuilder = url.newBuilder()
val paramsName = url.queryParameterNames() val paramsName = url.queryParameterNames()
val paramsValue = getCommonParams(paramsName) val paramsValue = getCommonParams(paramsName)
paramsValue.forEach { entry-> paramsValue.forEach { entry ->
newBuilder. newBuilder.addQueryParameter(entry.key, entry.value)
addQueryParameter(entry.key,entry.value)
} }
it.proceed(request.newBuilder().url(newBuilder.build()).build()) it.proceed(request.newBuilder().url(newBuilder.build()).build())
...@@ -279,7 +319,7 @@ class HttpConfig { ...@@ -279,7 +319,7 @@ class HttpConfig {
val request = it.request() val request = it.request()
val paramsString = StringBuilder() val paramsString = StringBuilder()
val params = ArrayList<Param>() val params = ArrayList<Param>()
if ("POST"==request.method()){ if ("POST" == request.method()) {
val body = request.body() val body = request.body()
if (body is FormBody) { if (body is FormBody) {
(0 until body.size()).mapTo(destination = params) { (0 until body.size()).mapTo(destination = params) {
...@@ -294,7 +334,9 @@ class HttpConfig { ...@@ -294,7 +334,9 @@ class HttpConfig {
if ("text/plain; charset=utf-8" == part.body().contentType()!!.toString()) { if ("text/plain; charset=utf-8" == part.body().contentType()!!.toString()) {
val headerStr = part.headers()!!.toString() val headerStr = part.headers()!!.toString()
val name = val name =
headerStr.split("\"\\n".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()[0].split("=\"".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()[1] headerStr.split("\"\\n".toRegex()).dropLastWhile { it.isEmpty() }
.toTypedArray()[0].split("=\"".toRegex())
.dropLastWhile { it.isEmpty() }.toTypedArray()[1]
val buffer = Buffer() val buffer = Buffer()
part.body().writeTo(buffer as BufferedSink) part.body().writeTo(buffer as BufferedSink)
val value = buffer.readUtf8() val value = buffer.readUtf8()
...@@ -302,11 +344,11 @@ class HttpConfig { ...@@ -302,11 +344,11 @@ class HttpConfig {
} }
} }
} }
} else if ("GET"==request.method()){ } else if ("GET" == request.method()) {
val url = request.url() val url = request.url()
val queryParameterNames = url.queryParameterNames() val queryParameterNames = url.queryParameterNames()
queryParameterNames.forEach { string -> queryParameterNames.forEach { string ->
params.add(Param(string, url.queryParameter(string)?:"")) params.add(Param(string, url.queryParameter(string) ?: ""))
} }
} }
...@@ -329,7 +371,7 @@ class HttpConfig { ...@@ -329,7 +371,7 @@ class HttpConfig {
val builder = it.request() val builder = it.request()
.newBuilder() .newBuilder()
.header(AUTHORIZATION_NAME, oldAuth) .header(AUTHORIZATION_NAME, oldAuth)
.header(AUTHORIZATION_JAVA_NAME, newAuth ) .header(AUTHORIZATION_JAVA_NAME, newAuth)
.addHeader("Connection", "close") .addHeader("Connection", "close")
.addHeader(FFROM, PlatformDataManager.getRam().getChannelName()) .addHeader(FFROM, PlatformDataManager.getRam().getChannelName())
.addHeader(IS_FROM_APP, "1") .addHeader(IS_FROM_APP, "1")
...@@ -353,13 +395,17 @@ class HttpConfig { ...@@ -353,13 +395,17 @@ class HttpConfig {
private fun getOldAuth(paramsString: StringBuilder): String { private fun getOldAuth(paramsString: StringBuilder): String {
return "$YDL ${EncryptUtils.encryptMD5ToString( return "$YDL ${EncryptUtils.encryptMD5ToString(
paramsString.toString()+ SESSION_KEY paramsString.toString() + SESSION_KEY
)}" )}"
} }
private fun getNewAuth(paramsString: StringBuilder): String { private fun getNewAuth(paramsString: StringBuilder): String {
//md5({静态秘钥} + {参数} + md5{动态秘钥(明文)} //md5({静态秘钥} + {参数} + md5{动态秘钥(明文)}
return "$YDL ${EncryptUtils.encryptMD5ToString(SESSION_KEY+ paramsString.toString()+EncryptUtils.encryptMD5ToString(DYNAMIC_SESSION_KEY))}" return "$YDL ${EncryptUtils.encryptMD5ToString(
SESSION_KEY + paramsString.toString() + EncryptUtils.encryptMD5ToString(
DYNAMIC_SESSION_KEY
)
)}"
} }
//初始化网络环境 //初始化网络环境
...@@ -394,12 +440,12 @@ class HttpConfig { ...@@ -394,12 +440,12 @@ class HttpConfig {
} }
@SuppressLint("CheckResult") @SuppressLint("CheckResult")
fun initAuth(){ fun initAuth() {
ApiRequestUtil.getDynamicToken() ApiRequestUtil.getDynamicToken()
.compose(RxUtils.applySchedulers()) .compose(RxUtils.applySchedulers())
.compose(RxUtils.resultJavaData()) .compose(RxUtils.resultJavaData())
.subscribe({ .subscribe({
if (!TextUtils.isEmpty(it.appKey)){ if (!TextUtils.isEmpty(it.appKey)) {
DYNAMIC_SESSION_KEY = it?.appKey.toString() DYNAMIC_SESSION_KEY = it?.appKey.toString()
} }
}) { }) {
...@@ -408,14 +454,14 @@ class HttpConfig { ...@@ -408,14 +454,14 @@ class HttpConfig {
} }
@SuppressLint("CheckResult") @SuppressLint("CheckResult")
fun initSocketConfig(finallyAction:Action) { fun initSocketConfig(finallyAction: Action) {
ApiRequestUtil.getJavaGlobalInfo() ApiRequestUtil.getJavaGlobalInfo()
.compose(RxUtils.applySchedulers()) .compose(RxUtils.applySchedulers())
.compose(RxUtils.resultJavaData()) .compose(RxUtils.resultJavaData())
.doFinally(finallyAction) .doFinally(finallyAction)
.subscribe({ .subscribe({
if (it!=null&&!TextUtils.isEmpty(it.ip)){ if (it != null && !TextUtils.isEmpty(it.ip)) {
YdlPushAgent.setDebugAdree(it.ip,it.port.toInt()) YdlPushAgent.setDebugAdree(it.ip, it.port.toInt())
} }
}) { }) {
LogUtil.i("HttpConfig", it.toString()) LogUtil.i("HttpConfig", it.toString())
...@@ -427,8 +473,8 @@ class HttpConfig { ...@@ -427,8 +473,8 @@ class HttpConfig {
* *
*/ */
@SuppressLint("CheckResult") @SuppressLint("CheckResult")
fun initLoginBaseUrlConfig(urlMap :HashMap<String,String>){ fun initLoginBaseUrlConfig(urlMap: HashMap<String, String>) {
val map = HashMap<String,Any>() val map = HashMap<String, Any>()
val list = ArrayList<GatewayRequestDTO>() val list = ArrayList<GatewayRequestDTO>()
val gatewayRequestDTO = GatewayRequestDTO("login") val gatewayRequestDTO = GatewayRequestDTO("login")
list.add(gatewayRequestDTO) list.add(gatewayRequestDTO)
...@@ -437,10 +483,10 @@ class HttpConfig { ...@@ -437,10 +483,10 @@ class HttpConfig {
.compose(RxUtils.applySchedulers()) .compose(RxUtils.applySchedulers())
.compose(RxUtils.resultJavaData()) .compose(RxUtils.resultJavaData())
.subscribe({ .subscribe({
if (it.baseUrlGatewayDTOList.isNotEmpty()){ if (it.baseUrlGatewayDTOList.isNotEmpty()) {
isEncryption = it.baseUrlGatewayDTOList[0].goGateway isEncryption = it.baseUrlGatewayDTOList[0].goGateway
if (isEncryption){ if (isEncryption) {
JAVA_LOGIN_BASE_URL = it.baseUrlGatewayDTOList[0].baseUrl+"/" JAVA_LOGIN_BASE_URL = it.baseUrlGatewayDTOList[0].baseUrl + "/"
urlMap[YDL_DOMAIN_LOGIN_BASE_URL] = JAVA_LOGIN_BASE_URL urlMap[YDL_DOMAIN_LOGIN_BASE_URL] = JAVA_LOGIN_BASE_URL
ApiFactory.getInstance().setMultipleUrlMap(urlMap) ApiFactory.getInstance().setMultipleUrlMap(urlMap)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment