Commit 75709c7c by Nepxion

控制台增加权限拦截判断

parent 44ed139c
...@@ -32,8 +32,6 @@ public abstract class AbstractRestInvoker { ...@@ -32,8 +32,6 @@ 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;
...@@ -54,16 +52,16 @@ public abstract class AbstractRestInvoker { ...@@ -54,16 +52,16 @@ public abstract class AbstractRestInvoker {
String url = getUrl(host, port); String url = getUrl(host, port);
String result = null; String result = null;
if (checkPermissionEnabled) { try {
try { checkPermission(serviceInstance);
checkPermission(serviceInstance);
result = invokeRest(url); result = doRest(url);
} catch (Exception e) { if (!StringUtils.equals(result, "OK")) {
result = e.getMessage(); ConsoleErrorHandler errorHandler = (ConsoleErrorHandler) restTemplate.getErrorHandler();
result = errorHandler.getCause();
} }
} else { } catch (Exception e) {
result = invokeRest(url); result = e.getMessage();
} }
ResultEntity resultEntity = new ResultEntity(); ResultEntity resultEntity = new ResultEntity();
...@@ -80,16 +78,6 @@ public abstract class AbstractRestInvoker { ...@@ -80,16 +78,6 @@ 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