Przeglądaj źródła

租户无效时处理,超时后登出处理

huangzhiyong 7 lat temu
rodzic
commit
67967307e6

+ 3 - 3
hos-broker/src/main/resources/application.yml

@ -64,12 +64,12 @@ hos:
spring:
  profiles: test
  activemq:
    broker-url: tcp://172.19.103.42:61616
    broker-url: tcp://172.19.103.37:61616
    user: admin
    password: admin
  data:
    mongodb:
      host: 172.19.103.42
      host: 172.19.103.37
      port: 27017
      username: esb
      password: esb
@ -99,7 +99,7 @@ hos:
    path: /usr/local/mycat/   ##mycat的安装目录
  #jcraft shell操作
  jcraft:
    host: 172.19.103.42
    host: 172.19.103.37
    port: 22
    user: root
    password: ceshi

+ 1 - 1
hos-broker/src/main/resources/logback-spring.xml

@ -18,7 +18,7 @@
    </appender>
    <appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">    
        <file>{LOG_HOME}</file>        
        <file>{LOG_HOME}/output.log</file>        
        <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
            <fileNamePattern>{LOG_HOME}/%d{yyyy-MM-dd_HH_mm}.%i.log.zip</fileNamePattern>
            <minIndex>1</minIndex>

+ 8 - 6
hos-camel2/src/main/java/camel/central/archives/route/ArchivesRouterBuilder.java

@ -2,6 +2,8 @@ package camel.central.archives.route;
import com.yihu.hos.web.framework.constant.ArchivesConstant;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.camel.Exchange;
import org.apache.camel.ExchangePattern;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.jms.JmsComponent;
import org.apache.camel.model.ModelCamelContext;
@ -36,12 +38,12 @@ public class ArchivesRouterBuilder extends RouteBuilder {
        from("jetty:http://0.0.0.0:9999/api/datasetPackages?enableMultipartFilter=false").routeId("datasetUpload2")
//                .bean(ArchivesService.class,"bodyValue")
//                .removeHeaders("CamelHttp*")
                .to("http4://192.168.131.106:10140/api/v1.0/datasetPackages?bridgeEndpoint=true&throwExceptionOnFailure=false")//上传档案
//                .to("jetty:http://192.168.1.221:10140/api/v1.0/datasetPackages?bridgeEndpoint=true&disableStreamCache=true&throwExceptionOnFailure=false")//上传档案
//                .choice()
//                .when(header(Exchange.HTTP_RESPONSE_CODE).isEqualTo("200")).to(ExchangePattern.InOnly, ArchivesConstant.CAMEL_ENDPOINT)//成功:发送入库消息
//                .otherwise().log("上传失败").to("stream:out")
//                .endChoice()
//                .to("http4://192.168.131.106:10140/api/v1.0/datasetPackages?bridgeEndpoint=true&throwExceptionOnFailure=false")//上传档案
                .to("jetty:http://192.168.1.221:10140/api/v1.0/datasetPackages?bridgeEndpoint=true&throwExceptionOnFailure=false")//上传档案
                .choice()
                .when(header(Exchange.HTTP_RESPONSE_CODE).isEqualTo("200")).to(ExchangePattern.InOnly, ArchivesConstant.CAMEL_ENDPOINT)//成功:发送入库消息
                .otherwise().log("上传失败").to("stream:out")
                .endChoice()
        ;
        //入库请求(消费MQ消息,发送入库接口请求)

+ 26 - 5
src/main/java/com/yihu/hos/common/CommonPageController.java

@ -64,6 +64,28 @@ public class CommonPageController extends BaseController {
        return "pageView";
    }
    /**
     *  租户授权失败跳转页面
     * @param model
     * @return
     */
    @RequestMapping("tenantAutoFail")
    public String tenantAutoFail(Model model) {
        model.addAttribute("contentPage", "/common/tenantAutoFail");
        return "pageView";
    }
    /**
     *  集成登录验证失败跳转页面
     * @param model
     * @return
     */
    @RequestMapping("/oauth2/tokenValidFail")
    public String tokenValidFail(Model model) {
        model.addAttribute("contentPage", "/common/tokenValidFail");
        return "pageView";
    }
    /*
    登录页面
     */
@ -83,8 +105,8 @@ public class CommonPageController extends BaseController {
                PrintWriter out = null;
                try {
                    out = response.getWriter();
                    out.print("<script>alert('登录地址有误-用户授权失败!');</script>");
                    response.sendRedirect("/esb/loginPage");
//                    out.print("<script>alert('登录地址有误-用户授权失败!');</script>");
                    response.sendRedirect("/esb/tenantAutoFail");
                    out.flush();
                } catch (IOException e) {
                    e.printStackTrace();
@ -122,14 +144,13 @@ public class CommonPageController extends BaseController {
            System.out.println("auth:   " + auth);
            if (!auth) {
                //授权失败,切换回管理平台数据库
                auth = authenticateService.auth(session, saasAdmin);
                response.setCharacterEncoding("UTF-8");
                response.setHeader("Content-type", "text/html;charset=UTF-8");
                PrintWriter out = null;
                try {
                    out = response.getWriter();
                    out.print("<script>alert('请求地址不存在!');</script>");
                    response.sendRedirect("/esb/loginPage");
//                    out.print("<script>alert('请求地址不存在!');</script>");
                    response.sendRedirect("/esb/tenantAutoFail");
                    out.flush();
                } catch (IOException e) {
                    e.printStackTrace();

+ 2 - 0
src/main/java/com/yihu/hos/filter/SessionOutTimeFilter.java

@ -23,6 +23,8 @@ public class SessionOutTimeFilter extends OncePerRequestFilter {
    protected void doFilterInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain filterChain) throws ServletException, IOException {
        String path = httpServletRequest.getRequestURI();
        if (path.indexOf("/login") != -1
                || path.indexOf("/tenantAutoFail") != -1
                || path.indexOf("/tokenValidFail") != -1
                || path.indexOf("/system/loginAction") != -1
                || path.indexOf("/error") != -1
                || path.indexOf("/test.jsp") != -1

+ 12 - 5
src/main/java/com/yihu/hos/system/controller/SystemController.java

@ -84,19 +84,26 @@ public class SystemController {
        try {
            HttpSession session = request.getSession();
            String userCode = "";
            TenantSession tenantSession = (TenantSession)session.getAttribute(ContextAttributes.TENANT_SESSION);
            if (tenantSession !=null){
                userCode = tenantSession.getUserCode();
                authenticateService.logout(session);
            String tenant = "";
            if (session==null){
                tenant =  LocalContext.getContext().getAttachment(ContextAttributes.TENANT_NAME);
            }else {
                TenantSession tenantSession = (TenantSession)session.getAttribute(ContextAttributes.TENANT_SESSION);
                if (tenantSession !=null){
                    userCode = tenantSession.getUserCode();
                    authenticateService.logout(session);
                }
                tenant = tenantSession.getTenant();
            }
            session.removeAttribute("userInfo");
            LocalContext.getContext().removeAttachment(ContextAttributes.TENANT_NAME);
            ActionResult re = new ActionResult(true, "登出成功!");
            re.setData(tenantSession.getTenant());
            re.setData(tenant);
            return re;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
            return new ActionResult(false, "登出异常!");
        }
    }

+ 2 - 2
src/main/webapp/WEB-INF/ehr/jsp/common/signinJs.jsp

@ -28,11 +28,11 @@
                            location.href = '${contextRoot}/'+tenantName + '/oauth2/index?loginName='+data.obj.user;
                        }else{
                            location.href = '${contextRoot}/common/tokenValidFail';
                            location.href = '${contextRoot}/oauth2/tokenValidFail';
                        }
                    },
                    error: function (data) {
                        location.href = '${contextRoot}/common/tokenValidFail';
                        location.href = '${contextRoot}/oauth2/tokenValidFail';
                    }
                });
                return;