/**
* 封装jssdk 验证参数 权限验证配置
*
* @return
* @throws QQConnectException
* @throws IOException
*/
public String jsSDKPackage() throws IOException, QQConnectException {
logger.error("封装jssdk 验证参数 start ================");
//需要用户自己获取登陆用的openid.
String openid = "";
// 1 获取基础 token
Token baseToken = new Token();
Token token = null;
token = CommonUtil.getToken(openid, ConfigUtil.APPID, ConfigUtil.APP_SECRECT, getRequest());
String tk = baseToken.getAccessToken();
Token jsapi_ticket = CommonUtil.getJsapi_ticket(tk, getRequest());
String jsapi_t = "";
jsapi_t = jsapi_ticket.getAccessToken();
String json = "";
SortedMap
String url2 = CommonUtil.getRequestURL(getRequest());
String url = url2.split("jssdkurl=")[1];
params.put("url", url);
logger.error("url===" + url);
timestamp = Long.toString(new Date().getTime()).substring(0, 10);
String noncestr = PayCommonUtil.CreateNoncestr();
params.put("timestamp", timestamp);
logger.error("timestamp===" + timestamp);
params.put("noncestr", noncestr);
logger.error("noncestr===" + noncestr);
params.put("jsapi_ticket", jsapi_t);
logger.error("jsapi_ticket===" + jsapi_t);
String[] str = { "url", "timestamp", "noncestr", "jsapi_ticket" };
Arrays.sort(str); // 字典序排序
// 获取签名
signature = PayCommonUtil.createSignature(str, params);
params.put("signature", signature);
logger.error("signature===" + signature);
params.put("appid", ConfigUtil.APPID);
logger.error("appid===" + ConfigUtil.APPID);
params.put("openid", openid);
logger.error("openid===" + openid);
// 转换为json 字符串
json = JSONObject.fromObject(params).toString();
logger.error("jsSDKjson===" + json);
// getRequest().setAttribute("jsSDKjson", json);
// 字符串输出
super.write(json);
logger.error("封装jssdk 验证参数 end ================");
return null;
}