Package org.springframework.expression

Examples of org.springframework.expression.Expression


        SpringStepContext stepContext=new SpringStepContext(flowArgs,local);
        ExpressionParser parser = new SpelExpressionParser();
        List<String> stepArgs=new ArrayList<>();
       
        for(String that:argDefinitions) {
            Expression e=parser.parseExpression(that);
            StandardEvaluationContext c=new StandardEvaluationContext(stepContext);
            stepContext.assignVariables(c);
            String value = e.getValue(c,String.class);
            logger.trace("parsing ["+that+"] with result +["+value+"]");
            stepArgs.add(value);
        };
       
        return stepArgs;
View Full Code Here


        HashMap<String, Object> output = new HashMap<>(local);
        SpringStepContext stepContext=new SpringStepContext(flowArgs,local);
        ExpressionParser parser = new SpelExpressionParser();
       
        for(Assignment that:assignments) {
            Expression e=parser.parseExpression(that.getExpression());
            StandardEvaluationContext c=new StandardEvaluationContext(stepContext);
            stepContext.assignVariables(c);
            Object value = e.getValue(c);
            logger.trace("parsing ["+that+"] with result +["+value+"]");
            if (output.containsKey(that.getAssignTo())) {
                throw new IllegalArgumentException("Cannot overwrite existing local variable ["+that.getAssignTo()+"]");
            }
            output.put(that.getAssignTo(),value);
View Full Code Here

    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        Expression authorize = getAuthorizeExpression();
        Expression filter = getFilterExpression();
        sb.append("[authorize: '").append(authorize == null ? "null" : authorize.getExpressionString());
        sb.append("', filter: '").append(filter == null ? "null" : filter.getExpressionString()).append("']");
        return sb.toString();
    }
View Full Code Here

    public PreInvocationAttribute createPreInvocationAttribute(String preFilterAttribute, String filterObject, String preAuthorizeAttribute) {
        try {
            // TODO: Optimization of permitAll
            ExpressionParser parser = getParser();
            Expression preAuthorizeExpression = preAuthorizeAttribute == null ? parser.parseExpression("permitAll") : parser.parseExpression(preAuthorizeAttribute);
            Expression preFilterExpression = preFilterAttribute == null ? null : parser.parseExpression(preFilterAttribute);
            return new PreInvocationExpressionAttribute(preFilterExpression, filterObject, preAuthorizeExpression);
        } catch (ParseException e) {
            throw new IllegalArgumentException("Failed to parse expression '" + e.getExpressionString() + "'", e);
        }
    }
View Full Code Here

    }

    public PostInvocationAttribute createPostInvocationAttribute(String postFilterAttribute, String postAuthorizeAttribute) {
        try {
            ExpressionParser parser = getParser();
            Expression postAuthorizeExpression = postAuthorizeAttribute == null ? null : parser.parseExpression(postAuthorizeAttribute);
            Expression postFilterExpression = postFilterAttribute == null ? null : parser.parseExpression(postFilterAttribute);

            if (postFilterExpression != null || postAuthorizeExpression != null) {
                return new PostInvocationExpressionAttribute(postFilterExpression, postAuthorizeExpression);
            }
        } catch (ParseException e) {
View Full Code Here

    private MethodSecurityExpressionHandler expressionHandler = new DefaultMethodSecurityExpressionHandler();

    public boolean before(Authentication authentication, MethodInvocation mi, PreInvocationAttribute attr) {
        PreInvocationExpressionAttribute preAttr = (PreInvocationExpressionAttribute) attr;
        EvaluationContext ctx = expressionHandler.createEvaluationContext(authentication, mi);
        Expression preFilter = preAttr.getFilterExpression();
        Expression preAuthorize = preAttr.getAuthorizeExpression();

        if (preFilter != null) {
            Object filterTarget = findFilterTarget(preAttr.getFilterTarget(), ctx, mi);

            expressionHandler.filter(filterTarget, preFilter, ctx);
View Full Code Here

    public Object after(Authentication authentication, MethodInvocation mi,
            PostInvocationAttribute postAttr, Object returnedObject) throws AccessDeniedException{
        PostInvocationExpressionAttribute pia = (PostInvocationExpressionAttribute) postAttr;
        EvaluationContext ctx = expressionHandler.createEvaluationContext(authentication, mi);
        Expression postFilter = pia.getFilterExpression();
        Expression postAuthorize = pia.getAuthorizeExpression();

        if (postFilter != null) {
            if (logger.isDebugEnabled()) {
                logger.debug("Applying PostFilter expression " + postFilter);
            }
View Full Code Here

    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        Expression authorize = getAuthorizeExpression();
        Expression filter = getFilterExpression();
        sb.append("[authorize: '").append(authorize == null ? "null" : authorize.getExpressionString());
        sb.append("', filter: '").append(filter == null ? "null" : filter.getExpressionString());
        sb.append("', filterTarget: '").append(filterTarget).append("']");
        return sb.toString();
    }
View Full Code Here

            return false;
        }

        SecurityExpressionHandler<FilterInvocation> handler = getExpressionHandler();

        Expression accessExpression;
        try {
            accessExpression = handler.getExpressionParser().parseExpression(getAccess());

        } catch (ParseException e) {
            IOException ioException = new IOException();
View Full Code Here

    @Test
    public void createEvaluationContextCustomTrustResolver() {
        handler.setTrustResolver(trustResolver);

        Expression expression = handler.getExpressionParser().parseExpression("anonymous");
        EvaluationContext context = handler.createEvaluationContext(authentication, invocation);
        assertThat(expression.getValue(context, Boolean.class)).isFalse();

        verify(trustResolver).isAnonymous(authentication);
    }
View Full Code Here

TOP

Related Classes of org.springframework.expression.Expression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.