添加PXY HTTP日志查询接口

This commit is contained in:
zhangdongxu
2018-07-19 19:30:14 +08:00
parent e53d58d238
commit 0630775f98
5 changed files with 230 additions and 23 deletions

View File

@@ -0,0 +1,120 @@
package com.nis.domain.restful;
import com.nis.domain.LogEntity;
import com.wordnik.swagger.annotations.ApiModelProperty;
/**
* @ClassName:PxyHttpLog
* @Description:TODO(这里用一句话描述这个类的作用)
* @author (zdx)
* @date 2018年7月19日 下午5:22:30
* @version V1.0
*/
public class PxyHttpLog extends LogEntity<PxyHttpLog> {
private static final long serialVersionUID = 6553069367645925554L;
@ApiModelProperty(value="url地址", required=true)
protected String url;
@ApiModelProperty(value="请求行", required=true)
protected String reqLine;
@ApiModelProperty(value="应答行", required=true)
protected String resLine;
@ApiModelProperty(value="Cookie值", required=true)
protected String cookie;
@ApiModelProperty(value="Referer值", required=true)
protected String referer;
@ApiModelProperty(value="UA值", required=true)
protected String userAgent;
@ApiModelProperty(value="Content-Length值", required=true)
protected String contentLen;
@ApiModelProperty(value="Content-Type值", required=true)
protected String contentType;
@ApiModelProperty(value="set-Cookie值", required=true)
protected String setCookie;
@ApiModelProperty(value="原始请求头", required=true)
protected String reqHeader;
@ApiModelProperty(value="原始应答头", required=true)
protected String respHeader;
@ApiModelProperty(value="原始请求体", required=true)
protected String reqBody;
@ApiModelProperty(value="原始应答体", required=true)
protected String respBody;
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getReqLine() {
return reqLine;
}
public void setReqLine(String reqLine) {
this.reqLine = reqLine;
}
public String getResLine() {
return resLine;
}
public void setResLine(String resLine) {
this.resLine = resLine;
}
public String getCookie() {
return cookie;
}
public void setCookie(String cookie) {
this.cookie = cookie;
}
public String getReferer() {
return referer;
}
public void setReferer(String referer) {
this.referer = referer;
}
public String getUserAgent() {
return userAgent;
}
public void setUserAgent(String userAgent) {
this.userAgent = userAgent;
}
public String getContentLen() {
return contentLen;
}
public void setContentLen(String contentLen) {
this.contentLen = contentLen;
}
public String getContentType() {
return contentType;
}
public void setContentType(String contentType) {
this.contentType = contentType;
}
public String getSetCookie() {
return setCookie;
}
public void setSetCookie(String setCookie) {
this.setCookie = setCookie;
}
public String getReqHeader() {
return reqHeader;
}
public void setReqHeader(String reqHeader) {
this.reqHeader = reqHeader;
}
public String getRespHeader() {
return respHeader;
}
public void setRespHeader(String respHeader) {
this.respHeader = respHeader;
}
public String getReqBody() {
return reqBody;
}
public void setReqBody(String reqBody) {
this.reqBody = reqBody;
}
public String getRespBody() {
return respBody;
}
public void setRespBody(String respBody) {
this.respBody = respBody;
}
}

View File

@@ -10,7 +10,6 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.nis.web.service.AuditLogThread;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -47,6 +46,7 @@ import com.nis.domain.restful.NtcSrcipDomesticReport;
import com.nis.domain.restful.NtcSshLog;
import com.nis.domain.restful.NtcSslLog;
import com.nis.domain.restful.NtcTagReport;
import com.nis.domain.restful.PxyHttpLog;
import com.nis.restful.RestServiceException;
import com.nis.util.Configurations;
import com.nis.util.Constants;
@@ -54,6 +54,7 @@ import com.nis.util.DateUtils;
import com.nis.util.HiveJDBC;
import com.nis.util.JsonMapper;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.AuditLogThread;
import com.nis.web.service.HiveSqlService;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.LogTestService;
@@ -92,7 +93,7 @@ public class LogController extends BaseRestController {
Page<NtcIpLog> ntcIpLogPage = null;
try {
resetTime(ntcIpLog);
testService.queryConditionCheck(auditLogThread, start, ntcIpLog, NtcIpLog.class, page);
ntcReportService.queryConditionCheck(auditLogThread, start, ntcIpLog, NtcIpLog.class, page);
ntcIpLogPage = new Page<NtcIpLog>();
ntcIpLogPage.setPageNo(page.getPageNo());
ntcIpLogPage.setPageSize(page.getPageSize());
@@ -158,7 +159,7 @@ public class LogController extends BaseRestController {
Page<NtcHttpLog> ntcHttpLogPage = null;
try {
resetTime(ntcHttpLog);
testService.queryConditionCheck(auditLogThread, start, ntcHttpLog, NtcHttpLog.class, page);
ntcReportService.queryConditionCheck(auditLogThread, start, ntcHttpLog, NtcHttpLog.class, page);
ntcHttpLogPage = new Page<NtcHttpLog>();
ntcHttpLogPage.setPageNo(page.getPageNo());
ntcHttpLogPage.setPageSize(page.getPageSize());
@@ -218,7 +219,7 @@ public class LogController extends BaseRestController {
Page<NtcDnsLog> ntcDnsLogPage = null;
try {
resetTime(ntcDnsLog);
testService.queryConditionCheck(auditLogThread, start, ntcDnsLog, NtcDnsLog.class, page);
ntcReportService.queryConditionCheck(auditLogThread, start, ntcDnsLog, NtcDnsLog.class, page);
ntcDnsLogPage = new Page<NtcDnsLog>();
ntcDnsLogPage.setPageNo(page.getPageNo());
ntcDnsLogPage.setPageSize(page.getPageSize());
@@ -278,7 +279,7 @@ public class LogController extends BaseRestController {
Page<NtcMailLog> ntcMailLogPage = null;
try {
resetTime(ntcMailLog);
testService.queryConditionCheck(auditLogThread, start, ntcMailLog, NtcMailLog.class, page);
ntcReportService.queryConditionCheck(auditLogThread, start, ntcMailLog, NtcMailLog.class, page);
ntcMailLogPage = new Page<NtcMailLog>();
ntcMailLogPage.setPageNo(page.getPageNo());
ntcMailLogPage.setPageSize(page.getPageSize());
@@ -338,7 +339,7 @@ public class LogController extends BaseRestController {
Page<NtcSslLog> ntcSslLogPage = null;
try {
resetTime(ntcSslLog);
testService.queryConditionCheck(auditLogThread, start, ntcSslLog, NtcSslLog.class, page);
ntcReportService.queryConditionCheck(auditLogThread, start, ntcSslLog, NtcSslLog.class, page);
ntcSslLogPage = new Page<NtcSslLog>();
ntcSslLogPage.setPageNo(page.getPageNo());
ntcSslLogPage.setPageSize(page.getPageSize());
@@ -398,7 +399,7 @@ public class LogController extends BaseRestController {
Page<NtcPptpLog> ntcPptpLogPage = null;
try {
resetTime(ntcPptpLog);
testService.queryConditionCheck(auditLogThread, start, ntcPptpLog, NtcPptpLog.class, page);
ntcReportService.queryConditionCheck(auditLogThread, start, ntcPptpLog, NtcPptpLog.class, page);
ntcPptpLogPage = new Page<NtcPptpLog>();
ntcPptpLogPage.setPageNo(page.getPageNo());
ntcPptpLogPage.setPageSize(page.getPageSize());
@@ -457,7 +458,7 @@ public class LogController extends BaseRestController {
Page<NtcL2tpLog> ntcL2tpLogPage = null;
try {
resetTime(ntcL2tpLog);
testService.queryConditionCheck(auditLogThread, start, ntcL2tpLog, NtcL2tpLog.class, page);
ntcReportService.queryConditionCheck(auditLogThread, start, ntcL2tpLog, NtcL2tpLog.class, page);
ntcL2tpLogPage = new Page<NtcL2tpLog>();
ntcL2tpLogPage.setPageNo(page.getPageNo());
ntcL2tpLogPage.setPageSize(page.getPageSize());
@@ -517,7 +518,7 @@ public class LogController extends BaseRestController {
Page<NtcOpenvpnLog> ntcOpenvpnLogPage = null;
try {
resetTime(ntcOpenvpnLog);
testService.queryConditionCheck(auditLogThread, start, ntcOpenvpnLog, NtcOpenvpnLog.class, page);
ntcReportService.queryConditionCheck(auditLogThread, start, ntcOpenvpnLog, NtcOpenvpnLog.class, page);
ntcOpenvpnLogPage = new Page<NtcOpenvpnLog>();
ntcOpenvpnLogPage.setPageNo(page.getPageNo());
ntcOpenvpnLogPage.setPageSize(page.getPageSize());
@@ -577,7 +578,7 @@ public class LogController extends BaseRestController {
Page<NtcIpsecLog> ntcIpsecLogPage = null;
try {
resetTime(ntcIpsecLog);
testService.queryConditionCheck(auditLogThread, start, ntcIpsecLog, NtcIpsecLog.class, page);
ntcReportService.queryConditionCheck(auditLogThread, start, ntcIpsecLog, NtcIpsecLog.class, page);
ntcIpsecLogPage = new Page<NtcIpsecLog>();
ntcIpsecLogPage.setPageNo(page.getPageNo());
ntcIpsecLogPage.setPageSize(page.getPageSize());
@@ -637,7 +638,7 @@ public class LogController extends BaseRestController {
Page<NtcSshLog> ntcSshLogPage = null;
try {
resetTime(ntcSshLog);
testService.queryConditionCheck(auditLogThread, start, ntcSshLog, NtcSshLog.class, page);
ntcReportService.queryConditionCheck(auditLogThread, start, ntcSshLog, NtcSshLog.class, page);
ntcSshLogPage = new Page<NtcSshLog>();
ntcSshLogPage.setPageNo(page.getPageNo());
ntcSshLogPage.setPageSize(page.getPageSize());
@@ -697,7 +698,7 @@ public class LogController extends BaseRestController {
Page<NtcFtpLog> ntcFtpLogPage = null;
try {
resetTime(ntcFtpLog);
testService.queryConditionCheck(auditLogThread, start, ntcFtpLog, NtcFtpLog.class, page);
ntcReportService.queryConditionCheck(auditLogThread, start, ntcFtpLog, NtcFtpLog.class, page);
ntcFtpLogPage = new Page<NtcFtpLog>();
ntcFtpLogPage.setPageNo(page.getPageNo());
ntcFtpLogPage.setPageSize(page.getPageSize());
@@ -755,7 +756,7 @@ public class LogController extends BaseRestController {
Page<NtcAppLog> ntcAppLogPage = null;
try {
resetTime(ntcAppLog);
testService.queryConditionCheck(auditLogThread, start, ntcAppLog, NtcAppLog.class, page);
ntcReportService.queryConditionCheck(auditLogThread, start, ntcAppLog, NtcAppLog.class, page);
ntcAppLogPage = new Page<NtcAppLog>();
ntcAppLogPage.setPageNo(page.getPageNo());
ntcAppLogPage.setPageSize(page.getPageSize());
@@ -813,7 +814,7 @@ public class LogController extends BaseRestController {
Page<NtcDdosLog> ntcDdosLogPage = null;
try {
resetTime(ntcDdosLog);
testService.queryConditionCheck(auditLogThread, start, ntcDdosLog, NtcDdosLog.class, page);
ntcReportService.queryConditionCheck(auditLogThread, start, ntcDdosLog, NtcDdosLog.class, page);
ntcDdosLogPage = new Page<NtcDdosLog>();
ntcDdosLogPage.setPageNo(page.getPageNo());
ntcDdosLogPage.setPageSize(page.getPageSize());
@@ -871,7 +872,7 @@ public class LogController extends BaseRestController {
Page<DkBehaviorLog> logPage = null;
try {
resetTime(dkBehaviorLog);
testService.queryConditionCheck(auditLogThread, start, dkBehaviorLog, DkBehaviorLog.class, page);
ntcReportService.queryConditionCheck(auditLogThread, start, dkBehaviorLog, DkBehaviorLog.class, page);
logPage = new Page<DkBehaviorLog>();
logPage.setPageNo(page.getPageNo());
logPage.setPageSize(page.getPageSize());
@@ -924,7 +925,7 @@ public class LogController extends BaseRestController {
Page<MmAvIpLog> logPage = null;
try {
resetTime(mmAvIpLog);
testService.queryConditionCheck(auditLogThread, start, mmAvIpLog, MmAvIpLog.class, page);
ntcReportService.queryConditionCheck(auditLogThread, start, mmAvIpLog, MmAvIpLog.class, page);
logPage = new Page<MmAvIpLog>();
logPage.setPageNo(page.getPageNo());
logPage.setPageSize(page.getPageSize());
@@ -977,7 +978,7 @@ public class LogController extends BaseRestController {
Page<MmAvUrlLog> logPage = null;
try {
resetTime(mmAvUrlLog);
testService.queryConditionCheck(auditLogThread, start, mmAvUrlLog, MmAvUrlLog.class, page);
ntcReportService.queryConditionCheck(auditLogThread, start, mmAvUrlLog, MmAvUrlLog.class, page);
logPage = new Page<MmAvUrlLog>();
logPage.setPageNo(page.getPageNo());
logPage.setPageSize(page.getPageSize());
@@ -1030,7 +1031,7 @@ public class LogController extends BaseRestController {
Page<MmPicIpLog> logPage = null;
try {
resetTime(mmPicIpLog);
testService.queryConditionCheck(auditLogThread, start, mmPicIpLog, MmPicIpLog.class, page);
ntcReportService.queryConditionCheck(auditLogThread, start, mmPicIpLog, MmPicIpLog.class, page);
logPage = new Page<MmPicIpLog>();
logPage.setPageNo(page.getPageNo());
logPage.setPageSize(page.getPageSize());
@@ -1083,7 +1084,7 @@ public class LogController extends BaseRestController {
Page<MmPicUrlLog> logPage = null;
try {
resetTime(mmPicUrlLog);
testService.queryConditionCheck(auditLogThread, start, mmPicUrlLog, MmPicUrlLog.class, page);
ntcReportService.queryConditionCheck(auditLogThread, start, mmPicUrlLog, MmPicUrlLog.class, page);
logPage = new Page<MmPicUrlLog>();
logPage.setPageNo(page.getPageNo());
logPage.setPageSize(page.getPageSize());
@@ -1137,7 +1138,7 @@ public class LogController extends BaseRestController {
Page<MmVoipLog> logPage = null;
try {
resetTime(mmVoipLog);
testService.queryConditionCheck(auditLogThread, start, mmVoipLog, MmAvIpLog.class, page);
ntcReportService.queryConditionCheck(auditLogThread, start, mmVoipLog, MmAvIpLog.class, page);
logPage = new Page<MmVoipLog>();
logPage.setPageNo(page.getPageNo());
logPage.setPageSize(page.getPageSize());
@@ -1179,6 +1180,59 @@ public class LogController extends BaseRestController {
return serviceLogResponse(auditLogThread, System.currentTimeMillis() - start, request, "VOIP日志检索成功",
logPage, 0);
}
@RequestMapping(value = "/pxyHttpLogs", method = RequestMethod.GET)
@ApiOperation(value = "PXY HTTP日志查询", httpMethod = "GET", notes = "对日志功能“控制策略”-“HTTP日志”提供数据基础查询服务")
public Map<String, ?> pxyHttpLogs(Page page, PxyHttpLog pxyHttpLog, Model model, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
AuditLogThread auditLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET,
request, null);
Page<PxyHttpLog> logPage = null;
try {
resetTime(pxyHttpLog);
ntcReportService.queryConditionCheck(auditLogThread, start, pxyHttpLog, PxyHttpLog.class, page);
logPage = new Page<PxyHttpLog>();
logPage.setPageNo(page.getPageNo());
logPage.setPageSize(page.getPageSize());
String orderBy = "";
if (null != page.getOrderBy() && !page.getOrderBy().equals("")) {
orderBy = Page.getOrderBySql(PxyHttpLog.class.getSimpleName(), page.getOrderBy());
} else {
orderBy = "found_Time";
}
ResultSet rs = HiveSqlService.getResultSet(page, pxyHttpLog,
Configurations.getStringProperty(PxyHttpLog.class.getSimpleName() + "HiveTable", "PXY_HTTP_LOG"),
getCol2Col(), orderBy, null);
Map<String, List> tableMapping = HiveJDBC.tableMapping(page, null, rs, PxyHttpLog.class, "foundTime",
"recvTime");
if (tableMapping == null) {
logPage.setList(new ArrayList());
} else {
List list = tableMapping.get("obj");
if (list.size() > 0) {
String jsonString = JsonMapper.toJsonString(list);
List<PxyHttpLog> List = (java.util.List<PxyHttpLog>) JsonMapper.fromJsonList(jsonString,
PxyHttpLog.class);
logPage.setList(List);
logPage.setCount(List.size());
} else {
logPage.setList(new ArrayList());
}
}
} catch (Exception e) {
e.printStackTrace();
auditLogThread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(auditLogThread, System.currentTimeMillis() - start, "PXY HTTP日志检索失败");
}
throw ((RestServiceException) e);
}
return serviceLogResponse(auditLogThread, System.currentTimeMillis() - start, request, "PXY HTTP日志检索成功",
logPage, 0);
}
@RequestMapping(value = "/ntcPzReport", method = RequestMethod.GET)
@ApiOperation(value = "配置日志总量统计", httpMethod = "GET", notes = "配置命中日志数量实时统计报表,对外提供多种数据表现形式,具体可应用于界面配置命中总量业务、配置报表业务等")
public Map<String, ?> ntcPzReport(Page page, NtcPzReport ntcPzReport, Model model, HttpServletRequest request,

View File

@@ -525,6 +525,38 @@
<result column="level" jdbcType="INTEGER" property="level" />
<result column="fd_type" jdbcType="INTEGER" property="fdType" />
</resultMap>
<resultMap id="PxyHttpLogMap" type="com.nis.domain.restful.PxyHttpLog">
<result column="cfg_id" jdbcType="BIGINT" property="cfgId" />
<result column="found_Time" jdbcType="TIMESTAMP" property="foundTime" />
<result column="recv_Time" jdbcType="TIMESTAMP" property="recvTime" />
<result column="trans_proto" jdbcType="VARCHAR" property="transProto" />
<result column="addr_type" jdbcType="INTEGER" property="addrType" />
<result column="d_ip" jdbcType="VARCHAR" property="dIp" />
<result column="s_ip" jdbcType="VARCHAR" property="sIp" />
<result column="d_port" jdbcType="VARCHAR" property="dPort" />
<result column="s_port" jdbcType="VARCHAR" property="sPort" />
<result column="service" jdbcType="INTEGER" property="service" />
<result column="entrance_id" jdbcType="BIGINT" property="entranceId" />
<result column="device_id" jdbcType="INTEGER" property="deviceId" />
<result column="direction" jdbcType="INTEGER" property="direction" />
<result column="stream_dir" jdbcType="INTEGER" property="streamDir" />
<result column="cap_ip" jdbcType="VARCHAR" property="capIp" />
<result column="addr_list" jdbcType="VARCHAR" property="addrList" />
<result column="user_region" jdbcType="VARCHAR" property="userRegion" />
<result column="url" jdbcType="VARCHAR" property="url" />
<result column="req_line" jdbcType="VARCHAR" property="reqLine" />
<result column="res_line" jdbcType="VARCHAR" property="resLine" />
<result column="cookie" jdbcType="VARCHAR" property="cookie" />
<result column="referer" jdbcType="VARCHAR" property="referer" />
<result column="user_agent" jdbcType="VARCHAR" property="userAgent" />
<result column="content_len" jdbcType="VARCHAR" property="contentLen" />
<result column="content_type" jdbcType="VARCHAR" property="contentType" />
<result column="set_cookie" jdbcType="VARCHAR" property="setCookie" />
<result column="req_header" jdbcType="VARCHAR" property="reqHeader" />
<result column="resp_header" jdbcType="VARCHAR" property="respHeader" />
<result column="req_body" jdbcType="VARCHAR" property="reqBody" />
<result column="resp_body" jdbcType="VARCHAR" property="respBody" />
</resultMap>
</mapper>

View File

@@ -221,12 +221,12 @@ public abstract class BaseLogService {
} catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger.error(e);
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchServiceType参数格式错误",
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchService参数格式错误",
RestBusinessCode.param_formate_error.getValue());
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger.error(e);
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchServiceType参数错误");
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchService参数错误");
}
try {
checkCloumnIsExist(thread, start, clazz, page);