Search in sources :

Example 1 with EvaluateAction

use of org.springframework.webflow.action.EvaluateAction in project cas by apereo.

the class AbstractCasWebflowConfigurer method createEvaluateAction.

@Override
public EvaluateAction createEvaluateAction(final String expression) {
    if (this.flowBuilderServices == null) {
        LOGGER.error("Flow builder services is not configured correctly.");
        return null;
    }
    final ParserContext ctx = new FluentParserContext();
    final Expression action = this.flowBuilderServices.getExpressionParser().parseExpression(expression, ctx);
    final EvaluateAction newAction = new EvaluateAction(action, null);
    LOGGER.debug("Created evaluate action for expression [[{}]]", action.getExpressionString());
    return newAction;
}
Also used : FluentParserContext(org.springframework.binding.expression.support.FluentParserContext) Expression(org.springframework.binding.expression.Expression) LiteralExpression(org.springframework.binding.expression.support.LiteralExpression) EvaluateAction(org.springframework.webflow.action.EvaluateAction) FluentParserContext(org.springframework.binding.expression.support.FluentParserContext) ParserContext(org.springframework.binding.expression.ParserContext)

Example 2 with EvaluateAction

use of org.springframework.webflow.action.EvaluateAction in project cas by apereo.

the class SpringWebflowEndpoint method convertActionToString.

private static String convertActionToString(final Action action) {
    if (action instanceof EvaluateAction) {
        return convertEvaluateActionToString(action);
    }
    if (action instanceof AnnotatedAction) {
        val eval = (AnnotatedAction) action;
        if (eval.getTargetAction() instanceof EvaluateAction) {
            return convertEvaluateActionToString(eval.getTargetAction());
        }
        return eval.getTargetAction().toString();
    }
    if (action instanceof SetAction) {
        val expF = ReflectionUtils.findField(action.getClass(), "nameExpression");
        val resultExpF = ReflectionUtils.findField(action.getClass(), "valueExpression");
        return "set " + stringifyActionField(action, expF) + " = " + stringifyActionField(action, resultExpF);
    }
    return action.toString();
}
Also used : lombok.val(lombok.val) SetAction(org.springframework.webflow.action.SetAction) EvaluateAction(org.springframework.webflow.action.EvaluateAction) AnnotatedAction(org.springframework.webflow.execution.AnnotatedAction)

Example 3 with EvaluateAction

use of org.springframework.webflow.action.EvaluateAction in project cas by apereo.

the class CasCaptchaWebflowConfigurerTests method verifyOperation.

@Test
public void verifyOperation() {
    assertFalse(casWebflowExecutionPlan.getWebflowConfigurers().isEmpty());
    val flow = (Flow) this.loginFlowDefinitionRegistry.getFlowDefinition(CasWebflowConfigurer.FLOW_ID_LOGIN);
    assertNotNull(flow);
    val state = (ActionState) flow.getState(CasWebflowConstants.STATE_ID_REAL_SUBMIT);
    assertTrue(Arrays.stream(state.getActionList().toArray()).filter(r -> r instanceof EvaluateAction).map(EvaluateAction.class::cast).anyMatch(r -> r.toString().contains(CasWebflowConstants.ACTION_ID_VALIDATE_CAPTCHA)));
}
Also used : lombok.val(lombok.val) Test(org.junit.jupiter.api.Test) ActionState(org.springframework.webflow.engine.ActionState) Arrays(java.util.Arrays) lombok.val(lombok.val) Assertions(org.junit.jupiter.api.Assertions) Import(org.springframework.context.annotation.Import) EvaluateAction(org.springframework.webflow.action.EvaluateAction) CasCaptchaConfiguration(org.apereo.cas.web.flow.config.CasCaptchaConfiguration) Flow(org.springframework.webflow.engine.Flow) Tag(org.junit.jupiter.api.Tag) EvaluateAction(org.springframework.webflow.action.EvaluateAction) ActionState(org.springframework.webflow.engine.ActionState) Flow(org.springframework.webflow.engine.Flow) Test(org.junit.jupiter.api.Test)

Example 4 with EvaluateAction

use of org.springframework.webflow.action.EvaluateAction in project cas by apereo.

the class SpringWebflowEndpoint method convertEvaluateActionToString.

private static String convertEvaluateActionToString(final Action action) {
    val eval = (EvaluateAction) action;
    val expF = ReflectionUtils.findField(eval.getClass(), "expression");
    val resultExpF = ReflectionUtils.findField(eval.getClass(), "resultExpression");
    return stringifyActionField(action, expF, resultExpF);
}
Also used : lombok.val(lombok.val) EvaluateAction(org.springframework.webflow.action.EvaluateAction)

Example 5 with EvaluateAction

use of org.springframework.webflow.action.EvaluateAction in project cas by apereo.

the class AbstractCasWebflowConfigurer method createEvaluateAction.

@Override
public EvaluateAction createEvaluateAction(final String expression) {
    if (this.flowBuilderServices == null) {
        LOGGER.warn("Flow builder services is not configured correctly.");
        return null;
    }
    val ctx = new FluentParserContext();
    val action = this.flowBuilderServices.getExpressionParser().parseExpression(expression, ctx);
    val newAction = new EvaluateAction(action, null);
    LOGGER.trace("Created evaluate action for expression [{}]", action.getExpressionString());
    return newAction;
}
Also used : lombok.val(lombok.val) FluentParserContext(org.springframework.binding.expression.support.FluentParserContext) EvaluateAction(org.springframework.webflow.action.EvaluateAction)

Aggregations

EvaluateAction (org.springframework.webflow.action.EvaluateAction)7 lombok.val (lombok.val)6 Test (org.junit.jupiter.api.Test)2 FluentParserContext (org.springframework.binding.expression.support.FluentParserContext)2 SetAction (org.springframework.webflow.action.SetAction)2 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 CasConfigurationProperties (org.apereo.cas.configuration.CasConfigurationProperties)1 CasCaptchaConfiguration (org.apereo.cas.web.flow.config.CasCaptchaConfiguration)1 Assertions (org.junit.jupiter.api.Assertions)1 Tag (org.junit.jupiter.api.Tag)1 ConversionService (org.springframework.binding.convert.ConversionService)1 Expression (org.springframework.binding.expression.Expression)1 ParserContext (org.springframework.binding.expression.ParserContext)1 LiteralExpression (org.springframework.binding.expression.support.LiteralExpression)1 Import (org.springframework.context.annotation.Import)1 StaticApplicationContext (org.springframework.context.support.StaticApplicationContext)1 ExternalRedirectAction (org.springframework.webflow.action.ExternalRedirectAction)1 RenderAction (org.springframework.webflow.action.RenderAction)1 ActionState (org.springframework.webflow.engine.ActionState)1