拦截器 实现签名

/**
* 基于上述的几个问题,我们来通过已下步骤来实现签名加密:
1. 通过分配给APP对应的app_key和app_secret来验证身份
2. 通过将请求的所有参数按照字母先后顺序排序后拼接再MD5加密老保证请求参数不被篡改
3. 请求里携带时间戳参数老保证请求的唯一和过期,重复的请求在指定时间(可配置)内有效
*/

 

logger.error("==> (StringUtils.isBlank(appKeyCode))AppKey未通过验证!请在请求头加入传参数:AppKey:"+appKeyCode);

try {
// String selectName = new String(request.getParameter("selectName").getBytes("iso-8859-1"),"utf-8");//用request获取URL传递的中文参数,防止乱码
response.setCharacterEncoding("utf-8");
PrintWriter out = response.getWriter();
response.setContentType("application/json; charset=utf-8");
out.print("==>有输出 (StringUtils.isBlank(appKeyCode))AppKey未通过验证!请在请求头加入传参数:AppKey:"+appKeyCode);
out.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
logger.error("异常!");
return false;
}

 

https://www.liangzl.com/get-article-detail-12238.html

 

posted @ 2020-02-28 09:12  A汉克先生  阅读(295)  评论(0编辑  收藏  举报