keyring内置证书导入功能

This commit is contained in:
段冬梅
2019-06-14 10:20:13 +08:00
parent 1031b0a118
commit b280c23021
6 changed files with 446 additions and 5 deletions

View File

@@ -0,0 +1,140 @@
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/include/taglib.jsp"%>
<<script type="text/javascript">
$(function(){
$("#certFileInfo,#uploadCertFile").on('click', function() {
$("#certFileI").trigger("click");
});
$("#certFileI").on('change', function() {
$("#certFileInfo").val($("#certFileI").val());
/* certFileValidate(); */
});
});
//增加对文件后缀名验证
function certFileValidate(){
var flag=false; //状态,检测文件后缀用
var arr=["cert"];
var cFile=$("#certFileI").val();//文件的值
//取出上传文件的扩展名
var index=cFile.lastIndexOf(".");
var ext = cFile.substr(index+1).toLowerCase();
//循环比较
for(var i=0;i<arr.length;i++)
{
if(ext == arr[i])
{
flag = true; //一旦找到合适的,立即退出循环
break;
}
}
//条件判断
$("div[for='certFileInfo']").empty();
$(".alert-error").addClass("hide");
if(!flag){
// ("文件名不合法");
$("div[for='certFileInfo']").empty();
$(".alert-error").removeClass("hide");
$("div[for='certFileInfo']").append("<label id='level-error' class='error'><spring:message code='file_in_wrong_format'/></label>");
return false;
}
return true;
}
var submitCertFrom=function(){
var certFile = $("#certFileI").val();
/* if(certFile!=''){
if(!certFileValidate()){
return false;
}
} */
certFile=$("#certFileInfo").val();
if((certFile==null || certFile=="")){
$("div[for='certFileInfo']").empty();
$(".alert-error").removeClass("hide");
$("div[for='certFileInfo']").append("<label id='level-error' class='error' for='certFileI'><spring:message code='required'/></label>");
return false;
}else{
$("div[for='certFileInfo']").empty();
$(".alert-error").addClass("hide");
loading('onloading...');
$("#certForm").submit();
}
}
</script>
<div class="modal fade" id="add_cert_modal" tabindex="-1" role="dialog" aria-labelledby="mo" aria-hidden="true">
<form id="certForm" action="${ctx}/proxy/intercept/strateagy/addKeyRingBuiltInCert?importPath=${importPath}" method="post" enctype="multipart/form-data" class="form-horizontal"
onsubmit="loading('<spring:message code='loading'/>');">
<input type="hidden" id="certTip" value="<spring:message code='cert_tip'/>">
<div class="modal-dialog" role="document" style="width:700px;">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">
<spring:message code="import_built_cert_file" />
</h5>
<button type="button" class="close" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="alert alert-error hide">
<!-- <button class="close" data-dismiss="alert"></button> -->
<span><div for="certFileInfo"></div></span>
</div>
<!-- 同主表cert配置信息 -->
<input type="hidden" name="cfgDesc" value="">
<input type="hidden" name="action" value="1">
<input type="hidden" name="isValid" value="1">
<input type="hidden" name="isAudit" value="1">
<input type="hidden" name="functionId" value="${cfg.functionId }">
<input type="hidden" name="serviceId" value="520">
<input type="hidden" name="cfgRegionCode" value="">
<input type="hidden" name="requestId" value="0">
<input type="hidden" name="isAreaEffective" value="0">
<input type="hidden" name="areaEffectiveIds" value="0">
<input type="hidden" name="classify" value="0"/>
<input type="hidden" name="attribute" value="0"/>
<input type="hidden" name="lable" value="0"/>
<input type="hidden" name="cancelRequestId" value=""/>
</br>
<div class="col-md-12">
<div class="form-group">
<label class="control-label col-md-3"><font
color="red">*</font><spring:message code="certificate" /> <spring:message code="file" /></label>
<div class="col-md-6">
<input id="certFileI" name="certFileI" type="file" multiple="multiple"
style="width: 330px; display: none" />
<div class="input-group">
<input id="certFileInfo" name="certFileInfo" readonly="readonly"
data-msg-required=""
placeholder="<spring:message code="select_file"/>"
class="required form-control"
style="background-color: transparent" aria-required="true"
type="text" value="">
<div class="input-group-btn">
<a id="uploadCertFile" class="btn btn-default btn-search"
href="javascript:" style=""><i class="fa fa-search"></i></a>
</div>
<input id="certFile" name="certFile" type="hidden" value=""/>
</div>
</div>
<div id="certInfo"></div>
</div>
</div>
</div>
<div class="modal-footer" style="border-top:0px">
<button type="button" class="btn red" onclick="submitCertFrom()">
<spring:message code="ok" />
</button>
<button type="button" class="btn" data-dismiss="modal">
<spring:message code="close" />
</button>
</div>
</div>
</div>
</form>
</div>

View File

@@ -38,6 +38,17 @@
}
}
});
var addCertFile=function(obj){
if($(obj).attr("attribute") != null && $(obj).attr("attribute") != ''){
attribute=$(obj).attr("attribute");
}
$("#add_cert_modal").modal({
backdrop:"static",
keyboard:false,
show:true
});
}
</script>
</head>
<body>
@@ -51,6 +62,12 @@
<i class="fa fa-plus"></i>
<spring:message code="add"></spring:message></button>
</shiro:hasPermission>
<c:if test="${!hasBuiltIn}">
<button type="button" class="btn btn-primary"
onClick="addCertFile(this)">
<i class="fa fa-plus"></i>
<spring:message code="import_built_cert_file"></spring:message></button>
</c:if>
</div>
<h3 class="page-title">
@@ -460,6 +477,7 @@
</div>
</div>
</div>
<!-- keyring cert配置新增 -->
<%@include file="/WEB-INF/views/cfg/intercept/strateagy/keyRingCertForm.jsp" %>
</body>
</html>

View File

@@ -540,7 +540,7 @@
</div>
</div>
<c:set var="trustedCertPath" value="/proxy/intercept/strateagy/trustedCertList?functionId=${cfg.functionId}"/>
<!-- crl配置新增 -->
<!-- truted cert配置新增 -->
<%@include file="/WEB-INF/views/cfg/intercept/strateagy/certForm.jsp" %>
<%-- <%@include file="/WEB-INF/views/cfg/intercept/strateagy/crlForm.jsp" %> --%>
</body>