|
@ -46,42 +46,36 @@ public class GatewayProcessor implements Processor {
|
|
// body = URLDecoder.decode(body, "UTF-8");
|
|
// body = URLDecoder.decode(body, "UTF-8");
|
|
Map<String, Object> params = exchange.getIn().getHeaders();
|
|
Map<String, Object> params = exchange.getIn().getHeaders();
|
|
if (params.get("appKey") == null) {
|
|
if (params.get("appKey") == null) {
|
|
exchange.getOut().setHeader(Exchange.HTTP_URI,"paramError");
|
|
|
|
return "direct:errorHandle"; //TODO:
|
|
|
|
|
|
return "restlet:http://0.0.0.0:8088/error/paramError?socketTimeout=60000&connectionTimeout=60000"; //TODO:
|
|
}
|
|
}
|
|
String appKey = params.get("appKey").toString();
|
|
String appKey = params.get("appKey").toString();
|
|
String secret = getSecret(appKey);
|
|
String secret = getSecret(appKey);
|
|
|
|
|
|
if (secret.equals("")) {
|
|
if (secret.equals("")) {
|
|
exchange.getOut().setHeader(Exchange.HTTP_URI,"paramError");
|
|
|
|
return "direct:errorHandle"; //TODO:
|
|
|
|
|
|
return "restlet:http://0.0.0.0:8088/error/paramError?socketTimeout=60000&connectionTimeout=60000"; //TODO:
|
|
}
|
|
}
|
|
|
|
|
|
boolean pass = checkParams(params);
|
|
boolean pass = checkParams(params);
|
|
if (!pass) {
|
|
if (!pass) {
|
|
exchange.getOut().setHeader(Exchange.HTTP_URI,"paramError");
|
|
|
|
return "direct:errorHandle"; //TODO:
|
|
|
|
|
|
return "jetty:http://0.0.0.0:8088/error/paramError?socketTimeout=60000&connectionTimeout=60000"; //TODO:
|
|
}
|
|
}
|
|
|
|
|
|
pass = checkTimeStamp(params);
|
|
pass = checkTimeStamp(params);
|
|
if (!pass) {
|
|
if (!pass) {
|
|
exchange.getOut().setHeader(Exchange.HTTP_URI,"outdateError");
|
|
|
|
return "direct:errorHandle"; //TODO:
|
|
|
|
|
|
return "restlet:http://0.0.0.0:8088/error/outdataError?socketTimeout=60000&connectionTimeout=60000"; //TODO:
|
|
}
|
|
}
|
|
|
|
|
|
//获取secret接口,不做sign验证
|
|
//获取secret接口,不做sign验证
|
|
if (!"admin.apps.get".equals(params.get("api"))) {
|
|
if (!"admin.apps.get".equals(params.get("api"))) {
|
|
pass = checkSign(params, secret);
|
|
pass = checkSign(params, secret);
|
|
if (!pass) {
|
|
if (!pass) {
|
|
exchange.getOut().setHeader(Exchange.HTTP_URI,"signValidError");
|
|
|
|
return "direct:errorHandle"; //TODO:
|
|
|
|
|
|
return "restlet:http://0.0.0.0:8088/error/signValidError?socketTimeout=60000&connectionTimeout=60000"; //TODO:
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
pass = checkAuthorized(params);
|
|
pass = checkAuthorized(params);
|
|
if (!pass) {
|
|
if (!pass) {
|
|
exchange.getOut().setHeader(Exchange.HTTP_URI,"unauthorizedError");
|
|
|
|
return "direct:errorHandle"; //TODO:
|
|
|
|
|
|
return "restlet:http://0.0.0.0:8088/error/unauthorizedError"; //TODO:
|
|
}
|
|
}
|
|
|
|
|
|
return genEndpoint(params, exchange);
|
|
return genEndpoint(params, exchange);
|