Example usage for org.springframework.security.access.expression SecurityExpressionOperations hasRole

List of usage examples for org.springframework.security.access.expression SecurityExpressionOperations hasRole

Introduction

In this page you can find the example usage for org.springframework.security.access.expression SecurityExpressionOperations hasRole.

Prototype

boolean hasRole(String role);

Source Link

Document

Determines if the #getAuthentication() has a particular authority within Authentication#getAuthorities() .

Usage

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

/**
 * Evaluate the {@link HasAuthorityConfigAttribute} instance.
 *
 * @param authentication              the authentication
 * @param filterInvocation            the filter invocation
 * @param hasAuthorityConfigAttribute the has authority config attribute
 * @return the boolean/*from ww  w  .j  a  v a2  s.c  om*/
 */
public boolean evaluate(Authentication authentication, FilterInvocation filterInvocation,
        HasAuthorityConfigAttribute hasAuthorityConfigAttribute) {
    SecurityExpressionOperations ops = createSecurityExpressionRoot(authentication, filterInvocation);
    return ops.hasRole(hasAuthorityConfigAttribute.getAttribute());
}