posts - 1,  comments - 3,  trackbacks - 0

     最近在项目中集成了CAS 结合Acegi来作单点登陆。感觉CAS虽然简单,用起来还是很爽的。不过前几天发布一个子系统的时候出现了下面的问题。

edu.yale.its.tp.cas.client.CASAuthenticationException: Unable to validate ProxyTicketValidator
    
< cas:authenticationFailure code = ' INVALID_SERVICE ' >
        ticket 
' ST-74-yBBJRjb3qnFle0Ynhq7sgUsdaox9nPoFbGu-20 '  does not match supplied service
    
</ cas:authenticationFailure >

     经排查,发现是CAS java client2.1.1 与Tomcat 5.5.16配合有问题。查看log,发现Cas Server端解析出的service URL前后相差了一个“?”,怀疑是cas client在新版tomcat下生成 service URL时出现问题,检查client代码,定位到edu.yale.its.tp.cas.client.Util的getService方法,跟踪了一下,发现
if (request.getQueryString() != null
        
{
            
// first, see whether we've got a 'ticket' at all
            int ticketLoc = request.getQueryString().indexOf("ticket=");

            
// if ticketLoc == 0, then it's the only parameter and we ignore
            
// the whole query string

            
// if no ticket is present, we use the query string wholesale
            if (ticketLoc == -1)
                sb.append(
"?" + request.getQueryString());
            
else if (ticketLoc > 0
{
                ticketLoc 
= request.getQueryString().indexOf("&ticket=");
                
if (ticketLoc == -1
                
{
                    
// there was a 'ticket=' unrelated to a parameter named
                    
// 'ticket'
                    sb.append("?" + request.getQueryString());
                }
 else if (ticketLoc > 0
                
{
                    
// otherwise, we use the query string up to "&ticket="
                    sb.append("?"
                            
+ request.getQueryString().substring(0, ticketLoc));
                }

            }

        }

发现对于没有参数的http请求,request.getQueryString()函数在Tomcat5.5.15中是返回null,而5.5.16中是返回""。到这里问题就清楚了,看来yale的这帮学生代码写得还是有点业余呀,直接加上对空string判断的逻辑,问题解决。
       这个bug我已经提交到cas的jira上了,应该很快可以fix了,在新版本client没有发布前,可以使用附件压缩包中的jar替换casclient.jar。
casclient.zip
posted on 2006-04-04 09:30 zhangwh6882 阅读(3929) 评论(3)  编辑  收藏 所属分类: SSO


FeedBack:
# re: CAS java client2.1.1 在Tomcat5.5.16下bug的解决
2006-07-19 10:17 | taole
版主我按照你的方法试过 ,但是还是会出到访问应用程序后提示输入验证用户名和密码以后就会出现错误页面,
异常如下:
*************************************
HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Unable to validate ProxyTicketValidator [[edu.yale.its.tp.cas.client.ProxyTicketValidator proxyList=[null] [edu.yale.its.tp.cas.client.ServiceTicketValidator casValidateUrl=[https://xufei:8443/cas/proxyValidate">https://xufei:8443/cas/proxyValidate] ticket=[ST-2-cHE06v0KjLXrd2YOwdbTQAM2hsZeCZfauiz-20] service=[http%3A%2F%2Fxufei%3A8080%2Fservlets-examples%2Fservlet%2FHelloWorldExample] renew=false]]]
edu.yale.its.tp.cas.client.filter.CASFilter.doFilter(CASFilter.java:381)
filters.ExampleFilter.doFilter(ExampleFilter.java:101)


root cause

edu.yale.its.tp.cas.client.CASAuthenticationException: Unable to validate ProxyTicketValidator [[edu.yale.its.tp.cas.client.ProxyTicketValidator proxyList=[null] [edu.yale.its.tp.cas.client.ServiceTicketValidator casValidateUrl=[https://xufei:8443/cas/proxyValidate">https://xufei:8443/cas/proxyValidate] ticket=[ST-2-cHE06v0KjLXrd2YOwdbTQAM2hsZeCZfauiz-20] service=[http%3A%2F%2Fxufei%3A8080%2Fservlets-examples%2Fservlet%2FHelloWorldExample] renew=false]]]
edu.yale.its.tp.cas.client.CASReceipt.getReceipt(CASReceipt.java:52)
edu.yale.its.tp.cas.client.filter.CASFilter.getAuthenticatedUser(CASFilter.java:455)
edu.yale.its.tp.cas.client.filter.CASFilter.doFilter(CASFilter.java:378)
filters.ExampleFilter.doFilter(ExampleFilter.java:101)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.
  回复  更多评论
  
# re: CAS java client2.1.1 在Tomcat5.5.16下bug的解决
2006-07-28 16:18 | feng
晕,我也遇到这个问题。如果一开始输入 https://localhost:8443,再继续访问的话,一点问题都没有。 但是如果一开始输入 http://localhost:8080的话,就出现上面的问题。下载斑竹的包也无用
郁闷  回复  更多评论
  
# re: CAS java client2.1.1 在Tomcat5.5.16下bug的解决
2007-05-18 14:41 | 555
能不能带出来参数给下面的画面

怎么将从数据库里面查到的数据放在session里  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航:
 
<2024年5月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

常用链接

留言簿(3)

随笔分类

随笔档案

搜索

  •  

积分与排名

  • 积分 - 4046
  • 排名 - 3273

最新评论