Example usage for org.springframework.security.web.access.expression WebSecurityExpressionRoot setPermissionEvaluator

List of usage examples for org.springframework.security.web.access.expression WebSecurityExpressionRoot setPermissionEvaluator

Introduction

In this page you can find the example usage for org.springframework.security.web.access.expression WebSecurityExpressionRoot setPermissionEvaluator.

Prototype

public void setPermissionEvaluator(PermissionEvaluator permissionEvaluator) 

Source Link

Usage

From source file:org.web4thejob.security.CustomWebSecurityExpressionHandler.java

@Override
protected SecurityExpressionRoot createSecurityExpressionRoot(Authentication authentication,
        FilterInvocation fi) {//from  w  w w  . j av  a 2 s . c o  m
    WebSecurityExpressionRoot root = new CustomWebSecurityExpressionRoot(authentication, fi);
    root.setPermissionEvaluator(getPermissionEvaluator());
    return root;
}

From source file:de.iew.framework.security.access.WebResourceAccessEvaluator.java

/**
 * Create security expression root.//from ww  w .  j  ava 2s  .c o m
 * <p>
 * Implements methods to test permissions.
 * </p>
 *
 * @param authentication the authentication
 * @param fi             the fi
 * @return the security expression operations
 */
protected SecurityExpressionOperations createSecurityExpressionRoot(Authentication authentication,
        FilterInvocation fi) {
    WebSecurityExpressionRoot root = new WebSecurityExpressionRoot(authentication, fi);
    root.setPermissionEvaluator(getPermissionEvaluator());
    root.setTrustResolver(trustResolver);
    root.setRoleHierarchy(getRoleHierarchy());
    return root;
}

From source file:org.squashtest.tm.web.internal.interceptor.SecurityExpressionResolverExposerInterceptor.java

/**
 * @see org.springframework.web.servlet.handler.HandlerInterceptorAdapter#postHandle(javax.servlet.http.HttpServletRequest,
 *      javax.servlet.http.HttpServletResponse, java.lang.Object, org.springframework.web.servlet.ModelAndView)
 *///from w  w  w .  j  a v  a 2 s .  c  o  m
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
        ModelAndView modelAndView) {
    if (modelAndView != null && modelAndView.hasView()
            && !StringUtils.startsWith(modelAndView.getViewName(), "redirect:")) {
        FilterInvocation filterInvocation = new FilterInvocation(request, response, DUMMY_CHAIN);

        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();

        if (authentication == null) {
            LOGGER.debug(
                    "No authentication available for '{}{}'. Thymeleaf won't have access to '#sec' in view '{}'",
                    request.getServletPath(), request.getPathInfo(), modelAndView.getViewName());
            return;
        }

        WebSecurityExpressionRoot expressionRoot = new WebSecurityExpressionRoot(authentication,
                filterInvocation);

        expressionRoot.setTrustResolver(trustResolver);
        expressionRoot.setPermissionEvaluator(permissionEvaluator);
        modelAndView.addObject("sec", expressionRoot);
    }
}