Search in sources :

Example 1 with FlowVariable

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;
}
Also used : CasConfigurationProperties(org.apereo.cas.configuration.CasConfigurationProperties) ReflectivePropertyAccessor(org.springframework.expression.spel.support.ReflectivePropertyAccessor) Arrays(java.util.Arrays) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) ViewFactory(org.springframework.webflow.execution.ViewFactory) DefaultTransitionCriteria(org.springframework.webflow.engine.support.DefaultTransitionCriteria) DefaultMapping(org.springframework.binding.mapping.impl.DefaultMapping) FlowBuilderServices(org.springframework.webflow.engine.builder.support.FlowBuilderServices) DecisionState(org.springframework.webflow.engine.DecisionState) TransitionableState(org.springframework.webflow.engine.TransitionableState) RuntimeBindingConversionExecutor(org.springframework.binding.convert.service.RuntimeBindingConversionExecutor) ConversionExecutor(org.springframework.binding.convert.ConversionExecutor) Map(java.util.Map) DefaultMapper(org.springframework.binding.mapping.impl.DefaultMapper) ScopeSearchingPropertyAccessor(org.springframework.webflow.expression.spel.ScopeSearchingPropertyAccessor) FlowDefinitionRegistry(org.springframework.webflow.definition.registry.FlowDefinitionRegistry) FlowVariable(org.springframework.webflow.engine.FlowVariable) Expression(org.springframework.binding.expression.Expression) WildcardTransitionCriteria(org.springframework.webflow.engine.WildcardTransitionCriteria) BeanFactoryVariableValueFactory(org.springframework.webflow.engine.support.BeanFactoryVariableValueFactory) Action(org.springframework.webflow.execution.Action) FlowVariablePropertyAccessor(org.springframework.webflow.expression.spel.FlowVariablePropertyAccessor) SpringELExpressionParser(org.springframework.binding.expression.spel.SpringELExpressionParser) TransitionCriteria(org.springframework.webflow.engine.TransitionCriteria) FlowDefinitionRegistryBuilder(org.springframework.webflow.config.FlowDefinitionRegistryBuilder) SubflowAttributeMapper(org.springframework.webflow.engine.SubflowAttributeMapper) List(java.util.List) EndState(org.springframework.webflow.engine.EndState) ViewState(org.springframework.webflow.engine.ViewState) ExpressionParser(org.springframework.binding.expression.ExpressionParser) PostConstruct(javax.annotation.PostConstruct) Optional(java.util.Optional) BeanExpressionContextAccessor(org.springframework.context.expression.BeanExpressionContextAccessor) GenericSubflowAttributeMapper(org.springframework.webflow.engine.support.GenericSubflowAttributeMapper) WebUtils(org.apereo.cas.web.support.WebUtils) DefaultTargetStateResolver(org.springframework.webflow.engine.support.DefaultTargetStateResolver) FluentParserContext(org.springframework.binding.expression.support.FluentParserContext) SubflowState(org.springframework.webflow.engine.SubflowState) ActionState(org.springframework.webflow.engine.ActionState) ParserContext(org.springframework.binding.expression.ParserContext) ExternalRedirectAction(org.springframework.webflow.action.ExternalRedirectAction) ActionExecutingViewFactory(org.springframework.webflow.engine.support.ActionExecutingViewFactory) ArrayList(java.util.ArrayList) LiteralExpression(org.springframework.binding.expression.support.LiteralExpression) Mapper(org.springframework.binding.mapping.Mapper) MapAccessor(org.springframework.context.expression.MapAccessor) ViewFactoryActionAdapter(org.springframework.webflow.action.ViewFactoryActionAdapter) FlowDefinition(org.springframework.webflow.definition.FlowDefinition) ActionPropertyAccessor(org.springframework.webflow.expression.spel.ActionPropertyAccessor) MultifactorAuthenticationProvider(org.apereo.cas.services.MultifactorAuthenticationProvider) MapAdaptablePropertyAccessor(org.springframework.webflow.expression.spel.MapAdaptablePropertyAccessor) Logger(org.slf4j.Logger) EvaluateAction(org.springframework.webflow.action.EvaluateAction) Flow(org.springframework.webflow.engine.Flow) SpelParserConfiguration(org.springframework.expression.spel.SpelParserConfiguration) Field(java.lang.reflect.Field) ApplicationContext(org.springframework.context.ApplicationContext) Transition(org.springframework.webflow.engine.Transition) BeanFactoryPropertyAccessor(org.springframework.webflow.expression.spel.BeanFactoryPropertyAccessor) BinderConfiguration(org.springframework.webflow.engine.builder.BinderConfiguration) EnvironmentAccessor(org.springframework.context.expression.EnvironmentAccessor) ReflectionUtils(org.springframework.util.ReflectionUtils) SpelExpressionParser(org.springframework.expression.spel.standard.SpelExpressionParser) MessageSourcePropertyAccessor(org.springframework.webflow.expression.spel.MessageSourcePropertyAccessor) BeanFactoryVariableValueFactory(org.springframework.webflow.engine.support.BeanFactoryVariableValueFactory) FlowVariable(org.springframework.webflow.engine.FlowVariable)

Example 2 with FlowVariable

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;
}
Also used : Flow(org.springframework.webflow.engine.Flow) FlowVariable(org.springframework.webflow.engine.FlowVariable)

Aggregations

Flow (org.springframework.webflow.engine.Flow)2 FlowVariable (org.springframework.webflow.engine.FlowVariable)2 Field (java.lang.reflect.Field)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 PostConstruct (javax.annotation.PostConstruct)1 CasConfigurationProperties (org.apereo.cas.configuration.CasConfigurationProperties)1 MultifactorAuthenticationProvider (org.apereo.cas.services.MultifactorAuthenticationProvider)1 WebUtils (org.apereo.cas.web.support.WebUtils)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 ConversionExecutor (org.springframework.binding.convert.ConversionExecutor)1 RuntimeBindingConversionExecutor (org.springframework.binding.convert.service.RuntimeBindingConversionExecutor)1 Expression (org.springframework.binding.expression.Expression)1 ExpressionParser (org.springframework.binding.expression.ExpressionParser)1 ParserContext (org.springframework.binding.expression.ParserContext)1