package com.jeeplus.modules.esignature.kinggridserver;

import com.jeeplus.modules.esignature.utils.HttpRequest;
import com.jeeplus.modules.esignature.utils.MD5;

public class KingGridServer {
	/**
	 * 信签服务器地址
	 */
	//public static final String SERVER_URL = "http://192.168.0.55:8081/tosignserver";
	public static final String SERVER_URL = "http://171.34.78.70:8081/tosignserver";
	/**
	 * 信签服务器对接应用ID
	 */
	public static final String APP_ID = "king";
	/**
	 * 信签服务器对接应用密钥
	 */
	public static final String APP_SECURITY = "e3f55030d473095d";
	
	/**
	 * 测试签署用户编码
	 */
	//public static final String SIGNER_CODE= "lidongzhang";
	public static final String SIGNER_CODE= "fgy201804101542";

	/**
	 * 模板创建合同使用的模板编码
	 */
	public static final String CONTRACT_TPL_CODE= "testTemplate";

	/**
	 * 生成信签请求操作对象
	 * @param url
	 * @return
	 */
	public static HttpRequest createHttpRequest(String url){
		String requestUrl;
		if(SERVER_URL.endsWith("/")){
			requestUrl =  SERVER_URL.substring(0, SERVER_URL.length()-1)+url;
		}else{
			requestUrl = SERVER_URL+url;
		}
		HttpRequest httpRequest = new HttpRequest(requestUrl);
		
		/**
		 * 如果是云服务，需要添加应用id到header
		 * 如果是私有云，可以不用设置
		 */
		httpRequest.addHeader("app_id", APP_ID);
		String  time = System.currentTimeMillis()+"";
		httpRequest.addHeader("time", time);
		httpRequest.addHeader("sign", MD5.toMD5(APP_ID+"."+time+'.'+APP_SECURITY));
		
		return httpRequest;
		
	}
	
	
}
