天天看點

如何在liferay5.1.2中配置CAS如何在liferay5.1.2中配置CAS

如何在liferay5.1.2中配置CAS

前言

Liferay5.1.2中直接內建了通路CAS伺服器的功能。是以準備好一個CAS伺服器就搞定了。

1.       在Liferay5.1.2中開啟CAS認證功能

打開工程的protal.properties檔案,修改以下幾項。

cas.auth.enabled=true   //打開CAS功能

cas.login.url=https://localhost:443/cas-web/login    //設定CAS伺服器登入的具體路徑

cas.logout.url=https://localhost:443/cas-web/logout    //設定CAS伺服器登出的具體路徑

cas.server.name=localhost    //設定Liferay的伺服器位址

cas.validate.url=https://localhost:443/cas-web/proxyValidate    //設定CAS伺服器校驗代理路徑

2.       在Liferay5.1.2 web.xml檔案中設定CAS過濾器

<!—過濾器 --!>

<filter>

    <filter-name>SSO CAS Filter</filter-name>

    <filter-class>com.liferay.portal.servlet.filters.sso.cas.CASFilter</filter-class>

       <init-param>

           <param-name>logout_url</param-name>

<param-value>https://localhost:443/cas-web/logout</param-value>

       </init-param>

       <init-param>

           <param-name>edu.yale.its.tp.cas.client.filter.loginUrl</param-name>

           <param-value>https://localhost:443/cas-web/login</param-value>

       </init-param>

       <init-param>

           <param-name>edu.yale.its.tp.cas.client.filter.validateUrl</param-name>

           <param-value>https://localhost:443/cas-web/proxyValidate</param-value>

       </init-param>

       <init-param>

           <param-name>edu.yale.its.tp.cas.client.filter.serviceUrl</param-name>

           <param-value>http://localhost/c/portal/login</param-value>

       </init-param>

    </filter>

<!—過濾器映射 --!>

<filter-mapping>

       <filter-name>SSO CAS Filter</filter-name>

       <url-pattern>/c/portal/login</url-pattern>

    </filter-mapping>

    <filter-mapping>

       <filter-name>SSO CAS Filter</filter-name>

       <url-pattern>/c/portal/logout</url-pattern>

    </filter-mapping>

在web.xml中增加如上所示的過濾器和映射。(Liferay5.1.2的web.xml檔案中已存在此過濾器,隻要将其打開,并修改相應的參數。)

3.       配置CAS服務

CAS服務的配置方式請參考其它文檔。這裡主要講述對于CeipLoginHandler對象的修改。首先在Ceip_user表中增加一個screenname字段。因為是這liferay預設的對比名稱。然後将screenname做為userName儲存到credentials對象中。