All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.baidu.haotianjing.sdk.risk.resolver.RiskAnalyzeEndpointResolver Maven / Gradle / Ivy

The newest version!
package com.baidu.haotianjing.sdk.risk.resolver;

import com.baidu.haotianjing.core.client.Client;
import com.baidu.haotianjing.core.client.ClientProfile;
import com.baidu.haotianjing.core.endpoint.EndpointResolver;
import com.baidu.haotianjing.core.exception.RiskSdkException;
import com.baidu.haotianjing.sdk.risk.model.RiskAnalyzeRequest;

import java.util.HashMap;
import java.util.Map;

/**
 * 风控服务集群可用性探测器
 * 需实现发送探测请求的测试请求,测试参数和后端服务平台已约定
 */
public class RiskAnalyzeEndpointResolver extends EndpointResolver {

    public RiskAnalyzeEndpointResolver(ClientProfile clientProfile, Client client) {
        super(clientProfile, client);
    }

    @Override
    public RiskAnalyzeRequest buildDetectRequest(String domain) throws RiskSdkException {
        return DetectRequestBuilder.build(domain);
    }

    static class DetectRequestBuilder {
        protected static RiskAnalyzeRequest build(String domain) throws RiskSdkException {
            RiskAnalyzeRequest riskAnalyzeRequest = new RiskAnalyzeRequest();
            riskAnalyzeRequest.setSc(SC_DEFAULT);
            riskAnalyzeRequest.setTs(String.valueOf(System.currentTimeMillis()));
            riskAnalyzeRequest.setZ(Z_DEFAULT);
            riskAnalyzeRequest.setApp(APP_DEFAULT);
            riskAnalyzeRequest.setAid(AID_DEFAULT);
            riskAnalyzeRequest.setVer(VER_DEFAULT);
            riskAnalyzeRequest.setAppid(APPID_DEFAULT);
            riskAnalyzeRequest.setEv(EV_DEFAULT);
            riskAnalyzeRequest.setIp(IP_DEFAULT);
            riskAnalyzeRequest.setUserid(USERID_DEFAULT);
            riskAnalyzeRequest.setHeader(HEADER_DEFAULT);
            riskAnalyzeRequest.setExtra(EXTRA_DEFAULT);
            riskAnalyzeRequest.setMode(MODE_DEFAULT);
            riskAnalyzeRequest.setDomain(domain);
            return riskAnalyzeRequest;
        }

        /* 业务风控测试请求约定参数值常量 */
        static final String SC_DEFAULT = "test";
        static final String Z_DEFAULT =
                "SILzS_dQhUzAT0vvaly1G4uZ2y6HG4VrLt29kq-IZzvHo06zO1ZkjbVMLTiomkOAhs_sRTKyDfv07vUxudgth1Q";
        static final String APP_DEFAULT = "android";
        static final String VER_DEFAULT = "1.0.0";
        static final String AID_DEFAULT = "9999";
        static final String APPID_DEFAULT = "1";
        static final String EV_DEFAULT = "test_detect";
        static final String USERID_DEFAULT = "haotianjing";
        static final String IP_DEFAULT = "127.0.0.1";
        static final Map HEADER_DEFAULT = new HashMap<>();
        static final Map EXTRA_DEFAULT = new HashMap<>();
        static final String MODE_DEFAULT = "0";
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy