Commit 2f0ef6ba by guojuxing

添加登录校验接口

parent fd8c1e3d
package com.gic.enterprise.ano;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
*
* @ClassName: IgnoreAuth
* @Description: 忽略登录认证的请求
* @author xugh
* @date 2018年5月28日 下午1:45:56
*
*/
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface IgnoreLogin {
}
package com.gic.enterprise.interceptor;
import com.alibaba.fastjson.JSON;
import com.gic.enterprise.ano.IgnoreLogin;
import com.gic.enterprise.base.UserInfo;
import com.gic.enterprise.constants.Constants;
import com.gic.enterprise.context.UserContext;
......@@ -12,6 +13,7 @@ import org.apache.commons.lang.StringUtils;
import org.apache.dubbo.rpc.RpcContext;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
......@@ -45,6 +47,16 @@ public class AuthInterceptor extends HandlerInterceptorAdapter {
RpcContext.getContext().getAttachments().put(Constants.USER_TOKEN, token);
System.out.println(JSON.toJSONString(RpcContext.getContext().getArguments()));
if (!(object.getClass().isAssignableFrom(HandlerMethod.class))) {
return true;
}
HandlerMethod handler = (HandlerMethod) object;
IgnoreLogin ignoreLogin = handler.getMethodAnnotation(IgnoreLogin.class);
if (null != ignoreLogin) {
return true;
}
//获取uri
String uri = request.getRequestURI();
String isControl = request.getParameter("isControl");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment