CAS服务器和客户端配置 证书的生成,导出,导入到jdk
2013-01-15 14:31
501 查看
生成证书:
用JDK自带的keytool生成证书
命令:
keytool -genkey -alias smalllove -keyalg RSA -keystore D:/keys/smallkey
导出证书
命令:
keytool -export -file d:/keys/small.crt -alias smalllove -keystore d:/keys/smallkey
将证书导入jdk
keytool -import -keystore C:\Java\jdk1.6.0_21\jre\lib\security\cacerts -file D:/keys/small.crt -alias smalllove
说明证书已导入到jdk中
服务器配置:
1.下载CAS的服务端,解压,把解压后的文件中modules文件夹中的cas-server-webapp-*.war文件拷贝到tomcat的webapps下面更改名字为cas.war(可以不更改,这里只是为了方便)
2.修改修改tomcat的server.xml文件去掉此文件83到93行之间的注释,修改为:
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
keystoreFile="D:/keys/smallkey"
keystorePass="smalllove"/>设置的密码
3.访问https://yourhost:8443/cas出现
登陆成功后:
服务器配置成功了嘿嘿!!
客户端配置:新建两个web工程client1 client2
配置:web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <filter>
<filter-name>CAS Authentication Filter</filter-name>
<filter-class>org.jasig.cas.client.authentication.AuthenticationFilter</filter-class>
<init-param>
<!-- CAS服务端登录地址 -->
<param-name>casServerLoginUrl</param-name>
<param-value>https://localhost/cas/</param-value>
</init-param>
<init-param>
<!-- 当前网站域名 -->
<param-name>serverName</param-name>
<param-value>http://localhost:8080</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CAS Authentication Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
导入jar包:
cas-client-core-3.1.10.jar
commons-logging-1.1.jar
http://localhost:8080/client1
进行访问 index.jsp 页面 ; 但是此时会被 web.xml 中配置的 filter 拦截:
进而跳转到 指定的 casServerLoginUrl 进行验证
然后输入 用户名,密码 如果验证成功, 将会成功跳转到 index.jsp
访问 http://localhost:8080/client2/
此时不需要 验证 直接跳转到 index.jsp 中
简单的CAS功能就这样了,我还在继续学习中
用JDK自带的keytool生成证书
命令:
keytool -genkey -alias smalllove -keyalg RSA -keystore D:/keys/smallkey
导出证书
命令:
keytool -export -file d:/keys/small.crt -alias smalllove -keystore d:/keys/smallkey
将证书导入jdk
keytool -import -keystore C:\Java\jdk1.6.0_21\jre\lib\security\cacerts -file D:/keys/small.crt -alias smalllove
说明证书已导入到jdk中
服务器配置:
1.下载CAS的服务端,解压,把解压后的文件中modules文件夹中的cas-server-webapp-*.war文件拷贝到tomcat的webapps下面更改名字为cas.war(可以不更改,这里只是为了方便)
2.修改修改tomcat的server.xml文件去掉此文件83到93行之间的注释,修改为:
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
keystoreFile="D:/keys/smallkey"
keystorePass="smalllove"/>设置的密码
3.访问https://yourhost:8443/cas出现
登陆成功后:
服务器配置成功了嘿嘿!!
客户端配置:新建两个web工程client1 client2
配置:web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <filter>
<filter-name>CAS Authentication Filter</filter-name>
<filter-class>org.jasig.cas.client.authentication.AuthenticationFilter</filter-class>
<init-param>
<!-- CAS服务端登录地址 -->
<param-name>casServerLoginUrl</param-name>
<param-value>https://localhost/cas/</param-value>
</init-param>
<init-param>
<!-- 当前网站域名 -->
<param-name>serverName</param-name>
<param-value>http://localhost:8080</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CAS Authentication Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
导入jar包:
cas-client-core-3.1.10.jar
commons-logging-1.1.jar
http://localhost:8080/client1
进行访问 index.jsp 页面 ; 但是此时会被 web.xml 中配置的 filter 拦截:
进而跳转到 指定的 casServerLoginUrl 进行验证
然后输入 用户名,密码 如果验证成功, 将会成功跳转到 index.jsp
访问 http://localhost:8080/client2/
此时不需要 验证 直接跳转到 index.jsp 中
简单的CAS功能就这样了,我还在继续学习中
相关文章推荐
- openssl生成服务器客户端秘钥已经颁发证书等配置命令
- CAS安装jdk信任证书的导入与导出
- Exchange部署之:配置客户端访问服务器角色CAS(部署证书/设置OWA)
- tomcat7+jdk的keytool生成证书 配置https
- 一个开发者账号多人多台电脑一起开发 证书 p12 配置文件 导入导出
- CAS SSO单点登录基础实践,配置CAS 服务器和CAS客户端
- keytool生成keystore、truststore、证书以及SSL单向认证在服务端tomcat和客户端的配置
- Exchge2010配置-为CAS服务器申请PKI证书
- [置顶] JDK自带工具keytool生成ssl证书(https自生成证书并配置到jboss和tomcat中)
- Tomcat启用HTTPS(生成证书、配置Tomcat服务器)
- SVN 服务端、客户端安装及配置、导入导出项目
- Windows Server 2003 导入Java生成的证书,保证iis对CAS的访问
- 客户端数字证书(企业CA证书)登陆---------(1)服务器证书的申请及配置
- keytool 使用:生成证书并导入JDK
- 批量将导入的图片生成对应的元件调整为无损位图质量,设置链接项导出,发布并生成配置文件,fljs小命令脚本 - [jsfl]
- SVN 服务端、客户端安装及配置、导入导出项目
- tomcat7+jdk的keytool生成证书 配置https
- MacOS openssl下生成建立CA并生成服务器和客户端证书方法
- Cas服务器设置(java),java、php客户端配置
- tomcat配置双向认证,客户端证书pkcs12格式,方便导入浏览器