| | |
| | | import com.java110.utils.exception.FilterException; |
| | | import com.java110.utils.util.StringUtil; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import com.java110.core.log.LoggerFactory; |
| | | |
| | | import javax.servlet.*; |
| | | import javax.servlet.http.Cookie; |
| | |
| | | */ |
| | | private String getToken(HttpServletRequest request) throws FilterException { |
| | | String token = ""; |
| | | for (Cookie cookie : request.getCookies()) { |
| | | if (CommonConstant.COOKIE_AUTH_TOKEN.equals(cookie.getName())) { |
| | | token = cookie.getValue(); |
| | | if (request.getCookies() != null && request.getCookies().length > 0) { |
| | | for (Cookie cookie : request.getCookies()) { |
| | | if (CommonConstant.COOKIE_AUTH_TOKEN.equals(cookie.getName())) { |
| | | token = cookie.getValue(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | String authorization = request.getHeader("Authorization"); |
| | | |
| | | if(StringUtil.isEmpty(token) && !StringUtil.isEmpty(authorization)){ |
| | | token = authorization.substring("Bearer ".length()); |
| | | } |
| | | |
| | | if (StringUtil.isNullOrNone(token)) { |
| | | throw new FilterException(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR, "您还没有登录,请先登录"); |
| | | } |