com.alibaba.citrus.service.pipeline.PipelineContext Java Examples
The following examples show how to use
com.alibaba.citrus.service.pipeline.PipelineContext.
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 |
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: LocaleValve.java From dubbox-hystrix with Apache License 2.0 | 5 votes |
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 #3
Source File: LocaleValve.java From dubbo3 with Apache License 2.0 | 5 votes |
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 #4
Source File: LocaleValve.java From dubbox with Apache License 2.0 | 5 votes |
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: LocaleValve.java From dubbox with Apache License 2.0 | 5 votes |
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 #6
Source File: AuthorizationValve.java From dubbox with Apache License 2.0 | 4 votes |
public void invoke(PipelineContext pipelineContext) throws Exception { if (logger.isInfoEnabled()) { logger.info("AuthorizationValve of uri: " + request.getRequestURI()); } String uri = request.getRequestURI(); String contextPath = request.getContextPath(); if (contextPath != null && contextPath.length() > 0 && ! "/".equals(contextPath)) { uri = uri.substring(contextPath.length()); } if (uri.equals(logout)) { if (! isLogout()) { setLogout(true); showLoginForm(); } else { setLogout(false); response.sendRedirect(contextPath == null || contextPath.length() == 0 ? "/" : contextPath); } return; } //FIXME if(! uri.startsWith("/status/")){ User user = null; String authType = null; String authorization = request.getHeader("Authorization"); if (authorization != null && authorization.length() > 0) { int i = authorization.indexOf(' '); if (i >= 0) { authType = authorization.substring(0, i); String authPrincipal = authorization.substring(i + 1); if (BASIC_CHALLENGE.equalsIgnoreCase(authType)) { user = loginByBase(authPrincipal); } else if (DIGEST_CHALLENGE.equalsIgnoreCase(authType)) { user = loginByDigest(authPrincipal); } } } if (user == null || user.getUsername() == null || user.getUsername().length() == 0) { showLoginForm(); pipelineContext.breakPipeline(1); } if (user != null && StringUtils.isNotEmpty(user.getUsername())) { request.getSession().setAttribute(WebConstants.CURRENT_USER_KEY, user); pipelineContext.invokeNext(); } }else{ pipelineContext.invokeNext(); } }
Example #7
Source File: ServicePrivilegeCheckValve.java From dubbox with Apache License 2.0 | 4 votes |
public void invoke(PipelineContext pipelineContext) throws Exception { User user = (User) request.getSession().getAttribute(WebConstants.CURRENT_USER_KEY); invokeCheckServicePrivilege(user); pipelineContext.invokeNext(); }
Example #8
Source File: AuthorizationValve.java From dubbox-hystrix with Apache License 2.0 | 4 votes |
public void invoke(PipelineContext pipelineContext) throws Exception { if (logger.isInfoEnabled()) { logger.info("AuthorizationValve of uri: " + request.getRequestURI()); } String uri = request.getRequestURI(); String contextPath = request.getContextPath(); if (contextPath != null && contextPath.length() > 0 && ! "/".equals(contextPath)) { uri = uri.substring(contextPath.length()); } if (uri.equals(logout)) { if (! isLogout()) { setLogout(true); showLoginForm(); } else { setLogout(false); response.sendRedirect(contextPath == null || contextPath.length() == 0 ? "/" : contextPath); } return; } //FIXME if(! uri.startsWith("/status/")){ User user = null; String authType = null; String authorization = request.getHeader("Authorization"); if (authorization != null && authorization.length() > 0) { int i = authorization.indexOf(' '); if (i >= 0) { authType = authorization.substring(0, i); String authPrincipal = authorization.substring(i + 1); if (BASIC_CHALLENGE.equalsIgnoreCase(authType)) { user = loginByBase(authPrincipal); } else if (DIGEST_CHALLENGE.equalsIgnoreCase(authType)) { user = loginByDigest(authPrincipal); } } } if (user == null || user.getUsername() == null || user.getUsername().length() == 0) { showLoginForm(); pipelineContext.breakPipeline(1); } if (user != null && StringUtils.isNotEmpty(user.getUsername())) { request.getSession().setAttribute(WebConstants.CURRENT_USER_KEY, user); pipelineContext.invokeNext(); } }else{ pipelineContext.invokeNext(); } }
Example #9
Source File: ServicePrivilegeCheckValve.java From dubbox-hystrix with Apache License 2.0 | 4 votes |
public void invoke(PipelineContext pipelineContext) throws Exception { User user = (User) request.getSession().getAttribute(WebConstants.CURRENT_USER_KEY); invokeCheckServicePrivilege(user); pipelineContext.invokeNext(); }
Example #10
Source File: AuthorizationValve.java From dubbo3 with Apache License 2.0 | 4 votes |
public void invoke(PipelineContext pipelineContext) throws Exception { if (logger.isInfoEnabled()) { logger.info("AuthorizationValve of uri: " + request.getRequestURI()); } String uri = request.getRequestURI(); String contextPath = request.getContextPath(); if (contextPath != null && contextPath.length() > 0 && ! "/".equals(contextPath)) { uri = uri.substring(contextPath.length()); } if (uri.equals(logout)) { if (! isLogout()) { setLogout(true); showLoginForm(); } else { setLogout(false); response.sendRedirect(contextPath == null || contextPath.length() == 0 ? "/" : contextPath); } return; } //FIXME if(! uri.startsWith("/status/")){ User user = null; String authType = null; String authorization = request.getHeader("Authorization"); if (authorization != null && authorization.length() > 0) { int i = authorization.indexOf(' '); if (i >= 0) { authType = authorization.substring(0, i); String authPrincipal = authorization.substring(i + 1); if (BASIC_CHALLENGE.equalsIgnoreCase(authType)) { user = loginByBase(authPrincipal); } else if (DIGEST_CHALLENGE.equalsIgnoreCase(authType)) { user = loginByDigest(authPrincipal); } } } if (user == null || user.getUsername() == null || user.getUsername().length() == 0) { showLoginForm(); pipelineContext.breakPipeline(1); } if (user != null && StringUtils.isNotEmpty(user.getUsername())) { request.getSession().setAttribute(WebConstants.CURRENT_USER_KEY, user); pipelineContext.invokeNext(); } }else{ pipelineContext.invokeNext(); } }
Example #11
Source File: ServicePrivilegeCheckValve.java From dubbo3 with Apache License 2.0 | 4 votes |
public void invoke(PipelineContext pipelineContext) throws Exception { User user = (User) request.getSession().getAttribute(WebConstants.CURRENT_USER_KEY); invokeCheckServicePrivilege(user); pipelineContext.invokeNext(); }
Example #12
Source File: AuthorizationValve.java From dubbox with Apache License 2.0 | 4 votes |
public void invoke(PipelineContext pipelineContext) throws Exception { if (logger.isInfoEnabled()) { logger.info("AuthorizationValve of uri: " + request.getRequestURI()); } String uri = request.getRequestURI(); String contextPath = request.getContextPath(); if (contextPath != null && contextPath.length() > 0 && ! "/".equals(contextPath)) { uri = uri.substring(contextPath.length()); } if (uri.equals(logout)) { if (! isLogout()) { setLogout(true); showLoginForm(); } else { setLogout(false); response.sendRedirect(contextPath == null || contextPath.length() == 0 ? "/" : contextPath); } return; } //FIXME if(! uri.startsWith("/status/")){ User user = null; String authType = null; String authorization = request.getHeader("Authorization"); if (authorization != null && authorization.length() > 0) { int i = authorization.indexOf(' '); if (i >= 0) { authType = authorization.substring(0, i); String authPrincipal = authorization.substring(i + 1); if (BASIC_CHALLENGE.equalsIgnoreCase(authType)) { user = loginByBase(authPrincipal); } else if (DIGEST_CHALLENGE.equalsIgnoreCase(authType)) { user = loginByDigest(authPrincipal); } } } if (user == null || user.getUsername() == null || user.getUsername().length() == 0) { showLoginForm(); pipelineContext.breakPipeline(1); } if (user != null && StringUtils.isNotEmpty(user.getUsername())) { request.getSession().setAttribute(WebConstants.CURRENT_USER_KEY, user); pipelineContext.invokeNext(); } }else{ pipelineContext.invokeNext(); } }
Example #13
Source File: ServicePrivilegeCheckValve.java From dubbox with Apache License 2.0 | 4 votes |
public void invoke(PipelineContext pipelineContext) throws Exception { User user = (User) request.getSession().getAttribute(WebConstants.CURRENT_USER_KEY); invokeCheckServicePrivilege(user); pipelineContext.invokeNext(); }
Example #14
Source File: AuthorizationValve.java From dubbox with Apache License 2.0 | 4 votes |
public void invoke(PipelineContext pipelineContext) throws Exception { if (logger.isInfoEnabled()) { logger.info("AuthorizationValve of uri: " + request.getRequestURI()); } String uri = request.getRequestURI(); String contextPath = request.getContextPath(); if (contextPath != null && contextPath.length() > 0 && ! "/".equals(contextPath)) { uri = uri.substring(contextPath.length()); } if (uri.equals(logout)) { if (! isLogout()) { setLogout(true); showLoginForm(); } else { setLogout(false); response.sendRedirect(contextPath == null || contextPath.length() == 0 ? "/" : contextPath); } return; } //FIXME if(! uri.startsWith("/status/")){ User user = null; String authType = null; String authorization = request.getHeader("Authorization"); if (authorization != null && authorization.length() > 0) { int i = authorization.indexOf(' '); if (i >= 0) { authType = authorization.substring(0, i); String authPrincipal = authorization.substring(i + 1); if (BASIC_CHALLENGE.equalsIgnoreCase(authType)) { user = loginByBase(authPrincipal); } else if (DIGEST_CHALLENGE.equalsIgnoreCase(authType)) { user = loginByDigest(authPrincipal); } } } if (user == null || user.getUsername() == null || user.getUsername().length() == 0) { showLoginForm(); pipelineContext.breakPipeline(1); } if (user != null && StringUtils.isNotEmpty(user.getUsername())) { request.getSession().setAttribute(WebConstants.CURRENT_USER_KEY, user); pipelineContext.invokeNext(); } }else{ pipelineContext.invokeNext(); } }
Example #15
Source File: ServicePrivilegeCheckValve.java From dubbox with Apache License 2.0 | 4 votes |
public void invoke(PipelineContext pipelineContext) throws Exception { User user = (User) request.getSession().getAttribute(WebConstants.CURRENT_USER_KEY); invokeCheckServicePrivilege(user); pipelineContext.invokeNext(); }