Commit 7797ed1a by Nepxion

控制台增加权限拦截判断

parent ecb2fa83
...@@ -32,6 +32,8 @@ public abstract class AbstractRestInvoker { ...@@ -32,6 +32,8 @@ public abstract class AbstractRestInvoker {
protected List<ServiceInstance> serviceInstances; protected List<ServiceInstance> serviceInstances;
protected RestTemplate restTemplate; protected RestTemplate restTemplate;
private boolean checkPermissionEnabled = true;
public AbstractRestInvoker(List<ServiceInstance> serviceInstances, RestTemplate restTemplate) { public AbstractRestInvoker(List<ServiceInstance> serviceInstances, RestTemplate restTemplate) {
this.serviceInstances = serviceInstances; this.serviceInstances = serviceInstances;
this.restTemplate = restTemplate; this.restTemplate = restTemplate;
...@@ -52,16 +54,16 @@ public abstract class AbstractRestInvoker { ...@@ -52,16 +54,16 @@ public abstract class AbstractRestInvoker {
String url = getUrl(host, port); String url = getUrl(host, port);
String result = null; String result = null;
try { if (checkPermissionEnabled) {
checkPermission(serviceInstance); try {
checkPermission(serviceInstance);
result = doRest(url); result = invokeRest(url);
if (!StringUtils.equals(result, "OK")) { } catch (Exception e) {
ConsoleErrorHandler errorHandler = (ConsoleErrorHandler) restTemplate.getErrorHandler(); result = e.getMessage();
result = errorHandler.getCause();
} }
} catch (Exception e) { } else {
result = e.getMessage(); result = invokeRest(url);
} }
ResultEntity resultEntity = new ResultEntity(); ResultEntity resultEntity = new ResultEntity();
...@@ -78,6 +80,16 @@ public abstract class AbstractRestInvoker { ...@@ -78,6 +80,16 @@ public abstract class AbstractRestInvoker {
return ResponseEntity.ok().body(resultEntityList); return ResponseEntity.ok().body(resultEntityList);
} }
private String invokeRest(String url) {
String result = doRest(url);
if (!StringUtils.equals(result, "OK")) {
ConsoleErrorHandler errorHandler = (ConsoleErrorHandler) restTemplate.getErrorHandler();
result = errorHandler.getCause();
}
return result;
}
protected void checkDiscoveryControlPermission(ServiceInstance serviceInstance) { protected void checkDiscoveryControlPermission(ServiceInstance serviceInstance) {
Map<String, String> metaData = serviceInstance.getMetadata(); Map<String, String> metaData = serviceInstance.getMetadata();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment