Java Code Examples for com.alibaba.dubbo.registry.common.domain.User#hasServicePrivilege()

The following examples show how to use com.alibaba.dubbo.registry.common.domain.User#hasServicePrivilege() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServicePrivilegeCheckValve.java    From dubbox with Apache License 2.0 5 votes vote down vote up
private void invokeCheckServicePrivilege(User user) {
   	TurbineRunData rundata = getTurbineRunData(request);
   	HttpSession session = request.getSession();
   	
   	@SuppressWarnings("unchecked")
   	Map<String, String[]> requestMapping = request.getParameterMap();
   	
   	//记录上次操作到请求中
	String returnURL = "";
	if(session.getAttribute("returnURL")==null){
		returnURL = request.getContextPath();
	}else{
		returnURL = (String)session.getAttribute("returnURL");
	}
   	
   	if(requestMapping.get("service").length>0){
   		String service = ((String[]) requestMapping.get("service"))[0];
   		String method = "index";
   		if(requestMapping.get("_method").length>0){
   			method = requestMapping.get("_method")[0];
   		}
   		
   		boolean exclude = "index".equals(method) || "show".equals(method);
   		if(!exclude){
          	 	if (user != null && !user.hasServicePrivilege(service)) {
          	 		request.setAttribute("returnURL",returnURL);
          	 		redirectToNoRight(rundata);
               }
   		}
   	}
   	String type = requestMapping.get("_type").length == 0 ? null : requestMapping.get("_type")[0];
   	if(!"noServicePrivilege".equals(type)){
   		session.setAttribute("returnURL", request.getRequestURI());
   	}
   	return;
}
 
Example 2
Source File: ServicePrivilegeCheckValve.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
private void invokeCheckServicePrivilege(User user) {
   	TurbineRunData rundata = getTurbineRunData(request);
   	HttpSession session = request.getSession();
   	
   	@SuppressWarnings("unchecked")
   	Map<String, String[]> requestMapping = request.getParameterMap();
   	
   	//记录上次操作到请求中
	String returnURL = "";
	if(session.getAttribute("returnURL")==null){
		returnURL = request.getContextPath();
	}else{
		returnURL = (String)session.getAttribute("returnURL");
	}
   	
   	if(requestMapping.get("service").length>0){
   		String service = ((String[]) requestMapping.get("service"))[0];
   		String method = "index";
   		if(requestMapping.get("_method").length>0){
   			method = requestMapping.get("_method")[0];
   		}
   		
   		boolean exclude = "index".equals(method) || "show".equals(method);
   		if(!exclude){
          	 	if (user != null && !user.hasServicePrivilege(service)) {
          	 		request.setAttribute("returnURL",returnURL);
          	 		redirectToNoRight(rundata);
               }
   		}
   	}
   	String type = requestMapping.get("_type").length == 0 ? null : requestMapping.get("_type")[0];
   	if(!"noServicePrivilege".equals(type)){
   		session.setAttribute("returnURL", request.getRequestURI());
   	}
   	return;
}
 
Example 3
Source File: ServicePrivilegeCheckValve.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
private void invokeCheckServicePrivilege(User user) {
   	TurbineRunData rundata = getTurbineRunData(request);
   	HttpSession session = request.getSession();
   	
   	@SuppressWarnings("unchecked")
   	Map<String, String[]> requestMapping = request.getParameterMap();
   	
   	//记录上次操作到请求中
	String returnURL = "";
	if(session.getAttribute("returnURL")==null){
		returnURL = request.getContextPath();
	}else{
		returnURL = (String)session.getAttribute("returnURL");
	}
   	
   	if(requestMapping.get("service").length>0){
   		String service = ((String[]) requestMapping.get("service"))[0];
   		String method = "index";
   		if(requestMapping.get("_method").length>0){
   			method = requestMapping.get("_method")[0];
   		}
   		
   		boolean exclude = "index".equals(method) || "show".equals(method);
   		if(!exclude){
          	 	if (user != null && !user.hasServicePrivilege(service)) {
          	 		request.setAttribute("returnURL",returnURL);
          	 		redirectToNoRight(rundata);
               }
   		}
   	}
   	String type = requestMapping.get("_type").length == 0 ? null : requestMapping.get("_type")[0];
   	if(!"noServicePrivilege".equals(type)){
   		session.setAttribute("returnURL", request.getRequestURI());
   	}
   	return;
}
 
Example 4
Source File: ServicePrivilegeCheckValve.java    From dubbox with Apache License 2.0 5 votes vote down vote up
private void invokeCheckServicePrivilege(User user) {
   	TurbineRunData rundata = getTurbineRunData(request);
   	HttpSession session = request.getSession();
   	
   	@SuppressWarnings("unchecked")
   	Map<String, String[]> requestMapping = request.getParameterMap();
   	
   	//记录上次操作到请求中
	String returnURL = "";
	if(session.getAttribute("returnURL")==null){
		returnURL = request.getContextPath();
	}else{
		returnURL = (String)session.getAttribute("returnURL");
	}
   	
   	if(requestMapping.get("service").length>0){
   		String service = ((String[]) requestMapping.get("service"))[0];
   		String method = "index";
   		if(requestMapping.get("_method").length>0){
   			method = requestMapping.get("_method")[0];
   		}
   		
   		boolean exclude = "index".equals(method) || "show".equals(method);
   		if(!exclude){
          	 	if (user != null && !user.hasServicePrivilege(service)) {
          	 		request.setAttribute("returnURL",returnURL);
          	 		redirectToNoRight(rundata);
               }
   		}
   	}
   	String type = requestMapping.get("_type").length == 0 ? null : requestMapping.get("_type")[0];
   	if(!"noServicePrivilege".equals(type)){
   		session.setAttribute("returnURL", request.getRequestURI());
   	}
   	return;
}
 
Example 5
Source File: ServicePrivilegeCheckValve.java    From dubbox with Apache License 2.0 5 votes vote down vote up
private void invokeCheckServicePrivilege(User user) {
   	TurbineRunData rundata = getTurbineRunData(request);
   	HttpSession session = request.getSession();
   	
   	@SuppressWarnings("unchecked")
   	Map<String, String[]> requestMapping = request.getParameterMap();
   	
   	//记录上次操作到请求中
	String returnURL = "";
	if(session.getAttribute("returnURL")==null){
		returnURL = request.getContextPath();
	}else{
		returnURL = (String)session.getAttribute("returnURL");
	}
   	
   	if(requestMapping.get("service").length>0){
   		String service = ((String[]) requestMapping.get("service"))[0];
   		String method = "index";
   		if(requestMapping.get("_method").length>0){
   			method = requestMapping.get("_method")[0];
   		}
   		
   		boolean exclude = "index".equals(method) || "show".equals(method);
   		if(!exclude){
          	 	if (user != null && !user.hasServicePrivilege(service)) {
          	 		request.setAttribute("returnURL",returnURL);
          	 		redirectToNoRight(rundata);
               }
   		}
   	}
   	String type = requestMapping.get("_type").length == 0 ? null : requestMapping.get("_type")[0];
   	if(!"noServicePrivilege".equals(type)){
   		session.setAttribute("returnURL", request.getRequestURI());
   	}
   	return;
}