|  | @ -9,6 +9,7 @@ import javax.servlet.FilterChain;
 | 
	
		
			
				|  |  | import javax.servlet.ServletException;
 | 
	
		
			
				|  |  | import javax.servlet.http.HttpServletRequest;
 | 
	
		
			
				|  |  | import javax.servlet.http.HttpServletResponse;
 | 
	
		
			
				|  |  | import javax.servlet.http.HttpSession;
 | 
	
		
			
				|  |  | import java.io.IOException;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | /**
 | 
	
	
		
			
				|  | @ -20,45 +21,49 @@ import java.io.IOException;
 | 
	
		
			
				|  |  | public class SessionOutTimeFilter extends OncePerRequestFilter {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Override
 | 
	
		
			
				|  |  |     protected void doFilterInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain filterChain) throws ServletException, IOException {
 | 
	
		
			
				|  |  |         String path = httpServletRequest.getRequestURI();
 | 
	
		
			
				|  |  |         if (path.indexOf("/login") != -1
 | 
	
		
			
				|  |  |                 || path.indexOf("/system/loginAction") != -1
 | 
	
		
			
				|  |  |                 || path.indexOf("/error") != -1
 | 
	
		
			
				|  |  |                 || path.indexOf("/test.jsp") != -1
 | 
	
		
			
				|  |  |                 || path.indexOf("/logoutAction") != -1
 | 
	
		
			
				|  |  |                 || path.indexOf(httpServletRequest.getContextPath() + "/static-dev") != -1
 | 
	
		
			
				|  |  |                 || path.indexOf(httpServletRequest.getContextPath() + "/develop") != -1
 | 
	
		
			
				|  |  |                 || path.indexOf(httpServletRequest.getContextPath() + "/rest") != -1
 | 
	
		
			
				|  |  |                 || path.indexOf(httpServletRequest.getContextPath() + "/process") != -1
 | 
	
		
			
				|  |  |                 || path.indexOf("swagger") != -1
 | 
	
		
			
				|  |  |                 || path.indexOf(httpServletRequest.getContextPath() + "/v2/api-docs") != -1
 | 
	
		
			
				|  |  |                 || path.indexOf("/tenant/delFile") != -1
 | 
	
		
			
				|  |  |                 || path.indexOf(httpServletRequest.getContextPath() + "/mobile") != -1) {
 | 
	
		
			
				|  |  |             filterChain.doFilter(httpServletRequest, httpServletResponse);
 | 
	
		
			
				|  |  |     protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
 | 
	
		
			
				|  |  |             throws ServletException, IOException {
 | 
	
		
			
				|  |  |         String requestUri = request.getRequestURI();
 | 
	
		
			
				|  |  |         String contextPath = request.getContextPath();
 | 
	
		
			
				|  |  |         HttpSession session = request.getSession();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (requestUri.indexOf("/login") != -1
 | 
	
		
			
				|  |  |                 || requestUri.indexOf("/system/loginAction") != -1
 | 
	
		
			
				|  |  |                 || requestUri.indexOf("/error") != -1
 | 
	
		
			
				|  |  |                 || requestUri.indexOf("/test.jsp") != -1
 | 
	
		
			
				|  |  |                 || requestUri.indexOf("/logoutAction") != -1
 | 
	
		
			
				|  |  |                 || requestUri.indexOf(contextPath + "/static-dev") != -1
 | 
	
		
			
				|  |  |                 || requestUri.indexOf(contextPath + "/develop") != -1
 | 
	
		
			
				|  |  |                 || requestUri.indexOf(contextPath + "/rest") != -1
 | 
	
		
			
				|  |  |                 || requestUri.indexOf(contextPath + "/process") != -1
 | 
	
		
			
				|  |  |                 || requestUri.indexOf("swagger") != -1
 | 
	
		
			
				|  |  |                 || requestUri.indexOf(contextPath + "/v2/api-docs") != -1
 | 
	
		
			
				|  |  |                 || requestUri.indexOf("/tenant/delFile") != -1
 | 
	
		
			
				|  |  |                 || requestUri.indexOf(contextPath + "/mobile") != -1) {
 | 
	
		
			
				|  |  |             filterChain.doFilter(request, response);
 | 
	
		
			
				|  |  |             return;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String requestUri = httpServletRequest.getRequestURI();
 | 
	
		
			
				|  |  |         //
 | 
	
		
			
				|  |  |         if (requestUri!=null && !requestUri.contains("/oauth2")) {
 | 
	
		
			
				|  |  |             if (httpServletRequest.getSession(false) == null
 | 
	
		
			
				|  |  |                     || httpServletRequest.getSession().getAttribute("userInfo") == null) {
 | 
	
		
			
				|  |  |         if (requestUri != null && !requestUri.contains("/oauth2")) {
 | 
	
		
			
				|  |  |             if (session == null || session.getAttribute("userInfo") == null) {
 | 
	
		
			
				|  |  |                 // AJAX REQUEST PROCESS
 | 
	
		
			
				|  |  |                 String attachment = LocalContext.getContext().getAttachment(ContextAttributes.TENANT_NAME);
 | 
	
		
			
				|  |  |                 if ("XMLHttpRequest".equalsIgnoreCase(httpServletRequest.getHeader("X-Requested-With"))) {
 | 
	
		
			
				|  |  |                     httpServletResponse.setHeader("sessionStatus", "timeOut");
 | 
	
		
			
				|  |  |                     httpServletResponse.getWriter().print("{}");
 | 
	
		
			
				|  |  |                     httpServletResponse.sendRedirect(httpServletRequest.getContextPath() + "/logoutAction");
 | 
	
		
			
				|  |  |                 if ("XMLHttpRequest".equalsIgnoreCase(request.getHeader("X-Requested-With"))) {
 | 
	
		
			
				|  |  |                     response.setHeader("sessionStatus", "timeOut");
 | 
	
		
			
				|  |  |                     response.getWriter().print("{}");
 | 
	
		
			
				|  |  |                     response.sendRedirect(request.getContextPath() + "/logoutAction");
 | 
	
		
			
				|  |  |                     return;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 httpServletRequest.getSession().setAttribute("attachment",attachment);
 | 
	
		
			
				|  |  |                 httpServletResponse.sendRedirect(httpServletRequest.getContextPath() + "/" + attachment + "/loginPage");
 | 
	
		
			
				|  |  |                 request.getSession().setAttribute("attachment", attachment);
 | 
	
		
			
				|  |  |                 response.sendRedirect(request.getContextPath() + "/" + attachment + "/loginPage");
 | 
	
		
			
				|  |  |                 return;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         } else if (requestUri.endsWith("/oauth2/autoLogin")) {
 | 
	
		
			
				|  |  |             // 从医疗云平台自动登录共享交换平台,则session永不过期。避免过期后返回到共享交换平台登录页。
 | 
	
		
			
				|  |  |             session.setMaxInactiveInterval(-1);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         filterChain.doFilter(httpServletRequest, httpServletResponse);
 | 
	
		
			
				|  |  |         filterChain.doFilter(request, response);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | }
 |