Skip to content

Commit edb0e6e

Browse files
committed
非开放请求不允许传 @combine@key
1 parent a3bf644 commit edb0e6e

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

APIJSONORM/src/main/java/apijson/orm/AbstractVerifier.java

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
package apijson.orm;
77

88
import static apijson.JSON.*;
9+
import static apijson.JSONMap.KEY_COMBINE;
10+
import static apijson.JSONMap.KEY_KEY;
911
import static apijson.RequestMethod.DELETE;
1012
import static apijson.RequestMethod.GET;
1113
import static apijson.RequestMethod.GETS;
@@ -219,7 +221,7 @@ public static HashMap<RequestMethod, String[]> getAccessMap(MethodAccess access)
219221

220222
@Override
221223
public String getVisitorIdKey(SQLConfig<T, M, L> config) {
222-
return config.getUserIdKey();
224+
return config == null ? getUserIdKey(null, null, null, null) : config.getUserIdKey();
223225
}
224226

225227
@Override
@@ -346,21 +348,23 @@ public void verifyAllowRole(SQLConfig<T, M, L> config, String table, RequestMeth
346348
* @throws Exception
347349
* @see {@link JSONMap#KEY_ROLE}
348350
*/
349-
public void verifyUseRole(SQLConfig<T, M, L> config, String table, RequestMethod method, String role) throws Exception {
351+
public void verifyUseRole(@NotNull SQLConfig<T, M, L> config, String table, RequestMethod method, String role) throws Exception {
350352
Log.d(TAG, "verifyUseRole table = " + table + "; method = " + method + "; role = " + role);
353+
Objects.requireNonNull(config);
351354
//验证角色,假定真实强制匹配<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
352355

353-
String visitorIdKey = getVisitorIdKey(config);
354356
if (table == null) {
355-
table = config == null ? null : config.getTable();
357+
table = config.getTable();
356358
}
357359
if (method == null) {
358-
method = config == null ? GET : config.getMethod();
360+
method = config.getMethod();
359361
}
360362
if (role == null) {
361-
role = config == null ? UNKNOWN : config.getRole();
363+
role = config.getRole();
362364
}
363365

366+
String visitorIdKey = getVisitorIdKey(config);
367+
364368
Object requestId;
365369
switch (role) {
366370
case LOGIN://verifyRole通过就行
@@ -1087,14 +1091,23 @@ public static <T, M extends Map<String, Object>, L extends List<Object>> M parse
10871091

10881092
// 判断不允许传的key<<<<<<<<<<<<<<<<<<<<<<<<<
10891093
for (String rk : rkset) {
1094+
if (rk == null) { // 无效的key
1095+
real.remove(rk);
1096+
continue;
1097+
}
1098+
10901099
if (refuseSet.contains(rk)) { // 不允许的字段
10911100
throw new IllegalArgumentException(method + "请求," + name
10921101
+ " 里面不允许传 " + rk + " 等" + StringUtil.get(refuseSet) + "内的任何字段!");
10931102
}
10941103

1095-
if (rk == null) { // 无效的key
1096-
real.remove(rk);
1097-
continue;
1104+
if (KEY_COMBINE.equals(rk)) {
1105+
throw new UnsupportedOperationException(method + " 请求," + rk + " 不合法!" +
1106+
"非开放请求不允许传 " + KEY_COMBINE + ":value !");
1107+
}
1108+
if (KEY_KEY.equals(rk)) {
1109+
throw new UnsupportedOperationException(method + " 请求," + rk + " 不合法!" +
1110+
"非开放请求不允许传 " + KEY_KEY + ":value !");
10981111
}
10991112

11001113
Object rv = real.get(rk);

0 commit comments

Comments
 (0)