snat策略增加用户类型选项.

This commit is contained in:
zhangwq
2018-12-06 15:00:05 +08:00
parent 23b402fc50
commit 04e35d5b3c
10 changed files with 257 additions and 39 deletions

View File

@@ -18,6 +18,11 @@ public class IpReusePolicyCfg extends BaseCfg<IpReusePolicyCfg>{
private String userName;
private String addrPoolName; // 仅用于列表条件检索
private Integer ipType;
private Integer ipPattern;
private String srcIpAddress;
private String destIpAddress;
public Integer getUserId() {
return userId;
}
@@ -60,5 +65,29 @@ public class IpReusePolicyCfg extends BaseCfg<IpReusePolicyCfg>{
public void setAddrPoolName(String addrPoolName) {
this.addrPoolName = addrPoolName;
}
public Integer getIpType() {
return ipType;
}
public void setIpType(Integer ipType) {
this.ipType = ipType;
}
public String getSrcIpAddress() {
return srcIpAddress;
}
public void setSrcIpAddress(String srcIpAddress) {
this.srcIpAddress = srcIpAddress;
}
public Integer getIpPattern() {
return ipPattern;
}
public void setIpPattern(Integer ipPattern) {
this.ipPattern = ipPattern;
}
public String getDestIpAddress() {
return destIpAddress;
}
public void setDestIpAddress(String destIpAddress) {
this.destIpAddress = destIpAddress;
}
}

View File

@@ -25,4 +25,6 @@ public interface IpMultiplexDao extends CrudDao<IpMultiplexDao>{
// 校验地址池是否被引用
List<IpReusePolicyCfg> checkAddrPoolIsUsed(@Param("addrPoolId")String addrPoolId);
void updatePolicyAuditStatus(IpReusePolicyCfg cfg);
}

View File

@@ -8,6 +8,9 @@
<result column="addr_pool_id" property="addrPoolId" jdbcType="INTEGER"/>
<result column="user_name" property="userName" jdbcType="VARCHAR"/>
<result column="user_type" property="userType" jdbcType="VARCHAR"/>
<result column="ip_type" property="ipType" jdbcType="INTEGER" />
<result column="ip_pattern" property="ipPattern" jdbcType="INTEGER" />
<result column="src_ip_address" property="srcIpAddress" jdbcType="VARCHAR" />
<result column="do_log" property="doLog" jdbcType="INTEGER" />
<result column="is_valid" property="isValid" jdbcType="INTEGER" />
@@ -38,7 +41,7 @@
</resultMap>
<sql id="policyColumns">
r.CFG_ID,r.CFG_DESC,r.ADDR_POOL_ID,r.USER_NAME,r.USER_TYPE,
r.CFG_ID,r.CFG_DESC,r.ADDR_POOL_ID,r.USER_NAME,r.USER_TYPE,r.IP_TYPE,r.IP_PATTERN,r.SRC_IP_ADDRESS,
r.ACTION,r.DO_LOG,r.IS_VALID,r.IS_AUDIT,r.CFG_REGION_CODE,r.CFG_TYPE,r.FUNCTION_ID,
r.SERVICE_ID,r.COMPILE_ID,r.REQUEST_ID,r.CLASSIFY,r.ATTRIBUTE,r.LABLE,
r.CREATOR_ID,r.CREATE_TIME,r.EDITOR_ID,r.EDIT_TIME,r.AUDITOR_ID,r.AUDIT_TIME,
@@ -75,12 +78,11 @@
<if test="compileId != null">
AND r.compile_id=#{compileId,jdbcType=BIGINT}
</if>
<if test="srcIpAddress != null and srcIpAddress != ''">
AND r.src_ip_address=#{srcIpAddress,jdbcType=VARCHAR}
</if>
<if test="userName != null and userName != ''">
AND r.user_id in (SELECT u.id FROM user_manage u
<where>
u.user_name LIKE concat(concat('%',#{userName,jdbcType=VARCHAR}),'%')
</where>
)
AND r.user_name LIKE concat(concat('%',#{userName,jdbcType=VARCHAR}),'%')
</if>
<if test="addrPoolName != null and addrPoolName != ''">
AND r.addr_pool_id in (SELECT i.cfg_id FROM ip_reuse_addr_pool i
@@ -173,6 +175,9 @@
addr_pool_id,
user_name,
user_type,
ip_type,
ip_pattern,
src_ip_address,
action,
do_log,
is_valid,
@@ -204,6 +209,9 @@
#{addrPoolId,jdbcType=INTEGER},
#{userName,jdbcType=VARCHAR},
#{userType,jdbcType=VARCHAR},
#{ipType,jdbcType=INTEGER},
#{ipPattern,jdbcType=INTEGER},
#{srcIpAddress,jdbcType=VARCHAR},
#{action,jdbcType=INTEGER},
#{doLog,jdbcType=INTEGER},
0,
@@ -246,7 +254,7 @@
update ip_reuse_policy_cfg
<set>
<trim suffixOverrides=",">
<if test="userName != null and userName != ''" >
<if test="userName != null" >
user_name = #{userName,jdbcType=VARCHAR},
</if>
<if test="userType != null and userType != ''" >
@@ -257,6 +265,15 @@
</if>
<if test="addrPoolId != null" >
addr_pool_id = #{addrPoolId,jdbcType=INTEGER},
</if>
<!-- <if test="ipType != null" > -->
ip_type = #{ipType,jdbcType=INTEGER},
<!-- </if>
<if test="ipPattern != null"> -->
ip_pattern=#{ipPattern,jdbcType=INTEGER},
<!-- </if> -->
<if test="srcIpAddress != null">
src_ip_address=#{srcIpAddress,jdbcType=VARCHAR},
</if>
<if test="translateParam != null and translateParam != ''" >
translate_param = #{translateParam,jdbcType=VARCHAR},
@@ -312,6 +329,28 @@
</update>
<update id="updatePolicyAuditStatus" parameterType="com.nis.domain.configuration.IpReusePolicyCfg">
update ip_reuse_policy_cfg
<set>
<trim suffixOverrides=",">
<if test="isValid != null" >
is_valid = #{isValid,jdbcType=INTEGER},
</if>
<if test="isAudit != null" >
is_audit = #{isAudit,jdbcType=INTEGER},
</if>
<if test="auditorId != null" >
auditor_id = #{auditorId,jdbcType=INTEGER},
</if>
<if test="auditTime != null and createTime != ''" >
audit_time = #{auditTime,jdbcType=TIMESTAMP},
</if>
</trim>
</set>
WHERE cfg_id = #{cfgId,jdbcType=BIGINT}
</update>
<select id="checkAddrPoolIsUsed" resultMap="policyMap">
SELECT
<include refid="policyColumns"/>

View File

@@ -119,7 +119,17 @@ public class IpAddrPoolCfgService extends BaseService{
// 2.更新地址池IP信息
ipAddrPoolCfgDao.deleteReuseIpCfgs(addrPoolId);
for (BaseIpCfg IpCfg : entity.getIpCfgs()) {
BeanUtils.copyProperties(entity, IpCfg, new String[]{"cfgId"});
try {
List<Integer> compileIds = ConfigServiceUtil.getId(1,1);
if(compileIds != null && compileIds.size() > 0 ){
IpCfg.setCompileId(compileIds.get(0));
}
} catch (Exception e) {
e.printStackTrace();
logger.info("获取编译ID出错");
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
}
BeanUtils.copyProperties(entity, IpCfg, new String[]{"cfgId","compileId"});
IpCfg.setUserRegion1(addrPoolId+"");
ipAddrPoolCfgDao.saveReuseIpCfgs(IpCfg);
}
@@ -169,7 +179,7 @@ public class IpAddrPoolCfgService extends BaseService{
List<IpAddrPool> resStrategyList=new ArrayList<IpAddrPool>();
for(BaseIpCfg ipcfg : cfg.getIpCfgs()) {
IpAddrPool ip = new IpAddrPool();
BeanUtils.copyProperties(cfg, ipcfg, new String[]{"cfgId"});
BeanUtils.copyProperties(cfg, ipcfg, new String[]{"cfgId","compileId"});
List<IpCfg> cfgs = BaseService.ipConvert(new IpCfg(), ipcfg);
if (cfgs.size() > 1) {
throw new RuntimeException("CallBack IP did not support IP range!");
@@ -216,7 +226,7 @@ public class IpAddrPoolCfgService extends BaseService{
List<IpAddrPool> resStrategyList=new ArrayList<IpAddrPool>();
for(BaseIpCfg ipcfg : cfg.getIpCfgs()) {
IpAddrPool ip = new IpAddrPool();
BeanUtils.copyProperties(cfg, ipcfg, new String[]{"cfgId"});
BeanUtils.copyProperties(cfg, ipcfg, new String[]{"cfgId","compileId"});
List<IpCfg> cfgs = BaseService.ipConvert(new IpCfg(), ipcfg);
if (cfgs.size() > 1) {
throw new RuntimeException("CallBack IP did not support IP range!");

View File

@@ -56,10 +56,12 @@ public class IpMultiplexService extends BaseService{
entity.setIsAudit(0);
setAreaEffectiveIds(entity);
// 获取用户/账号类型
if(StringUtils.isNotBlank(entity.getUserName())){
String userType = ipMultiplexDao.getUserType(entity.getUserName());
entity.setUserType(userType);
if("VPN".equals(entity.getUserType())){
entity.setIpType(null);
entity.setIpPattern(null);
entity.setSrcIpAddress("");
}else{
entity.setUserName("");
}
// 更新策略信息
@@ -120,8 +122,7 @@ public class IpMultiplexService extends BaseService{
cfg.setIsAudit(isAudit);
cfg.setAuditorId(UserUtils.getUser().getId());
cfg.setAuditTime(auditTime);
cfg.setDoLog(null);
ipMultiplexDao.updatePolicyCfg(cfg);
ipMultiplexDao.updatePolicyAuditStatus(cfg);
SysDictInfoService sysDictInfoService = SpringContextHolder.getBean(SysDictInfoService.class);
// 获取配置信息
@@ -133,7 +134,7 @@ public class IpMultiplexService extends BaseService{
params.put("configId", cfg.getCompileId());
params.put("addrPoolId", cfg.getAddrPoolId());
params.put("userType", cfg.getUserType());
params.put("userId", keywordsEscape(cfg.getUserName()));
params.put("userId", keywordsEscape(StringUtils.isNotBlank(cfg.getUserName())?cfg.getUserName():cfg.getSrcIpAddress()));
params.put("doLog", cfg.getDoLog());
params.put("action", cfg.getAction());
params.put("service", cfg.getServiceId());
@@ -164,7 +165,7 @@ public class IpMultiplexService extends BaseService{
params.put("configId", cfg.getCompileId());
params.put("addrPoolId", cfg.getAddrPoolId());
params.put("userType", cfg.getUserType());
params.put("userId", keywordsEscape(cfg.getUserName()));
params.put("userId", keywordsEscape(StringUtils.isNotBlank(cfg.getUserName())?cfg.getUserName():cfg.getSrcIpAddress()));
params.put("doLog", cfg.getDoLog());
params.put("action", cfg.getAction());
params.put("service", cfg.getServiceId());

View File

@@ -1340,3 +1340,7 @@ info_failed=Information Acquisition Failure
address_pool_ip_configuration=Address Pool IP Configuration
cgi_failed=CGI Server
ip_check=Please enter a correct IP address
user_type=User Type
policy_vpn_user=VPN access user name
policy_sipv4_user=Three tier access to IP(IPv4)
policy_sipv6_user=Three tier access to IP(IPv6)

View File

@@ -1344,3 +1344,7 @@ crl_file=\u0424\u0430\u0439\u043B Crl
equal_password=\u041D\u0435\u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u043F\u0430\u0440\u043E\u043B\u0438!
cgi_failed=CGL \u0441\u0435\u0440\u0432\u0435\u0440
ip_check=\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u044B\u0439 IP-\u0430\u0434\u0440\u0435\u0441
user_type=User Type
policy_vpn_user=VPN access user name
policy_sipv4_user=Three tier access to IP(IPv4)
policy_sipv6_user=Three tier access to IP(IPv6)

View File

@@ -1338,3 +1338,7 @@ info_failed=\u4FE1\u606F\u83B7\u53D6\u5931\u8D25
address_pool_ip_configuration=\u5730\u5740\u6C60 IP\u914D\u7F6E
cgi_failed=CGI\u670D\u52A1
ip_check=\u8BF7\u586B\u5199\u6B63\u786E\u7684IP\u5730\u5740
user_type=\u7528\u6237\u7C7B\u578B
policy_vpn_user=VPN\u63A5\u5165\u7528\u6237\u540D
policy_sipv4_user=\u4E09\u5C42\u63A5\u5165\u6E90IP(IPv4)
policy_sipv6_user=\u4E09\u5C42\u63A5\u5165\u6E90IP(IPv6)

View File

@@ -41,7 +41,45 @@ $(function(){
}
}
});
$("select[name$='ipType']").selectpicker();
switchUserType($("select[name$='userType']"));
$("select[name$='userType']").on("change",function(){
switchUserType(this);
});
$("select[name$='ipType']").on("change",function(){
switchIpInfo(this);
});
$("select[name$='ipPattern']").on("change",function(){
switchIpInfo(this);
});
});
var switchUserType = function(obj){
var type = $(obj).val();
if(type == ''){
$(".user").parents(".col-md-6").addClass("hidden");
$(".clientIp").parents(".col-md-6").addClass("hidden");
$(".ipPattern").parents(".col-md-6").addClass("hidden");
}else if(type == 'VPN'){
$(".user").parents(".col-md-6").removeClass("hidden");
$(".clientIp").parents(".col-md-6").addClass("hidden");
$(".ipPattern").parents(".col-md-6").addClass("hidden");
}else if(type == 'SIPv4'){
$(".user").parents(".col-md-6").addClass("hidden");
$(".clientIp").parents(".col-md-6").removeClass("hidden");
$(".ipPattern").parents(".col-md-6").removeClass("hidden");
$("select[name$='ipType']").selectpicker("val","4");
}else{
$(".user").parents(".col-md-6").addClass("hidden");
$(".clientIp").parents(".col-md-6").removeClass("hidden");
$(".ipPattern").parents(".col-md-6").removeClass("hidden");
$("select[name$='ipType']").selectpicker("val","6");
}
$("select[name$='ipType']").trigger("change");
$("select[name$='ipType']").selectpicker("refresh");
}
</script>
</head>
<body>
@@ -132,16 +170,13 @@ $(function(){
<div class="col-md-6">
<div class="form-group">
<label class="control-label col-md-3"><font color="red">*</font><spring:message code="user"/></label>
<label class="control-label col-md-3"><font color="red">*</font><spring:message code="address_pool"/></label>
<div class="col-md-6">
<select name="userName" class="selectpicker show-tick form-control required" data-live-search="true" data-live-search-placeholder="search">
<select id="addrPoolSel" name="addrPoolId" class="selectpicker show-tick form-control required" data-live-search="true" data-live-search-placeholder="search">
<option value="" ><spring:message code="select"/></option>
<c:forEach items="${users }" var="user">
<option value="${user.userName}" <c:if test="${_cfg.userName eq user.userName }">selected</c:if>><spring:message code="${user.userName}"/></option>
</c:forEach>
</select>
</div>
<div for="userName"></div>
<div for="addrPoolId"></div>
</div>
</div>
@@ -174,16 +209,88 @@ $(function(){
</div>
</c:if>
</div>
<div class="row">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label class="control-label col-md-3"><font color="red">*</font><spring:message code="address_pool"/></label>
<label class="control-label col-md-3"><font color="red">*</font><spring:message code="user_type"/></label>
<div class="col-md-6">
<select id="addrPoolSel" name="addrPoolId" class="selectpicker show-tick form-control required" data-live-search="true" data-live-search-placeholder="search">
<option value="" ><spring:message code="select"/></option>
<select name="userType" class="selectpicker show-tick form-control required">
<option value=""><spring:message code="select"/></option>
<option value="VPN" <c:if test="${_cfg.userType eq 'VPN' }">selected</c:if>><spring:message code="policy_vpn_user"/></option>
<option value="SIPv4" <c:if test="${_cfg.userType eq 'SIPv4' }">selected</c:if>><spring:message code="policy_sipv4_user"/></option>
<option value="SIPv6" <c:if test="${_cfg.userType eq 'SIPv6' }">selected</c:if>><spring:message code="policy_sipv6_user"/></option>
</select>
</div>
<div for="addrPoolId"></div>
<div for="userType"></div>
</div>
</div>
<div class="col-md-6 hidden">
<div class="form-group">
<label class="control-label col-md-3"><font color="red">*</font><spring:message code="user"/></label>
<div class="col-md-6">
<select name="userName" class="selectpicker show-tick form-control required user" data-live-search="true" data-live-search-placeholder="search">
<option value="" ><spring:message code="select"/></option>
<c:forEach items="${users}" var="user">
<option value="${user.userName}" <c:if test="${_cfg.userName eq user.userName }">selected</c:if>><spring:message code="${user.userName}"/></option>
</c:forEach>
</select>
</div>
<div for="userName"></div>
</div>
</div>
<div class="col-md-6 hidden">
<div class="form-group">
<label class="control-label col-md-3"><font color="red">*</font><spring:message code="ip_pattern"/></label>
<div class="col-md-6">
<select name="ipPattern" class="selectpicker show-tick form-control required ipPattern">
<c:forEach items="${fns:getDictList('IP_PATTERN')}" var="ipPatternC">
<option value="${ipPatternC.itemCode}" <c:if test="${ipPatternC.itemCode == _cfg.ipPattern }">selected</c:if>>
<spring:message code="${ipPatternC.itemValue}"/>
</option>
</c:forEach>
</select>
</div>
<div for="ipPattern"></div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6 hidden">
<div class="form-group">
<label class="control-label col-md-3"><font color="red">*</font><spring:message code="ip_type"/></label>
<div class="col-md-6">
<select name="ipType" class="selectpicker show-tick form-control required">
<c:forEach items="${fns:getDictList('IP_TYPE')}" var="ipTypeC">
<option value="${ipTypeC.itemCode}" <c:if test="${ipTypeC.itemCode==4 }">selected</c:if> >
<spring:message code="${ipTypeC.itemValue}"/>
</option>
</c:forEach>
</select>
</div>
<div for="ipType"></div>
</div>
</div>
<div class="col-md-6 hidden">
<div class="form-group">
<label class="control-label col-md-3"><font color="red">*</font><spring:message code="ip"/></label>
<div class="col-md-6">
<input class="form-control required ipCheck clientIp" type="text" name="srcIpAddress" value="${_cfg.srcIpAddress }">
</div>
<div for="srcIpAddress"></div>
</div>
</div>
</div>
<div class="row dest">
<div class="col-md-6">
<div class="form-group">
<label class="control-label col-md-3"><font color="red">*</font><spring:message code="server_ip"/></label>
<div class="col-md-6">
<input class="form-control required ipCheck" type="text" name="destIpAddress" >
</div>
<div for="destIpAddress"></div>
</div>
</div>
</div>
@@ -204,6 +311,7 @@ $(function(){
</div>
</div>
</div>
</div>
<%-- <br><%@include file="/WEB-INF/include/form/areaInfo.jsp"%> --%>
<br>
<%@include file="/WEB-INF/include/form/basicInfo.jsp" %>

View File

@@ -13,6 +13,8 @@
$("#intype").val("${cfg.addrPoolName}");
}else if("${cfg.userName}"){
$("#intype").val("${cfg.userName}");
}else if("${cfg.srcIpAddress}"){
$("#intype").val("${cfg.srcIpAddress}");
}else if("${cfg.compileId}"){
$("#intype").val("${cfg.compileId}");
}else{
@@ -97,8 +99,9 @@
<form:select path="seltype" class="selectpicker select2 input-small" >
<form:option value="cfgDesc"><spring:message code="config_describe"></spring:message></form:option>
<form:option value="userName"><spring:message code="user"></spring:message></form:option>
<form:option value="compileId"><spring:message code="cfg_id"></spring:message></form:option>
<form:option value="srcIpAddress"><spring:message code="ip"></spring:message></form:option>
<form:option value="userName"><spring:message code="user"></spring:message></form:option>
<form:option value="addrPoolName"><spring:message code="address_pool"></spring:message></form:option>
<form:option value="isValid"><spring:message code="valid_identifier"></spring:message></form:option>
</form:select>
@@ -281,7 +284,9 @@
<th class="sort-column r.cfg_id" style="display: none"><spring:message code="cfg_id"/></th>
<th class="sort-column r.cfg_desc cfgDesc"><spring:message code="config_describe"/></th>
<th><spring:message code="address_pool"/></th>
<th><spring:message code="user_type"/></th>
<th><spring:message code="user"/></th>
<th><spring:message code="ip"/></th>
<%-- <th class="sort-column a.action"><spring:message code="block_type"/></th> --%>
<th class="sort-column r.is_valid"><spring:message code="valid_identifier"/></th>
@@ -315,6 +320,17 @@
</c:if>
</c:forEach>
</td>
<td>
<c:if test="${indexCfg.userType eq 'VPN' }">
<spring:message code="policy_vpn_user"/>
</c:if>
<c:if test="${indexCfg.userType eq 'SIPv4' }">
<spring:message code="policy_sipv4_user"/>
</c:if>
<c:if test="${indexCfg.userType eq 'SIPv6' }">
<spring:message code="policy_sipv6_user"/>
</c:if>
</td>
<td>
<c:forEach items="${users }" var="user">
<c:if test="${indexCfg.userName eq user.userName }">
@@ -322,6 +338,7 @@
</c:if>
</c:forEach>
</td>
<td>${indexCfg.srcIpAddress }</td>
<%-- <td>
<c:forEach items="${fns:getDictList('SERVICE_ACTION') }" var="dict">