Commit 98654e0b by WeiCong

完善数据安全框架

parent a20df4c4
...@@ -19,6 +19,8 @@ public class NoUiRequest { ...@@ -19,6 +19,8 @@ public class NoUiRequest {
private Map<String, ?> dataMap = new HashMap<String, Object>(); private Map<String, ?> dataMap = new HashMap<String, Object>();
private Map<String, ?> saveDisplayMap = new HashMap<String, Object>(); private Map<String, ?> saveDisplayMap = new HashMap<String, Object>();
private boolean isSecurity=false; private boolean isSecurity=false;
private String reqUrl;
private String trnName;
public NoUiRequest() { public NoUiRequest() {
...@@ -34,6 +36,15 @@ public class NoUiRequest { ...@@ -34,6 +36,15 @@ public class NoUiRequest {
this.userId = userId; this.userId = userId;
this.terminalType = terminalType; this.terminalType = terminalType;
this.mappingUrl = mappingUrl; this.mappingUrl = mappingUrl;
String[] mappingArgs = mappingUrl.split("/");
if(mappingArgs.length>1){
this.trnName = mappingArgs[mappingArgs.length - 2];
if(request.getRequestURI().indexOf(this.trnName)>0){
this.reqUrl=request.getRequestURI().substring(request.getRequestURI().indexOf(this.trnName)-1);
}else{
this.reqUrl=mappingUrl;
}
}
if(!StringUtil.isEmpty(security)){ if(!StringUtil.isEmpty(security)){
this.isSecurity=true; this.isSecurity=true;
} }
...@@ -125,4 +136,12 @@ public class NoUiRequest { ...@@ -125,4 +136,12 @@ public class NoUiRequest {
public boolean isSecurity() { public boolean isSecurity() {
return isSecurity; return isSecurity;
} }
public String getReqUrl() {
return reqUrl;
}
public String getTrnName() {
return trnName;
}
} }
...@@ -44,12 +44,12 @@ public abstract class AbstractCommonController { ...@@ -44,12 +44,12 @@ public abstract class AbstractCommonController {
@Autowired @Autowired
private NoUiVersion noUiVersion; private NoUiVersion noUiVersion;
public String getMainPanel(){ public String getMainPanel() {
return ""; return "";
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Object event(String mappingUrl, String eventType, Map<String, Object> dataMap, MultipartFile file,HttpServletRequest request, HttpServletResponse response) { public Object event(String mappingUrl, String eventType, Map<String, Object> dataMap, MultipartFile file, HttpServletRequest request, HttpServletResponse response) {
NoUiContext context = null; NoUiContext context = null;
Result ret = null; Result ret = null;
...@@ -68,10 +68,9 @@ public abstract class AbstractCommonController { ...@@ -68,10 +68,9 @@ public abstract class AbstractCommonController {
} }
// 设置old sysmod // 设置old sysmod
RedisLoginInfo redisLoginInfo = null; RedisLoginInfo redisLoginInfo = null;
if( !StringUtils.isEmpty(noUiRequest.getUserId()) ) //开放模式下 if (!StringUtils.isEmpty(noUiRequest.getUserId())) //开放模式下
redisLoginInfo = (RedisLoginInfo) RedisUtil.get(StringUtil.userUniqueId(noUiRequest)); redisLoginInfo = (RedisLoginInfo) RedisUtil.get(StringUtil.userUniqueId(noUiRequest));
if(redisLoginInfo != null) if (redisLoginInfo != null) {
{
NoUiPresentationUtil.setSysmod(context, (byte[]) redisLoginInfo.getSysmod()); NoUiPresentationUtil.setSysmod(context, (byte[]) redisLoginInfo.getSysmod());
context.setRedisLoginInfo(redisLoginInfo); context.setRedisLoginInfo(redisLoginInfo);
} }
...@@ -80,27 +79,31 @@ public abstract class AbstractCommonController { ...@@ -80,27 +79,31 @@ public abstract class AbstractCommonController {
context.getSession().chain(true, trnName); context.getSession().chain(true, trnName);
//执行可能存在的主面板的初始化 //执行可能存在的主面板的初始化
if(this.getMainPanel().length() > 0) if (this.getMainPanel().length() > 0) {
{ IPanel mainPanel = (IPanel) context.getSession().getBaseObject(null, this.getMainPanel());
IPanel mainPanel = (IPanel)context.getSession().getBaseObject(null, this.getMainPanel());
mainPanel.invokeDefaultRules(context); mainPanel.invokeDefaultRules(context);
} }
// 模型赋值 // 模型赋值
NoUiPresentationUtil.hanleInput(context, noUiRequest, alias); NoUiPresentationUtil.hanleInput(context, noUiRequest, alias);
//数据安全性拦截-篡改数据拦截 //数据安全性拦截-篡改数据拦截
if(DataSecurityUtil.isSafeMode() && noUiRequest.isSecurity()){ if (DataSecurityUtil.isSafeMode() && noUiRequest.isSecurity()) {
if(paramsMap.containsKey(DataSecurityUtil.BACKGROUND_ID)){ if (DataSecurityUtil.needDecrypt(noUiRequest.getReqUrl())) {
String[] clientpars = DataSecurityUtil.getSafeConfigByTrnName(context,trnName); if (paramsMap.containsKey(DataSecurityUtil.BACKGROUND_ID)) {
if(!ArrayUtils.isEmpty(clientpars)){ String[] clientpars = DataSecurityUtil.getSafeConfigByReqUrl(context, noUiRequest.getReqUrl() + DataSecurityUtil.DECRYPT_FIX);
if (!ArrayUtils.isEmpty(clientpars)) {
//合法性校验操作(场景:用户做修改、删除时调用) //合法性校验操作(场景:用户做修改、删除时调用)
serverEnc= (String) paramsMap.get(DataSecurityUtil.BACKGROUND_ID); serverEnc = (String) paramsMap.get(DataSecurityUtil.BACKGROUND_ID);
String errmsg=null; String errmsg = null;
if((errmsg=DataSecurityUtil.checkIllegalData(serverEnc,clientpars,noUiRequest.getUserId()))!=null){ if ((errmsg = DataSecurityUtil.checkIllegalData(serverEnc, clientpars, noUiRequest.getUserId())) != null) {
Result rt = new Result(ErrorCodes.ERROR, errmsg, null, noUiVersion.getVersion()); Result rt = new Result(ErrorCodes.ERROR, errmsg, null, noUiVersion.getVersion());
return rt; return rt;
} }
} }
} else {
Result rt = new Result(ErrorCodes.ERROR, DataSecurityUtil.ERROR_SERVERENC_NULL, null, noUiVersion.getVersion());
return rt;
}
} }
} }
...@@ -140,7 +143,7 @@ public abstract class AbstractCommonController { ...@@ -140,7 +143,7 @@ public abstract class AbstractCommonController {
} }
// 保存新的RedisLoginInfo // 保存新的RedisLoginInfo
if(redisLoginInfo!=null) //当为开放模式下,redisLoginInfo 为空 if (redisLoginInfo != null) //当为开放模式下,redisLoginInfo 为空
{ {
byte[] sysmodBytes = NoUiPresentationUtil.sysmodToBytes(context); byte[] sysmodBytes = NoUiPresentationUtil.sysmodToBytes(context);
redisLoginInfo.setSysmod(sysmodBytes); redisLoginInfo.setSysmod(sysmodBytes);
...@@ -150,14 +153,12 @@ public abstract class AbstractCommonController { ...@@ -150,14 +153,12 @@ public abstract class AbstractCommonController {
Map<String, Object> afterReturnData = handleReturnData(eventType, context, noUiRequest, alias); Map<String, Object> afterReturnData = handleReturnData(eventType, context, noUiRequest, alias);
//数据安全性拦截-篡改数据加密 //数据安全性拦截-篡改数据加密
if(DataSecurityUtil.isSafeMode() && noUiRequest.isSecurity()){ if (DataSecurityUtil.isSafeMode() && noUiRequest.isSecurity()) {
if(!paramsMap.containsKey(DataSecurityUtil.BACKGROUND_ID)){ if (DataSecurityUtil.needEncrypt(noUiRequest.getReqUrl())) {
//加密操作(场景:用户查询指定信息时调用,后续会做修改,删除等操作) //加密操作(场景:用户查询指定信息时调用,后续会做修改,删除等操作)
String[] pars = DataSecurityUtil.getSafeConfigByTrnName(context,trnName); String[] pars = DataSecurityUtil.getSafeConfigByReqUrl(context, noUiRequest.getReqUrl() + DataSecurityUtil.ENCRYPT_FIX);
if(!ArrayUtils.isEmpty(pars)){ serverEnc = DataSecurityUtil.encrypt(pars, noUiRequest.getUserId());
serverEnc=DataSecurityUtil.encrypt(pars,noUiRequest.getUserId()); afterReturnData.put(DataSecurityUtil.BACKGROUND_ID, serverEnc);
afterReturnData.put(DataSecurityUtil.BACKGROUND_ID,serverEnc);
}
} }
} }
...@@ -167,8 +168,7 @@ public abstract class AbstractCommonController { ...@@ -167,8 +168,7 @@ public abstract class AbstractCommonController {
log.error("OnClick command error", e); log.error("OnClick command error", e);
ret = ResultUtil.result(ErrorCodes.ERROR, "hander error", "service error", noUiVersion.getVersion()); ret = ResultUtil.result(ErrorCodes.ERROR, "hander error", "service error", noUiVersion.getVersion());
} finally { } finally {
if (context != null) if (context != null) {
{
//context.getSupport().disconnect(); //context.getSupport().disconnect();
context.dispose(); context.dispose();
} }
...@@ -210,19 +210,17 @@ public abstract class AbstractCommonController { ...@@ -210,19 +210,17 @@ public abstract class AbstractCommonController {
for (Map.Entry<String, String> aliasEntry : alias.getRel().entrySet()) { for (Map.Entry<String, String> aliasEntry : alias.getRel().entrySet()) {
String aliasKey = aliasEntry.getKey(); String aliasKey = aliasEntry.getKey();
String aliasPath = aliasEntry.getValue(); String aliasPath = aliasEntry.getValue();
if(aliasPath == null) if (aliasPath == null) {
{ log.error("错误的mapping:" + noUiRequest.getMappingUrl() + "--" + aliasKey + "--" + aliasPath);
log.error("错误的mapping:"+noUiRequest.getMappingUrl()+"--"+aliasKey+"--"+aliasPath);
continue; continue;
} }
if(modifyEntry.getKey() == null) if (modifyEntry.getKey() == null) {
{ log.error("错误的modifymap:" + noUiRequest.getMappingUrl() + "--" + modifyMap);
log.error("错误的modifymap:"+noUiRequest.getMappingUrl()+"--"+modifyMap);
continue; continue;
} }
if (aliasPath.startsWith(modifyEntry.getKey())) { if (aliasPath.startsWith(modifyEntry.getKey())) {
Object val = modifyEntry.getValue(); Object val = modifyEntry.getValue();
if(aliasKey == null) if (aliasKey == null)
continue; continue;
data.put(aliasKey, NoUiPresentationUtil.handIBaseObject(context, val, aliasEntry.getValue())); data.put(aliasKey, NoUiPresentationUtil.handIBaseObject(context, val, aliasEntry.getValue()));
containsKeys.add(modifyEntry.getKey()); containsKeys.add(modifyEntry.getKey());
...@@ -238,7 +236,7 @@ public abstract class AbstractCommonController { ...@@ -238,7 +236,7 @@ public abstract class AbstractCommonController {
System.out.println("modify datafield:" + (modifyMap.get(key) instanceof IDatafield)); System.out.println("modify datafield:" + (modifyMap.get(key) instanceof IDatafield));
System.out.println("modify module:" + (modifyMap.get(key) instanceof IModule)); System.out.println("modify module:" + (modifyMap.get(key) instanceof IModule));
System.out.println("modify moduleList:" + (modifyMap.get(key) instanceof IModuleList)); System.out.println("modify moduleList:" + (modifyMap.get(key) instanceof IModuleList));
if(key == null) if (key == null)
continue; continue;
data.put(key, NoUiPresentationUtil.handIBaseObject(context, modifyMap.get(key), key)); data.put(key, NoUiPresentationUtil.handIBaseObject(context, modifyMap.get(key), key));
} }
......
#安全开关(ON:开;OFF:关) #安全开关(ON:开;OFF:关)
switch=ON switch=ON
#客户管理——查询
/dblpty/sel_encode=\\ptyp\\ptylst[]\\inr
#客户管理——修改 #客户管理——修改
dbepty=\\ptygrp\\rec\\inr,\\ptygrp\\rec\\extkey /dbepty/init_decode=\\ptygrp\\rec\\inr
/dbepty/init_encode=\\ptygrp\\rec\\inr,\\ptygrp\\rec\\extkey
/dbepty/sav_decode=\\ptygrp\\rec\\inr,\\ptygrp\\rec\\extkey
#客户管理——删除 #客户管理——删除
dbdpty=\\ptygrp\\rec\\inr /dbdpty/init_decode=\\ptygrp\\rec\\inr
/dbdpty/init_encode=\\ptygrp\\rec\\inr
/dbdpty/sav_decode=\\ptygrp\\rec\\inr
# #
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment