瀏覽代碼

网关调用

huangzhiyong 8 年之前
父節點
當前提交
a429190407

+ 6 - 3
hos-camel2/src/main/java/camel/gateway/processor/GatewayProcessor.java

@ -55,9 +55,12 @@ public class GatewayProcessor implements Processor {
            return "jetty:http://0.0.0.0:9999/error/outdataError";    //TODO:
        }
        pass = checkSign(params, secret);
        if (!pass) {
            return "jetty:http://0.0.0.0:9999/error/signValidError";    //TODO:
        //获取secret接口,不做sign验证
        if (!"admin.apps.get".equals(params.get("api"))) {
            pass = checkSign(params, secret);
            if (!pass) {
                return "jetty:http://0.0.0.0:9999/error/signValidError";    //TODO:
            }
        }
        pass = checkAuthorized(params);

+ 6 - 0
hos-camel2/src/main/resources/application.yml

@ -0,0 +1,6 @@
application:
  message: test
server:
  context-path: /
  port: 8001
  session-timeout:  3000

+ 153 - 0
hos-web-framework/src/main/java/com/yihu/hos/web/framework/util/SignVerifyUtil.java

@ -0,0 +1,153 @@
package com.yihu.hos.web.framework.util;
import com.yihu.hos.core.datatype.StringUtil;
import com.yihu.hos.core.encrypt.MD5;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2017/3/15.
 */
public class SignVerifyUtil {
    private final String version = "1.0";
    private TreeMap<String, String> paramMap = new TreeMap<>();
    private String timestamp;
    //TODO 配置文件中配置
    private String gatewayUrl = "seb-gatewayUrl";
    private String api;
    private String appKey = "esb-key";
    private String token;
    public static void main(String[] args) throws Exception {
        SignVerifyUtil paramSignUtil = new SignVerifyUtil();
        paramSignUtil.setApi("collect");
        paramSignUtil.addParam("patientId", "11111", true);
        paramSignUtil.addParam("eventNo", "2222222", true);
        paramSignUtil.genParam();
        String s = paramSignUtil.signParam("secret");
        System.out.println(s);
    }
    public void setApi(String api) {
        this.api = api;
    }
    public void setGatewayUrl(String gatewayUrl) {
        this.gatewayUrl = gatewayUrl;
    }
    public void addParam(Map<String, String> params) throws Exception {
        if (params != null) {
            params.remove("sign");
            paramMap.put("api", params.get("api").toString());
            paramMap.put("v", params.get("v").toString());
            paramMap.put("timestamp", params.get("timestamp").toString());
            paramMap.put("param", params.get("param").toString());
            paramMap.put("appKey", params.get("appKey").toString());
        } else {
            return;
        }
    }
    /**
     * sign 签名生成  (   md5(secret + params拼接字符串 + secret)   )
     *
     * @return
     */
    public String signParam(String secret) {
        Iterator<Map.Entry<String, String>> iterator = paramMap.entrySet().iterator();
        StringBuilder builder = new StringBuilder();
        builder.append(secret);
        while (iterator.hasNext()) {
            Map.Entry<String, String> next = iterator.next();
            String key = next.getKey();
            String value = next.getValue();
            builder.append(key);
            builder.append(value);
        }
        builder.append(secret);
        try {
            return MD5.hash(builder.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    /**
     * http请求 参数拼接
     *
     * @return
     * @throws Exception
     */
    public String genParam() throws Exception {
        Iterator<Map.Entry<String, String>> iterator = paramMap.entrySet().iterator();
        StringBuilder builder = new StringBuilder();
        while (iterator.hasNext()) {
            Map.Entry<String, String> next = iterator.next();
            String key = next.getKey();
            String value = next.getValue();
            if (value == null) {
                throw new Exception("参数错误:参数" + key + "值为空.");
            }
            if (builder.length() == 0) {
                builder.append("?");
            } else {
                builder.append("&");
            }
            builder.append(key);
            builder.append("=");
            builder.append(URLEncoder.encode(value, "UTF-8"));
        }
        return builder.toString();
    }
    //TODO 获取应用token
    public String getToken() {
        return null;
    }
    public void setToken(String token) {
        this.token = token;
    }
    private void addParam(String paramName, String paramValue, boolean bMust) throws Exception {
        if (StringUtil.isEmpty(paramValue)) {
            if (bMust) {
                throw new Exception(paramName + "参数不能为空.");
            } else {
                return;
            }
        }
        String encodeValue = URLEncoder.encode(paramValue, "UTF-8");
        paramMap.put(paramName, encodeValue);
    }
    /**
     * 获取 ISO 8601格式的时间戳
     *
     * @return
     */
    private String getTimestamp() {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss:SSZ");
        timestamp = format.format(new Date());
        return timestamp;
    }
}

+ 139 - 17
hos-web-framework/src/main/java/com/yihu/hos/web/framework/util/controller/BaseController.java

@ -8,6 +8,8 @@ import com.yihu.hos.core.http.HttpClientKit;
import com.yihu.hos.core.log.Logger;
import com.yihu.hos.core.log.LoggerFactory;
import com.yihu.hos.web.framework.model.DetailModelResult;
import com.yihu.hos.web.framework.util.SignVerifyUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.ModelAndView;
@ -17,10 +19,8 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.text.SimpleDateFormat;
import java.util.*;
//import net.sf.json.JSONArray;
//import net.sf.json.JSONObject;
@ -34,8 +34,11 @@ import java.util.Map;
public class BaseController extends AbstractController {
    static private final Logger logger = LoggerFactory.getLogger(BaseController.class);
    @Value("${service-gateway.portalUrl}")
    public String portalUrl;
    @Value("${service-gateway.url}")
    public String url;
    @Autowired
    private ObjectMapper objectMapper;
    public BaseController() {
    }
@ -70,16 +73,15 @@ public class BaseController extends AbstractController {
    }
    public List jsonArrayToList(String jsonArray, Class tClass) {
        ObjectMapper mapper = new ObjectMapper();
        ArrayList list = new ArrayList();
        ArrayNode newJsonArray = null;
        try {
            newJsonArray = mapper.readValue(jsonArray, ArrayNode.class);
            newJsonArray = objectMapper.readValue(jsonArray, ArrayNode.class);
            if (newJsonArray != null && newJsonArray.size() > 0) {
                Iterator it = newJsonArray.iterator();
                while (it.hasNext()) {
                    JsonNode jsonObj = (JsonNode) it.next();
                    Object model = mapper.readValue(jsonObj.toString(), tClass);
                    Object model = objectMapper.readValue(jsonObj.toString(), tClass);
                    list.add(model);
                }
            }
@ -90,7 +92,6 @@ public class BaseController extends AbstractController {
    }
    public Object jsonToObject(String json, Class tClass) {
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            return objectMapper.readValue(json, tClass);
        } catch (IOException e) {
@ -102,28 +103,149 @@ public class BaseController extends AbstractController {
        return null;
    }
    public boolean validToken(String clientId,String token) {
        boolean result = false;
        ObjectMapper objectMapper = new ObjectMapper();
        //TODO 设置固定的验证入口地址
        HTTPResponse response = HttpClientKit.post(portalUrl + "/oauth/validToken?clientId=" + clientId + "&accessToken=" + token);
    /**
     * 获取oauth2 accessToken
     *
     * @param clientId
     * @param code     oauth2 code
     * @return
     */
    public String getToken(String clientId, String code) {
        HTTPResponse response = HttpClientKit.post(url + "/oauth/getToken?clientId=" + clientId + "&code=" + code);
        if (response.getStatusCode() != 200) {
            System.out.println("获取 token 请求失败!");
            return "";
        }
        try {
            Map map = objectMapper.readValue(response.getBody(), Map.class);
            if ((Boolean) map.get("successFlg")) {
                Map<String, Object> obj = (Map) map.get("obj");
                if (obj == null) {
                    return "";
                }
                String token = obj.get("token").toString();
                return token;
            } else {
                System.out.println("token获取失败:" + map.get("errorMsg"));
                return "";
            }
        } catch (IOException e) {
            System.out.println("token获取请求异常:");
            e.printStackTrace();
            return "";
        }
    }
    private String getSecret(String appKey) {
        Map<String, String> params = new HashMap<>();
        try {
        params.put("app_id", appKey);
            Map<String, String> requestParams = genRequestParams(appKey, "admin.apps.get", "", params);
            //TODO 设置固定的验证入口地址
        HTTPResponse response = HttpClientKit.post(url,requestParams);
        if (response.getStatusCode() != 200) {
            System.out.println("请求失败!");
            return false;
            return "";
        }
            Map map = objectMapper.readValue(response.getBody(), Map.class);
            if ((Boolean) map.get("successFlg")) {
                Map<String, Object> obj = (Map) map.get("obj");
                if (obj == null) {
                    return "";
                }
                String secret = obj.get("secret").toString();
                return secret;
            } else {
                System.out.println("验证失败:" + map.get("errorMsg"));
                return "";
            }
        } catch (IOException e) {
            e.printStackTrace();
            return "";
        }
    }
    /**
     * token验证
     *
     * @param clientId
     * @param token
     * @return
     */
    public boolean validToken(String clientId, String token) {
        try {
            // 统一网关访问
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
            Map<String, String> parmas = new HashMap<>();
            parmas.put("clientId", clientId);
            parmas.put("accessToken", token);
            String paramsStr = objectMapper.writeValueAsString(parmas);
            Map<String, String> requestBody = new HashMap<>();
            requestBody.put("api", "portal.oauth.validToken.post");
            requestBody.put("param", paramsStr);
            requestBody.put("timestamp", format.format(new Date()));
            requestBody.put("v", "1.0");
            requestBody.put("appKey", clientId);
            SignVerifyUtil paramSign = new SignVerifyUtil();
            paramSign.addParam(requestBody);
//            paramSign.genParam();
            //TODO 获取app secret传入验证
            String secret = getSecret(clientId);
            String md5Sign = paramSign.signParam(secret);
            requestBody.put("sign", md5Sign);
            HTTPResponse response = HttpClientKit.post(url, requestBody);
            if (response.getStatusCode() != 200) {
                System.out.println("验证token 请求失败!");
                return false;
            }
            Map map = objectMapper.readValue(response.getBody(), Map.class);
            if ((Boolean) map.get("successFlg")) {
                return true;
            } else {
                System.out.println("验证失败:" + map.get("errorMsg"));
                System.out.println("token验证失败:" + map.get("errorMsg"));
                return false;
            }
        } catch (IOException e) {
            System.out.println("token验证异常:");
            e.printStackTrace();
            return false;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }
    public Map<String, String> genRequestParams(String clientId, String api, String secret, Map<String, String> params) {
        Map<String, String> requestBody = new HashMap<>();
        try {
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
            String paramsStr = objectMapper.writeValueAsString(params);
            requestBody.put("api", api);
            requestBody.put("param", paramsStr);
            requestBody.put("timestamp", format.format(new Date()));
            requestBody.put("v", "1.0");
            requestBody.put("appKey", clientId);
            SignVerifyUtil paramSign = new SignVerifyUtil();
            paramSign.addParam(requestBody);
//            paramSign.genParam();
            //TODO 获取app secret传入验证
            String md5Sign = paramSign.signParam(secret);
            requestBody.put("sign", md5Sign);
            return requestBody;
        } catch (IOException e) {
            System.out.println("token验证异常:");
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}

+ 94 - 84
src/main/java/com/yihu/hos/common/CommonPageController.java

@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@ -40,11 +41,11 @@ public class CommonPageController extends BaseController {
    登录页面
     */
    @RequestMapping("loginPage")
    public String login(Model model, HttpServletRequest request,HttpServletResponse response) {
    public String login(Model model, HttpServletRequest request, HttpServletResponse response) {
        HttpSession session = request.getSession();
        try {
            boolean auth = authenticateService.auth(session, saasAdmin);
            if (!auth){
            if (!auth) {
                //授权失败
                response.setCharacterEncoding("UTF-8");
                response.setHeader("Content-type", "text/html;charset=UTF-8");
@ -59,20 +60,21 @@ public class CommonPageController extends BaseController {
                } finally {
                    IOUtils.closeQuietly(out);
                }
            }else {
            } else {
                remoteShellService.start();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        model.addAttribute("contentPage","/common/login");
        model.addAttribute("contentPage", "/common/login");
        return "pageView";
    }
    /**
     * 租户登录页面
     *
     * @param model
     * @param tenantName
     * @param request
@ -80,37 +82,37 @@ public class CommonPageController extends BaseController {
     */
    @RequestMapping("{tenantName}/loginPage")
    public String tenantLogin(Model model,
                            @PathVariable(name = "tenantName") String tenantName,
                            HttpServletRequest request,HttpServletResponse response) throws IOException {
                              @PathVariable(name = "tenantName") String tenantName,
                              HttpServletRequest request, HttpServletResponse response) throws IOException {
        HttpSession session = request.getSession();
        boolean auth = false;
        try {
            auth = authenticateService.auth(session, tenantName);
        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.flush();
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                IOUtils.closeQuietly(out);
            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.flush();
                } catch (IOException e) {
                    e.printStackTrace();
                } finally {
                    IOUtils.closeQuietly(out);
                }
            } else {
                remoteShellService.start();
            }
        }else {
            remoteShellService.start();
        }
        } catch (Exception e) {
            e.printStackTrace();
        }
        model.addAttribute("contentPage","/common/login");
        model.addAttribute("contentPage", "/common/login");
        return "pageView";
    }
@ -121,69 +123,77 @@ public class CommonPageController extends BaseController {
    @RequestMapping("{tenantName}/indexPage")
    public String tenantIndex(
            @PathVariable(name = "tenantName") String tenantName,
            HttpServletRequest request,Model model) {
            HttpServletRequest request, Model model) {
        HttpSession session = request.getSession();
        boolean auth = false;
        String clientId  = request.getParameter("clientId");
        String token  = request.getParameter("token");
        boolean succ = validToken(clientId, token);
        if (succ){
            //TODO 根据token和clientId 获取用户信息
            SystemUser userInfo = new SystemUser();
            userInfo.setLoginCode("admin");
            userInfo.setUserName("管理员");
            session.setAttribute("userInfo",userInfo);
            try {
                auth = authenticateService.auth(session, tenantName);
                if (auth){
        String clientId = request.getParameter(ContextAttributes.CLIENTID);
        String token = request.getParameter(ContextAttributes.ACCESSTOKEN);
        //通过clientId和 oauth2 code 获取token
//        String token = getToken(clientId, code);
        if (!StringUtils.isEmpty(token)) {
            //验证token
            boolean succ = validToken(clientId, token);
            if (succ) {
                //TODO 根据token和clientId 获取用户信息
                SystemUser userInfo = new SystemUser();
                userInfo.setLoginCode("admin");
                userInfo.setUserName("管理员");
                session.setAttribute("userInfo", userInfo);
                try {
                    auth = authenticateService.auth(session, tenantName);
                    if (!auth) {
                        model.addAttribute("contentPage", "/common/tokenValidFail");
                        return "pageView";
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }catch (Exception e){
                e.printStackTrace();
                model.addAttribute("userName", "admin");
                model.addAttribute("tenant", tenantName);
                //获取菜单
                String menu = "[{id: 1, text: '任务管理',icon:'${staticRoot}/images/index/menu2_icon.png'},\n" +
                        "        {id: 11, pid: 1, text: '任务跟踪', url: '${contextRoot}/datacollect/trackJob',targetType:'1'},\n" +
                        "        {id: 12, pid: 1, text: '任务补采', url: '${contextRoot}/datacollect/repeatDatacollect'},\n" +
                        "        {id: 13, pid: 1, text: '任务配置', url: '${contextRoot}/datacollect/configJob'},\n" +
                        "        {id: 2, text: '标准管理',icon:'${staticRoot}/images/index/menu3_icon.png'},\n" +
                        "        {id: 21, pid: 2, text: '集成标准', url: '${contextRoot}/integration/initial/standard'},\n" +
                        "        {id: 22, pid: 2, text: '应用标准', url: '${contextRoot}/integration/initial/application'},\n" +
                        "        {id: 23, pid: 2, text: '适配方案', url: '${contextRoot}/adapterPlan/initial'},\n" +
                        "        {id: 3, text: '资源管理',icon:'${staticRoot}/images/index/menu4_icon.png'},\n" +
                        "        {id: 31, pid: 3, text: '资源注册', url: '${contextRoot}/resource/resource/initial'},\n" +
                        "        {id: 32, pid: 3, text: '资源浏览', url: '${contextRoot}/resource/resourcePage'},\n" +
                        "        {id: 34, pid: 3, text: '资源分类', url: '${contextRoot}/resource/rsCategory/initial'},\n" +
                        "        {id: 35, pid: 3, text: '业务资源', url: '${contextRoot}/resourceRest/initial'},\n" +
                        "        {id: 4, text: '维度管理',icon:'${staticRoot}/images/index/menu5_icon.png'},\n" +
                        "        {id: 41, pid: 4, text: '维度配置', url: '${contextRoot}/dimension/dimension'},\n" +
                        "        {id: 42, pid: 4, text: '维度类别配置', url: '${contextRoot}/dimension/dimensioncatetory'},\n" +
                        "        {id: 9, text: '系统配置',icon:'${staticRoot}/images/index/menu6_icon.png'},\n" +
                        "        {id: 91, pid: 9, text: '机构配置', url: '${contextRoot}/org/initial'},\n" +
                        "        {id: 92, pid: 9, text: '数据源配置', url: '${contextRoot}/datasource/configSources'},\n" +
                        "        {id: 93, pid: 9, text: '菜单配置', url: '${contextRoot}/menu/initial'},\n" +
                        "        {id: 100, pid: 9, text: '菜单按钮配置', url: '${contextRoot}/menu/menuAction/initial'},\n" +
                        "        {id: 94, pid: 9, text: '用户管理', url: '${contextRoot}/user/initial'},\n" +
                        "        {id: 95, pid: 9, text: '角色管理', url: '${contextRoot}/role/initial'},\n" +
                        "        {id: 96, pid: 9, text: '权限管理', url: '${contextRoot}/authority/initial'},\n" +
                        "        {id: 97, pid: 9, text: '字典管理', url: '${contextRoot}/dict/initial' },\n" +
                        "        {id: 98, pid: 9, text: '系统参数', url: '${contextRoot}/param/initial'},\n" +
                        "        {id: 99, pid: 9, text: '<spring:message code=\"title.app.manage\"/>', url: '${contextRoot}/app/initial'}]";
                model.addAttribute("menu", menu);
                model.addAttribute("contentPage", "/common/index");
            } else {
                //TODO  返回验证错误页面
                model.addAttribute("contentPage", "/common/tokenValidFail");
            }
            model.addAttribute("userName", "admin");
            model.addAttribute("tenant",tenantName);
            //获取菜单
            String menu = "[{id: 1, text: '任务管理',icon:'${staticRoot}/images/index/menu2_icon.png'},\n" +
                    "        {id: 11, pid: 1, text: '任务跟踪', url: '${contextRoot}/datacollect/trackJob',targetType:'1'},\n" +
                    "        {id: 12, pid: 1, text: '任务补采', url: '${contextRoot}/datacollect/repeatDatacollect'},\n" +
                    "        {id: 13, pid: 1, text: '任务配置', url: '${contextRoot}/datacollect/configJob'},\n" +
                    "        {id: 2, text: '标准管理',icon:'${staticRoot}/images/index/menu3_icon.png'},\n" +
                    "        {id: 21, pid: 2, text: '集成标准', url: '${contextRoot}/integration/initial/standard'},\n" +
                    "        {id: 22, pid: 2, text: '应用标准', url: '${contextRoot}/integration/initial/application'},\n" +
                    "        {id: 23, pid: 2, text: '适配方案', url: '${contextRoot}/adapterPlan/initial'},\n" +
                    "        {id: 3, text: '资源管理',icon:'${staticRoot}/images/index/menu4_icon.png'},\n" +
                    "        {id: 31, pid: 3, text: '资源注册', url: '${contextRoot}/resource/resource/initial'},\n" +
                    "        {id: 32, pid: 3, text: '资源浏览', url: '${contextRoot}/resource/resourcePage'},\n" +
                    "        {id: 34, pid: 3, text: '资源分类', url: '${contextRoot}/resource/rsCategory/initial'},\n" +
                    "        {id: 35, pid: 3, text: '业务资源', url: '${contextRoot}/resourceRest/initial'},\n" +
                    "        {id: 4, text: '维度管理',icon:'${staticRoot}/images/index/menu5_icon.png'},\n" +
                    "        {id: 41, pid: 4, text: '维度配置', url: '${contextRoot}/dimension/dimension'},\n" +
                    "        {id: 42, pid: 4, text: '维度类别配置', url: '${contextRoot}/dimension/dimensioncatetory'},\n" +
                    "        {id: 9, text: '系统配置',icon:'${staticRoot}/images/index/menu6_icon.png'},\n" +
                    "        {id: 91, pid: 9, text: '机构配置', url: '${contextRoot}/org/initial'},\n" +
                    "        {id: 92, pid: 9, text: '数据源配置', url: '${contextRoot}/datasource/configSources'},\n" +
                    "        {id: 93, pid: 9, text: '菜单配置', url: '${contextRoot}/menu/initial'},\n" +
                    "        {id: 100, pid: 9, text: '菜单按钮配置', url: '${contextRoot}/menu/menuAction/initial'},\n" +
                    "        {id: 94, pid: 9, text: '用户管理', url: '${contextRoot}/user/initial'},\n" +
                    "        {id: 95, pid: 9, text: '角色管理', url: '${contextRoot}/role/initial'},\n" +
                    "        {id: 96, pid: 9, text: '权限管理', url: '${contextRoot}/authority/initial'},\n" +
                    "        {id: 97, pid: 9, text: '字典管理', url: '${contextRoot}/dict/initial' },\n" +
                    "        {id: 98, pid: 9, text: '系统参数', url: '${contextRoot}/param/initial'},\n" +
                    "        {id: 99, pid: 9, text: '<spring:message code=\"title.app.manage\"/>', url: '${contextRoot}/app/initial'}]";
            model.addAttribute("menu", menu);
            model.addAttribute("contentPage","/common/index");
        }else {
        } else {
            //TODO  返回验证错误页面
            model.addAttribute("contentPage","/common/tokenValidFail");
            model.addAttribute("contentPage", "/common/tokenValidFail");
        }
        return "pageView";
    }
@ -191,13 +201,13 @@ public class CommonPageController extends BaseController {
首页页面
 */
    @RequestMapping("indexPage")
    public String index(HttpServletRequest request,Model model) {
    public String index(HttpServletRequest request, Model model) {
        HttpSession session = request.getSession();
        SystemUser user = (SystemUser) session.getAttribute("userInfo");
        TenantSession tenantSession = (TenantSession) session.getAttribute(ContextAttributes.TENANT_SESSION);
        model.addAttribute("userName", user.getUserName());
        model.addAttribute("tenant",tenantSession.getTenant());
        model.addAttribute("tenant", tenantSession.getTenant());
        //获取菜单
        String menu = "[{id: 1, text: '任务管理',icon:'${staticRoot}/images/index/menu2_icon.png'},\n" +
                "        {id: 11, pid: 1, text: '任务跟踪', url: '${contextRoot}/datacollect/trackJob',targetType:'1'},\n" +
@ -229,7 +239,7 @@ public class CommonPageController extends BaseController {
        model.addAttribute("menu", menu);
        model.addAttribute("contentPage","/common/index");
        model.addAttribute("contentPage", "/common/index");
        return "pageView";
    }
@ -239,7 +249,7 @@ public class CommonPageController extends BaseController {
     */
    @RequestMapping("homePage")
    public String home(Model model) {
        model.addAttribute("contentPage","/common/home");
        model.addAttribute("contentPage", "/common/home");
        return "partView";
    }

+ 4 - 0
src/main/java/com/yihu/hos/common/constants/ContextAttributes.java

@ -14,4 +14,8 @@ public interface ContextAttributes {
    String SHELL_RESPONSE = "shell_repsonse.";
    //集成参数
    String ACCESSTOKEN = "accessToken";
    String CLIENTID = "clientId";
}

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

@ -42,8 +42,8 @@ public class SessionOutTimeFilter extends OncePerRequestFilter {
            return;
        }
        String token  = httpServletRequest.getParameter("token");
        String clientId  = httpServletRequest.getParameter("clientId");
        String token  = httpServletRequest.getParameter(ContextAttributes.ACCESSTOKEN);
        String clientId  = httpServletRequest.getParameter(ContextAttributes.CLIENTID);
        if (token == null || clientId == null){
        if (httpServletRequest.getSession(false) == null

+ 4 - 1
src/main/resources/application.yml

@ -21,6 +21,7 @@ spring:
spring:
  profiles: dev
  administrators: jkzl
  clientId: 0e3DIdNaQ2
  #SAAS管理员账号,暂时配置在此处
  datasource:
      driverClassName: com.mysql.jdbc.Driver
@ -60,6 +61,8 @@ hos:
    filePath: e://learn.sql   #租户基础表 sql文件位置
service-gateway:
  portalUrl: http://localhost:444/api/v1.0/portal
  adminUrl: http://localhost:10000/api/v1.0/admin
  url: http://localhost:9999/api
---
spring:
  profiles: test
@ -108,4 +111,4 @@ hos:
  mysql:
    filePath: /usr/local/esb/esb.sql   #租户基础表 sql文件位置
service-gateway:
  portalUrl: http://sdw2:444/api/v1.0/portal
  portalUrl: http://192.168.131.109:444/api/v1.0/portal