| | |
| | | package com.java110.service.filter; |
| | | |
| | | import com.auth0.jwt.JWT; |
| | | import com.auth0.jwt.JWTVerifier; |
| | | import com.auth0.jwt.algorithms.Algorithm; |
| | | import com.auth0.jwt.exceptions.JWTVerificationException; |
| | | import com.auth0.jwt.interfaces.Claim; |
| | | import com.auth0.jwt.interfaces.DecodedJWT; |
| | | import com.java110.common.constant.CommonConstant; |
| | | import com.java110.common.constant.ResponseConstant; |
| | | import com.java110.common.exception.FilterException; |
| | | import com.java110.common.factory.AuthenticationFactory; |
| | | import com.java110.common.factory.DataTransactionFactory; |
| | | import com.java110.core.factory.AuthenticationFactory; |
| | | import com.java110.core.factory.DataTransactionFactory; |
| | | import com.java110.common.util.StringUtil; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.web.filter.GenericFilterBean; |
| | | |
| | | import javax.servlet.FilterChain; |
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.io.PrintWriter; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * Created by wuxw on 2018/5/2. |
| | | */ |
| | | public class JwtFilter extends GenericFilterBean { |
| | | |
| | | private final static Logger logger = LoggerFactory.getLogger(JwtFilter.class); |
| | | |
| | | |
| | | public void doFilter(final ServletRequest req, final ServletResponse res, final FilterChain chain) |
| | | throws IOException, ServletException { |
| | |
| | | DataTransactionFactory.pageResponseJson(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR,e.getMessage(),null), |
| | | "UTF-8"); |
| | | }else{ |
| | | response.sendRedirect("/login?code="+e.getResult().getCode()+"&msg="+e.getResult().getMsg()); |
| | | response.sendRedirect("/login"); |
| | | } |
| | | |
| | | }catch (Exception e){ |
| | | response.sendRedirect("/login?code="+ResponseConstant.RESULT_CODE_INNER_ERROR+"&msg=鉴权失败"); |
| | | response.sendRedirect("/login"); |
| | | } |
| | | } |
| | | |