今天子涵先生第一次使用JMeter做测试时,便想到了测一下CAS的登录并发。然而在调试的时候特地注意了下,点击登录按钮时cas到底提交了些什么,其中的参数有何意义呢?
总结在前
execution:此参数用于指定一个唯一的流程实例;
_eventId:此参数用于确定页面的跳转关系,参数值如"submit";
lt:cas登录服务的票据;
username、password、dept_code是定制化登录相关的一些参数,此处不做详解。
源码探索
我们可以在登录拦截页面的源代码中看到几个参数lt
,execution
。
<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="登 录" 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基础讲解
感谢您的赏读。客官,点赞、留言再走呗~或者留下您的问题一起探讨