CAS系列:login中的execution参数的作用是什么?

今天子涵先生第一次使用JMeter做测试时,便想到了测一下CAS的登录并发。然而在调试的时候特地注意了下,点击登录按钮时cas到底提交了些什么,其中的参数有何意义呢?

在这里插入图片描述

总结在前

execution:此参数用于指定一个唯一的流程实例;
_eventId:此参数用于确定页面的跳转关系,参数值如"submit";
lt:cas登录服务的票据;
username、password、dept_code是定制化登录相关的一些参数,此处不做详解。

源码探索

我们可以在登录拦截页面的源代码中看到几个参数ltexecution

<li class="sub-form-box text-left">
	<input type="hidden" name="lt" value="${loginTicket}"/>
    <input type="hidden" name="execution" value="${flowExecutionKey}"/>
    <input type="hidden" name="_eventId" value="submit"/>
    <input id="login_btn" class="btn-submit btn btn-primary  btn-block" name="submit" accesskey="l" value="登&nbsp;&nbsp;录" tabindex="4" type="submit"/>
</li>

其中,lt全名是loginTicket是用户认证登录界面中的登录票据。execution的取值来源于flowExecutionKey,那这个flowExecutionKey到底是何方神圣?
顾名思义,execution一定和流程的执行有关。

execution的作用

execution在CAS中的使用的位置在:org.springframework.webflow.mvc.servlet.FlowHandlerAdapter#handle。

1、execution参数的获取:

execution参数获取是在CasDefaultFlowUrlHandler中完成的。

public final class CasDefaultFlowUrlHandler extends DefaultFlowUrlHandler {
    
    

    /** Default flow execution key parameter name, {@value}. Same as that used by {@link DefaultFlowUrlHandler}. */
    public static final String DEFAULT_FLOW_EXECUTION_KEY_PARAMETER = "execution";

    /** Flow execution parameter name. */
    private String flowExecutionKeyParameter = DEFAULT_FLOW_EXECUTION_KEY_PARAMETER;
        /**
     * Sets the parameter name used to carry flow execution key in request.
     *
     * @param parameterName Request parameter name.
     */
    public void setFlowExecutionKeyParameter(final String parameterName) {
    
    
        this.flowExecutionKeyParameter = parameterName;
    }
    ......
}

2、execution参数的作用

execution参数的使用是在loginHandlerAdapter适配器中完成的,我们看下源码:

	public ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
    
    
		FlowHandler flowHandler = (FlowHandler) handler;
		checkAndPrepare(request, response, false);
		//获取execution参数
		String flowExecutionKey = flowUrlHandler.getFlowExecutionKey(request);
		//execution用来标记流程编号
		if (flowExecutionKey != null) {
    
    
			try {
    
    
				ServletExternalContext context = createServletExternalContext(request, response);
				// 根据流程编号执行流程接下来的步骤
				FlowExecutionResult result = flowExecutor.resumeExecution(flowExecutionKey, context);
				handleFlowExecutionResult(result, context, request, response, flowHandler);
			} catch (FlowException e) {
    
    
				handleFlowException(e, request, response, flowHandler);
			}
		} else {
    
    
			try {
    
    
				String flowId = getFlowId(flowHandler, request);
				MutableAttributeMap input = getInputMap(flowHandler, request);
				ServletExternalContext context = createServletExternalContext(request, response);
				FlowExecutionResult result = flowExecutor.launchExecution(flowId, input, context);
				handleFlowExecutionResult(result, context, request, response, flowHandler);
			} catch (FlowException e) {
    
    
				handleFlowException(e, request, response, flowHandler);
			}
		}
		return null;
	}

致此,我们可以确定execution是Spring-webflow中用来标识流程的这样一个参数。通过进一步查找文档:

webflow的核心参数:
  1.execution:此参数用于指定一个唯一的流程实例,在页面提交时此处的值可以直接通过${flowExecutionKey}获得;
  2.、_eventId:此参数用于确定页面的跳转关系,对应shopping.xml中on属性中的值;
  3.flowExecutionUrl:在提交的时候可以直接使用此参数作为form表单中action的值:${flowExecutionUrl}
  上述的1,2参数是使用webflow框架在页面提交请求的时候必须带回的参数

CAS的流程注册

在这里插入图片描述

CAS流程的运行

根据execution进行流程运行图示。
在这里插入图片描述

参考文档:
Spring-webflow基础讲解

在这里插入图片描述

感谢您的赏读。客官,点赞、留言再走呗~或者留下您的问题一起探讨

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/l714417743/article/details/108184931