Class DefaultMethodSecurityExpressionHandler

  • All Implemented Interfaces:
    org.springframework.aop.framework.AopInfrastructureBean, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware, MethodSecurityExpressionHandler, SecurityExpressionHandler<org.aopalliance.intercept.MethodInvocation>

    public class DefaultMethodSecurityExpressionHandler
    extends AbstractSecurityExpressionHandler<org.aopalliance.intercept.MethodInvocation>
    implements MethodSecurityExpressionHandler
    The standard implementation of MethodSecurityExpressionHandler.

    A single instance should usually be shared amongst the beans that require expression support.

    • Field Detail

      • logger

        protected final org.apache.commons.logging.Log logger
    • Constructor Detail

      • DefaultMethodSecurityExpressionHandler

        public DefaultMethodSecurityExpressionHandler()
    • Method Detail

      • createEvaluationContextInternal

        public createEvaluationContextInternal​(Authentication auth,
                                                                                                                     org.aopalliance.intercept.MethodInvocation mi)
        Uses a MethodSecurityEvaluationContext as the EvaluationContext implementation.
        createEvaluationContextInternal in class AbstractSecurityExpressionHandler<org.aopalliance.intercept.MethodInvocation>
        auth - the current authentication object
        mi - the invocation (filter, method, channel)
        A StandardEvaluationContext or potentially a custom subclass if overridden.
      • filter

        public java.lang.Object filter​(java.lang.Object filterTarget,
                                       org.springframework.expression.Expression filterExpression,
                                       org.springframework.expression.EvaluationContext ctx)
        Filters the filterTarget object (which must be either a collection, array, map or stream), by evaluating the supplied expression.

        If a Collection or Map is used, the original instance will be modified to contain the elements for which the permission expression evaluates to true. For an array, a new array instance will be returned.

        Specified by:
        filter in interface MethodSecurityExpressionHandler
        filterTarget - the array or collection to be filtered.
        filterExpression - the expression which should be used as the filter condition. If it returns false on evaluation, the object will be removed from the returned collection
        ctx - the current evaluation context (as created through a call to SecurityExpressionHandler.createEvaluationContext(, Object)
        the filtered collection or array
      • setParameterNameDiscoverer

        public void setParameterNameDiscoverer​(org.springframework.core.ParameterNameDiscoverer parameterNameDiscoverer)
        Sets the ParameterNameDiscoverer to use. The default is DefaultSecurityParameterNameDiscoverer.
        parameterNameDiscoverer -
      • getParameterNameDiscoverer

        protected org.springframework.core.ParameterNameDiscoverer getParameterNameDiscoverer()
        The current ParameterNameDiscoverer
      • setPermissionCacheOptimizer

        public void setPermissionCacheOptimizer​(PermissionCacheOptimizer permissionCacheOptimizer)
      • setDefaultRolePrefix

        public void setDefaultRolePrefix​(java.lang.String defaultRolePrefix)

        Sets the default prefix to be added to SecurityExpressionRoot.hasAnyRole(String...) or SecurityExpressionRoot.hasRole(String). For example, if hasRole("ADMIN") or hasRole("ROLE_ADMIN") is passed in, then the role ROLE_ADMIN will be used when the defaultRolePrefix is "ROLE_" (default).

        If null or empty, then no default role prefix is used.

        defaultRolePrefix - the default prefix to add to roles. Default "ROLE_".
      • getDefaultRolePrefix

        protected java.lang.String getDefaultRolePrefix()
        The default role prefix