cas客户端配置

1、在pom.xml中增加配置主要是引入cas客户端的jar包,在dependencies节点中增加配置:

<dependency>

   <groupId>org.jasig.cas.client</groupId>

   <artifactId>cas-client-core</artifactId>

   <version>3.4.1</version>

</dependency>

2、从官网下载的源码包中,有个module目录,里面有制作好的war包,可以直接使用,当然也可以自行使用maven打包,把war包改名为cas.war,放到tomcat的webapps目录下,就可以使用了

3、在客户端web.xml配置相关

<!-- ======================== 单点登录开始 ======================== -->
	<!-- 用于单点退出,该过滤器用于实现单点登出功能,可选配置 -->
	<listener>
		<listener-class>org.jasig.cas.client.session.SingleSignOutHttpSessionListener</listener-class>
	</listener>

	<!-- 该过滤器用于实现单点登出功能,可选配置。 -->
	<filter>
		<filter-name>casSingleSignOutFilter</filter-name>
		<filter-class>org.jasig.cas.client.session.SingleSignOutFilter</filter-class>
		<init-param>
		    <param-name>casServerUrlPrefix</param-name>
		    <param-value>https://localhost:8081/cas/</param-value>
		</init-param>
	</filter>
	<filter-mapping>
		<filter-name>casSingleSignOutFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

    <!-- 登录认证,未登录用户导向CAS Server进行认证 --> 

	<filter>
		<filter-name>casFilter</filter-name>
		<filter-class>org.jasig.cas.client.authentication.AuthenticationFilter</filter-class>
		<init-param>
			<param-name>casServerLoginUrl</param-name>
			<param-value>https://localhost:8081/cas/login</param-value>
		</init-param>
		<init-param>
			<param-name>service</param-name>
			<param-value>http://localhost:9030/daan/invest/loginAction_casLogin.action</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>
	    <init-param>
	      <param-name>ignorePattern</param-name>
	      <param-value>/staticres/css/|/staticres/js/</param-value>
	    </init-param>
	</filter>
	<filter-mapping>
		<filter-name>casFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

	<!-- 该过滤器负责对Ticket的校验工作,必须启用它 -->
	<filter>
		<filter-name>casTicketValidationFilter</filter-name>
		<filter-class>org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter</filter-class>
		<init-param>
			<param-name>casServerUrlPrefix</param-name>
			<param-value>https://localhost:8081/cas</param-value>
		</init-param>

		<init-param>
			<param-name>serverName</param-name>
			<param-value>http://localhost:9030</param-value>
		</init-param>
	</filter>
	<filter-mapping>
		<filter-name>casTicketValidationFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
	
	<!-- 该过滤器使得开发者可以通过org.jasig.cas.client.util.AssertionHolder来获取用户的登录名。 -->
	<!-- 比如AssertionHolder.getAssertion().getPrincipal().getName()。 -->
	<filter>
		<filter-name>casAssertionThreadLocalFilter</filter-name>
		<filter-class>org.jasig.cas.client.util.AssertionThreadLocalFilter</filter-class>
	</filter>
	<filter-mapping>
		<filter-name>casAssertionThreadLocalFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

<!-- ======================== 单点登录结束 ======================== -->

4、Tomcat配置HTTPS方式

(1)1、开始-〉运行-〉cmd 进入到jdk下的bin目录

(2)生成认证

keytool -genkeypair -alias "ykjt2016" -keyalg "rsa" -keystore "F:/cas/keys/castest.keystore"

输入图片说明

*秘钥口令为:castest 图中标红的位置:为用户要访问的域名或者IP

(3)导出证书

keytool -export -alias "ykjt2016" -file "F:/cas/keys/castest.crt" -keystore "F:/cas/keys/castest.keystore"

输入图片说明

(4)导出加密证书

keytool -importkeystore -srckeystore "F:/cas/keys/castest.keystore" -destkeystore "F:/cas/keys/intermediate.p12" -deststoretype PKCS12

(5)利用openssl用将证书转换成pem格式

openssl pkcs12 -in F:/cas/keys/intermediate.p12 -out F:/cas/keys/castest.pem -nodes

openssl-0.9.8h-1-bin下载地址:http://downloads.sourceforge.net/gnuwin32/openssl-0.9.8h-1-bin.zip

转载于:https://my.oschina.net/ziruo/blog/883623

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值