mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
隐藏返回的sign
This commit is contained in:
@@ -150,6 +150,11 @@ public class ApiConfig {
|
||||
*/
|
||||
private boolean openLimit = true;
|
||||
|
||||
/**
|
||||
* 显示返回sign
|
||||
*/
|
||||
private boolean showReturnSign = true;
|
||||
|
||||
public void addAppSecret(Map<String, String> appSecretPair) {
|
||||
for (Map.Entry<String, String> entry : appSecretPair.entrySet()) {
|
||||
this.isvManager.update(new IsvDefinition(entry.getKey(), entry.getValue()));
|
||||
|
@@ -120,25 +120,19 @@ public abstract class BaseExecutorAdapter<T, R> implements ResultExecutor<T, R>
|
||||
public String merge(T exchange, JSONObject jsonObjectService) {
|
||||
JSONObject ret = new JSONObject();
|
||||
String name = "error";
|
||||
String sign = "";
|
||||
Map<String, ?> params = this.getApiParam(exchange);
|
||||
if (params != null) {
|
||||
Object method = params.get(ParamNames.API_NAME);
|
||||
if (method != null) {
|
||||
name = String.valueOf(method);
|
||||
}
|
||||
Object clientSign = params.get(ParamNames.SIGN_NAME);
|
||||
if (clientSign != null) {
|
||||
sign = String.valueOf(clientSign);
|
||||
}
|
||||
}
|
||||
ApiConfig apiConfig = ApiConfig.getInstance();
|
||||
// 点换成下划线
|
||||
DataNameBuilder dataNameBuilder = apiConfig.getDataNameBuilder();
|
||||
String method = dataNameBuilder.build(name);
|
||||
ret.put(method, jsonObjectService);
|
||||
// 先隐藏返回签名字段
|
||||
ret.put(ParamNames.SIGN_NAME, sign);
|
||||
this.appendReturnSign(apiConfig, params, ret);
|
||||
ResultAppender resultAppender = apiConfig.getResultAppender();
|
||||
if (resultAppender != null) {
|
||||
resultAppender.append(ret, params);
|
||||
@@ -146,4 +140,22 @@ public abstract class BaseExecutorAdapter<T, R> implements ResultExecutor<T, R>
|
||||
return ret.toJSONString();
|
||||
}
|
||||
|
||||
protected void appendReturnSign(ApiConfig apiConfig, Map<String, ?> params, JSONObject ret) {
|
||||
if (apiConfig.isShowReturnSign() && params != null) {
|
||||
Object appKey = params.get(ParamNames.APP_KEY_NAME);
|
||||
String sign = this.createReturnSign(String.valueOf(appKey));
|
||||
ret.put(ParamNames.SIGN_NAME, sign);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 这里需要使用平台的私钥生成一个sign,需要配置两套公私钥。目前暂未实现
|
||||
* @param appKey
|
||||
* @return
|
||||
*/
|
||||
protected String createReturnSign(String appKey) {
|
||||
// TODO: 返回sign
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user