文件名从 se-system/src/main/java/com/terra/system/helper/WebHelper.java 修改 |
| | |
| | | package com.terra.system.helper; |
| | | package com.terra.common.helper; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.terra.common.entity.all.HttpStatus; |
| | | import com.terra.common.entity.all.ResponseMsg; |
| | | import com.terra.system.entity.all.SettingData; |
| | | import com.terra.common.entity.all.SettingData; |
| | | import com.terra.common.entity.all.StaticData; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | |
| | | */ |
| | | public static String getIpAddress(HttpServletRequest request) { |
| | | String ip = request.getHeader("X-Forwarded-For"); |
| | | if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) { |
| | | if (ip == null || ip.isEmpty() || UNKNOWN.equalsIgnoreCase(ip)) { |
| | | ip = request.getHeader("Proxy-Client-IP"); |
| | | } |
| | | if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) { |
| | | if (ip == null || ip.isEmpty() || UNKNOWN.equalsIgnoreCase(ip)) { |
| | | ip = request.getHeader("WL-Proxy-Client-IP"); |
| | | } |
| | | if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) { |
| | | if (ip == null || ip.isEmpty() || UNKNOWN.equalsIgnoreCase(ip)) { |
| | | ip = request.getHeader("HTTP_X_FORWARDED_FOR"); |
| | | } |
| | | if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) { |
| | | if (ip == null || ip.isEmpty() || UNKNOWN.equalsIgnoreCase(ip)) { |
| | | ip = request.getHeader("HTTP_X_FORWARDED"); |
| | | } |
| | | if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) { |
| | | if (ip == null || ip.isEmpty() || UNKNOWN.equalsIgnoreCase(ip)) { |
| | | ip = request.getHeader("HTTP_X_CLUSTER_CLIENT_IP"); |
| | | } |
| | | if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) { |
| | | if (ip == null || ip.isEmpty() || UNKNOWN.equalsIgnoreCase(ip)) { |
| | | ip = request.getHeader("HTTP_CLIENT_IP"); |
| | | } |
| | | if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) { |
| | | if (ip == null || ip.isEmpty() || UNKNOWN.equalsIgnoreCase(ip)) { |
| | | ip = request.getHeader("HTTP_FORWARDED_FOR"); |
| | | } |
| | | if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) { |
| | | if (ip == null || ip.isEmpty() || UNKNOWN.equalsIgnoreCase(ip)) { |
| | | ip = request.getHeader("HTTP_FORWARDED"); |
| | | } |
| | | if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) { |
| | | if (ip == null || ip.isEmpty() || UNKNOWN.equalsIgnoreCase(ip)) { |
| | | ip = request.getHeader("HTTP_VIA"); |
| | | } |
| | | if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) { |
| | | if (ip == null || ip.isEmpty() || UNKNOWN.equalsIgnoreCase(ip)) { |
| | | ip = request.getHeader("REMOTE_ADDR"); |
| | | } |
| | | if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) { |
| | | if (ip == null || ip.isEmpty() || UNKNOWN.equalsIgnoreCase(ip)) { |
| | | ip = request.getRemoteAddr(); |
| | | } |
| | | if (ip.contains(COMMA)) { |
| | |
| | | */ |
| | | public static String getTokenFromCookie(HttpServletRequest request) { |
| | | Cookie[] cookies = request.getCookies(); |
| | | if (cookies == null || cookies.length == 0) { |
| | | if (cookies == null) { |
| | | return null; |
| | | } |
| | | |
| | |
| | | */ |
| | | public static void deleteCookie(String cookieKey, HttpServletRequest request, HttpServletResponse response) { |
| | | Cookie[] cookies = request.getCookies(); |
| | | if (cookies != null && cookies.length > 0) { |
| | | if (cookies != null) { |
| | | for (Cookie c : cookies) { |
| | | if (cookieKey.equalsIgnoreCase(c.getName())) { |
| | | c.setMaxAge(0); |
| | |
| | | */ |
| | | public static void deleteCookies(HttpServletRequest request, HttpServletResponse response) { |
| | | Cookie[] cookies = request.getCookies(); |
| | | if (cookies != null && cookies.length > 0) { |
| | | if (cookies != null) { |
| | | for (Cookie c : cookies) { |
| | | c.setMaxAge(0); |
| | | c.setPath("/"); |
| | |
| | | */ |
| | | public static String getCookieByKey(String key, HttpServletRequest request) { |
| | | Cookie[] cookies = request.getCookies(); |
| | | if (cookies == null || cookies.length == 0) { |
| | | if (cookies == null) { |
| | | return null; |
| | | } |
| | | |