File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
2024-11-14
File name
Commit message
Commit date
File name
Commit message
Commit date
package itn.let.utl.sim.service;
import javax.servlet.http.HttpServletRequest;
import itn.com.cmm.util.IpUtil;
//import itn.com.cmm.service.EgovProperties;
/**
* 클라이언트(Client)의 IP주소, OS정보, 웹브라우저정보를 조회하는 Business Interface class
* @author 공통서비스개발팀 박지욱
* @since 2009.01.19
* @version 1.0
* @see
*
* <pre>
* << 개정이력(Modification Information) >>
*
* 수정일 수정자 수정내용
* ------- -------- ---------------------------
* 2009.01.19 박지욱 최초 생성
* 2011.08.31 JJY 경량환경 템플릿 커스터마이징버전 생성
*
* </pre>
*/
public class EgovClntInfo {
/**
* 클라이언트(Client)의 IP주소를 조회하는 기능
* @param HttpServletRequest request Request객체
* @return String ipAddr IP주소
* @exception Exception
*/
public static String getClntIP(HttpServletRequest request) throws Exception {
String ip = request.getHeader("X-Forwarded-For") == null ? request.getHeader("X-Forwarded-For") : request.getHeader("X-Forwarded-For").replaceAll("10.12.107.11", "").replaceAll(",", "").trim();
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_CLIENT_IP");
}
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
}
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
return ip;
}
public static String getClntIP2(HttpServletRequest request) throws Exception {
// IP주소
//String ipAddr = request.getRemoteAddr();
// String ipAddr = IpUtil.getClientIP(request) ;
// IP주소
//String ipAddr = request.getRemoteAddr();
String ip = request.getHeader("X-Forwarded-For") == null ? request.getHeader("X-Forwarded-For") : request.getHeader("X-Forwarded-For").replaceAll("10.12.107.11", "").replaceAll(",", "").trim();
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_CLIENT_IP");
}
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
}
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
return ip;
}
/**
* 클라이언트(Client)의 OS 정보를 조회하는 기능
* @param HttpServletRequest request Request객체
* @return String osInfo OS 정보
* @exception Exception
public static String getClntOsInfo(HttpServletRequest request) throws Exception {
String user_agent = request.getHeader("user-agent");
String os_info = user_agent.toUpperCase().split(";")[2].split("\\)")[0];
//String os_conf = EgovProperties.getProperty(Globals.CLIENT_CONF_PATH, os_info.replaceAll(" ", ""));
String os_conf = EgovProperties.getProperty("", os_info.replaceAll(" ", ""));
String osInfo = "";
if (os_conf != null && !"".equals(os_conf)) {
osInfo = os_conf;
} else {
osInfo = os_info;
}
return osInfo;
}
*/
/**
* 클라이언트(Client)의 웹브라우저 종류를 조회하는 기능
* @param HttpServletRequest request Request객체
* @return String webKind 웹브라우저 종류
* @exception Exception
*/
public static String getClntWebKind(HttpServletRequest request) throws Exception {
String user_agent = request.getHeader("user-agent");
// 웹브라우저 종류 조회
String webKind = "";
if (user_agent.toUpperCase().indexOf("GECKO") != -1) {
if (user_agent.toUpperCase().indexOf("NESCAPE") != -1) {
webKind = "Netscape (Gecko/Netscape)";
} else if (user_agent.toUpperCase().indexOf("FIREFOX") != -1) {
webKind = "Mozilla Firefox (Gecko/Firefox)";
} else {
webKind = "Mozilla (Gecko/Mozilla)";
}
} else if (user_agent.toUpperCase().indexOf("MSIE") != -1) {
if (user_agent.toUpperCase().indexOf("OPERA") != -1) {
webKind = "Opera (MSIE/Opera/Compatible)";
} else {
webKind = "Internet Explorer (MSIE/Compatible)";
}
} else if (user_agent.toUpperCase().indexOf("SAFARI") != -1) {
if (user_agent.toUpperCase().indexOf("CHROME") != -1) {
webKind = "Google Chrome";
} else {
webKind = "Safari";
}
} else if (user_agent.toUpperCase().indexOf("THUNDERBIRD") != -1) {
webKind = "Thunderbird";
} else {
webKind = "Other Web Browsers";
}
return webKind;
}
/**
* 클라이언트(Client)의 웹브라우저 버전을 조회하는 기능
* @param HttpServletRequest request Request객체
* @return String webVer 웹브라우저 버전
* @exception Exception
*/
public static String getClntWebVer(HttpServletRequest request) throws Exception {
String user_agent = request.getHeader("user-agent");
// 웹브라우저 버전 조회
String webVer = "";
String [] arr = {"MSIE", "OPERA", "NETSCAPE", "FIREFOX", "SAFARI"};
for (int i = 0; i < arr.length; i++) {
int s_loc = user_agent.toUpperCase().indexOf(arr[i]);
if (s_loc != -1) {
int f_loc = s_loc + arr[i].length();
webVer = user_agent.toUpperCase().substring(f_loc, f_loc+5);
webVer = webVer.replaceAll("/", "").replaceAll(";", "").replaceAll("^", "").replaceAll(",", "").replaceAll("//.", "");
}
}
return webVer;
}
}