Merge branch 'develop' of http://10.0.6.99/gwall/gwall.git into develop

This commit is contained in:
wangxin
2018-06-11 13:54:50 +08:00
4 changed files with 205 additions and 1 deletions

View File

@@ -0,0 +1,34 @@
package com.nis.domain.log;
public class IpsecLog extends BaseLogEntity<IpsecLog> {
/**
*
*/
private static final long serialVersionUID = 351171176772839901L;
private Integer exProtocol;//交换协议1-ISAKMP(V1) 2-IKEv2 3-其它
private Integer isakmpMode;//加密方式0-其它1-IPSEC 2-无
private String chapName;//用户名称
public Integer getExProtocol() {
return exProtocol;
}
public void setExProtocol(Integer exProtocol) {
this.exProtocol = exProtocol;
}
public Integer getIsakmpMode() {
return isakmpMode;
}
public void setIsakmpMode(Integer isakmpMode) {
this.isakmpMode = isakmpMode;
}
public String getChapName() {
return chapName;
}
public void setChapName(String chapName) {
this.chapName = chapName;
}
}

View File

@@ -0,0 +1,55 @@
package com.nis.domain.log;
public class NtcSshLog extends BaseLogEntity<OpenVpnLog> {
/**
*
*/
private static final long serialVersionUID = -5291611528905986066L;
private String version; //版本信息
private String hostKey;//主机密钥
private String hostCookie; //主机Cookie
private String encryptMode;//加密方式 具体的加密算法
private String mac;//消息认证码 HMAC、CRC等
private Integer tunnelType;//;通道类型:1-SSH, 2-SSHD, 3-SFTP
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getHostKey() {
return hostKey;
}
public void setHostKey(String hostKey) {
this.hostKey = hostKey;
}
public String getHostCookie() {
return hostCookie;
}
public void setHostCookie(String hostCookie) {
this.hostCookie = hostCookie;
}
public String getEncryptMode() {
return encryptMode;
}
public void setEncryptMode(String encryptMode) {
this.encryptMode = encryptMode;
}
public String getMac() {
return mac;
}
public void setMac(String mac) {
this.mac = mac;
}
public Integer getTunnelType() {
return tunnelType;
}
public void setTunnelType(Integer tunnelType) {
this.tunnelType = tunnelType;
}
}

View File

@@ -0,0 +1,40 @@
package com.nis.domain.log;
public class OpenVpnLog extends BaseLogEntity<OpenVpnLog> {
/**
*
*/
private static final long serialVersionUID = -3197594223008465746L;
private String version;//版本号
private String encryptMode;//加密方式
private Integer hmac;//是否有HMAC
private Integer tunnelType;//通道类型
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getEncryptMode() {
return encryptMode;
}
public void setEncryptMode(String encryptMode) {
this.encryptMode = encryptMode;
}
public Integer getHmac() {
return hmac;
}
public void setHmac(Integer hmac) {
this.hmac = hmac;
}
public Integer getTunnelType() {
return tunnelType;
}
public void setTunnelType(Integer tunnelType) {
this.tunnelType = tunnelType;
}
}

View File

@@ -15,14 +15,19 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.http.HttpStatus;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.DefaultHttpRequestRetryHandler;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.apache.log4j.Logger;
@@ -35,7 +40,7 @@ import org.apache.log4j.Logger;
* @version V1.0
*/
public class HttpClientUtil {
protected final Logger logger = Logger.getLogger(HttpClientUtil.class);
protected static Logger logger = Logger.getLogger(HttpClientUtil.class);
/**
* 处理get请求.
* @param url 请求路径
@@ -105,12 +110,82 @@ public class HttpClientUtil {
// }
return content;
}
/**
* http get 获取消息
* @param destUrl 业务地址
* @param params 参数列表
* @return 查询结果数据json
*/
public static String getMsg(String destUrl, Map<String, Object> params) {
CloseableHttpResponse response = null;
String result = null;
try {
URIBuilder uriBuilder = new URIBuilder(destUrl);
for (String param : params.keySet()) {
uriBuilder.addParameter(param, params.get(param).toString());
}
HttpGet request = new HttpGet(uriBuilder.build());
request.setConfig(requestConfig);
response = getHttpClient().execute(request);
int status = response.getStatusLine().getStatusCode();
if (status == HttpStatus.SC_OK) {
result = EntityUtils.toString(response.getEntity());
logger.debug("获取消息成功,相应内容如下: " + result);
}
} catch (Exception e) {
e.printStackTrace();
logger.debug("获取消息失败,相应内容如下: " + e);
} finally {
try {
if (response != null) {
response.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return result;
}
private static CloseableHttpClient httpClient = null;
private static RequestConfig requestConfig;
public static final int HTTP_SOCKET_TIMEOUT= 30000;
public static final int HTTP_CONNECT_TIMEOUT= 10000;
public static final int HTTP_CONNECT_REQUEST_TIMEOUT = 50000;
public static final int HTTP_CONNECT_RETRY_TIMES = 3;
//http 连接池
public static CloseableHttpClient getHttpClient() {
if (httpClient == null) {
//http 连接池管理 需后续实现
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
// 将最大连接数增加到200
cm.setMaxTotal(200);
// 将每个路由基础的连接增加到20
cm.setDefaultMaxPerRoute(20);
requestConfig = RequestConfig.custom()
.setSocketTimeout( HTTP_SOCKET_TIMEOUT)
.setConnectTimeout( HTTP_CONNECT_TIMEOUT)
.setConnectionRequestTimeout( HTTP_CONNECT_REQUEST_TIMEOUT)
.build();
httpClient = HttpClients.custom()
.setConnectionManager(cm)
.setDefaultRequestConfig(requestConfig)
.setRetryHandler(new DefaultHttpRequestRetryHandler( HTTP_CONNECT_RETRY_TIMES, false))
.build();
}
return httpClient;
}
public static void main(String[] args) throws ClientProtocolException, IOException {
HttpClientUtil hd = new HttpClientUtil();
hd.get("http://10.0.6.115:9200/_sql?sql=select * from dfipportlog-2016-09-07-15 limit 1 10");
Map<String,String> map = new HashMap();
map.put("id","1");
hd.post("http://localhost:8080/springMVC/menu/getChildren.do",map);
}
}