From 3ebd22e0149a8cffdcdd265cb0cde3805eba477b Mon Sep 17 00:00:00 2001 From: zhanghongqing Date: Wed, 17 Oct 2018 17:18:47 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=81=E4=B9=A6=E4=B8=8A=E4=BC=A0=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=96=87=E4=BB=B6=E5=90=8E=E7=BC=80=E5=90=8D=E9=AA=8C?= =?UTF-8?q?=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/messages/message_en.properties | 7 +- .../resources/messages/message_ru.properties | 7 +- .../messages/message_zh_CN.properties | 7 +- .../views/cfg/intercept/strateagy/form.jsp | 90 +++++++++++++++++++ 4 files changed, 108 insertions(+), 3 deletions(-) diff --git a/src/main/resources/messages/message_en.properties b/src/main/resources/messages/message_en.properties index 04c37a742..2ee2d69c1 100644 --- a/src/main/resources/messages/message_en.properties +++ b/src/main/resources/messages/message_en.properties @@ -1246,4 +1246,9 @@ mail_address_monit=Mail Address Monit mail_address_reject=Mail Address Reject ipsec_protocol=IPSEC Protocol intercept_intensity=Intercept Related Domains -exceeds_duration_limit=File upload failure,The duration of uploaded files exceeds the limit. \ No newline at end of file +exceeds_duration_limit=File upload failure,The duration of uploaded files exceeds the limit. +file_in_wrong_format=File Format Error +select_certificate=Please Select Certificate Type First +root_certificate=der cer crt pem +intermediate_entity_certificate=p12 +private_certificate=pem key p12 \ No newline at end of file diff --git a/src/main/resources/messages/message_ru.properties b/src/main/resources/messages/message_ru.properties index 85aedf68d..12952910c 100644 --- a/src/main/resources/messages/message_ru.properties +++ b/src/main/resources/messages/message_ru.properties @@ -1266,4 +1266,9 @@ mail_address_monit=Mail Address Monit mail_address_reject=Mail Address Reject ipsec_protocol=IPSEC Protocol intercept_intensity=Intercept Related Domains -exceeds_duration_limit=File upload failure,The duration of uploaded files exceeds the limit. \ No newline at end of file +exceeds_duration_limit=File upload failure,The duration of uploaded files exceeds the limit. +file_in_wrong_format=File Format Error +select_certificate=Please Select Certificate Type First +root_certificate=der cer crt pem +intermediate_entity_certificate=p12 +private_certificate=pem key p12 \ No newline at end of file diff --git a/src/main/resources/messages/message_zh_CN.properties b/src/main/resources/messages/message_zh_CN.properties index c5618fddc..6f9391a05 100644 --- a/src/main/resources/messages/message_zh_CN.properties +++ b/src/main/resources/messages/message_zh_CN.properties @@ -1240,4 +1240,9 @@ mail_address_monit=\u90AE\u4EF6\u5730\u5740\u76D1\u6D4B mail_address_reject=\u90AE\u4EF6\u5730\u5740\u7BA1\u63A7 ipsec_protocol=IPSEC\u534F\u8BAE intercept_intensity=\u62E6\u622A\u5F3A\u5EA6 -exceeds_duration_limit=\u6587\u4EF6\u4E0A\u4F20\u5931\u8D25,\u6587\u4EF6\u65F6\u957F\u8D85\u51FA\u9650\u5236. +exceeds_duration_limit=\u6587\u4EF6\u4E0A\u4F20\u5931\u8D25,\u6587\u4EF6\u65F6\u957F\u8D85\u51FA\u9650\u5236. +file_in_wrong_format=\u6587\u4EF6\u683C\u5F0F\u9519\u8BEF +select_certificate=\u8BF7\u5148\u9009\u62E9\u6587\u4EF6\u8BC1\u4E66\u7C7B\u578B +root_certificate=der cer crt pem +intermediate_entity_certificate=p12 +private_certificate=pem key p12 \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/cfg/intercept/strateagy/form.jsp b/src/main/webapp/WEB-INF/views/cfg/intercept/strateagy/form.jsp index db6801544..fad668328 100644 --- a/src/main/webapp/WEB-INF/views/cfg/intercept/strateagy/form.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/intercept/strateagy/form.jsp @@ -13,9 +13,11 @@ $(function(){ }); $("#publicKeyFileI").on('change', function() { $("#publicKeyFileInfo").val($("#publicKeyFileI").val()); + publicFileValidate(); }); $("#privateKeyFileI").on('change', function() { $("#privateKeyFileInfo").val($("#privateKeyFileI").val()); + privateFileValidate(); }); switchKeyringType(); $("select[name=keyringType]").on('change', function() { @@ -37,6 +39,19 @@ $(function(){ var privateFile = $("#privateKeyFileI").val(); var publicKeyFile = $("#publicKeyFile").val(); var privateKeyFile = $("#privateKeyFile").val(); + + if(publicFile!=''){ + if(!publicFileValidate()){ + return false; + } + + } + if(privateFile!=''){ + if(!privateFileValidate()){ + return false; + } + } + if((publicFile==null||publicFile=="") && (publicKeyFile==null || publicKeyFile=="")){ $("div[for='publicKeyFileI']").append(""); return false; @@ -50,6 +65,7 @@ $(function(){ }, errorContainer: "#messageBox" }); + }); var switchCfgType=function(){ var cfgType=$("input[name='cfgType']:checked").val() @@ -64,6 +80,20 @@ var switchCfgType=function(){ var switchKeyringType=function(){ var keyringType=$("select[name=keyringType]").val(); var expireAfter=$("input[name=expireAfter]").val(); + if(keyringType!=''){ + if(keyringType=='root'){ + $("#publicInfo").empty(); + $("#publicInfo").append("  "); + }else{ + $("#publicInfo").empty(); + $("#publicInfo").append("  "); + } + }else{ + $("#publicInfo").empty(); +// $("#publicInfo").append("  "); + } + + if(keyringType =='end-entity'){ //实体证书不允许输入,并且默认0 $("input[name=expireAfter]").val(0); $(".expireAfter").addClass("hidden"); @@ -74,6 +104,64 @@ var switchKeyringType=function(){ $(".expireAfter").removeClass("hidden"); } } + +//增加对文件后缀名验证 +function publicFileValidate(){ + var keyringType=$("select[name=keyringType]").val(); + var flag=false; //状态,检测文件后缀用 + var arr=["der","cer","crt","pem","p12"];//使用是什么格式的后缀der、cer、crt、pem + if(keyringType=='root'){ + arr=["der","cer","crt","pem"]; + }else{ + arr=["p12"]; + } + var cFile=$("#publicKeyFileI").val();//文件的值 + //取出上传文件的扩展名 + var index=cFile.lastIndexOf("."); + var ext = cFile.substr(index+1).toLowerCase(); + //循环比较 + for(var i=0;i"); + return false; + } + return true; +} +function privateFileValidate(){ + var flag=false; //状态,检测文件后缀用 + var arr=["key","p12","pem"];//使用是什么格式的后缀pem、key、p12 + var cFile=$("#privateKeyFileI").val();//文件的值 + //取出上传文件的扩展名 + var index=cFile.lastIndexOf("."); + var ext = cFile.substr(index+1).toLowerCase(); + //循环比较 + for(var i=0;i"); + return false; + } + return true; +} @@ -189,6 +277,7 @@ var switchKeyringType=function(){ +
@@ -214,6 +303,7 @@ var switchKeyringType=function(){ +