91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

cas_client之代理配置

發布時間:2020-08-02 08:16:36 來源:網絡 閱讀:427 作者:qq58bf61367490f 欄目:開發技術

本環境基于cas3.4.2進行配置,3個tomcat環境:單點登錄tomcat、代理tomcat和被代理tomcat。目的是通過代理app1訪問被代理app2,此配置完全根據源代碼分析而來(因此基礎好的直接讀源代碼研究更好)。

1、單點登錄tomcat發布配置,網上有很多資料,不在贅述。

2、代理app配置:網上有說

AuthenticationFilter和Cas20ProxyReceivingTicketValidationFilter2個過濾器順序需要調換,其實是錯誤的,把握好以下紅色字體足以。

proxyCallback網上介紹的很草率,這里只需要在代理端新建一個servlet作為代理url即可,內部邏輯什么都不用做。
<!-- SSO配置 -->
<filter>
    <filter-name>CAS Authentication Filter</filter-name>
    <filter-class>org.jasig.cas.client.authentication.AuthenticationFilter</filter-class>
    <init-param>
        <param-name>casServerLoginUrl</param-name>
        <param-value>http://127.0.0.1:8081/tjsso/login</param-value>
    </init-param>
    <init-param>
        <param-name>serverName</param-name>
        <param-value>http://127.0.0.1:8080</param-value>
    </init-param>
</filter>

<filter>
    <filter-name>CAS Validation Filter</filter-name>
    <filter-class>
        org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter
    </filter-class>
    <init-param>
        <param-name>casServerUrlPrefix</param-name>
        <param-value>http://127.0.0.1:8081/tjsso</param-value>
    </init-param>
    <init-param>
        <param-name>serverName</param-name>
        <param-value>http://127.0.0.1:8080</param-value>
    </init-param>
    <init-param>
        <param-name>useSession</param-name>
        <param-value>true</param-value>
    </init-param>
    <init-param>
        <param-name>redirectAfterValidation</param-name>
        <param-value>true</param-value>
    </init-param>
    
</filter>

<filter>
    <filter-name>CAS HttpServletRequest Wrapper Filter</filter-name>
    <filter-class>
        org.jasig.cas.client.util.HttpServletRequestWrapperFilter
    </filter-class>
</filter>
<filter>
    <filter-name>CAS Assertion Thread Local Filter</filter-name>
    <filter-class>
        org.jasig.cas.client.util.AssertionThreadLocalFilter
    </filter-class>
</filter>
<filter-mapping>
    <filter-name>CAS Validation Filter</filter-name>
    <url-pattern>/proxyCallback</url-pattern>
</filter-mapping>
<filter-mapping>
    <filter-name>CAS Authentication Filter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
    <filter-name>CAS Validation Filter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
    <filter-name>CAS HttpServletRequest Wrapper Filter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
    <filter-name>CAS Assertion Thread Local Filter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<!--web定義的代理回調-->

3、被代理app配置:

  <!-- SSO配置 -->
<filter>
  <filter-name>CAS Authentication Filter</filter-name>
  <filter-class>org.jasig.cas.client.authentication.AuthenticationFilter</filter-class>
  <init-param>
    <param-name>casServerLoginUrl</param-name>
    <param-value>http://127.0.0.1:8081/tjsso/login</param-value>
  </init-param>
  <init-param>
    <param-name>serverName</param-name>
    <param-value>http://127.0.0.1:8080</param-value>
  </init-param>
</filter>
<filter>
  <filter-name>CAS Validation Filter</filter-name>
  <filter-class>
    org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter
  </filter-class>
  <init-param>
    <param-name>casServerUrlPrefix</param-name>
    <param-value>http://127.0.0.1:8081/tjsso</param-value>
  </init-param>
  <init-param>
    <param-name>serverName</param-name>
    <param-value>http://127.0.0.1:8080</param-value>
  </init-param>
  <init-param>
    <param-name>useSession</param-name>
    <param-value>true</param-value>
  </init-param>
  <init-param>
    <param-name>redirectAfterValidation</param-name>
    <param-value>true</param-value>
  </init-param>
  
</filter>
<filter>
  <filter-name>CAS HttpServletRequest Wrapper Filter</filter-name>
  <filter-class>
    org.jasig.cas.client.util.HttpServletRequestWrapperFilter
  </filter-class>
</filter>
<filter>
  <filter-name>CAS Assertion Thread Local Filter</filter-name>
  <filter-class>
    org.jasig.cas.client.util.AssertionThreadLocalFilter
  </filter-class>
</filter>
<filter-mapping>
  <filter-name>CAS Authentication Filter</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
  <filter-name>CAS Validation Filter</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
  <filter-name>CAS HttpServletRequest Wrapper Filter</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
  <filter-name>CAS Assertion Thread Local Filter</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>

4、實例驗證,在代理端新建一個servlet,我這里就是上述配置的

casProxyTest

源碼如下:

com.supermap.proxy;

org.jasig.cas.client.authentication.AttributePrincipal;
org.jasig.cas.client.util.AssertionHolder;

javax.servlet.ServletException;
javax.servlet.http.HttpServlet;
javax.servlet.http.HttpServletRequest;
javax.servlet.http.HttpServletResponse;
java.io.BufferedReader;
java.io.IOException;
java.io.InputStreamReader;
java.io.OutputStream;
java.net.HttpURLConnection;
java.net.URL;
java.net.URLEncoder;

CasProxyTestServlet HttpServlet {
    doGet(HttpServletRequest req, HttpServletResponse resp)
            ServletException, IOException {
        (req, resp);
    }

    (HttpServletRequest req, HttpServletResponse resp)
            ServletException, IOException {
        AttributePrincipal principal = AssertionHolder.().getPrincipal();
        String proxyTicket = principal.getProxyTicketFor();
        URL url = URL(+ URLEncoder.(proxyTicket, ));
        HttpURLConnection conn = (HttpURLConnection)url.openConnection();
        conn.setDoOutput();
        conn.setDoInput();
        OutputStream out = conn.getOutputStream();
        out.write((+URLEncoder.(proxyTicket, )).getBytes());
        out.flush();
        out.close();
        BufferedReader br = BufferedReader(InputStreamReader(conn.getInputStream(), ));
        StringBuffer content = StringBuffer();
        String line = ;
        ((line=br.readLine()) != ) {
            content.append(line).append();
        }
        resp.getWriter().write(content.toString());
    }
}

總結:其中的原理在網上有很多資料介紹,最主要還是需要個人去研讀源代碼,把握核心。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

巴里| 南康市| 高邮市| 五大连池市| 昭平县| 嵩明县| 东乡族自治县| 建水县| 油尖旺区| 阜宁县| 苏尼特右旗| 灌云县| 阳谷县| 油尖旺区| 中卫市| 大足县| 新野县| 长丰县| 平和县| 莱芜市| 凤翔县| 乐昌市| 抚远县| 沐川县| 搜索| 巴彦淖尔市| 津南区| 南安市| 石渠县| 札达县| 图片| 鱼台县| 江阴市| 义乌市| 保康县| 新泰市| 栖霞市| 遂川县| 开原市| 综艺| 喀什市|