First, Set SpringSide's web.xml, we use Acegi CAS Filter:
< filter-mapping >
< filter-name > hibernateFilter </ filter-name >
< url-pattern > /j_acegi_cas_security_check </ url-pattern >
</ filter-mapping >
We Should Set Main ACEGI application Context:
1) filterChainProxy should add a cas filter as Acegi's Sample, but here, we reuse
authenticationProcessingFilter, which we act as cas client filter.
< bean id ="filterChainProxy"
class ="org.acegisecurity.util.FilterChainProxy" >
< property name ="filterInvocationDefinitionSource" >
< value >
CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
PATTERN_TYPE_APACHE_ANT
/**=httpSessionContextIntegrationFilter,anonymousProcessingFilter,authenticationProcessingFilter,rememberMeProcessingFilter,logoutFilter,channelProcessingFilter,basicProcessingFilter,securityContextHolderAwareRequestFilter,exceptionTranslationFilter,filterInvocationInterceptor
</ value >
</ property >
</ bean >
2) authenticationProcessingFilter, of course, play the most important role in this
applicationContext_acegi.xml.
In SpringSide, /admin is protected resource, so defaultTargetUrl protected it
and all those request to the target url must be authenticated by authenticationManager.
<bean id="authenticationProcessingFilter" class="org.acegisecurity.ui.cas.CasProcessingFilter">
<property name="authenticationManager" ref="authenticationManager"/>
<property name="authenticationFailureUrl">
<value>/security/login.jsp?login_error=1</value>
</property>
<property name="defaultTargetUrl">
<value>/admin/</value>
</property>
<property name="filterProcessesUrl">
<value>/j_acegi_cas_security_check</value>
</property>
<property name="rememberMeServices" ref="rememberMeServices"/>
<property name="exceptionMappings">
<value>
org.acegisecurity.userdetails.UsernameNotFoundException=/security/login.jsp?login_error=user_not_found_error
org.acegisecurity.BadCredentialsException=/security/login.jsp?login_error=user_psw_error
org.acegisecurity.concurrent.ConcurrentLoginException=/security/login.jsp?login_error=too_many_user_error
</value>
</property>
</bean>
3) Then, we set all the needed beans in CAS Filter
<!-- ========= Acegi as a CAS Client的配置============= -->
<bean id="exceptionTranslationFilter" class="org.acegisecurity.ui.ExceptionTranslationFilter">
<property name="authenticationEntryPoint">
<ref local="casProcessingFilterEntryPoint"/>
</property>
</bean>
<!-- cas config -->
<bean id="casProcessingFilterEntryPoint" class="org.acegisecurity.ui.cas.CasProcessingFilterEntryPoint">
<property name="loginUrl"><value>https://sourcesite:8443/cas/login</value></property>
<property name="serviceProperties"><ref local="serviceProperties"/></property>
</bean>
<bean id="authenticationManager" class="org.acegisecurity.providers.ProviderManager">
<property name="providers">
<list>
<ref local="casAuthenticationProvider"/>
</list>
</property>
</bean>
<bean id="casAuthenticationProvider" class="org.acegisecurity.providers.cas.CasAuthenticationProvider">
<property name="casAuthoritiesPopulator"><ref bean="casAuthoritiesPopulator"/></property>
<property name="casProxyDecider"><ref local="casProxyDecider"/></property>
<property name="ticketValidator"><ref local="casProxyTicketValidator"/></property>
<property name="statelessTicketCache"><ref local="statelessTicketCache"/></property>
<property name="key"><value>my_password_for_this_auth_provider_only</value></property>
</bean>
<bean id="casProxyTicketValidator" class="org.acegisecurity.providers.cas.ticketvalidator.CasProxyTicketValidator">
<property name="casValidate"><value>https://sourcesite:8443/cas/proxyValidate</value></property>
<property name="serviceProperties"><ref local="serviceProperties"/></property>
</bean>
<!--
<bean id="casProxyDecider" class="org.acegisecurity.providers.cas.proxy.AcceptAnyCasProxy" />
-->
<bean id="casProxyDecider" class="org.acegisecurity.providers.cas.proxy.RejectProxyTickets" />
<bean id="serviceProperties" class="org.acegisecurity.ui.cas.ServiceProperties">
<property name="service">
<value>http://gzug:8080/springside/j_acegi_cas_security_check</value>
</property>
<property name="sendRenew">
<value>false</value>
</property>
</bean>
<bean id="statelessTicketCache" class="org.acegisecurity.providers.cas.cache.EhCacheBasedTicketCache">
<property name="cache">
<bean class="org.springframework.cache.ehcache.EhCacheFactoryBean">
<property name="cacheManager">
<bean class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"/>
</property>
<property name="cacheName" value="userCache"/>
</bean>
</property>
</bean>
<bean id="casAuthoritiesPopulator" class="org.acegisecurity.providers.cas.populator.DaoCasAuthoritiesPopulator">
<property name="userDetailsService"><ref local="jdbcDaoImpl"/></property>
</bean>
<bean id="casProcessingFilter" class="org.acegisecurity.ui.cas.CasProcessingFilter">
<property name="authenticationManager"><ref local="authenticationManager"/></property>
<property name="authenticationFailureUrl"><value>/casfailed.jsp</value></property>
<property name="defaultTargetUrl"><value>/</value></property>
<property name="filterProcessesUrl"><value>/j_acegi_cas_security_check</value></property>
</bean>
casProcessingFilterEntryPoint is very critical,
loginUrl is the CAS Server's /login url, you should set up your CAS Server(2.0 or 3.0) and config for
those JKS keystore after enable SSL in Tomcat(Tomcat 5.5/conf/server.xml) and place the cacerts that
have the CAS Server's public cert to Acegi Client's JDK/jre/lib/security/
Check serviceProperties to make sure that SpringSide Service url is config as /j_acegi_cas_security_check
because Yale CAS use ticket cache for SSO impl, so we should config for statelessTicketCache
Just use springframework's ehcache for cacheManager.
SpringSide use jdbcDaoImpl which perform database authentication. So I am very happy to use it
as casAuthoritiesPopulator , which will set use detail for the user. And these info are very useful for
application authorization.
<bean id="jdbcDaoImpl"
class="org.acegisecurity.userdetails.jdbc.JdbcDaoImpl">
<property name="dataSource" ref="dataSource"/>
<property name="usersByUsernameQuery">
<value>
select loginid,passwd,1 from ss_users where status='1' and loginid = ?
</value>
</property>
<property name="authoritiesByUsernameQuery">
<value>
select u.loginid,p.name from ss_users u,ss_roles r,ss_permissions
p,ss_user_role ur,ss_role_permis rp where u.id=ur.user_id and
r.id=ur.role_id and p.id=rp.permis_id and
r.id=rp.role_id and p.status='1' and u.loginid=?
</value>
</property>
</bean>
There is little difference between casclient 2.0.12 and Acegi, right?
Note that in my env, gzug:8080/springside is bookstore webapp
and sourcesite:8443 is the CAS 3 Server.
Hope for suggestion.....
分享到:
相关推荐
在Web应用中, AceGI提供了一套强大的访问控制和身份验证机制,而CAS则作为外部认证服务器,可以为多个应用提供统一的用户验证。通过整合两者,可以简化用户登录流程,同时加强整体系统的安全性。 1.2 环境: 整合...
在Acegi Security与CAS的整合中,CAS负责用户的认证过程,即验证用户的身份;而Acegi Security则负责后续的应用程序授权,即确定用户可以访问哪些资源。这种分工明确的设计模式,既简化了开发者的集成工作,又提高了...
- **配置CAS客户端**:首先,需要在AceGI的配置中添加对CAS的支持,这通常涉及到在`applicationContext-security.xml`文件中引入CAS的客户端组件,并配置CAS服务器的URL、服务验证URL等。 - **处理服务验证**:当...
CAS处理用户认证,而Acegi则负责在客户端应用中的授权。理解并成功实施这一配置,不仅需要对SSO原理有所了解,还需要掌握Spring框架和数据库集成的相关知识。在实际操作过程中,可能会遇到各种问题,如网络连接问题...
CAS服务器负责处理用户的登录验证,而Acegi Security则作为客户端,负责与CAS服务器进行通信,并处理在Spring应用中的认证流程。 在这个`acegi-security-cas-0.7.1.jar`文件中,包含了Acegi Security的CAS模块,它...
在实际项目中,开发者需要将 Acegi Security-cas-0.8.1.1.jar 添加到项目的类路径中,并配置相关的安全拦截器、认证管理器和 CAS 服务器连接设置。例如,他们可能需要在 Spring 配置文件中定义 `...
敏捷Acegi、CAS++构建安全的Java系统pdf——part5
Acegi是一个专门为SpringFramework提供安全机制的项目,全称为Acegi Security System for Spring.
将acegi和cas的war包修改并整合测试,里面包含所需依赖包。经过分卷压缩一共3个文件.
JAVA开发专家:敏捷Acegi、CAS:构建安全的Java系统 pdf
在实际应用中,开发者需要配置Acegi Security以连接到CAS服务器,并定义安全规则来控制用户对不同资源的访问。这可能涉及XML配置文件的编辑,以及自定义认证和授权策略的实现。此外,还需要在Web应用程序的入口点...
CAS服务器负责验证用户身份,而Acegi Security则负责在客户端应用中处理授权逻辑。当用户首次登录CAS服务器后,后续访问其他支持CAS的应用时无需再次登录,提高了用户体验。 `acegi-security-cas-0.7.0.jar`是这个...
在实际应用中,使用Acegi Security CAS时,你需要将jar文件添加到项目的类路径中,并在Spring的配置文件中配置Acegi Security的相关设置,包括定义安全拦截器、用户认证源、角色分配等。此外,你还需要在服务器端...
它会生成长期有效的令牌存储在客户端,下次登录时自动完成认证。 三、Acegi Security的工作流程 1. 用户尝试访问受保护的URL。 2. Acegi Security的过滤器链被触发,首先进行身份验证,如检查请求中的`...
CAS 服务器负责验证用户的身份,而客户端应用则依赖于 CAS 服务器的认证结果,无需存储和验证用户凭证。 **三、集成背景** 将 CAS 与 Acegi 结合,可以使 Acegi 应用程序利用 CAS 的身份验证服务,避免了每个应用...
最后,为了使Basic认证工作,你需要在客户端(通常是浏览器)发送请求时附带正确的Authorization头。例如,当用户尝试访问受保护的资源时,如果没有提供有效的凭据,服务器会返回一个401未授权响应,此时浏览器会弹...
在实际使用过程中,开发者需要了解如何配置Acegi Security以连接到CAS服务器,设置认证和授权规则,以及处理各种安全事件。这通常涉及到在Spring配置文件中定义安全相关的bean,如CasAuthenticationProvider、...
在提供的压缩包文件中,`acegi-security-cas-0.8.1.jar`是实际的库文件,包含了Acegi Security CAS的所有类和资源,可以被Spring应用程序作为依赖引入。而`springframework-license.txt`很可能是Spring框架的许可...