网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

如何在SpringSecurity中使用CAS

这篇文章将为大家详细讲解有关如何在Spring Security中使用CAS,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。

创新互联主要从事网站设计、成都网站制作、网页设计、企业做网站、公司建网站等业务。立足成都服务宣城,十余年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:028-86922220

配置

web.xml


 casFilterChain
 org.springframework.web.filter.DelegatingFilterProxy


 casFilterChain
 /*



 org.jasig.cas.client.session.SingleSignOutHttpSessionListener

applicationContext-security.xml




 
  
   
    
   
  
 

 

 
  
  
 

 
  
  
 

 
  
  
  
 

 

 

properties

#CAS服务地址
cas.url=https://cas.example.com:8443
#CAS客户端地址,就是本应用的地址
client.url=http://localhost:8080

分析

在applicationContext-security.xml中的security filter chain中,我们使用了5个filter,分别是:singleSignOutFilter、cas20ProxyReceivingTicketValidationFilter、authenticationFilter、httpServletRequestWrapperFilter、assertionThreadLocalFilter。

为什么不用spring-security-cas

spring-security-cas

在spring-security-cas中负责ticket validator filter使用的是org.springframework.security.cas.authentication.CasAuthenticationProvider。

private CasAuthenticationToken authenticateNow(final Authentication authentication) throws AuthenticationException {
 try {
  final Assertion assertion = this.ticketValidator.validate(authentication.getCredentials().toString(), getServiceUrl(authentication));
  ...

在构建validator的validator方法的第二个参数时

private String getServiceUrl(Authentication authentication) {
 String serviceUrl;
 if(authentication.getDetails() instanceof ServiceAuthenticationDetails) {
  serviceUrl = ((ServiceAuthenticationDetails)authentication.getDetails()).getServiceUrl();
 }else if(serviceProperties == null){
  throw new IllegalStateException("serviceProperties cannot be null unless Authentication.getDetails() implements ServiceAuthenticationDetails.");
 }else if(serviceProperties.getService() == null){
  throw new IllegalStateException("serviceProperties.getService() cannot be null unless Authentication.getDetails() implements ServiceAuthenticationDetails.");
 }else {
  serviceUrl = serviceProperties.getService();
 }
 if(logger.isDebugEnabled()) {
  logger.debug("serviceUrl = "+serviceUrl);
 }
 return serviceUrl;
}

关于如何在Spring Security中使用CAS就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。


网页题目:如何在SpringSecurity中使用CAS
文章来源:http://bjjierui.cn/article/geesio.html

其他资讯