From 8bb7f7fe804dbbbbad798f0d9fbc2aa16defe0c0 Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Tue, 22 Oct 2024 18:46:50 +0800 Subject: [PATCH] =?UTF-8?q?[=E4=BF=AE=E5=A4=8D]=20=E5=B7=A5=E5=8D=95?= =?UTF-8?q?=E5=A4=84=E7=90=86-=E8=A1=A8=E6=A0=BC=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E7=9A=84=E5=AF=86=E7=A0=81=E6=9F=A5=E7=9C=8B=E6=9D=83=E9=99=90?= =?UTF-8?q?=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1272435695910912]工单处理-表格组件的密码查看权限异常 http://192.168.0.96:8090/demo/rdm.html#/bug-detail/939050947543040/939050947543057/1272435695910912 --- .../form/attribute/core/FormHandlerBase.java | 55 +++++++ .../IFormAttributeDataConversionHandler.java | 15 +- .../attribute/handler/PasswordHandler.java | 21 ++- .../attribute/handler/SubassemblyHandler.java | 149 +++++++++--------- .../handler/TableInputerHandler.java | 109 +++++++------ 5 files changed, 219 insertions(+), 130 deletions(-) diff --git a/src/main/java/neatlogic/framework/form/attribute/core/FormHandlerBase.java b/src/main/java/neatlogic/framework/form/attribute/core/FormHandlerBase.java index 72ba229ce..5c8980037 100644 --- a/src/main/java/neatlogic/framework/form/attribute/core/FormHandlerBase.java +++ b/src/main/java/neatlogic/framework/form/attribute/core/FormHandlerBase.java @@ -18,16 +18,20 @@ package neatlogic.framework.form.attribute.core; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.common.util.RC4Util; import neatlogic.framework.form.dto.AttributeDataVo; import neatlogic.framework.form.exception.AttributeValidException; import neatlogic.framework.form.exception.FormExtendAttributeConfigIllegalException; import neatlogic.framework.matrix.dao.mapper.MatrixMapper; import neatlogic.framework.util.$; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; import javax.annotation.Resource; import java.util.Collections; import java.util.List; +import java.util.Map; +import java.util.Objects; public abstract class FormHandlerBase implements IFormAttributeHandler, IFormAttributeDataConversionHandler { @@ -184,4 +188,55 @@ public abstract class FormHandlerBase implements IFormAttributeHandler, IFormAtt protected void myValidateExtendAttributeConfig(String key, JSONObject config) { } + + /** + * 组件内部密码组件密码解密 + * @param source + * @param attributeUuid + * @param otherParamConfig + * @return + */ + protected JSONObject withinPasswordDecryption(Object source, String attributeUuid, JSONObject otherParamConfig) { + JSONObject resultObj = new JSONObject(); + JSONArray dataArray = null; + if (source instanceof JSONArray) { + dataArray = (JSONArray) source; + } + if (CollectionUtils.isEmpty(dataArray)) { + return resultObj; + } + String rowUuid = otherParamConfig.getString("rowUuid"); + for (Object obj : dataArray) { + if (obj instanceof JSONObject) { + JSONObject dataObj = (JSONObject) obj; + if (MapUtils.isNotEmpty(dataObj)) { + for (Map.Entry entry : dataObj.entrySet()) { + if (Objects.equals(entry.getKey(), "uuid")) { + continue; + } + if (Objects.equals(entry.getKey(), attributeUuid)) { + if (Objects.equals(dataObj.getString("uuid"), rowUuid)) { + String password = RC4Util.decrypt((String) entry.getValue()); + resultObj.put("password", password); + } + } else { + if (entry.getValue() instanceof JSONArray) { + JSONObject passwordDecryptionObj = withinPasswordDecryption(entry.getValue(), attributeUuid, otherParamConfig); + if (MapUtils.isNotEmpty(passwordDecryptionObj)) { + JSONArray parentUuidList = passwordDecryptionObj.getJSONArray("parentUuidList"); + if (parentUuidList == null) { + parentUuidList = new JSONArray(); + passwordDecryptionObj.put("parentUuidList", parentUuidList); + } + parentUuidList.add(entry.getKey()); + return passwordDecryptionObj; + } + } + } + } + } + } + } + return resultObj; + } } diff --git a/src/main/java/neatlogic/framework/form/attribute/core/IFormAttributeDataConversionHandler.java b/src/main/java/neatlogic/framework/form/attribute/core/IFormAttributeDataConversionHandler.java index 47b479379..ac2f07b55 100644 --- a/src/main/java/neatlogic/framework/form/attribute/core/IFormAttributeDataConversionHandler.java +++ b/src/main/java/neatlogic/framework/form/attribute/core/IFormAttributeDataConversionHandler.java @@ -124,13 +124,24 @@ public interface IFormAttributeDataConversionHandler { return source; } +// /** +// * 密码解密 +// * @param source 属性原始数据 +// * @param configObj 属性配置信息 +// * @return 返回解密后的数据 +// */ +// default String passwordDecryption(Object source, JSONObject configObj, String attributeUuid, JSONObject otherParamConfig) { +// return null; +// } + /** * 密码解密 * @param source 属性原始数据 - * @param configObj 属性配置信息 + * @param attributeUuid 属性UUID + * @param otherParamConfig 其他参数信息 * @return 返回解密后的数据 */ - default String passwordDecryption(Object source, JSONObject configObj, String attributeUuid, JSONObject otherParamConfig) { + default JSONObject passwordDecryption(Object source, String attributeUuid, JSONObject otherParamConfig) { return null; } diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/PasswordHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/PasswordHandler.java index 92b3b4148..80c4b2f07 100644 --- a/src/main/java/neatlogic/module/framework/form/attribute/handler/PasswordHandler.java +++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/PasswordHandler.java @@ -163,14 +163,27 @@ public class PasswordHandler extends FormHandlerBase { return source; } +// @Override +// public String passwordDecryption(Object source, JSONObject configObj, String attributeUuid, JSONObject otherParamConfig) { +// if (source == null) { +// return null; +// } +// if (source instanceof String) { +// return RC4Util.decrypt((String) source); +// } +// return null; +// } + @Override - public String passwordDecryption(Object source, JSONObject configObj, String attributeUuid, JSONObject otherParamConfig) { + public JSONObject passwordDecryption(Object source, String attributeUuid, JSONObject otherParamConfig) { + JSONObject resultObj = new JSONObject(); if (source == null) { - return null; + return resultObj; } if (source instanceof String) { - return RC4Util.decrypt((String) source); + String password = RC4Util.decrypt((String) source); + resultObj.put("password", password); } - return null; + return resultObj; } } diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/SubassemblyHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/SubassemblyHandler.java index 854171ee1..e6e2de24a 100644 --- a/src/main/java/neatlogic/module/framework/form/attribute/handler/SubassemblyHandler.java +++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/SubassemblyHandler.java @@ -153,77 +153,82 @@ public class SubassemblyHandler extends FormHandlerBase { return dataArray; } - @Override - public String passwordDecryption(Object source, JSONObject configObj, String attributeUuid, JSONObject otherParamConfig) { - JSONArray dataArray = null; - if (source instanceof JSONArray) { - dataArray = (JSONArray) source; - } - if (CollectionUtils.isEmpty(dataArray)) { - return null; - } - JSONObject formData = configObj.getJSONObject("formData"); - if (MapUtils.isNotEmpty(formData)) { - JSONObject formConfig = formData.getJSONObject("formConfig"); - if (MapUtils.isNotEmpty(formConfig)) { - JSONArray tableList = formConfig.getJSONArray("tableList"); - if (CollectionUtils.isNotEmpty(tableList)) { - for (int i = 0; i < tableList.size(); i++) { - JSONObject tableObj = tableList.getJSONObject(i); - if (MapUtils.isNotEmpty(tableObj)) { - JSONObject component = tableObj.getJSONObject("component"); - if (MapUtils.isNotEmpty(component)) { - String handler = component.getString("handler"); - if (Objects.equals(handler, FormHandler.FORMPASSWORD.getHandler()) - || Objects.equals(handler, FormHandler.FORMTABLEINPUTER.getHandler()) - || Objects.equals(handler, FormHandler.FORMSUBASSEMBLY.getHandler())) { - String uuid = component.getString("uuid"); - JSONObject config = component.getJSONObject("config"); - IFormAttributeDataConversionHandler formAttributeDataConversionHandler = FormAttributeDataConversionHandlerFactory.getHandler(handler); - if (Objects.equals(handler, FormHandler.FORMPASSWORD.getHandler())) { - if (Objects.equals(uuid, attributeUuid)) { - String rowUuid = otherParamConfig.getString("rowUuid"); - for (int j = 0; j < dataArray.size(); j++) { - JSONObject dataObj = dataArray.getJSONObject(j); - if (MapUtils.isNotEmpty(dataObj)) { - if (Objects.equals(dataObj.getString("uuid"), rowUuid)) { - Object data = dataObj.get(uuid); - if (data != null) { - String result = formAttributeDataConversionHandler.passwordDecryption(data, config, attributeUuid, otherParamConfig); - if (result != null) { - return result; - } - } - } - } - } - } - - } else { - if (Objects.equals(handler, FormHandler.FORMSUBASSEMBLY.getHandler())) { - JSONObject formData1 = component.getJSONObject("formData"); - config.put("formData", formData1); - } - for (int j = 0; j < dataArray.size(); j++) { - JSONObject dataObj = dataArray.getJSONObject(j); - if (MapUtils.isNotEmpty(dataObj)) { - Object data = dataObj.get(uuid); - if (data != null) { - String result = formAttributeDataConversionHandler.passwordDecryption(data, config, attributeUuid, otherParamConfig); - if (result != null) { - return result; - } - } - } - } - } - } - } - } - } - } - } - } - return null; +// @Override +// public String passwordDecryption(Object source, JSONObject configObj, String attributeUuid, JSONObject otherParamConfig) { +// JSONArray dataArray = null; +// if (source instanceof JSONArray) { +// dataArray = (JSONArray) source; +// } +// if (CollectionUtils.isEmpty(dataArray)) { +// return null; +// } +// JSONObject formData = configObj.getJSONObject("formData"); +// if (MapUtils.isNotEmpty(formData)) { +// JSONObject formConfig = formData.getJSONObject("formConfig"); +// if (MapUtils.isNotEmpty(formConfig)) { +// JSONArray tableList = formConfig.getJSONArray("tableList"); +// if (CollectionUtils.isNotEmpty(tableList)) { +// for (int i = 0; i < tableList.size(); i++) { +// JSONObject tableObj = tableList.getJSONObject(i); +// if (MapUtils.isNotEmpty(tableObj)) { +// JSONObject component = tableObj.getJSONObject("component"); +// if (MapUtils.isNotEmpty(component)) { +// String handler = component.getString("handler"); +// if (Objects.equals(handler, FormHandler.FORMPASSWORD.getHandler()) +// || Objects.equals(handler, FormHandler.FORMTABLEINPUTER.getHandler()) +// || Objects.equals(handler, FormHandler.FORMSUBASSEMBLY.getHandler())) { +// String uuid = component.getString("uuid"); +// JSONObject config = component.getJSONObject("config"); +// IFormAttributeDataConversionHandler formAttributeDataConversionHandler = FormAttributeDataConversionHandlerFactory.getHandler(handler); +// if (Objects.equals(handler, FormHandler.FORMPASSWORD.getHandler())) { +// if (Objects.equals(uuid, attributeUuid)) { +// String rowUuid = otherParamConfig.getString("rowUuid"); +// for (int j = 0; j < dataArray.size(); j++) { +// JSONObject dataObj = dataArray.getJSONObject(j); +// if (MapUtils.isNotEmpty(dataObj)) { +// if (Objects.equals(dataObj.getString("uuid"), rowUuid)) { +// Object data = dataObj.get(uuid); +// if (data != null) { +// String result = formAttributeDataConversionHandler.passwordDecryption(data, config, attributeUuid, otherParamConfig); +// if (result != null) { +// return result; +// } +// } +// } +// } +// } +// } +// +// } else { +// if (Objects.equals(handler, FormHandler.FORMSUBASSEMBLY.getHandler())) { +// JSONObject formData1 = component.getJSONObject("formData"); +// config.put("formData", formData1); +// } +// for (int j = 0; j < dataArray.size(); j++) { +// JSONObject dataObj = dataArray.getJSONObject(j); +// if (MapUtils.isNotEmpty(dataObj)) { +// Object data = dataObj.get(uuid); +// if (data != null) { +// String result = formAttributeDataConversionHandler.passwordDecryption(data, config, attributeUuid, otherParamConfig); +// if (result != null) { +// return result; +// } +// } +// } +// } +// } +// } +// } +// } +// } +// } +// } +// } +// return null; +// } + + @Override + public JSONObject passwordDecryption(Object source, String attributeUuid, JSONObject otherParamConfig) { + return withinPasswordDecryption(source, attributeUuid, otherParamConfig); } } diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/TableInputerHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/TableInputerHandler.java index ad0b25b4d..6043a12c1 100644 --- a/src/main/java/neatlogic/module/framework/form/attribute/handler/TableInputerHandler.java +++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/TableInputerHandler.java @@ -899,58 +899,63 @@ public class TableInputerHandler extends FormHandlerBase { return dataArray; } +// @Override +// public String passwordDecryption(Object source, JSONObject configObj, String attributeUuid, JSONObject otherParamConfig) { +// JSONArray dataArray = null; +// if (source instanceof JSONArray) { +// dataArray = (JSONArray) source; +// } +// if (CollectionUtils.isEmpty(dataArray)) { +// return null; +// } +// String rowUuid = otherParamConfig.getString("rowUuid"); +// JSONArray dataConfig = configObj.getJSONArray("dataConfig"); +// if (CollectionUtils.isNotEmpty(dataConfig)) { +// for (int i = 0; i < dataConfig.size(); i++) { +// JSONObject attr = dataConfig.getJSONObject(i); +// String handler = attr.getString("handler"); +// if (Objects.equals(handler, FormHandler.FORMPASSWORD.getHandler())) { +// String uuid = attr.getString("uuid"); +// if (Objects.equals(uuid, attributeUuid)) { +// for (int j = 0; j < dataArray.size(); j++) { +// JSONObject dataObj = dataArray.getJSONObject(j); +// if (MapUtils.isNotEmpty(dataObj)) { +// if (Objects.equals(dataObj.getString("uuid"), rowUuid)) { +// String data = dataObj.getString(uuid); +// if (StringUtils.isNotBlank(data)) { +//// dataObj.put(uuid, RC4Util.encrypt(data)); +// return RC4Util.decrypt(data); +// } +// } +// } +// } +// } +// } else if (Objects.equals(handler, "formtable")) { +// JSONObject config = attr.getJSONObject("config"); +// if (MapUtils.isEmpty(config)) { +// continue; +// } +// String uuid = attr.getString("uuid"); +// for (int j = 0; j < dataArray.size(); j++) { +// JSONObject dataObj = dataArray.getJSONObject(j); +// if (MapUtils.isNotEmpty(dataObj)) { +// JSONArray data = dataObj.getJSONArray(uuid); +// if (CollectionUtils.isNotEmpty(data)) { +// String result = this.passwordDecryption(data, config, attributeUuid, otherParamConfig); +// if (result != null) { +// return result; +// } +// } +// } +// } +// } +// } +// } +// return null; +// } + @Override - public String passwordDecryption(Object source, JSONObject configObj, String attributeUuid, JSONObject otherParamConfig) { - JSONArray dataArray = null; - if (source instanceof JSONArray) { - dataArray = (JSONArray) source; - } - if (CollectionUtils.isEmpty(dataArray)) { - return null; - } - String rowUuid = otherParamConfig.getString("rowUuid"); - JSONArray dataConfig = configObj.getJSONArray("dataConfig"); - if (CollectionUtils.isNotEmpty(dataConfig)) { - for (int i = 0; i < dataConfig.size(); i++) { - JSONObject attr = dataConfig.getJSONObject(i); - String handler = attr.getString("handler"); - if (Objects.equals(handler, FormHandler.FORMPASSWORD.getHandler())) { - String uuid = attr.getString("uuid"); - if (Objects.equals(uuid, attributeUuid)) { - for (int j = 0; j < dataArray.size(); j++) { - JSONObject dataObj = dataArray.getJSONObject(j); - if (MapUtils.isNotEmpty(dataObj)) { - if (Objects.equals(dataObj.getString("uuid"), rowUuid)) { - String data = dataObj.getString(uuid); - if (StringUtils.isNotBlank(data)) { -// dataObj.put(uuid, RC4Util.encrypt(data)); - return RC4Util.decrypt(data); - } - } - } - } - } - } else if (Objects.equals(handler, "formtable")) { - JSONObject config = attr.getJSONObject("config"); - if (MapUtils.isEmpty(config)) { - continue; - } - String uuid = attr.getString("uuid"); - for (int j = 0; j < dataArray.size(); j++) { - JSONObject dataObj = dataArray.getJSONObject(j); - if (MapUtils.isNotEmpty(dataObj)) { - JSONArray data = dataObj.getJSONArray(uuid); - if (CollectionUtils.isNotEmpty(data)) { - String result = this.passwordDecryption(data, config, attributeUuid, otherParamConfig); - if (result != null) { - return result; - } - } - } - } - } - } - } - return null; + public JSONObject passwordDecryption(Object source, String attributeUuid, JSONObject otherParamConfig) { + return withinPasswordDecryption(source, attributeUuid, otherParamConfig); } } -- Gitee