- 浏览: 249941 次
- 性别:
- 来自: 苏州
文章分类
- 全部博客 (289)
- java (72)
- oracle (3)
- mysql (5)
- spring (28)
- hibernate (2)
- osgi (0)
- linux (2)
- ExtJs (1)
- jvm (0)
- mybatis (7)
- 分布式 (11)
- MINA (6)
- apache+tomcat (13)
- js+htm (7)
- android (44)
- http (1)
- hbase+hdoop (0)
- memcache (13)
- search (27)
- 部署及性能 (12)
- mongoDB (2)
- 多线程 (12)
- 安全管理验证 (9)
- struts (1)
- webservice (0)
- easyUI (1)
- spring security (16)
- pattern (6)
- 算法 (2)
最新评论
-
lzh8189146:
CommonsHttpSolrServer这个类,现在是不是没 ...
CommonsHttpSolrServer -
xiaochanzi:
我按照你的方法试了下,tomcat6可以发布,但是访问任何网页 ...
基于内嵌Tomcat的应用开发 -
phoneeye:
麻烦你,如果是抄来的文章,请给出来源。谢谢
ant 两则技巧 -
neverforget:
转载不注明出处
Spring Security3.1登陆验证 替换 usernamepasswordfilter -
liang1022:
若不使用eclipse ,如何在命令行下 运行服务端程序 ?
WebService CXF学习(入门篇2):HelloWorld
转载:
http://www.hxdw.com/bbs/post/print?bid=60&id=144183
Topic: Spring Security 3 与 CAS单点登录配置-Client
1.Spring Security 3 与 CAS单点登录配置-Client | Copy to clipboard |
Posted by: netboy Posted on: 2010-11-12 11:27 如果CAS配置完成。就可以进行Client的配置了。 以下Client的配置前提是你对Spring Security有一定了解。如果不熟悉,还是希望能先读一下Spring Security相关的文章。 下面是Client的Spring Security 3的最基础的配置 1.配置<http>标签 Xml代码 <http auto-config="false" entry-point-ref="casEntryPoint" servlet-api-provision="true"> <intercept-url pattern="/manage/**" access="ROLE_ADMIN" /> <intercept-url pattern="/**" access="ROLE_USER,ROLE_ADMIN" /> <!-- logout-success-url="/login.html" --> <logout logout-url="/logout.html" success-handler-ref="casLogoutSuccessHandler"/> <custom-filter position="FORM_LOGIN_FILTER" ref="casFilter"/> </http> <http auto-config="false" entry-point-ref="casEntryPoint" servlet-api-provision="true"> <intercept-url pattern="/manage/**" access="ROLE_ADMIN" /> <intercept-url pattern="/**" access="ROLE_USER,ROLE_ADMIN" /> <!-- logout-success-url="/login.html" --> <logout logout-url="/logout.html" success-handler-ref="casLogoutSuccessHandler"/> <custom-filter position="FORM_LOGIN_FILTER" ref="casFilter"/> </http> 这里,重点是: * 不使用http的自动配置。 * entry-point-ref="casEntryPoint"作用是认证的入口,是一个实现 AuthenticationEntryPoint接口的类。为ExceptionTranslationFilter类提供认证依据。 * <custom-filter position="FORM_LOGIN_FILTER" ref="casFilter"/> 使用自定义的Filter,放置在过滤器链的FORM_LOGIN_FILTER的位置。 似乎casFilter与casEntryPoint的功能有重叠。 其实,casEntryPoint只是提供认证入口的作用,当没有权限,将跳转到该地址。 casFilter是处理CAS service ticket的。当无权访问时,会使用casEntryPoint提供认证入口。 2.分别配置casEntryPoint和casFilter 配置:casEntryPoint Xml代码 <beans:bean id="casEntryPoint" class="org.springframework.security.cas.web.CasAuthenticationEntryPoint"> <beans:property name="loginUrl" value="https://cas.boc.com:8443/casServer/login"/> <beans:property name="serviceProperties" ref="serviceProperties"/> </beans:bean> <beans:bean id="serviceProperties" class="org.springframework.security.cas.ServiceProperties"> <beans:property name="service" value="https://report.boc.com:8443/report/j_spring_cas_security_check"/> <beans:property name="sendRenew" value="false"/> </beans:bean> <beans:bean id="casEntryPoint" class="org.springframework.security.cas.web.CasAuthenticationEntryPoint"> <beans:property name="loginUrl" value="https://cas.boc.com:8443/casServer/login"/> <beans:property name="serviceProperties" ref="serviceProperties"/> </beans:bean> <beans:bean id="serviceProperties" class="org.springframework.security.cas.ServiceProperties"> <beans:property name="service" value="https://report.boc.com:8443/report/j_spring_cas_security_check"/> <beans:property name="sendRenew" value="false"/> </beans:bean> 配置casFilter Xml代码 <beans:bean id="casFilter" class="org.springframework.security.cas.web.CasAuthenticationFilter"> <beans:property name="authenticationManager" ref="authenticationManager"/> </beans:bean> <authentication-manager alias="authenticationManager"> <authentication-provider ref="casAuthenticationProvider"/> </authentication-manager> <beans:bean id="userDetailsService" class="com.reportstart.security.service.impl.BocUserDetaislServiceImpl"> <beans:property name="userDao"> <beans:ref bean="userDao"/> </beans:property> </beans:bean> <beans:bean id="casAuthenticationUserDetailsService" class="org.springframework.security.core.userdetails.UserDetailsByNameServiceWrapper"> <beans:property name="userDetailsService" > <beans:ref local="userDetailsService"/> </beans:property> </beans:bean> <beans:bean id="casAuthenticationProvider" class="org.springframework.security.cas.authentication.CasAuthenticationProvider"> <beans:property name="authenticationUserDetailsService" ref="casAuthenticationUserDetailsService"/> <beans:property name="serviceProperties" ref="serviceProperties" /> <beans:property name="ticketValidator"> <beans:bean class="org.jasig.cas.client.validation.Cas20ServiceTicketValidator"> <beans:constructor-arg index="0" value="https://cas.boc.com:8443/casServer" /> </beans:bean> </beans:property> <beans:property name="key" value="an_id_for_this_auth_provider_only"/> </beans:bean> </beans:bean> <beans:bean id="casFilter" class="org.springframework.security.cas.web.CasAuthenticationFilter"> <beans:property name="authenticationManager" ref="authenticationManager"/> </beans:bean> <authentication-manager alias="authenticationManager"> <authentication-provider ref="casAuthenticationProvider"/> </authentication-manager> <beans:bean id="userDetailsService" class="com.reportstart.security.service.impl.BocUserDetaislServiceImpl"> <beans:property name="userDao"> <beans:ref bean="userDao"/> </beans:property> </beans:bean> <beans:bean id="casAuthenticationUserDetailsService" class="org.springframework.security.core.userdetails.UserDetailsByNameServiceWrapper"> <beans:property name="userDetailsService" > <beans:ref local="userDetailsService"/> </beans:property> </beans:bean> <beans:bean id="casAuthenticationProvider" class="org.springframework.security.cas.authentication.CasAuthenticationProvider"> <beans:property name="authenticationUserDetailsService" ref="casAuthenticationUserDetailsService"/> <beans:property name="serviceProperties" ref="serviceProperties" /> <beans:property name="ticketValidator"> <beans:bean class="org.jasig.cas.client.validation.Cas20ServiceTicketValidator"> <beans:constructor-arg index="0" value="https://cas.boc.com:8443/casServer" /> </beans:bean> </beans:property> <beans:property name="key" value="an_id_for_this_auth_provider_only"/> </beans:bean> </beans:bean> 如果对Spring Security比较熟悉,就不用多说什么了。 这里的"https://report.boc.com:8443/report/j_spring_cas_security_check"地址要注意,以后这个地址要注册到CAS service里,从而改变CAS的"open model". 也只有这个地址是指向Client的,其他都指向Server 最后,casLogoutSuccessHandler 如果Client要注销,需在Client先注销,之后让Server注销提供的ticket。 如果不这样,不论是只注销Client还是Server,注销后,系统仍然还是可以访问的。 (按照开始的想法,注销Client,Client应该可以主动去Server去注销ticket,但是org.springframework.security.web.authentication.logout.LogoutFilter总注销自己,而不去跟Client交互。如果你知道的话,请告知。) CasLogoutSuccessHandler 代码 Java代码 package net.viiso.security.util; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.security.core.Authentication; import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; public class CasLogoutSuccessHandler implements LogoutSuccessHandler { private String url = ""; @Override public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { if ("".equals(url)) { url = "https://cas.boc.com:8443/casServer/logout"; } response.sendRedirect(url); } public void setTargetUrl(String url) { this.url = url; } } package net.viiso.security.util; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.security.core.Authentication; import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; public class CasLogoutSuccessHandler implements LogoutSuccessHandler { private String url = ""; @Override public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { if ("".equals(url)) { url = "https://cas.boc.com:8443/casServer/logout"; } response.sendRedirect(url); } public void setTargetUrl(String url) { this.url = url; } } 启动后,对一个安全地址进行访问,会跳到CAS登录地址。 如果登录成功,会跳至访问页。 到此,简单的Client已经配置完成。 接下来,还要在Server注册Client。这个虽然不是必须,但是出于安全考虑,如果CAS服务器在外网,就非常有必要对支持的Client进行注册了,因为当你访问Client在CAS登陆成功后,CAS会给你的Client提供登录者的用户信息。如果你模拟一个Client应用,使用暴力方式,不断给CAS提供用户口令和密码,会对安全性造成破坏。 另外,也可以给CAS登录页加一个验证码。 |
发表评论
-
在spring security3上实现验证码
2012-04-21 16:07 613在spring security3上实现验证码 h ... -
Spring Security3.1登陆验证 替换 usernamepasswordfilter
2012-04-15 02:01 3369一、前言 在上一篇http://blog.c ... -
Spring Security 3应用的11个步骤
2012-04-15 01:47 1127Spring Security 3应用的11个步骤 ... -
在spring security3上实现验证码
2012-03-01 08:44 600转载: 在spring securi ... -
spring security 密码编码器
2012-03-14 08:13 930spring security 密码编码器 (2 ... -
spring security 配置详解
2012-02-25 11:50 2137http://static.springsource.org/ ... -
图解Spring Security默认使用的过滤器
2012-02-24 08:13 738转载:http://www.flyysoft.com/plus ... -
Spring Security 3 与 CAS单点登录配置-Server
2012-03-15 19:56 1256转载:http://www.hxdw.com/bbs/post ... -
Spring Security 可动态授权RBAC权限模块实践
2012-02-19 13:25 2009Spring Security 可动态授权RBA ... -
Spring Security 3 基于角色访问控制过程详解
2012-02-19 13:25 1372访问控制:由于我们配 ... -
修改spring security源码实现动态授权
2012-02-21 08:15 885修改spring security源码实现动态 ... -
spring security 3.0 logout filter 代码中的一个小bug
2012-03-15 19:57 962spring security 3.0 log ... -
spring security 源码分析: 过滤器
2012-03-19 08:23 980spring security 源码分析: 过 ... -
spring security遇到的一些问题
2012-03-19 08:24 634spring security遇到的一些问题 ... -
spring security 源码解读 1
2012-03-19 08:24 834http://feiyan35488.iteye.com/bl ...
相关推荐
springcloud-twocache springcloud-twocache本地加redis高效双级缓存 使用教程 打包安装项目 git clone https://github.com/dounine/spring-cloud.git cd spring-cloud gradle install -xtest 在项目中引用 build....
springboot集成mqtt,实现了单topic订阅消息与消费消息,同时也实现了订阅多个topic,每个topic都有独立的监听监听的消息的消费
本项目介绍如何将Spring Boot与Spring Kafka结合使用以使用Kafka主题中的JSON / String消息 启动Zookeeper bin/zookeeper-server-start.sh config/zookeeper.properties 启动Kafka服务器 bin/kafka-server-start....
cmq-client近期项目中使用到CMQ,鉴于官方提供SDK太过简陋且存在严重BUG,于是自己简单的实现了一个,虽只实现了routingKey相关部分,但也足够一般使用。此外虽然本项目实现了应用启动时自动创建Topic、Queue、...
带Kafka的样本Spring Boot 公开了一个使用json消息并发布到kafka主题中的api 要通过泊坞窗启动zookeeper和kafka,请执行以下操作: docker-compose up 生成应用程序映像 docker build --no-cache -t sample_kafka...
Dynamiq Ruby 客户端DynamiqClient 为 Dynamiq RESTful API 提供了一个 Ruby 接口安装将此行添加到应用程序的 Gemfile 中: gem 'dynamiq-ruby-client'然后执行: $ bundle install或者自己安装: $ gem install ...
3.Re:怎样用java实现短信发送[Re: creatyang] Copy to clipboard Posted by:jacksunPosted on:2003-04-21 15:02看看西门子的JAVA API,就在com.siemens.mp.gsm.SMS类里有一个方法send(String number, String data)
camel配置TIBCO-topic配置文件详解
mqtt-async-client-rs 使用Rust函数和tokio用Rust编写的MQTT 3.1.1客户端。 仓库: : 文档: : 货箱: : CI在Travis CI的基础上构建: : 拉取请求和Github问题,欢迎您! 运行自动化测试 只需进行cargo test ...
申请资源时需要根据需求选择对应的 Region,例如 MQTT 需要使用华北2的接入点,那么 Topic 等资源就在华北2 申请,资源申请具体请参见申请 MQ 资源。 注意:MQTT 使用的多级子 Topic 不需要申请,代码里直接使用...
Kafka MM2同步Kafka集群时,自定义复制策略(ReplicationPolicy),保证目标topic名称和source集群中的一致,详情见:...
您可以使用以下指南在Azure上创建启用了Kafka的事件中心: 创建一个名为test-topic事件(又称为Event Hub) test-topic 现在,您必须配置以下两个Spring属性,例如,在application.yml 。 event-hubs-connection-...
spring +activemq topic消息持久化订阅实例,整个项目中有activemq和spring的整合的所有实例,topic的持久化配置是在ApplicationContext3C、ApplicationContext3C2以及ApplicationContext3P三个中,消息生产者:...
前几章我们分别利用spring rmi、httpinvoker、httpclient、webservice技术实现不同服务器间的远程...3) Spring整合activemq配置 4) 定义消息发布者(生产者) 5) 定义消息订阅者(消费者) 6) Spring mvc配置 7) 实例测试
##################################1、工程说明##################...3) 实现了普通队列消息发送与监听,实现了基于TOPIC的消息发布与订阅 4) IBM-MQ无需提前创建主题,TongLink需要提前创建主题以及对应的虚拟队列;
./kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 2 --topic KAFKAJSTests 消费 以这种方式解雇使用者(至多为您拥有的分区数): KAFKACLUSTER=localhost ...
思路:Storm集群从Kafkatopic主题获取数据,解析后写入MySQL,注意我们使用MyBatis工具与数据库交互 项目结构 部署MySQL 我们在服务器上部署一台MySQL数据库 具体参考这篇文章 数据库表结构如下: ...
00-配置指导导读 01-设备管理 02-上网配置 03-二层注册及无线加密配置 04-三层注册及无线加密配置 05-无线认证典型案例 06-无线 07-WLAN数据转发 08-AP胖瘦切换 09-登录密码找回 10-恢复出厂方法 11-版本升级方法 12...
SpringAMQP TopicExchange 通过配置类、注解2种方式实现
Apache kafka 解压文件夹焦油-xzf kafka_2.10-0.8.2.0.tgz cd kafka_2.10-0.8.2.0 启动 Zoopkeeper bin/zookeeper-server-start.sh config/zookeeper.properties & 启动服务器bin/kafka-server-start.sh 配置/server...