CAS中exection的key产生类
spring-webflow
框架中,请求一个已有的流程必须要指定execution
才可以正确返回该flow
现在都到哪一Step
了。所以参数execution
对于flow
来说非常重要,就类似于session
存在前端的cookie
中的session id
信息一样,如果没有这个值的话,那又只能重新开启一个新的flow
了。
spring-webflow
的execution
产生由FlowExecutionKeyFactory
接口定义。在CAS-Server
中重新定义了execution
的产生算法.具体的实现类由org.apereo.cas.web.flow.executor.ClientFlowExecutionRepository
完成。execution
对应的实体接口FlowExecutionKey
。在CAS_Server
中采用ClientFlowExecutionKey
类。 toString
之后的格式默认是
private static final String KEY_FORMAT = "<uuid>_<base64-encoded-flow-state>";
所以产生的execution
的值比较长,基本长下面这个样子:
553360a0-1327-47a0-8b89-cc205d9aa615_ZXlKaGJHY2lPaUpJVXpVeE1pSXNJblI1Y0NJNklrcFhWQ0o5LlBEMi01TkswR0xaV0toOVVGRklRbWcxSEpnTTRqWENNdGEyNzhyREd6YzctZzQxX3hLNGpBTlc1RlJfVUhkMk9LSWN6NGxScFNiSTNQbEZManFBamJxWENtSmJDa0h2MFNvQm9TeHEyQVZJaVJyeTNwLUE5YXpHTGI1SmlqTjB5bFFWa0I4MjJqa0QtVFFpSExNWkJ2YzZjMjMwc3BzeG5VNjNBNnZNRzllc2F5cEhEczlOcEVnSVRkcFAyRXdja3FvNUFvM185QmswbllRRWkwMFpWYkxnOVVsM1hGU1R2Z1hNLTFCMnczdWNQQ3lzdnhZS3VuemNIck56WEN4cFptVDQ3aUkta1BwcU1DZDNfUGVkU3l6UzVrMG9hTDd4NV9ESVlidVlEczNCeTdtMkF1czJHNVdtV1NTbDZfeFlfTjQ5VDZwb3JNbjlsVFpyalVxS3Q3aUJHekpSTGtCcHQxNnY1UFJMbUg0cTRnZXlXTXczUWpFbWZVLXFzeUZoUHhhdzRRR21nakN0WXpsSkJuSVlDUVBJUmdiaVR6QkRjcVZKamNXaE8zdW92YTJfdUVPOWxJeHlPVVU4NDlFS01qakVFeEJZNzYyanFRdklVc1MtYXBIbUh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UZTajhaSHNPcHlyR09HQUF0bjlpQU5kUGxndEhfZ3dpdlE5dHdycjN6ZllaejQ1MnlXQ1Qyb1VuNldDZFlHSjRxUjhQbWNEeUJ6eDI3TVQ2UENtR3p0R2FGZmNmYS56ZUZpM25CNmJEc2FMRkcxNk94eVRLcGJpVWdzeVBCa3RRYk0zTVhONnhpNHlYNHE3LWRxaGwtbl93ZVBhVDNlTzNlbzVFZUV3dDZwMWNVdG4yZXM5dw==
Cas-Server是如何把这个配置进去的
CAS的配置类为CasWebflowContextConfiguration
,在该类中定义流程时会使用FlowExecutor
。
@RefreshScope
@Bean
@Lazy(false)
public FlowExecutor loginFlowExecutor() {
val factory = new WebflowExecutorFactory(casProperties.getWebflow(),
loginFlowRegistry(), this.webflowCipherExecutor.getObject(),
FLOW_EXECUTION_LISTENERS);
return factory.build();
}
在WebflowExecutorFactory
中的方法buildFlowExecutorViaClientFlowExecution
会使用到ClientFlowExecutionRepository
类。该类具有获取execution
key的功能.
@Override
public FlowExecutionKey getKey(final FlowExecution execution) {
try {
return new ClientFlowExecutionKey(
this.transcoder.encode(
new SerializedFlowExecutionState(execution)
)
);
} catch (final Exception e) {
throw new ClientFlowExecutionRepositoryException("Error encoding flow execution", e);
}
}
综上,这里面的几个关键类:
CasWebflowContextConfiguration
WebflowExecutorFactory
FlowExecutor
ClientFlowExecutionRepository
ClientFlowExecutionKey