俊星的BLOG

CAS初步配置

此处的CAS是指Central Authentication Service,也即统一认真服务,这里采用的是JASIG提供的相关服务端及客户端类库,结合TOMCAT进行测试。

1、下载相关的服务器端和客户端类库,官网是:http://www.jasig.org/cas/,目前我采用的是:
服务器端:cas-server-3.3.4-release.zip
客户端:cas-client-2.0.11.zip

2、配置TOMCAT的SSL,具体可见上一篇博文:
在%CATALINA_HOME%/conf/server.xml中,添加:
<Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS"
               keystoreFile="F:\eclipse\workspace\httpc\tomcat3.keystore"
               keystorePass="123456"/>
配置OK后,可通过访问“https://localhost:8443/examples/servlets/servlet/HelloWorldExample”来进行验证

3、配置CAS服务器端:
将cas-server-3.3.4-release.zip中modules文件夹下的cas-server-webapp-3.3.4.war的解压到TOMCAT的webapps目录下。
重启TOMCAT后,可以通过访问“http://localhost:8080/cas/login”并输入相同的用户名密码来进行验证。
另:需要特别说明,cas应用中默认配置的是SimpleTestUsernamePasswordAuthenticationHandler,该处理类只要保持用户名、密码一直即可通过验证。

4、配置CAS客户端:
在webapps\examples\WEB-INF中,对web.xml添加如下内容:
<filter>
   <filter-name>CAS Filter</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://localhost:8443/cas/login</param-value>
   </init-param>
   <init-param>
     <param-name>edu.yale.its.tp.cas.client.filter.validateUrl</param-name>
     <param-value>https://localhost:8443/cas/serviceValidate</param-value>
   </init-param>
   <init-param>
     <param-name>edu.yale.its.tp.cas.client.filter.serverName</param-name>
     <param-value>localhost:8080</param-value>
   </init-param>
  </filter>
  <filter-mapping>
   <filter-name>CAS Filter</filter-name>
   <url-pattern>/servlets/servlet/HelloWorldExample</url-pattern>
  </filter-mapping>
同时,将cas-client-2.0.11.zip中的casclient.jar,拷贝到webapps\examples\WEB-INF\lib中,重启TOMCAT即可进行验证。

5、验证CAS:
a、在浏览器中访问“http://localhost:8080/examples/servlets/servlet/HelloWorldExample”
b、基于前面配置的过滤器,浏览器会定向CAS的认证页面“https://localhost:8443/cas/login?service=http%3A%2F%2Flocalhost%3A8080%2Fexamples%2Fservlets%2Fservlet%2FHelloWorldExample”
c、在CAS的认证页面中输入相同的用户名密码test/test后,执行登录
d、浏览器提示安全警告,点击确定后即转入到“http://localhost:8080/examples/servlets/servlet/HelloWorldExample?ticket=ST-1-xWK9nwArDLbjCwYiXOqu-cas”,同时页面打出“Hello World”,配置成功。

posted on 2010-10-26 14:36 俊星 阅读(721) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: