com.alibaba.citrus.turbine.TurbineRunData Java Examples

The following examples show how to use com.alibaba.citrus.turbine.TurbineRunData. 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: LocaleValve.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void invoke(PipelineContext pipelineContext) throws Exception {
    TurbineRunData rundata = getTurbineRunData(request);
    if (ignoreTarget(rundata.getTarget())) {
        pipelineContext.invokeNext();
        return;
    }

    //默认是中文
    String[] temp = rundata.getCookies().getStrings("locale");
    String locale = null;
    if (temp != null) {
        if (temp.length > 1) {
            locale = temp[temp.length - 1];
        } else if (temp.length == 1) {
            locale = temp[0];
        }
    }
    if (locale == null || "".equals(locale)) {
        locale = "zh";
    }

    Locale newLocale = Locale.SIMPLIFIED_CHINESE;
    if ("en".equals(locale)) {
        newLocale = Locale.ENGLISH;
    } else if ("zh".equals(locale)) {
        newLocale = Locale.SIMPLIFIED_CHINESE;
    } else if ("zh_TW".equals(locale)) {
        newLocale = Locale.TRADITIONAL_CHINESE;
    }
    LocaleUtil.setLocale(newLocale);

    pipelineContext.invokeNext();
}
 
Example #2
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 #3
Source File: ServicePrivilegeCheckValve.java    From dubbox with Apache License 2.0 5 votes vote down vote up
/**
    * 无权限跳转
    * @param rundata
    */
   private void redirectToNoRight(TurbineRunData rundata) {
       if(logger.isInfoEnabled()) {
           logger.info("No right to access: " + request.getRequestURI());
       }
       
   	rundata.getParameters().setString("returnURL1", (String)rundata.getRequest().getAttribute("returnURL"));
       rundata.setRedirectLocation("http://localhost:8080/governance/noServicePrivilege?returnURL="+rundata.getRequest().getAttribute("returnURL"));
   	return;
}
 
Example #4
Source File: LocaleValve.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
public void invoke(PipelineContext pipelineContext) throws Exception {
    TurbineRunData rundata = getTurbineRunData(request);
    if (ignoreTarget(rundata.getTarget())) {
        pipelineContext.invokeNext();
        return;
    }

    //默认是中文
    String[] temp = rundata.getCookies().getStrings("locale");
    String locale = null;
    if (temp != null) {
        if (temp.length > 1) {
            locale = temp[temp.length - 1];
        } else if (temp.length == 1) {
            locale = temp[0];
        }
    }
    if (locale == null || "".equals(locale)) {
        locale = "zh";
    }

    Locale newLocale = Locale.SIMPLIFIED_CHINESE;
    if ("en".equals(locale)) {
        newLocale = Locale.ENGLISH;
    } else if ("zh".equals(locale)) {
        newLocale = Locale.SIMPLIFIED_CHINESE;
    } else if ("zh_TW".equals(locale)) {
        newLocale = Locale.TRADITIONAL_CHINESE;
    }
    LocaleUtil.setLocale(newLocale);

    pipelineContext.invokeNext();
}
 
Example #5
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 #6
Source File: ServicePrivilegeCheckValve.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
/**
    * 无权限跳转
    * @param rundata
    */
   private void redirectToNoRight(TurbineRunData rundata) {
       if(logger.isInfoEnabled()) {
           logger.info("No right to access: " + request.getRequestURI());
       }
       
   	rundata.getParameters().setString("returnURL1", (String)rundata.getRequest().getAttribute("returnURL"));
       rundata.setRedirectLocation("http://localhost:8080/governance/noServicePrivilege?returnURL="+rundata.getRequest().getAttribute("returnURL"));
   	return;
}
 
Example #7
Source File: LocaleValve.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
public void invoke(PipelineContext pipelineContext) throws Exception {
    TurbineRunData rundata = getTurbineRunData(request);
    if (ignoreTarget(rundata.getTarget())) {
        pipelineContext.invokeNext();
        return;
    }

    //默认是中文
    String[] temp = rundata.getCookies().getStrings("locale");
    String locale = null;
    if (temp != null) {
        if (temp.length > 1) {
            locale = temp[temp.length - 1];
        } else if (temp.length == 1) {
            locale = temp[0];
        }
    }
    if (locale == null || "".equals(locale)) {
        locale = "zh";
    }

    Locale newLocale = Locale.SIMPLIFIED_CHINESE;
    if ("en".equals(locale)) {
        newLocale = Locale.ENGLISH;
    } else if ("zh".equals(locale)) {
        newLocale = Locale.SIMPLIFIED_CHINESE;
    } else if ("zh_TW".equals(locale)) {
        newLocale = Locale.TRADITIONAL_CHINESE;
    }
    LocaleUtil.setLocale(newLocale);

    pipelineContext.invokeNext();
}
 
Example #8
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 #9
Source File: ServicePrivilegeCheckValve.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
/**
    * 无权限跳转
    * @param rundata
    */
   private void redirectToNoRight(TurbineRunData rundata) {
       if(logger.isInfoEnabled()) {
           logger.info("No right to access: " + request.getRequestURI());
       }
       
   	rundata.getParameters().setString("returnURL1", (String)rundata.getRequest().getAttribute("returnURL"));
       rundata.setRedirectLocation("http://localhost:8080/governance/noServicePrivilege?returnURL="+rundata.getRequest().getAttribute("returnURL"));
   	return;
}
 
Example #10
Source File: LocaleValve.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void invoke(PipelineContext pipelineContext) throws Exception {
    TurbineRunData rundata = getTurbineRunData(request);
    if (ignoreTarget(rundata.getTarget())) {
        pipelineContext.invokeNext();
        return;
    }

    //默认是中文
    String[] temp = rundata.getCookies().getStrings("locale");
    String locale = null;
    if (temp != null) {
        if (temp.length > 1) {
            locale = temp[temp.length - 1];
        } else if (temp.length == 1) {
            locale = temp[0];
        }
    }
    if (locale == null || "".equals(locale)) {
        locale = "zh";
    }

    Locale newLocale = Locale.SIMPLIFIED_CHINESE;
    if ("en".equals(locale)) {
        newLocale = Locale.ENGLISH;
    } else if ("zh".equals(locale)) {
        newLocale = Locale.SIMPLIFIED_CHINESE;
    } else if ("zh_TW".equals(locale)) {
        newLocale = Locale.TRADITIONAL_CHINESE;
    }
    LocaleUtil.setLocale(newLocale);

    pipelineContext.invokeNext();
}
 
Example #11
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 #12
Source File: ServicePrivilegeCheckValve.java    From dubbox with Apache License 2.0 5 votes vote down vote up
/**
    * 无权限跳转
    * @param rundata
    */
   private void redirectToNoRight(TurbineRunData rundata) {
       if(logger.isInfoEnabled()) {
           logger.info("No right to access: " + request.getRequestURI());
       }
       
   	rundata.getParameters().setString("returnURL1", (String)rundata.getRequest().getAttribute("returnURL"));
       rundata.setRedirectLocation("http://localhost:8080/governance/noServicePrivilege?returnURL="+rundata.getRequest().getAttribute("returnURL"));
   	return;
}
 
Example #13
Source File: LocaleValve.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void invoke(PipelineContext pipelineContext) throws Exception {
    TurbineRunData rundata = getTurbineRunData(request);
    if (ignoreTarget(rundata.getTarget())) {
        pipelineContext.invokeNext();
        return;
    }

    //默认是中文
    String[] temp = rundata.getCookies().getStrings("locale");
    String locale = null;
    if (temp != null) {
        if (temp.length > 1) {
            locale = temp[temp.length - 1];
        } else if (temp.length == 1) {
            locale = temp[0];
        }
    }
    if (locale == null || "".equals(locale)) {
        locale = "zh";
    }

    Locale newLocale = Locale.SIMPLIFIED_CHINESE;
    if ("en".equals(locale)) {
        newLocale = Locale.ENGLISH;
    } else if ("zh".equals(locale)) {
        newLocale = Locale.SIMPLIFIED_CHINESE;
    } else if ("zh_TW".equals(locale)) {
        newLocale = Locale.TRADITIONAL_CHINESE;
    }
    LocaleUtil.setLocale(newLocale);

    pipelineContext.invokeNext();
}
 
Example #14
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 #15
Source File: ServicePrivilegeCheckValve.java    From dubbox with Apache License 2.0 5 votes vote down vote up
/**
    * 无权限跳转
    * @param rundata
    */
   private void redirectToNoRight(TurbineRunData rundata) {
       if(logger.isInfoEnabled()) {
           logger.info("No right to access: " + request.getRequestURI());
       }
       
   	rundata.getParameters().setString("returnURL1", (String)rundata.getRequest().getAttribute("returnURL"));
       rundata.setRedirectLocation("http://localhost:8080/governance/noServicePrivilege?returnURL="+rundata.getRequest().getAttribute("returnURL"));
   	return;
}