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;
|
private boolean openLimit = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 显示返回sign
|
||||||
|
*/
|
||||||
|
private boolean showReturnSign = true;
|
||||||
|
|
||||||
public void addAppSecret(Map<String, String> appSecretPair) {
|
public void addAppSecret(Map<String, String> appSecretPair) {
|
||||||
for (Map.Entry<String, String> entry : appSecretPair.entrySet()) {
|
for (Map.Entry<String, String> entry : appSecretPair.entrySet()) {
|
||||||
this.isvManager.update(new IsvDefinition(entry.getKey(), entry.getValue()));
|
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) {
|
public String merge(T exchange, JSONObject jsonObjectService) {
|
||||||
JSONObject ret = new JSONObject();
|
JSONObject ret = new JSONObject();
|
||||||
String name = "error";
|
String name = "error";
|
||||||
String sign = "";
|
|
||||||
Map<String, ?> params = this.getApiParam(exchange);
|
Map<String, ?> params = this.getApiParam(exchange);
|
||||||
if (params != null) {
|
if (params != null) {
|
||||||
Object method = params.get(ParamNames.API_NAME);
|
Object method = params.get(ParamNames.API_NAME);
|
||||||
if (method != null) {
|
if (method != null) {
|
||||||
name = String.valueOf(method);
|
name = String.valueOf(method);
|
||||||
}
|
}
|
||||||
Object clientSign = params.get(ParamNames.SIGN_NAME);
|
|
||||||
if (clientSign != null) {
|
|
||||||
sign = String.valueOf(clientSign);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ApiConfig apiConfig = ApiConfig.getInstance();
|
ApiConfig apiConfig = ApiConfig.getInstance();
|
||||||
// 点换成下划线
|
// 点换成下划线
|
||||||
DataNameBuilder dataNameBuilder = apiConfig.getDataNameBuilder();
|
DataNameBuilder dataNameBuilder = apiConfig.getDataNameBuilder();
|
||||||
String method = dataNameBuilder.build(name);
|
String method = dataNameBuilder.build(name);
|
||||||
ret.put(method, jsonObjectService);
|
ret.put(method, jsonObjectService);
|
||||||
// 先隐藏返回签名字段
|
this.appendReturnSign(apiConfig, params, ret);
|
||||||
ret.put(ParamNames.SIGN_NAME, sign);
|
|
||||||
ResultAppender resultAppender = apiConfig.getResultAppender();
|
ResultAppender resultAppender = apiConfig.getResultAppender();
|
||||||
if (resultAppender != null) {
|
if (resultAppender != null) {
|
||||||
resultAppender.append(ret, params);
|
resultAppender.append(ret, params);
|
||||||
@@ -146,4 +140,22 @@ public abstract class BaseExecutorAdapter<T, R> implements ResultExecutor<T, R>
|
|||||||
return ret.toJSONString();
|
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