FOTA v.0.9.2.7版本的 MD5 值为:2305fdf4520259063967289da5df0dc6
以下内容为反编译后的 TokenInterceptor.java 源代码,内容仅作参考
package com.incall.apps.lib.tsp.util;
import android.util.Log;
import com.incall.apps.lib.tsp.define.TSPEnviroment;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
public class TokenInterceptor implements Interceptor {
private static final Object LOCK_OBJ;
private static String TAG = TokenInterceptor.class.getName();
private static final Charset UTF8;
private static OkHttpClient mClient;
private static Set<String> whiteUrlSet;
static {
HashSet hashSet = new HashSet(4);
whiteUrlSet = hashSet;
hashSet.add(TSPEnviroment.PRODUCT.SYSTEM_AUTH_URL);
whiteUrlSet.add("https://pre-incall.changan.com.cn/api/hu/2.0/getAccessToken");
whiteUrlSet.add("https://preprod.changan.com.cn/api/hu/2.0/getAccessToken");
whiteUrlSet.add(TSPEnviroment.TEST.SYSTEM_AUTH_URL);
UTF8 = Charset.forName("UTF-8");
LOCK_OBJ = new Object();
}
private static OkHttpClient getClient() {
if (mClient == null) {
mClient = new OkHttpClient.Builder().readTimeout(20L, TimeUnit.SECONDS).connectTimeout(10L, TimeUnit.SECONDS).hostnameVerifier(new HostnameVerifier() {
@Override
public boolean verify(String hostname, SSLSession session) {
return true;
}
}).build();
}
return mClient;
}
@Override
public Response intercept(Interceptor.Chain chain) throws IOException {
Request originRequest = chain.request();
Response originResponse = chain.proceed(chain.request());
if (!originRequest.isHttps()) {
return originResponse;
}
String originReqUrl = originRequest.url().toString();
if (isWhiteUrl(originReqUrl)) {
Log.d(TAG, "intercept: filter white Url :" + originReqUrl);
return originResponse;
}
return originResponse;
}
boolean isWhiteUrl(String reqUrl) {
return !whiteUrlSet.isEmpty() && whiteUrlSet.contains(reqUrl);
}
}