use of org.springframework.webflow.engine.FlowVariable in project cas by apereo.
the class AbstractCasWebflowConfigurer method createFlowVariable.
/**
* Create flow variable flow variable.
*
* @param flow the flow
* @param id the id
* @param type the type
* @return the flow variable
*/
protected FlowVariable createFlowVariable(final Flow flow, final String id, final Class type) {
final Optional<FlowVariable> opt = Arrays.stream(flow.getVariables()).filter(v -> v.getName().equalsIgnoreCase(id)).findFirst();
if (opt.isPresent()) {
return opt.get();
}
final FlowVariable flowVar = new FlowVariable(id, new BeanFactoryVariableValueFactory(type, applicationContext.getAutowireCapableBeanFactory()));
flow.addVariable(flowVar);
return flowVar;
}
use of org.springframework.webflow.engine.FlowVariable in project cas by apereo.
the class ClearWebflowCredentialAction method doExecute.
@Override
protected Event doExecute(final RequestContext requestContext) throws Exception {
WebUtils.putCredential(requestContext, null);
final String current = requestContext.getCurrentEvent().getId();
if (current.equalsIgnoreCase(CasWebflowConstants.TRANSITION_ID_AUTHENTICATION_FAILURE) || current.equalsIgnoreCase(CasWebflowConstants.TRANSITION_ID_ERROR)) {
LOGGER.debug("Current event signaled a failure. Recreating credentials instance from the context");
try {
final Flow flow = (Flow) requestContext.getFlowExecutionContext().getDefinition();
final FlowVariable var = flow.getVariable(CasWebflowConstants.VAR_ID_CREDENTIAL);
var.create(requestContext);
} catch (final Exception e) {
throw Throwables.propagate(e);
}
}
return null;
}
Aggregations