Skip to content

Commit b24b4b7

Browse files
committed
Server: 非 DEBUG 模式下不允许访问字段 debug 为 0 的表
1 parent 9d2460c commit b24b4b7

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

APIJSON-Java-Server/APIJSONBoot/src/main/java/apijson/demo/server/DemoVerifier.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static JSONObject init(boolean shutdownWhenServerError) throws ServerExce
8282
request.putAll(accessItem.toArray(0, 0, ACCESS_));
8383
} //Access[]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
8484

85-
85+
8686
JSONObject response = new DemoParser(RequestMethod.GET, true).parseResponse(request);
8787
if (JSONResponse.isSuccess(response) == false) {
8888
Log.e(TAG, "\n\n\n\n\n !!!! 查询权限配置异常 !!!\n" + response.getString(JSONResponse.KEY_MSG) + "\n\n\n\n\n");
@@ -96,7 +96,7 @@ public static JSONObject init(boolean shutdownWhenServerError) throws ServerExce
9696
}
9797

9898
Log.d(TAG, "init < for ACCESS_MAP.size() = " + ACCESS_MAP.size() + " <<<<<<<<<<<<<<<<<<<<<<<<");
99-
99+
100100
ACCESS_MAP.clear();
101101

102102
JSONObject item;
@@ -117,31 +117,35 @@ public static JSONObject init(boolean shutdownWhenServerError) throws ServerExce
117117

118118
String name = item.getString("name");
119119
String alias = item.getString("alias");
120-
120+
121121
/**TODO
122122
* 以下判断写得比较复杂,因为表设计不够好,但为了兼容旧版 APIJSON 服务 和 APIAuto 工具而保留了下来。
123123
* 如果是 name 为接口传参的 表对象 的 key,对应一个可缺省的 tableName,判断就会简单不少。
124124
*/
125-
125+
126126
if (StringUtil.isEmpty(name, true)) {
127127
onServerError("字段 name 的值不能为空!", shutdownWhenServerError);
128128
}
129-
129+
130130
if (StringUtil.isEmpty(alias, true)) {
131131
if (JSONRequest.isTableKey(name) == false) {
132132
onServerError("name: " + name + "不合法!字段 alias 的值为空时,name 必须为合法表名!", shutdownWhenServerError);
133133
}
134-
135-
ACCESS_MAP.put(name, map);
134+
135+
if (Log.DEBUG || item.getBooleanValue("debug") == false) {
136+
ACCESS_MAP.put(name, map);
137+
}
136138
}
137139
else {
138140
if (JSONRequest.isTableKey(alias) == false) {
139141
onServerError("alias: " + alias + "不合法!字段 alias 的值只能为 空 或者 合法表名!", shutdownWhenServerError);
140142
}
141-
142-
ACCESS_MAP.put(alias, map);
143+
144+
if (Log.DEBUG || item.getBooleanValue("debug") == false) {
145+
ACCESS_MAP.put(alias, map);
146+
}
143147
}
144-
148+
145149
}
146150

147151
Log.d(TAG, "init for /> ACCESS_MAP.size() = " + ACCESS_MAP.size() + " >>>>>>>>>>>>>>>>>>>>>>>");

APIJSON-Java-Server/APIJSONFinal/src/main/java/apijson/demo/server/DemoVerifier.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,19 @@ public static JSONObject init(boolean shutdownWhenServerError) throws ServerExce
131131
if (JSONRequest.isTableKey(name) == false) {
132132
onServerError("name: " + name + "不合法!字段 alias 的值为空时,name 必须为合法表名!", shutdownWhenServerError);
133133
}
134-
135-
ACCESS_MAP.put(name, map);
134+
135+
if (Log.DEBUG || item.getBooleanValue("debug") == false) {
136+
ACCESS_MAP.put(name, map);
137+
}
136138
}
137139
else {
138140
if (JSONRequest.isTableKey(alias) == false) {
139141
onServerError("alias: " + alias + "不合法!字段 alias 的值只能为 空 或者 合法表名!", shutdownWhenServerError);
140142
}
141-
142-
ACCESS_MAP.put(alias, map);
143+
144+
if (Log.DEBUG || item.getBooleanValue("debug") == false) {
145+
ACCESS_MAP.put(alias, map);
146+
}
143147
}
144148

145149
}

0 commit comments

Comments
 (0)