您的位置:首页 > 其它

CAS-Client客户端研究(二)-Cas20ProxyReceivingTicketValidationFilter

2016-07-08 00:00 369 查看
最近研究CAS,先从客户开始来说明CAS的逻辑,可能会结合源代码。

必要说明:http://blog.csdn.net/yuwenruli/article/details/6602180

言归正传,Cas20ProxyReceivingTicketValidationFilter 是继承AbstractTicketValidationFilter,这里有几个模板方法。例如:getTicketValidator,preFilter,onSuccessfulValidation,onFailedValidation等。大的逻辑在AbstractTicketValidationFilter的doFilter方法中,而Cas20ProxyReceivingTicketValidationFilter 主要实现了父类中的模板方法。总体逻辑如下,有部分细节需要另外的说明的,只是在总体中提到,后面会深入说明的。



这些是大体上逻辑,那么上面说到的那些模板方法在Cas20ProxyReceivingTicketValidationFilter中有什么具体实现呢,让我们一个个来看好了。

preFilter,这个方法是判断前置条件,各个子类的前置条件是有各个子类自己去决定的,在本过滤器中,前置条件很简单,参数proxyReceptorUrl为空或者请求的uri不是以proxyReceptorUrl结尾的,则返回true,然后读取并相应代理请求。

getTicketValidator 这个方法主要是产生TicketValidator对象,先来说说TicketValidator有什么用,只有一个方法Assertion validate(String ticket, String service) throws TicketValidationException;,根据票据和service来产生Assertion对象,那么到底是什么票据呢?还记得CAS登录整个ie过程嘛,没有登录跳转到CAS服务器,认证通过后ie有跳转到需要访问的应用,这个时候会有两个票据产生,一个TGT票据,这个是和用户有关的,另外一个是ST票据,ST票据是通过跳转post参数传递过来了,默认的参数名为ticket。那么service是什么呢?就是你需要访问的app的url地址,包括url参数。好了,知道了TicketValidator做什么用的,我们来说说怎么创建TicketValidator对象,根据acceptAnyProxy,allowedProxyChains,casServerUrlPrefix等参数来创建,其中casServerUrlPrefix是需要要的。

onSuccessfulValidation,onFailedValidation这个两个方法都使用父类中的默认实现,也就是啥也不做的。

renew - specifies whether renew=true should be sent to the CAS server. Valid values are either "true" or "false" (or no value at all).

gateway - specifies whether gateway=true should be sent to the CAS server. Valid values are either "true" or "false" (or no value at all).

artifactParameterName - specifies the name of the request parameter on where to find the artifact (i.e. "ticket").

serviceParameterName - specifies the name of the request parameter on where to find the service (i.e. "service").

renew - specifies whether renew=true should be sent to the CAS server. Valid values are either "true" or "false" (or no value at all).

gateway - specifies whether gateway=true should be sent to the CAS server. Valid values are either "true" or "false" (or no value at all).

artifactParameterName - specifies the name of the request parameter on where to find the artifact (i.e. "ticket").

serviceParameterName - specifies the name of the request parameter on where to find the service (i.e. "service").
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: