1.实现一个ItsClient 客户端用来实例化调用验证功能
public class ItsClient {
private static final String routing = "/v1.0/sectoken/otp_validation";
// ! HTTPS消息验证地址
private String httpsVerifyUrl = "";
// ! otp ipAddr
private String ipAddr = "";
// ! otp port
private String port = "";
// ! otp appID
private String appID = "";
// ! otp appKey
private String appKey = "";
// ! 错误码
private int errorCode = 0;
// ! 错误消息
private String errorMessage = "";
TreeMap errorCodeTable = new TreeMap() {
{
put(200, "请求成功");
put(400, "输入不合法,比如请求数据不是json");
put(401, "AppID不合法");
put(402, "指纹不合法");
put(410, "非法用户,验证otp时,传入的uid有误,找不到用户");
put(411, "错误的otp");
put(412, "一个周期内动态口令只能使用一次");
put(413, "已达一个周期内最大尝试次数");
put(500, "ITS服务器内部错误");
put(601, "参数错误");
put(602, "sha1签名失败");
put(603, "操作json失败");
put(604, "url访问错误:");
put(605, "较验返回指纹失败");
}
};
public ItsClient() {
this.ipAddr = ItsConf.GetIpAddr();
this.port = ItsConf.GetPort();
this.appID = ItsConf.GetOtpAppID();
this.appKey = ItsConf.GetOtpAppKey();
httpsVerifyUrl = "https://" + this.ipAddr + ':' + this.port + routing;
}
//获取错误信息
public String GetErrorMessage() {
return this.errorMessa