Junky's IT Notebook

          導航

          <2007年5月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          隨筆分類(224)

          文章分類(5)

          隨筆檔案(228)

          文章檔案(7)

          統計

          留言簿(8)

          積分與排名

          WebSphere Studio

          閱讀排行榜

          評論排行榜

          用Yale CAS Server 來實現單點登陸(SSO)(轉)

          CAS (Central Authentication Service)是Yale大學的ITS開發的一套JAVA實現的開源
          的SSO(single sign-on)的服務。

          這里用一個簡單的例子來說明用CAS來實現單點登陸(SSO)。

          Yale CAS Server 的配置過程

          CAS (Central Authentication Service)是Yale大學的ITS開發的一套JAVA實現的開源
          的SSO(single sign-on)的服務。該服務是以一個java web app(eg:cas.war)來進行服務的,
          使用時需要將cas.war發布到一個servlet2.3兼容的服務器上,并且服務器需要支持SSL,
          在需要使用該服務的其他服務器(客戶),只要進行簡單的配置就可以實現SSO了。

          CAS 的客戶端可以有很多種,因為驗證的結果是以XML的格式返回的,CAS的客戶端已
          打包進去的有java,perl,python,asp,apache module等好幾種客戶端示例,你還可以根據
          需要實現一個自己的客戶端,非常簡單!~

          下面我們以tomcat 5.0 作為CAS Server(server1),另外一臺tomcat5.0 為client(client1)
          為例進行說明。

          1.下載cas-server和cas-client(可選,建議使用)
          http://www.yale.edu/tp/cas/cas-server-2.0.12.zip
          http://www.yale.edu/tp/cas/cas-client-2.0.11.zip

          2.將cas-server-2.0.12.zip解壓,并將lib/cas.war拷貝到server1的webapps下

          3.產生SERVER的證書
          keytool -genkey -alias my-alias-name -keyalg RSA -keystore keystore-file

          4.在server1配置tomcat使用HTTPS

          $CATALINA_HOME/conf/server.xml里

          <Connector className="org.apache.coyote.tomcat5.CoyoteConnector"
          port="8443" minProcessors="5" maxProcessors="75"
          enableLookups="true" disableUploadTimeout="true"
          acceptCount="100" debug="0" scheme="https"
          secure="true">
          <Factory className="org.apache.coyote.tomcat5.CoyoteServerSocketFactory"
          keystoreFile="/path/to/your/keystore-file"
          keystorePass="your-password" clientAuth="false" protocol="TLS" />
          </Connector>

          5.在要使用CAS的客戶端client1里設置(以servlets-examples這個APP為例),我們使用
          ServletFilter(CAS client里提供的)來實現SSO的檢查。

          修改servlets-examples/WEB-INF/web.xml

          <filter>
          <filter-name>CASFilter</filter-name>
          <filter-class>edu.yale.its.tp.cas.client.filter.CASFilter</filter-class>
          <init-param>
          <param-name>edu.yale.its.tp.cas.client.filter.loginUrl</param-name>
          <param-value>https://your.cas.server.name(eg:server1):port/cas/login</param-value>
          </init-param>
          <init-param>
          <param-name>edu.yale.its.tp.cas.client.filter.validateUrl</param-name>
          <param-value>https://your.cas.server.name(eg:server1):port/cas/proxyValidate</param-value>
          </init-param>

          <init-param>
          <param-name>edu.yale.its.tp.cas.client.filter.serverName</param-name>
          <param-value>your.client.server.name(eg:client1):port</param-value>
          </init-param>

          </filter>

          <filter-mapping>
          <filter-name>CASFilter</filter-name>
          <url-pattern>/servlet/*</url-pattern>
          </filter-mapping>

          6.將cas-client-2.0.11.zip解壓,把java/lib/casclient.jar拷貝到client1服務器上的
          webapps/servlets-examples/WEB-INF/lib目錄下(如果沒有就建一個)

          7.導出SERVER的證書,用來給所有需要用到的客戶端導入
          keytool -export -file myserver.cert -alias my-alias-name -keystore keystore-file

          8.在客戶端的JVM里導入信任的SERVER的證書(根據情況有可能需要管理員權限)
          keytool -import -keystore $JAVA_HOME/jre/lib/security/cacerts -file myserver.cert -alias my-alias-name

          9.test & done.
          把server1和client1分別起來,檢查啟動的LOG是否正常,如果一切OK,就訪問
          http://client1:8080/servlets-examples/servlet/HelloWorldExample
          系統會自動跳轉到一個驗證頁面,隨便輸入一個相同的賬號,密碼,嚴正通過之后就會訪問
          到真正的HelloWorldExample這個servlet了

          更多信息請參考
          http://www.yale.edu/tp/cas/
          http://www-106.ibm.com/developerworks/web/library/wa-singlesign/


          posted on 2007-05-18 17:14 junky 閱讀(254) 評論(0)  編輯  收藏 所屬分類: security

          主站蜘蛛池模板: 伊春市| 巴彦淖尔市| 桦甸市| 巫山县| 安乡县| 临猗县| 德化县| 确山县| 稻城县| 屏山县| 喀什市| 吉隆县| 梅河口市| 巴彦淖尔市| 商河县| 肥西县| 岢岚县| 高陵县| 民权县| 苏尼特右旗| 本溪市| 科技| 紫金县| 长海县| 库尔勒市| 汝州市| 霍城县| 汤阴县| 马龙县| 忻州市| 寿光市| 海丰县| 巩留县| 枣庄市| 岗巴县| 贞丰县| 陇南市| 普兰县| 米泉市| 长顺县| 凯里市|