java 怎么实现sign校验
答案:1 悬赏:40 手机版
解决时间 2021-11-24 12:25
- 提问者网友:献世佛
- 2021-11-23 13:45
java 怎么实现sign校验
最佳答案
- 五星知识达人网友:大漠
- 2021-11-23 14:04
@Around("within(@org.springframework.stereotype.Controller *) && @annotation(is)")
public Object validIdentityAndSecure(ProceedingJoinPoint pjp, SecureValid is)
throws Exception {
Object[] args = pjp.getArgs();
//Controller中所有方法的参数,前两个分别为:Request,Response
HttpServletRequest request = (HttpServletRequest) args[0];
// HttpServletResponse response = (HttpServletResponse)args[1];
String appid = request.getParameter("appid");
int app_id = Integer.valueOf(appid);
String signature = request.getParameter("signature");
String clientSignature = request.getParameter("client_signature");
String uri = request.getRequestURI();
String provider = request.getParameter("provider");
if (StringUtils.isEmpty(provider)) {
provider = "passport";
}
// 对appid和signature进行校验
try {
appService.validateAppid(app_id);
boolean isValid = accountService.validSignature(app_id, signature, clientSignature);
if (!isValid) throw new ProblemException(ErrorUtil.ERR_CODE_COM_SING);
} catch (Exception e) {
return handleException(e, provider, uri);
}
// 继续执行接下来的代码
Object retVal = null;
try {
retVal = pjp.proceed();
} catch (Throwable e) {
if (e instanceof Exception) { return handleException((Exception) e, provider, uri); }
}
// 目前的接口走不到这里
return retVal;
}
请采纳!
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯