<%@ page import="weaver.general.Util" %>
<%@ page import="weaver.hrm.User" %>
<%@ page import="weaver.integration.logging.Logger" %>
<%@ page import="weaver.integration.logging.LoggerFactory" %>
<%@ page import="java.net.URL" %>
<%@ page import="weaver.file.Prop" %>
<%@ page import="weaver.security.util.SecurityMethodUtil" %>
<%@ page import="java.util.Properties" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%
    Logger logger = LoggerFactory.getLogger(getClass());
    String path = Util.null2String( request.getParameter("path"));

    //delegate认证，跳转逻辑处理
    String delegate_islogined = Util.null2String( request.getParameter("delegate_islogined"));
    User user = (User) request.getSession(true).getAttribute("weaver_user@bean");
    if (user == null) {
        response.sendRedirect(request.getContextPath() + "/wui/index.html");
        return;
    }

    if (path.startsWith("http")) {
        String serverName = request.getServerName();
        URL url = new URL(path);
        String pathHost = Util.null2String(url.getHost());
        Properties casHostWhiteListFile = Prop.loadTemplateProp("casHostWhiteList");
        if (casHostWhiteListFile != null){
            String hostWhite = Util.null2String(Prop.getPropValue("casHostWhiteList","hostWhite"));
            String[] hostWhiteArray = hostWhite.split(",");
            boolean noright = false;
            if (serverName.equals(pathHost)){
                noright = true;
            } else {
                for (String host: hostWhiteArray){
                    if (pathHost.equals(host)) {
                        noright = true;
                        break;
                    }
                }
            }

            if (!noright){
                response.sendRedirect("/notice/noright.jsp");
                return;
            }
        }

    }

    if (path != null && path.endsWith("/wui/index.html")) {
        path = path.substring(0, path.indexOf("/wui/index.html")) + "/wui/index.html#/main";
    }
    //XSS过滤
    path = Util.toHtml(path);
    if (true){
        response.sendRedirect(path);
        return;
    }
%>

