Package org.springframework.security.web.access.expression

Examples of org.springframework.security.web.access.expression.WebSecurityExpressionHandler


        final String expr =
                ((accessExpression != null && accessExpression.startsWith("${") && accessExpression.endsWith("}"))?
                        accessExpression.substring(2, accessExpression.length() - 1) :
                        accessExpression);
       
        final WebSecurityExpressionHandler handler = getExpressionHandler(servletContext);

        Expression expressionObject = null;
        try {
            expressionObject = handler.getExpressionParser().parseExpression(expr);
        } catch (ParseException e) {
            throw new TemplateProcessingException(
                    "An error happened trying to parse Spring Security access expression \""
                    expr + "\"", e);
        }

        final FilterInvocation filterInvocation = new FilterInvocation(request, response, DUMMY_CHAIN);
       
        final EvaluationContext evaluationContext = handler.createEvaluationContext(authentication, filterInvocation);
       
        /*
         * Initialize the context variables map.
         *
         * This will allow SpringSecurity expressions to include any variables from
View Full Code Here


        return super.doStartTag();
    }

    private int authorizeUsingAccessExpression(Authentication currentUser) throws JspException {
        // Get web expression
        WebSecurityExpressionHandler handler = getExpressionHandler();

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

        } catch (ParseException e) {
            throw new JspException(e);
        }

        FilterInvocation f = new FilterInvocation(pageContext.getRequest(), pageContext.getResponse(), DUMMY_CHAIN);

        if (ExpressionUtils.evaluateAsBoolean(accessExpression, handler.createEvaluationContext(currentUser, f))) {
            return EVAL_BODY_INCLUDE;
        }

        return SKIP_BODY;
    }
View Full Code Here

TOP

Related Classes of org.springframework.security.web.access.expression.WebSecurityExpressionHandler

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.